blob: 0b6f22d0cb583097b9781184531533a986087b61 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
624 return framebuffer->completeness();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000625 }
626
627 return 0;
628}
629
Kenneth Russell67ea1902014-10-06 16:44:50 -0700630void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000631{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000632 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000633
Geoff Langbfdea662014-07-23 14:16:32 -0400634 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400635 if (context)
636 {
637 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
638
639 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000640 {
Geoff Langb1196682014-07-23 13:47:29 -0400641 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000643 }
Geoff Langbfdea662014-07-23 14:16:32 -0400644
645 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
646 {
Geoff Langb1196682014-07-23 13:47:29 -0400647 context->recordError(gl::Error(GL_INVALID_VALUE));
648 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400649 }
650
Geoff Langcc79b8c2014-07-25 13:48:02 -0400651 gl::Error error = context->clear(mask);
652 if (error.isError())
653 {
654 context->recordError(error);
655 return;
656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000657 }
658}
659
Kenneth Russell67ea1902014-10-06 16:44:50 -0700660void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000662 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000663 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000664
Geoff Langbfdea662014-07-23 14:16:32 -0400665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400666 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000667 {
Geoff Langbfdea662014-07-23 14:16:32 -0400668 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 }
670}
671
Kenneth Russell67ea1902014-10-06 16:44:50 -0700672void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000674 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675
Geoff Langbfdea662014-07-23 14:16:32 -0400676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400677 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000678 {
Geoff Langbfdea662014-07-23 14:16:32 -0400679 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 }
681}
682
Kenneth Russell67ea1902014-10-06 16:44:50 -0700683void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000685 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686
Geoff Langbfdea662014-07-23 14:16:32 -0400687 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400688 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000689 {
Geoff Langbfdea662014-07-23 14:16:32 -0400690 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 }
692}
693
Kenneth Russell67ea1902014-10-06 16:44:50 -0700694void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000695{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000696 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000697 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000698
Geoff Langbfdea662014-07-23 14:16:32 -0400699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400700 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000701 {
Geoff Langbfdea662014-07-23 14:16:32 -0400702 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 }
704}
705
Kenneth Russell67ea1902014-10-06 16:44:50 -0700706void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000708 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709
Geoff Langbfdea662014-07-23 14:16:32 -0400710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400711 if (context)
712 {
713 gl::Shader *shaderObject = context->getShader(shader);
714
715 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000716 {
Geoff Langbfdea662014-07-23 14:16:32 -0400717 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langb1196682014-07-23 13:47:29 -0400719 context->recordError(gl::Error(GL_INVALID_OPERATION));
720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000721 }
Geoff Langbfdea662014-07-23 14:16:32 -0400722 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000723 {
Geoff Langb1196682014-07-23 13:47:29 -0400724 context->recordError(gl::Error(GL_INVALID_VALUE));
725 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000726 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000727 }
Geoff Langbfdea662014-07-23 14:16:32 -0400728
729 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000730 }
Geoff Langbfdea662014-07-23 14:16:32 -0400731}
732
Kenneth Russell67ea1902014-10-06 16:44:50 -0700733void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400734 GLint border, GLsizei imageSize, const GLvoid* data)
735{
736 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
737 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
738 target, level, internalformat, width, height, border, imageSize, data);
739
740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400741 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000742 {
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context->getClientVersion() < 3 &&
744 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
745 0, 0, width, height, border, GL_NONE, GL_NONE, data))
746 {
747 return;
748 }
749
750 if (context->getClientVersion() >= 3 &&
751 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
752 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
753 {
754 return;
755 }
756
Geoff Lang5d601382014-07-22 15:14:06 -0400757 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
758 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400759 {
Geoff Langb1196682014-07-23 13:47:29 -0400760 context->recordError(gl::Error(GL_INVALID_VALUE));
761 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400762 }
763
764 switch (target)
765 {
766 case GL_TEXTURE_2D:
767 {
768 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400769 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400770 if (error.isError())
771 {
772 context->recordError(error);
773 return;
774 }
Geoff Langbfdea662014-07-23 14:16:32 -0400775 }
776 break;
777
778 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
779 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
784 {
785 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400786 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400787 if (error.isError())
788 {
789 context->recordError(error);
790 return;
791 }
Geoff Langbfdea662014-07-23 14:16:32 -0400792 }
793 break;
794
795 default:
Geoff Langb1196682014-07-23 13:47:29 -0400796 context->recordError(gl::Error(GL_INVALID_ENUM));
797 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400798 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000799 }
800}
801
Kenneth Russell67ea1902014-10-06 16:44:50 -0700802void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000803 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000805 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000806 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000807 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000808 target, level, xoffset, yoffset, width, height, format, imageSize, data);
809
Geoff Langbfdea662014-07-23 14:16:32 -0400810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400811 if (context)
812 {
813 if (context->getClientVersion() < 3 &&
814 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
815 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000816 {
Geoff Langbfdea662014-07-23 14:16:32 -0400817 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 }
Geoff Langbfdea662014-07-23 14:16:32 -0400819
820 if (context->getClientVersion() >= 3 &&
821 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
822 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
823 {
824 return;
825 }
826
Geoff Lang5d601382014-07-22 15:14:06 -0400827 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
828 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400829 {
Geoff Langb1196682014-07-23 13:47:29 -0400830 context->recordError(gl::Error(GL_INVALID_VALUE));
831 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400832 }
833
834 switch (target)
835 {
836 case GL_TEXTURE_2D:
837 {
838 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400839 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400840 if (error.isError())
841 {
842 context->recordError(error);
843 return;
844 }
Geoff Langbfdea662014-07-23 14:16:32 -0400845 }
846 break;
847
848 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
849 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
854 {
855 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400856 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400857 if (error.isError())
858 {
859 context->recordError(error);
860 return;
861 }
Geoff Langbfdea662014-07-23 14:16:32 -0400862 }
863 break;
864
865 default:
Geoff Langb1196682014-07-23 13:47:29 -0400866 context->recordError(gl::Error(GL_INVALID_ENUM));
867 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400868 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000869 }
870}
871
Kenneth Russell67ea1902014-10-06 16:44:50 -0700872void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000874 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000875 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000876 target, level, internalformat, x, y, width, height, border);
877
Geoff Langbfdea662014-07-23 14:16:32 -0400878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400879 if (context)
880 {
881 if (context->getClientVersion() < 3 &&
882 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
883 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000884 {
Geoff Langbfdea662014-07-23 14:16:32 -0400885 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 }
Geoff Langbfdea662014-07-23 14:16:32 -0400887
888 if (context->getClientVersion() >= 3 &&
889 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
890 0, 0, 0, x, y, width, height, border))
891 {
892 return;
893 }
894
895 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
896
897 switch (target)
898 {
899 case GL_TEXTURE_2D:
900 {
901 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400902 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
903 if (error.isError())
904 {
905 context->recordError(error);
906 return;
907 }
Geoff Langbfdea662014-07-23 14:16:32 -0400908 }
909 break;
910
911 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
912 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
917 {
918 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400919 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
920 if (error.isError())
921 {
922 context->recordError(error);
923 return;
924 }
Geoff Langbfdea662014-07-23 14:16:32 -0400925 }
926 break;
927
Geoff Langb1196682014-07-23 13:47:29 -0400928 default:
929 context->recordError(gl::Error(GL_INVALID_ENUM));
930 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400931 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000932 }
933}
934
Kenneth Russell67ea1902014-10-06 16:44:50 -0700935void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000937 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000938 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000939 target, level, xoffset, yoffset, x, y, width, height);
940
Geoff Langbfdea662014-07-23 14:16:32 -0400941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400942 if (context)
943 {
944 if (context->getClientVersion() < 3 &&
945 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
946 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000947 {
Geoff Langbfdea662014-07-23 14:16:32 -0400948 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000950
Geoff Langbfdea662014-07-23 14:16:32 -0400951 if (context->getClientVersion() >= 3 &&
952 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
953 xoffset, yoffset, 0, x, y, width, height, 0))
954 {
955 return;
956 }
957
958 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
959
960 switch (target)
961 {
962 case GL_TEXTURE_2D:
963 {
964 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400965 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
966 if (error.isError())
967 {
968 context->recordError(error);
969 return;
970 }
Geoff Langbfdea662014-07-23 14:16:32 -0400971 }
972 break;
973
974 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
975 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
980 {
981 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400982 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
983 if (error.isError())
984 {
985 context->recordError(error);
986 return;
987 }
Geoff Langbfdea662014-07-23 14:16:32 -0400988 }
989 break;
990
991 default:
Geoff Langb1196682014-07-23 13:47:29 -0400992 context->recordError(gl::Error(GL_INVALID_ENUM));
993 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400994 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000995 }
996}
997
Kenneth Russell67ea1902014-10-06 16:44:50 -0700998GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001000 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001
Geoff Langbfdea662014-07-23 14:16:32 -04001002 gl::Context *context = gl::getNonLostContext();
1003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001004 {
Geoff Langbfdea662014-07-23 14:16:32 -04001005 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 }
1007
1008 return 0;
1009}
1010
Kenneth Russell67ea1902014-10-06 16:44:50 -07001011GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001013 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014
Geoff Langbfdea662014-07-23 14:16:32 -04001015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001016 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001017 {
Geoff Langbfdea662014-07-23 14:16:32 -04001018 switch (type)
1019 {
1020 case GL_FRAGMENT_SHADER:
1021 case GL_VERTEX_SHADER:
1022 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001023
Geoff Langbfdea662014-07-23 14:16:32 -04001024 default:
Geoff Langb1196682014-07-23 13:47:29 -04001025 context->recordError(gl::Error(GL_INVALID_ENUM));
1026 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001028 }
1029
1030 return 0;
1031}
1032
Kenneth Russell67ea1902014-10-06 16:44:50 -07001033void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001034{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001035 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036
Geoff Langb1196682014-07-23 13:47:29 -04001037 gl::Context *context = gl::getNonLostContext();
1038 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001039 {
Geoff Langb1196682014-07-23 13:47:29 -04001040 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 case GL_FRONT:
1043 case GL_BACK:
1044 case GL_FRONT_AND_BACK:
1045 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001046
Geoff Langb1196682014-07-23 13:47:29 -04001047 default:
1048 context->recordError(gl::Error(GL_INVALID_ENUM));
1049 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001050 }
Geoff Langb1196682014-07-23 13:47:29 -04001051
1052 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001053 }
1054}
1055
Kenneth Russell67ea1902014-10-06 16:44:50 -07001056void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001058 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059
Geoff Langbfdea662014-07-23 14:16:32 -04001060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001061 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001062 {
Geoff Langb1196682014-07-23 13:47:29 -04001063 if (n < 0)
1064 {
1065 context->recordError(gl::Error(GL_INVALID_VALUE));
1066 return;
1067 }
1068
Geoff Langbfdea662014-07-23 14:16:32 -04001069 for (int i = 0; i < n; i++)
1070 {
1071 context->deleteBuffer(buffers[i]);
1072 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001073 }
1074}
1075
Kenneth Russell67ea1902014-10-06 16:44:50 -07001076void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001077{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001078 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079
Geoff Langbfdea662014-07-23 14:16:32 -04001080 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001081 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001082 {
Geoff Langb1196682014-07-23 13:47:29 -04001083 if (n < 0)
1084 {
1085 context->recordError(gl::Error(GL_INVALID_VALUE));
1086 return;
1087 }
1088
Geoff Langbfdea662014-07-23 14:16:32 -04001089 for (int i = 0; i < n; i++)
1090 {
1091 context->deleteFenceNV(fences[i]);
1092 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001093 }
1094}
1095
Kenneth Russell67ea1902014-10-06 16:44:50 -07001096void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001097{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001098 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099
Geoff Langbfdea662014-07-23 14:16:32 -04001100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001101 if (context)
1102 {
Geoff Langb1196682014-07-23 13:47:29 -04001103 if (n < 0)
1104 {
1105 context->recordError(gl::Error(GL_INVALID_VALUE));
1106 return;
1107 }
1108
Geoff Langbfdea662014-07-23 14:16:32 -04001109 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001110 {
Geoff Langbfdea662014-07-23 14:16:32 -04001111 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 }
1115 }
1116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001117}
1118
Kenneth Russell67ea1902014-10-06 16:44:50 -07001119void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001120{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001121 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122
Geoff Langbfdea662014-07-23 14:16:32 -04001123 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001124 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001125 {
Geoff Langb1196682014-07-23 13:47:29 -04001126 if (program == 0)
1127 {
1128 return;
1129 }
1130
Geoff Langbfdea662014-07-23 14:16:32 -04001131 if (!context->getProgram(program))
1132 {
1133 if(context->getShader(program))
1134 {
Geoff Langb1196682014-07-23 13:47:29 -04001135 context->recordError(gl::Error(GL_INVALID_OPERATION));
1136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001137 }
1138 else
1139 {
Geoff Langb1196682014-07-23 13:47:29 -04001140 context->recordError(gl::Error(GL_INVALID_VALUE));
1141 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001142 }
1143 }
1144
1145 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146 }
1147}
1148
Kenneth Russell67ea1902014-10-06 16:44:50 -07001149void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001150{
1151 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1152
Geoff Langbfdea662014-07-23 14:16:32 -04001153 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001154 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001155 {
Geoff Langb1196682014-07-23 13:47:29 -04001156 if (n < 0)
1157 {
1158 context->recordError(gl::Error(GL_INVALID_VALUE));
1159 return;
1160 }
1161
Geoff Langbfdea662014-07-23 14:16:32 -04001162 for (int i = 0; i < n; i++)
1163 {
1164 context->deleteQuery(ids[i]);
1165 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001166 }
1167}
1168
Kenneth Russell67ea1902014-10-06 16:44:50 -07001169void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001170{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001171 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172
Geoff Langbfdea662014-07-23 14:16:32 -04001173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001174 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001175 {
Geoff Langb1196682014-07-23 13:47:29 -04001176 if (n < 0)
1177 {
1178 context->recordError(gl::Error(GL_INVALID_VALUE));
1179 return;
1180 }
1181
Geoff Langbfdea662014-07-23 14:16:32 -04001182 for (int i = 0; i < n; i++)
1183 {
1184 context->deleteRenderbuffer(renderbuffers[i]);
1185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001186 }
1187}
1188
Kenneth Russell67ea1902014-10-06 16:44:50 -07001189void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001191 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192
Geoff Langbfdea662014-07-23 14:16:32 -04001193 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001194 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001195 {
Geoff Langb1196682014-07-23 13:47:29 -04001196 if (shader == 0)
1197 {
1198 return;
1199 }
1200
Geoff Langbfdea662014-07-23 14:16:32 -04001201 if (!context->getShader(shader))
1202 {
1203 if(context->getProgram(shader))
1204 {
Geoff Langb1196682014-07-23 13:47:29 -04001205 context->recordError(gl::Error(GL_INVALID_OPERATION));
1206 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001207 }
1208 else
1209 {
Geoff Langb1196682014-07-23 13:47:29 -04001210 context->recordError(gl::Error(GL_INVALID_VALUE));
1211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001212 }
1213 }
1214
1215 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001216 }
1217}
1218
Kenneth Russell67ea1902014-10-06 16:44:50 -07001219void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001220{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001221 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222
Geoff Langbfdea662014-07-23 14:16:32 -04001223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001224 if (context)
1225 {
Geoff Langb1196682014-07-23 13:47:29 -04001226 if (n < 0)
1227 {
1228 context->recordError(gl::Error(GL_INVALID_VALUE));
1229 return;
1230 }
1231
Geoff Langbfdea662014-07-23 14:16:32 -04001232 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001233 {
Geoff Langbfdea662014-07-23 14:16:32 -04001234 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 }
1238 }
1239 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001240}
1241
Kenneth Russell67ea1902014-10-06 16:44:50 -07001242void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001243{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001244 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245
Geoff Langbfdea662014-07-23 14:16:32 -04001246 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001247 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001248 {
Geoff Langb1196682014-07-23 13:47:29 -04001249 switch (func)
1250 {
1251 case GL_NEVER:
1252 case GL_ALWAYS:
1253 case GL_LESS:
1254 case GL_LEQUAL:
1255 case GL_EQUAL:
1256 case GL_GREATER:
1257 case GL_GEQUAL:
1258 case GL_NOTEQUAL:
1259 context->getState().setDepthFunc(func);
1260 break;
1261
1262 default:
1263 context->recordError(gl::Error(GL_INVALID_ENUM));
1264 return;
1265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001266 }
1267}
1268
Kenneth Russell67ea1902014-10-06 16:44:50 -07001269void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001270{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001271 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272
Geoff Langbfdea662014-07-23 14:16:32 -04001273 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001274 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001275 {
Geoff Langbfdea662014-07-23 14:16:32 -04001276 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 }
1278}
1279
Kenneth Russell67ea1902014-10-06 16:44:50 -07001280void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001282 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283
Geoff Langbfdea662014-07-23 14:16:32 -04001284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001285 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001286 {
Geoff Langbfdea662014-07-23 14:16:32 -04001287 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 }
1289}
1290
Kenneth Russell67ea1902014-10-06 16:44:50 -07001291void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001293 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294
Geoff Langbfdea662014-07-23 14:16:32 -04001295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001297 {
Geoff Langbfdea662014-07-23 14:16:32 -04001298 gl::Program *programObject = context->getProgram(program);
1299 gl::Shader *shaderObject = context->getShader(shader);
1300
1301 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001302 {
Geoff Langbfdea662014-07-23 14:16:32 -04001303 gl::Shader *shaderByProgramHandle;
1304 shaderByProgramHandle = context->getShader(program);
1305 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001306 {
Geoff Langb1196682014-07-23 13:47:29 -04001307 context->recordError(gl::Error(GL_INVALID_VALUE));
1308 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001309 }
Geoff Langbfdea662014-07-23 14:16:32 -04001310 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001311 {
Geoff Langb1196682014-07-23 13:47:29 -04001312 context->recordError(gl::Error(GL_INVALID_OPERATION));
1313 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001314 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001315 }
Geoff Langbfdea662014-07-23 14:16:32 -04001316
1317 if (!shaderObject)
1318 {
1319 gl::Program *programByShaderHandle = context->getProgram(shader);
1320 if (!programByShaderHandle)
1321 {
Geoff Langb1196682014-07-23 13:47:29 -04001322 context->recordError(gl::Error(GL_INVALID_VALUE));
1323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001324 }
1325 else
1326 {
Geoff Langb1196682014-07-23 13:47:29 -04001327 context->recordError(gl::Error(GL_INVALID_OPERATION));
1328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001329 }
1330 }
1331
1332 if (!programObject->detachShader(shaderObject))
1333 {
Geoff Langb1196682014-07-23 13:47:29 -04001334 context->recordError(gl::Error(GL_INVALID_OPERATION));
1335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001336 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001337 }
1338}
1339
Kenneth Russell67ea1902014-10-06 16:44:50 -07001340void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001342 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343
Geoff Langbfdea662014-07-23 14:16:32 -04001344 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001345 if (context)
1346 {
1347 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001348 {
Geoff Langb1196682014-07-23 13:47:29 -04001349 context->recordError(gl::Error(GL_INVALID_ENUM));
1350 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001351 }
Geoff Langbfdea662014-07-23 14:16:32 -04001352
1353 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001354 }
1355}
1356
Kenneth Russell67ea1902014-10-06 16:44:50 -07001357void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001359 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360
Geoff Langbfdea662014-07-23 14:16:32 -04001361 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001362 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001363 {
Geoff Langb1196682014-07-23 13:47:29 -04001364 if (index >= gl::MAX_VERTEX_ATTRIBS)
1365 {
1366 context->recordError(gl::Error(GL_INVALID_VALUE));
1367 return;
1368 }
1369
Geoff Langbfdea662014-07-23 14:16:32 -04001370 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001371 }
1372}
1373
Kenneth Russell67ea1902014-10-06 16:44:50 -07001374void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001375{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001376 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377
Geoff Langbfdea662014-07-23 14:16:32 -04001378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001379 if (context)
1380 {
Jamie Madill2b976812014-08-25 15:47:49 -04001381 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001382 {
Geoff Langbfdea662014-07-23 14:16:32 -04001383 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 }
Geoff Langbfdea662014-07-23 14:16:32 -04001385
Geoff Langc77e8c32014-09-08 16:28:24 -04001386 gl::Error error = context->drawArrays(mode, first, count, 0);
1387 if (error.isError())
1388 {
1389 context->recordError(error);
1390 return;
1391 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001392 }
1393}
1394
Kenneth Russell67ea1902014-10-06 16:44:50 -07001395void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001396{
1397 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1398
Geoff Langbfdea662014-07-23 14:16:32 -04001399 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001400 if (context)
1401 {
Geoff Lang87a93302014-09-16 13:29:43 -04001402 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001403 {
Geoff Langbfdea662014-07-23 14:16:32 -04001404 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 }
Geoff Langbfdea662014-07-23 14:16:32 -04001406
Geoff Langc77e8c32014-09-08 16:28:24 -04001407 gl::Error error = context->drawArrays(mode, first, count, primcount);
1408 if (error.isError())
1409 {
1410 context->recordError(error);
1411 return;
1412 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001413 }
1414}
1415
Kenneth Russell67ea1902014-10-06 16:44:50 -07001416void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001417{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001418 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001419 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001420
Geoff Langbfdea662014-07-23 14:16:32 -04001421 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001422 if (context)
1423 {
Jamie Madill2b976812014-08-25 15:47:49 -04001424 rx::RangeUI indexRange;
1425 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001426 {
Geoff Langbfdea662014-07-23 14:16:32 -04001427 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 }
Geoff Langbfdea662014-07-23 14:16:32 -04001429
Geoff Langc77e8c32014-09-08 16:28:24 -04001430 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1431 if (error.isError())
1432 {
1433 context->recordError(error);
1434 return;
1435 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001436 }
1437}
1438
Kenneth Russell67ea1902014-10-06 16:44:50 -07001439void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001440{
1441 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1442 mode, count, type, indices, primcount);
1443
Geoff Langbfdea662014-07-23 14:16:32 -04001444 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001445 if (context)
1446 {
Jamie Madill2b976812014-08-25 15:47:49 -04001447 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001448 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001449 {
Geoff Langbfdea662014-07-23 14:16:32 -04001450 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 }
Geoff Langbfdea662014-07-23 14:16:32 -04001452
Geoff Langc77e8c32014-09-08 16:28:24 -04001453 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1454 if (error.isError())
1455 {
1456 context->recordError(error);
1457 return;
1458 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001459 }
1460}
1461
Kenneth Russell67ea1902014-10-06 16:44:50 -07001462void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001463{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001464 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465
Geoff Langbfdea662014-07-23 14:16:32 -04001466 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001467 if (context)
1468 {
1469 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001470 {
Geoff Langb1196682014-07-23 13:47:29 -04001471 context->recordError(gl::Error(GL_INVALID_ENUM));
1472 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001473 }
Geoff Langbfdea662014-07-23 14:16:32 -04001474
1475 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001476 }
1477}
1478
Kenneth Russell67ea1902014-10-06 16:44:50 -07001479void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001481 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
Geoff Langbfdea662014-07-23 14:16:32 -04001483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001484 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001485 {
Geoff Langb1196682014-07-23 13:47:29 -04001486 if (index >= gl::MAX_VERTEX_ATTRIBS)
1487 {
1488 context->recordError(gl::Error(GL_INVALID_VALUE));
1489 return;
1490 }
1491
Geoff Langbfdea662014-07-23 14:16:32 -04001492 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001493 }
1494}
1495
Kenneth Russell67ea1902014-10-06 16:44:50 -07001496void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001497{
1498 EVENT("GLenum target = 0x%X)", target);
1499
Geoff Langbfdea662014-07-23 14:16:32 -04001500 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001501 if (context)
1502 {
1503 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001504 {
Geoff Langbfdea662014-07-23 14:16:32 -04001505 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 }
Geoff Langbfdea662014-07-23 14:16:32 -04001507
Geoff Lang5aad9672014-09-08 11:10:42 -04001508 gl::Error error = context->endQuery(target);
1509 if (error.isError())
1510 {
1511 context->recordError(error);
1512 return;
1513 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001514 }
1515}
1516
Kenneth Russell67ea1902014-10-06 16:44:50 -07001517void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001518{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001519 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520
Geoff Langbfdea662014-07-23 14:16:32 -04001521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001522 if (context)
1523 {
1524 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1525
1526 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001527 {
Geoff Langb1196682014-07-23 13:47:29 -04001528 context->recordError(gl::Error(GL_INVALID_OPERATION));
1529 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001530 }
Geoff Langbfdea662014-07-23 14:16:32 -04001531
1532 if (fenceObject->isFence() != GL_TRUE)
1533 {
Geoff Langb1196682014-07-23 13:47:29 -04001534 context->recordError(gl::Error(GL_INVALID_OPERATION));
1535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001536 }
1537
1538 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001539 }
1540}
1541
Kenneth Russell67ea1902014-10-06 16:44:50 -07001542void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001543{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001544 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545
Geoff Langbfdea662014-07-23 14:16:32 -04001546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001547 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001548 {
Geoff Lang26298562014-10-01 10:49:03 -04001549 gl::Error error = context->sync(true);
1550 if (error.isError())
1551 {
1552 context->recordError(error);
1553 return;
1554 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555 }
1556}
1557
Kenneth Russell67ea1902014-10-06 16:44:50 -07001558void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001559{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001560 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561
Geoff Langbfdea662014-07-23 14:16:32 -04001562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001563 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001564 {
Geoff Lang26298562014-10-01 10:49:03 -04001565 gl::Error error = context->sync(false);
1566 if (error.isError())
1567 {
1568 context->recordError(error);
1569 return;
1570 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 }
1572}
1573
Kenneth Russell67ea1902014-10-06 16:44:50 -07001574void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001575{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001576 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001577 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001578
Geoff Langbfdea662014-07-23 14:16:32 -04001579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001580 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
Geoff Langb1196682014-07-23 13:47:29 -04001582 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1583 {
1584 context->recordError(gl::Error(GL_INVALID_ENUM));
1585 return;
1586 }
1587
Geoff Langbfdea662014-07-23 14:16:32 -04001588 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1589 {
1590 return;
1591 }
1592
1593 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1594 ASSERT(framebuffer);
1595
1596 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1597 {
1598 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1599 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1600 }
1601 else
1602 {
1603 switch (attachment)
1604 {
1605 case GL_DEPTH_ATTACHMENT:
1606 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1607 break;
1608 case GL_STENCIL_ATTACHMENT:
1609 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1610 break;
1611 case GL_DEPTH_STENCIL_ATTACHMENT:
1612 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1613 break;
1614 default:
1615 UNREACHABLE();
1616 break;
1617 }
1618 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 }
1620}
1621
Kenneth Russell67ea1902014-10-06 16:44:50 -07001622void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001624 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001625 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001626
Geoff Langbfdea662014-07-23 14:16:32 -04001627 gl::Context *context = gl::getNonLostContext();
1628 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001629 {
Geoff Langbfdea662014-07-23 14:16:32 -04001630 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 return;
1633 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001634
Geoff Langbfdea662014-07-23 14:16:32 -04001635 if (texture == 0)
1636 {
1637 textarget = GL_NONE;
1638 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001639
Geoff Langbfdea662014-07-23 14:16:32 -04001640 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1643 {
1644 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1645 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1646 }
1647 else
1648 {
1649 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001650 {
Geoff Langbfdea662014-07-23 14:16:32 -04001651 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1652 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1653 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001654 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
1656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langb1196682014-07-23 13:47:29 -04001663 gl::Context *context = gl::getNonLostContext();
1664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001667 {
Geoff Langb1196682014-07-23 13:47:29 -04001668 case GL_CW:
1669 case GL_CCW:
1670 context->getState().setFrontFace(mode);
1671 break;
1672 default:
1673 context->recordError(gl::Error(GL_INVALID_ENUM));
1674 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685 {
Geoff Langb1196682014-07-23 13:47:29 -04001686 if (n < 0)
1687 {
1688 context->recordError(gl::Error(GL_INVALID_VALUE));
1689 return;
1690 }
1691
Geoff Langbfdea662014-07-23 14:16:32 -04001692 for (int i = 0; i < n; i++)
1693 {
1694 buffers[i] = context->createBuffer();
1695 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001696 }
1697}
1698
Kenneth Russell67ea1902014-10-06 16:44:50 -07001699void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001701 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001702
Geoff Langbfdea662014-07-23 14:16:32 -04001703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001704 if (context)
1705 {
1706 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001707 {
Geoff Langb1196682014-07-23 13:47:29 -04001708 context->recordError(gl::Error(GL_INVALID_ENUM));
1709 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 }
Geoff Langbfdea662014-07-23 14:16:32 -04001711
1712 gl::Texture *texture = context->getTargetTexture(target);
1713
1714 if (texture == NULL)
1715 {
Geoff Langb1196682014-07-23 13:47:29 -04001716 context->recordError(gl::Error(GL_INVALID_OPERATION));
1717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001718 }
1719
1720 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1721 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001722 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001723
1724 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1725 // unsized formats or that are color renderable and filterable. Since we do not track if
1726 // the texture was created with sized or unsized format (only sized formats are stored),
1727 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1728 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1729 // textures since they're the only texture format that can be created with unsized formats
1730 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1731 // was the last version to use add them.
1732 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1733 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1734 internalFormat == GL_ALPHA8_EXT;
1735
Geoff Lang5d601382014-07-22 15:14:06 -04001736 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1737 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001738 {
Geoff Langb1196682014-07-23 13:47:29 -04001739 context->recordError(gl::Error(GL_INVALID_OPERATION));
1740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001741 }
1742
1743 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001744 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001745 {
Geoff Langb1196682014-07-23 13:47:29 -04001746 context->recordError(gl::Error(GL_INVALID_OPERATION));
1747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001748 }
1749
1750 // Non-power of 2 ES2 check
1751 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1752 {
1753 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001754 context->recordError(gl::Error(GL_INVALID_OPERATION));
1755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001756 }
1757
1758 // Cube completeness check
1759 if (target == GL_TEXTURE_CUBE_MAP)
1760 {
1761 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1762 if (!textureCube->isCubeComplete())
1763 {
Geoff Langb1196682014-07-23 13:47:29 -04001764 context->recordError(gl::Error(GL_INVALID_OPERATION));
1765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001766 }
1767 }
1768
1769 texture->generateMipmaps();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001770 }
1771}
1772
Kenneth Russell67ea1902014-10-06 16:44:50 -07001773void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001774{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001775 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001776
Geoff Langbfdea662014-07-23 14:16:32 -04001777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001778 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001779 {
Geoff Langb1196682014-07-23 13:47:29 -04001780 if (n < 0)
1781 {
1782 context->recordError(gl::Error(GL_INVALID_VALUE));
1783 return;
1784 }
1785
Geoff Langbfdea662014-07-23 14:16:32 -04001786 for (int i = 0; i < n; i++)
1787 {
1788 fences[i] = context->createFenceNV();
1789 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001790 }
1791}
1792
Kenneth Russell67ea1902014-10-06 16:44:50 -07001793void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001794{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001795 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001796
Geoff Langbfdea662014-07-23 14:16:32 -04001797 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001798 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799 {
Geoff Langb1196682014-07-23 13:47:29 -04001800 if (n < 0)
1801 {
1802 context->recordError(gl::Error(GL_INVALID_VALUE));
1803 return;
1804 }
1805
Geoff Langbfdea662014-07-23 14:16:32 -04001806 for (int i = 0; i < n; i++)
1807 {
1808 framebuffers[i] = context->createFramebuffer();
1809 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001810 }
1811}
1812
Kenneth Russell67ea1902014-10-06 16:44:50 -07001813void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001814{
1815 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1816
Geoff Langbfdea662014-07-23 14:16:32 -04001817 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001818 if (context)
1819 {
1820 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001821 {
Geoff Langb1196682014-07-23 13:47:29 -04001822 context->recordError(gl::Error(GL_INVALID_VALUE));
1823 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001824 }
Geoff Langbfdea662014-07-23 14:16:32 -04001825
1826 for (GLsizei i = 0; i < n; i++)
1827 {
1828 ids[i] = context->createQuery();
1829 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001830 }
1831}
1832
Kenneth Russell67ea1902014-10-06 16:44:50 -07001833void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001834{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001835 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001836
Geoff Langbfdea662014-07-23 14:16:32 -04001837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001838 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839 {
Geoff Langb1196682014-07-23 13:47:29 -04001840 if (n < 0)
1841 {
1842 context->recordError(gl::Error(GL_INVALID_VALUE));
1843 return;
1844 }
1845
Geoff Langbfdea662014-07-23 14:16:32 -04001846 for (int i = 0; i < n; i++)
1847 {
1848 renderbuffers[i] = context->createRenderbuffer();
1849 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001850 }
1851}
1852
Kenneth Russell67ea1902014-10-06 16:44:50 -07001853void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001854{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001855 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001856
Geoff Langbfdea662014-07-23 14:16:32 -04001857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001858 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859 {
Geoff Langb1196682014-07-23 13:47:29 -04001860 if (n < 0)
1861 {
1862 context->recordError(gl::Error(GL_INVALID_VALUE));
1863 return;
1864 }
1865
Geoff Langbfdea662014-07-23 14:16:32 -04001866 for (int i = 0; i < n; i++)
1867 {
1868 textures[i] = context->createTexture();
1869 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001870 }
1871}
1872
Kenneth Russell67ea1902014-10-06 16:44:50 -07001873void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001874{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001875 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001876 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001877 program, index, bufsize, length, size, type, name);
1878
Geoff Langbfdea662014-07-23 14:16:32 -04001879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001880 if (context)
1881 {
Geoff Langb1196682014-07-23 13:47:29 -04001882 if (bufsize < 0)
1883 {
1884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
1886 }
1887
Geoff Langbfdea662014-07-23 14:16:32 -04001888 gl::Program *programObject = context->getProgram(program);
1889
1890 if (!programObject)
1891 {
1892 if (context->getShader(program))
1893 {
Geoff Langb1196682014-07-23 13:47:29 -04001894 context->recordError(gl::Error(GL_INVALID_OPERATION));
1895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001896 }
1897 else
1898 {
Geoff Langb1196682014-07-23 13:47:29 -04001899 context->recordError(gl::Error(GL_INVALID_VALUE));
1900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001901 }
1902 }
1903
1904 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001905 {
Geoff Langb1196682014-07-23 13:47:29 -04001906 context->recordError(gl::Error(GL_INVALID_VALUE));
1907 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001908 }
1909
Geoff Langbfdea662014-07-23 14:16:32 -04001910 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911 }
1912}
1913
Kenneth Russell67ea1902014-10-06 16:44:50 -07001914void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001916 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001917 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001918 program, index, bufsize, length, size, type, name);
1919
Geoff Langbfdea662014-07-23 14:16:32 -04001920
1921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001922 if (context)
1923 {
Geoff Langb1196682014-07-23 13:47:29 -04001924 if (bufsize < 0)
1925 {
1926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
1928 }
1929
Geoff Langbfdea662014-07-23 14:16:32 -04001930 gl::Program *programObject = context->getProgram(program);
1931
1932 if (!programObject)
1933 {
1934 if (context->getShader(program))
1935 {
Geoff Langb1196682014-07-23 13:47:29 -04001936 context->recordError(gl::Error(GL_INVALID_OPERATION));
1937 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001938 }
1939 else
1940 {
Geoff Langb1196682014-07-23 13:47:29 -04001941 context->recordError(gl::Error(GL_INVALID_VALUE));
1942 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001943 }
1944 }
1945
1946 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001947 {
Geoff Langb1196682014-07-23 13:47:29 -04001948 context->recordError(gl::Error(GL_INVALID_VALUE));
1949 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001950 }
1951
Geoff Langbfdea662014-07-23 14:16:32 -04001952 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001953 }
1954}
1955
Kenneth Russell67ea1902014-10-06 16:44:50 -07001956void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001957{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001958 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001959 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001960
Geoff Langbfdea662014-07-23 14:16:32 -04001961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001962 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001963 {
Geoff Langb1196682014-07-23 13:47:29 -04001964 if (maxcount < 0)
1965 {
1966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
1968 }
1969
Geoff Langbfdea662014-07-23 14:16:32 -04001970 gl::Program *programObject = context->getProgram(program);
1971
1972 if (!programObject)
1973 {
1974 if (context->getShader(program))
1975 {
Geoff Langb1196682014-07-23 13:47:29 -04001976 context->recordError(gl::Error(GL_INVALID_OPERATION));
1977 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001978 }
1979 else
1980 {
Geoff Langb1196682014-07-23 13:47:29 -04001981 context->recordError(gl::Error(GL_INVALID_VALUE));
1982 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001983 }
1984 }
1985
1986 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001987 }
1988}
1989
Kenneth Russell67ea1902014-10-06 16:44:50 -07001990GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001991{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001992 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001993
Geoff Langbfdea662014-07-23 14:16:32 -04001994 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001995 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 {
Geoff Langbfdea662014-07-23 14:16:32 -04001997 gl::Program *programObject = context->getProgram(program);
1998
1999 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002000 {
Geoff Langbfdea662014-07-23 14:16:32 -04002001 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002002 {
Geoff Langb1196682014-07-23 13:47:29 -04002003 context->recordError(gl::Error(GL_INVALID_OPERATION));
2004 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002005 }
Geoff Langbfdea662014-07-23 14:16:32 -04002006 else
2007 {
Geoff Langb1196682014-07-23 13:47:29 -04002008 context->recordError(gl::Error(GL_INVALID_VALUE));
2009 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002010 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002011 }
Geoff Langbfdea662014-07-23 14:16:32 -04002012
2013 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2014 if (!programObject->isLinked() || !programBinary)
2015 {
Geoff Langb1196682014-07-23 13:47:29 -04002016 context->recordError(gl::Error(GL_INVALID_OPERATION));
2017 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002018 }
2019
2020 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 }
2022
2023 return -1;
2024}
2025
Kenneth Russell67ea1902014-10-06 16:44:50 -07002026void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002027{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002028 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029
Geoff Langbfdea662014-07-23 14:16:32 -04002030 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002031 if (context)
2032 {
2033 GLenum nativeType;
2034 unsigned int numParams = 0;
2035 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002036 {
Geoff Langbfdea662014-07-23 14:16:32 -04002037 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002038 }
Geoff Langbfdea662014-07-23 14:16:32 -04002039
2040 if (nativeType == GL_BOOL)
2041 {
2042 context->getBooleanv(pname, params);
2043 }
2044 else
2045 {
2046 CastStateValues(context, nativeType, pname, numParams, params);
2047 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002048 }
2049}
2050
Kenneth Russell67ea1902014-10-06 16:44:50 -07002051void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002052{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002053 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002054
Geoff Langbfdea662014-07-23 14:16:32 -04002055 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002056 if (context)
2057 {
2058 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002059 {
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_ENUM));
2061 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002062 }
Geoff Langbfdea662014-07-23 14:16:32 -04002063
2064 if (!gl::ValidBufferParameter(context, pname))
2065 {
Geoff Langb1196682014-07-23 13:47:29 -04002066 context->recordError(gl::Error(GL_INVALID_ENUM));
2067 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002068 }
2069
2070 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2071
2072 if (!buffer)
2073 {
2074 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002075 context->recordError(gl::Error(GL_INVALID_OPERATION));
2076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002077 }
2078
2079 switch (pname)
2080 {
2081 case GL_BUFFER_USAGE:
2082 *params = static_cast<GLint>(buffer->getUsage());
2083 break;
2084 case GL_BUFFER_SIZE:
2085 *params = gl::clampCast<GLint>(buffer->getSize());
2086 break;
2087 case GL_BUFFER_ACCESS_FLAGS:
2088 *params = buffer->getAccessFlags();
2089 break;
2090 case GL_BUFFER_MAPPED:
2091 *params = static_cast<GLint>(buffer->isMapped());
2092 break;
2093 case GL_BUFFER_MAP_OFFSET:
2094 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2095 break;
2096 case GL_BUFFER_MAP_LENGTH:
2097 *params = gl::clampCast<GLint>(buffer->getMapLength());
2098 break;
2099 default: UNREACHABLE(); break;
2100 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002101 }
2102}
2103
Kenneth Russell67ea1902014-10-06 16:44:50 -07002104GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002105{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002106 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002107
2108 gl::Context *context = gl::getContext();
2109
2110 if (context)
2111 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002112 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113 }
2114
2115 return GL_NO_ERROR;
2116}
2117
Kenneth Russell67ea1902014-10-06 16:44:50 -07002118void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002119{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002120 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002121
Geoff Langbfdea662014-07-23 14:16:32 -04002122 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002123 if (context)
2124 {
2125 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2126
2127 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002128 {
Geoff Langb1196682014-07-23 13:47:29 -04002129 context->recordError(gl::Error(GL_INVALID_OPERATION));
2130 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002131 }
Geoff Langbfdea662014-07-23 14:16:32 -04002132
2133 if (fenceObject->isFence() != GL_TRUE)
2134 {
Geoff Langb1196682014-07-23 13:47:29 -04002135 context->recordError(gl::Error(GL_INVALID_OPERATION));
2136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002137 }
2138
2139 switch (pname)
2140 {
2141 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002142 {
2143 // GL_NV_fence spec:
2144 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2145 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2146 GLboolean status = GL_TRUE;
2147 if (fenceObject->getStatus() != GL_TRUE)
2148 {
2149 gl::Error error = fenceObject->testFence(&status);
2150 if (error.isError())
2151 {
2152 context->recordError(error);
2153 return;
2154 }
2155 }
2156 *params = status;
2157 break;
2158 }
2159
Geoff Langbfdea662014-07-23 14:16:32 -04002160 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002161 {
2162 *params = fenceObject->getCondition();
2163 break;
2164 }
Geoff Langbfdea662014-07-23 14:16:32 -04002165
Geoff Langb1196682014-07-23 13:47:29 -04002166 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002167 {
2168 context->recordError(gl::Error(GL_INVALID_ENUM));
2169 return;
2170 }
Geoff Lang882033e2014-09-30 11:26:07 -04002171 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002172 }
2173}
2174
Kenneth Russell67ea1902014-10-06 16:44:50 -07002175void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002176{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002177 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002178
Geoff Langbfdea662014-07-23 14:16:32 -04002179 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002180 if (context)
2181 {
2182 GLenum nativeType;
2183 unsigned int numParams = 0;
2184 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002185 {
Geoff Langbfdea662014-07-23 14:16:32 -04002186 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002187 }
Geoff Langbfdea662014-07-23 14:16:32 -04002188
2189 if (nativeType == GL_FLOAT)
2190 {
2191 context->getFloatv(pname, params);
2192 }
2193 else
2194 {
2195 CastStateValues(context, nativeType, pname, numParams, params);
2196 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002197 }
2198}
2199
Kenneth Russell67ea1902014-10-06 16:44:50 -07002200void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002201{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002202 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002203 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002204
Geoff Langbfdea662014-07-23 14:16:32 -04002205 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002206 if (context)
2207 {
2208 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209 {
Geoff Langb1196682014-07-23 13:47:29 -04002210 context->recordError(gl::Error(GL_INVALID_ENUM));
2211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002212 }
2213
2214 int clientVersion = context->getClientVersion();
2215
2216 switch (pname)
2217 {
2218 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2220 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2221 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2222 break;
Geoff Langb1196682014-07-23 13:47:29 -04002223
Geoff Langbfdea662014-07-23 14:16:32 -04002224 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2225 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002226 {
Geoff Langb1196682014-07-23 13:47:29 -04002227 context->recordError(gl::Error(GL_INVALID_ENUM));
2228 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002229 }
Geoff Langbfdea662014-07-23 14:16:32 -04002230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2233 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2234 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2235 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2236 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2237 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2238 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2239 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2240 if (clientVersion < 3)
2241 {
Geoff Langb1196682014-07-23 13:47:29 -04002242 context->recordError(gl::Error(GL_INVALID_ENUM));
2243 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002244 }
2245 break;
Geoff Langb1196682014-07-23 13:47:29 -04002246
Geoff Langbfdea662014-07-23 14:16:32 -04002247 default:
Geoff Langb1196682014-07-23 13:47:29 -04002248 context->recordError(gl::Error(GL_INVALID_ENUM));
2249 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002250 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002251
Geoff Langbfdea662014-07-23 14:16:32 -04002252 // Determine if the attachment is a valid enum
2253 switch (attachment)
2254 {
2255 case GL_BACK:
2256 case GL_FRONT:
2257 case GL_DEPTH:
2258 case GL_STENCIL:
2259 case GL_DEPTH_STENCIL_ATTACHMENT:
2260 if (clientVersion < 3)
2261 {
Geoff Langb1196682014-07-23 13:47:29 -04002262 context->recordError(gl::Error(GL_INVALID_ENUM));
2263 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002264 }
2265 break;
2266
2267 case GL_DEPTH_ATTACHMENT:
2268 case GL_STENCIL_ATTACHMENT:
2269 break;
2270
2271 default:
2272 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2273 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2274 {
Geoff Langb1196682014-07-23 13:47:29 -04002275 context->recordError(gl::Error(GL_INVALID_ENUM));
2276 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002277 }
2278 break;
2279 }
2280
2281 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2282 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2283
2284 if (framebufferHandle == 0)
2285 {
2286 if (clientVersion < 3)
2287 {
Geoff Langb1196682014-07-23 13:47:29 -04002288 context->recordError(gl::Error(GL_INVALID_OPERATION));
2289 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002290 }
2291
2292 switch (attachment)
2293 {
2294 case GL_BACK:
2295 case GL_DEPTH:
2296 case GL_STENCIL:
2297 break;
Geoff Langb1196682014-07-23 13:47:29 -04002298
Geoff Langbfdea662014-07-23 14:16:32 -04002299 default:
Geoff Langb1196682014-07-23 13:47:29 -04002300 context->recordError(gl::Error(GL_INVALID_OPERATION));
2301 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002302 }
2303 }
2304 else
2305 {
2306 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2307 {
2308 // Valid attachment query
2309 }
2310 else
2311 {
2312 switch (attachment)
2313 {
2314 case GL_DEPTH_ATTACHMENT:
2315 case GL_STENCIL_ATTACHMENT:
2316 break;
Geoff Langb1196682014-07-23 13:47:29 -04002317
Geoff Langbfdea662014-07-23 14:16:32 -04002318 case GL_DEPTH_STENCIL_ATTACHMENT:
2319 if (framebuffer->hasValidDepthStencil())
2320 {
Geoff Langb1196682014-07-23 13:47:29 -04002321 context->recordError(gl::Error(GL_INVALID_OPERATION));
2322 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002323 }
2324 break;
Geoff Langb1196682014-07-23 13:47:29 -04002325
Geoff Langbfdea662014-07-23 14:16:32 -04002326 default:
Geoff Langb1196682014-07-23 13:47:29 -04002327 context->recordError(gl::Error(GL_INVALID_OPERATION));
2328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002329 }
2330 }
2331 }
2332
2333 GLenum attachmentType = GL_NONE;
2334 GLuint attachmentHandle = 0;
2335 GLuint attachmentLevel = 0;
2336 GLuint attachmentLayer = 0;
2337
2338 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2339
2340 if (attachmentObject)
2341 {
2342 attachmentType = attachmentObject->type();
2343 attachmentHandle = attachmentObject->id();
2344 attachmentLevel = attachmentObject->mipLevel();
2345 attachmentLayer = attachmentObject->layer();
2346 }
2347
2348 GLenum attachmentObjectType; // Type category
2349 if (framebufferHandle == 0)
2350 {
2351 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2352 }
2353 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2354 {
2355 attachmentObjectType = attachmentType;
2356 }
2357 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2358 {
2359 attachmentObjectType = GL_TEXTURE;
2360 }
2361 else
2362 {
2363 UNREACHABLE();
2364 return;
2365 }
2366
2367 if (attachmentObjectType == GL_NONE)
2368 {
2369 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2370 // is NONE, then querying any other pname will generate INVALID_ENUM.
2371
2372 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2373 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2374 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002375
Geoff Lang646559f2013-08-15 11:08:15 -04002376 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002377 {
Geoff Lang646559f2013-08-15 11:08:15 -04002378 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002379 *params = attachmentObjectType;
2380 break;
2381
Geoff Lang646559f2013-08-15 11:08:15 -04002382 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002383 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002384 {
Geoff Langb1196682014-07-23 13:47:29 -04002385 context->recordError(gl::Error(GL_INVALID_ENUM));
2386 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002387 }
Geoff Langbfdea662014-07-23 14:16:32 -04002388 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002389 break;
2390
2391 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002392 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002393 {
Geoff Langb1196682014-07-23 13:47:29 -04002394 context->recordError(gl::Error(GL_INVALID_ENUM));
2395 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002396 }
2397 else
2398 {
Geoff Langb1196682014-07-23 13:47:29 -04002399 context->recordError(gl::Error(GL_INVALID_OPERATION));
2400 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002401 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002402 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002403 }
Geoff Langbfdea662014-07-23 14:16:32 -04002404 else
2405 {
2406 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2407 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2408 ASSERT(attachmentObject != NULL);
2409
2410 switch (pname)
2411 {
2412 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2413 *params = attachmentObjectType;
2414 break;
2415
2416 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2417 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2418 {
Geoff Langb1196682014-07-23 13:47:29 -04002419 context->recordError(gl::Error(GL_INVALID_ENUM));
2420 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002421 }
2422 *params = attachmentHandle;
2423 break;
2424
2425 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2426 if (attachmentObjectType != GL_TEXTURE)
2427 {
Geoff Langb1196682014-07-23 13:47:29 -04002428 context->recordError(gl::Error(GL_INVALID_ENUM));
2429 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002430 }
2431 *params = attachmentLevel;
2432 break;
2433
2434 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2435 if (attachmentObjectType != GL_TEXTURE)
2436 {
Geoff Langb1196682014-07-23 13:47:29 -04002437 context->recordError(gl::Error(GL_INVALID_ENUM));
2438 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002439 }
2440 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2441 break;
2442
2443 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2444 *params = attachmentObject->getRedSize();
2445 break;
2446
2447 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2448 *params = attachmentObject->getGreenSize();
2449 break;
2450
2451 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2452 *params = attachmentObject->getBlueSize();
2453 break;
2454
2455 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2456 *params = attachmentObject->getAlphaSize();
2457 break;
2458
2459 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2460 *params = attachmentObject->getDepthSize();
2461 break;
2462
2463 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2464 *params = attachmentObject->getStencilSize();
2465 break;
2466
2467 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002468 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002469 {
Geoff Langb1196682014-07-23 13:47:29 -04002470 context->recordError(gl::Error(GL_INVALID_OPERATION));
2471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002472 }
2473 *params = attachmentObject->getComponentType();
2474 break;
2475
2476 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2477 *params = attachmentObject->getColorEncoding();
2478 break;
2479
2480 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2481 if (attachmentObjectType != GL_TEXTURE)
2482 {
Geoff Langb1196682014-07-23 13:47:29 -04002483 context->recordError(gl::Error(GL_INVALID_ENUM));
2484 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002485 }
2486 *params = attachmentLayer;
2487 break;
2488
2489 default:
2490 UNREACHABLE();
2491 break;
2492 }
2493 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002494 }
2495}
2496
Kenneth Russell67ea1902014-10-06 16:44:50 -07002497GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002498{
2499 EVENT("()");
2500
Geoff Langbfdea662014-07-23 14:16:32 -04002501 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002502
Geoff Langbfdea662014-07-23 14:16:32 -04002503 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002504 {
Geoff Langbfdea662014-07-23 14:16:32 -04002505 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002506 }
Geoff Langbfdea662014-07-23 14:16:32 -04002507
2508 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002509}
2510
Kenneth Russell67ea1902014-10-06 16:44:50 -07002511void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002512{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002513 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002514
Geoff Langbfdea662014-07-23 14:16:32 -04002515 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002516 if (context)
2517 {
2518 GLenum nativeType;
2519 unsigned int numParams = 0;
2520
2521 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002522 {
Geoff Langbfdea662014-07-23 14:16:32 -04002523 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002524 }
Geoff Langbfdea662014-07-23 14:16:32 -04002525
2526 if (nativeType == GL_INT)
2527 {
2528 context->getIntegerv(pname, params);
2529 }
2530 else
2531 {
2532 CastStateValues(context, nativeType, pname, numParams, params);
2533 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002534 }
2535}
2536
Kenneth Russell67ea1902014-10-06 16:44:50 -07002537void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002538{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002539 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002540
Geoff Langbfdea662014-07-23 14:16:32 -04002541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002542 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543 {
Geoff Langbfdea662014-07-23 14:16:32 -04002544 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002545
Geoff Langbfdea662014-07-23 14:16:32 -04002546 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002547 {
Geoff Langb1196682014-07-23 13:47:29 -04002548 context->recordError(gl::Error(GL_INVALID_VALUE));
2549 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002550 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002551
Geoff Langbfdea662014-07-23 14:16:32 -04002552 if (context->getClientVersion() < 3)
2553 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002554 switch (pname)
2555 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002556 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002557 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002558 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002559 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002560 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002561 context->recordError(gl::Error(GL_INVALID_ENUM));
2562 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002563 }
2564 }
Geoff Langbfdea662014-07-23 14:16:32 -04002565
2566 switch (pname)
2567 {
2568 case GL_DELETE_STATUS:
2569 *params = programObject->isFlaggedForDeletion();
2570 return;
2571 case GL_LINK_STATUS:
2572 *params = programObject->isLinked();
2573 return;
2574 case GL_VALIDATE_STATUS:
2575 *params = programObject->isValidated();
2576 return;
2577 case GL_INFO_LOG_LENGTH:
2578 *params = programObject->getInfoLogLength();
2579 return;
2580 case GL_ATTACHED_SHADERS:
2581 *params = programObject->getAttachedShadersCount();
2582 return;
2583 case GL_ACTIVE_ATTRIBUTES:
2584 *params = programObject->getActiveAttributeCount();
2585 return;
2586 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2587 *params = programObject->getActiveAttributeMaxLength();
2588 return;
2589 case GL_ACTIVE_UNIFORMS:
2590 *params = programObject->getActiveUniformCount();
2591 return;
2592 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2593 *params = programObject->getActiveUniformMaxLength();
2594 return;
2595 case GL_PROGRAM_BINARY_LENGTH_OES:
2596 *params = programObject->getProgramBinaryLength();
2597 return;
2598 case GL_ACTIVE_UNIFORM_BLOCKS:
2599 *params = programObject->getActiveUniformBlockCount();
2600 return;
2601 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2602 *params = programObject->getActiveUniformBlockMaxLength();
2603 break;
2604 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2605 *params = programObject->getTransformFeedbackBufferMode();
2606 break;
2607 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2608 *params = programObject->getTransformFeedbackVaryingCount();
2609 break;
2610 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2611 *params = programObject->getTransformFeedbackVaryingMaxLength();
2612 break;
Geoff Langb1196682014-07-23 13:47:29 -04002613
Geoff Langbfdea662014-07-23 14:16:32 -04002614 default:
Geoff Langb1196682014-07-23 13:47:29 -04002615 context->recordError(gl::Error(GL_INVALID_ENUM));
2616 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002617 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002618 }
2619}
2620
Kenneth Russell67ea1902014-10-06 16:44:50 -07002621void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002622{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002623 EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002624 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002625
Geoff Langbfdea662014-07-23 14:16:32 -04002626 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002627 if (context)
2628 {
Geoff Langb1196682014-07-23 13:47:29 -04002629 if (bufsize < 0)
2630 {
2631 context->recordError(gl::Error(GL_INVALID_VALUE));
2632 return;
2633 }
2634
Geoff Langbfdea662014-07-23 14:16:32 -04002635 gl::Program *programObject = context->getProgram(program);
2636
2637 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002638 {
Geoff Langb1196682014-07-23 13:47:29 -04002639 context->recordError(gl::Error(GL_INVALID_VALUE));
2640 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002641 }
2642
Geoff Langbfdea662014-07-23 14:16:32 -04002643 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002644 }
2645}
2646
Kenneth Russell67ea1902014-10-06 16:44:50 -07002647void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002648{
2649 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2650
Geoff Langbfdea662014-07-23 14:16:32 -04002651 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002652 if (context)
2653 {
2654 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002655 {
Geoff Langb1196682014-07-23 13:47:29 -04002656 context->recordError(gl::Error(GL_INVALID_ENUM));
2657 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002658 }
Geoff Langbfdea662014-07-23 14:16:32 -04002659
2660 switch (pname)
2661 {
2662 case GL_CURRENT_QUERY_EXT:
2663 params[0] = context->getState().getActiveQueryId(target);
2664 break;
2665
2666 default:
Geoff Langb1196682014-07-23 13:47:29 -04002667 context->recordError(gl::Error(GL_INVALID_ENUM));
2668 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002669 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002670 }
2671}
2672
Kenneth Russell67ea1902014-10-06 16:44:50 -07002673void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002674{
2675 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2676
Geoff Langbfdea662014-07-23 14:16:32 -04002677 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002678 if (context)
2679 {
2680 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2681
2682 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002683 {
Geoff Langb1196682014-07-23 13:47:29 -04002684 context->recordError(gl::Error(GL_INVALID_OPERATION));
2685 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002686 }
Geoff Langbfdea662014-07-23 14:16:32 -04002687
2688 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2689 {
Geoff Langb1196682014-07-23 13:47:29 -04002690 context->recordError(gl::Error(GL_INVALID_OPERATION));
2691 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002692 }
2693
2694 switch(pname)
2695 {
2696 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002697 {
2698 gl::Error error = queryObject->getResult(params);
2699 if (error.isError())
2700 {
2701 context->recordError(error);
2702 return;
2703 }
2704 }
Geoff Langbfdea662014-07-23 14:16:32 -04002705 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002706
Geoff Langbfdea662014-07-23 14:16:32 -04002707 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002708 {
2709 gl::Error error = queryObject->isResultAvailable(params);
2710 if (error.isError())
2711 {
2712 context->recordError(error);
2713 return;
2714 }
2715 }
Geoff Langbfdea662014-07-23 14:16:32 -04002716 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002717
Geoff Langbfdea662014-07-23 14:16:32 -04002718 default:
Geoff Langb1196682014-07-23 13:47:29 -04002719 context->recordError(gl::Error(GL_INVALID_ENUM));
2720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002721 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002722 }
2723}
2724
Kenneth Russell67ea1902014-10-06 16:44:50 -07002725void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002726{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002727 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002728
Geoff Langbfdea662014-07-23 14:16:32 -04002729 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002730 if (context)
2731 {
2732 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002733 {
Geoff Langb1196682014-07-23 13:47:29 -04002734 context->recordError(gl::Error(GL_INVALID_ENUM));
2735 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002736 }
Geoff Langbfdea662014-07-23 14:16:32 -04002737
2738 if (context->getState().getRenderbufferId() == 0)
2739 {
Geoff Langb1196682014-07-23 13:47:29 -04002740 context->recordError(gl::Error(GL_INVALID_OPERATION));
2741 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002742 }
2743
2744 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2745
2746 switch (pname)
2747 {
2748 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2749 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2750 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2751 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2752 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2753 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2754 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2755 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2756 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002757
Geoff Langbfdea662014-07-23 14:16:32 -04002758 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2759 if (!context->getExtensions().framebufferMultisample)
2760 {
Geoff Langb1196682014-07-23 13:47:29 -04002761 context->recordError(gl::Error(GL_INVALID_ENUM));
2762 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002763 }
2764 *params = renderbuffer->getSamples();
2765 break;
Geoff Langb1196682014-07-23 13:47:29 -04002766
Geoff Langbfdea662014-07-23 14:16:32 -04002767 default:
Geoff Langb1196682014-07-23 13:47:29 -04002768 context->recordError(gl::Error(GL_INVALID_ENUM));
2769 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002770 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002771 }
2772}
2773
Kenneth Russell67ea1902014-10-06 16:44:50 -07002774void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002775{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002776 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002777
Geoff Langbfdea662014-07-23 14:16:32 -04002778 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002779 if (context)
2780 {
2781 gl::Shader *shaderObject = context->getShader(shader);
2782
2783 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002784 {
Geoff Langb1196682014-07-23 13:47:29 -04002785 context->recordError(gl::Error(GL_INVALID_VALUE));
2786 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002787 }
Geoff Langbfdea662014-07-23 14:16:32 -04002788
2789 switch (pname)
2790 {
2791 case GL_SHADER_TYPE:
2792 *params = shaderObject->getType();
2793 return;
2794 case GL_DELETE_STATUS:
2795 *params = shaderObject->isFlaggedForDeletion();
2796 return;
2797 case GL_COMPILE_STATUS:
2798 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2799 return;
2800 case GL_INFO_LOG_LENGTH:
2801 *params = shaderObject->getInfoLogLength();
2802 return;
2803 case GL_SHADER_SOURCE_LENGTH:
2804 *params = shaderObject->getSourceLength();
2805 return;
2806 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2807 *params = shaderObject->getTranslatedSourceLength();
2808 return;
Geoff Langb1196682014-07-23 13:47:29 -04002809
Geoff Langbfdea662014-07-23 14:16:32 -04002810 default:
Geoff Langb1196682014-07-23 13:47:29 -04002811 context->recordError(gl::Error(GL_INVALID_ENUM));
2812 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002813 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002814 }
2815}
2816
Kenneth Russell67ea1902014-10-06 16:44:50 -07002817void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002818{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002819 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002820 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002821
Geoff Langbfdea662014-07-23 14:16:32 -04002822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002823 if (context)
2824 {
Geoff Langb1196682014-07-23 13:47:29 -04002825 if (bufsize < 0)
2826 {
2827 context->recordError(gl::Error(GL_INVALID_VALUE));
2828 return;
2829 }
2830
Geoff Langbfdea662014-07-23 14:16:32 -04002831 gl::Shader *shaderObject = context->getShader(shader);
2832
2833 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002834 {
Geoff Langb1196682014-07-23 13:47:29 -04002835 context->recordError(gl::Error(GL_INVALID_VALUE));
2836 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002837 }
2838
Geoff Langbfdea662014-07-23 14:16:32 -04002839 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002840 }
2841}
2842
Kenneth Russell67ea1902014-10-06 16:44:50 -07002843void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002845 EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002846 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002847
Geoff Langb1196682014-07-23 13:47:29 -04002848 gl::Context *context = gl::getNonLostContext();
2849 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002850 {
Geoff Langb1196682014-07-23 13:47:29 -04002851 switch (shadertype)
2852 {
2853 case GL_VERTEX_SHADER:
2854 case GL_FRAGMENT_SHADER:
2855 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002856
Geoff Langb1196682014-07-23 13:47:29 -04002857 default:
2858 context->recordError(gl::Error(GL_INVALID_ENUM));
2859 return;
2860 }
2861
2862 switch (precisiontype)
2863 {
2864 case GL_LOW_FLOAT:
2865 case GL_MEDIUM_FLOAT:
2866 case GL_HIGH_FLOAT:
2867 // Assume IEEE 754 precision
2868 range[0] = 127;
2869 range[1] = 127;
2870 *precision = 23;
2871 break;
2872
2873 case GL_LOW_INT:
2874 case GL_MEDIUM_INT:
2875 case GL_HIGH_INT:
2876 // Some (most) hardware only supports single-precision floating-point numbers,
2877 // which can accurately represent integers up to +/-16777216
2878 range[0] = 24;
2879 range[1] = 24;
2880 *precision = 0;
2881 break;
2882
2883 default:
2884 context->recordError(gl::Error(GL_INVALID_ENUM));
2885 return;
2886 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002887 }
2888}
2889
Kenneth Russell67ea1902014-10-06 16:44:50 -07002890void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002891{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002892 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002893 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002894
Geoff Langbfdea662014-07-23 14:16:32 -04002895 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002896 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002897 {
Geoff Langb1196682014-07-23 13:47:29 -04002898 if (bufsize < 0)
2899 {
2900 context->recordError(gl::Error(GL_INVALID_VALUE));
2901 return;
2902 }
2903
Geoff Langbfdea662014-07-23 14:16:32 -04002904 gl::Shader *shaderObject = context->getShader(shader);
2905
2906 if (!shaderObject)
2907 {
Geoff Langb1196682014-07-23 13:47:29 -04002908 context->recordError(gl::Error(GL_INVALID_OPERATION));
2909 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002910 }
2911
2912 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002913 }
2914}
2915
Kenneth Russell67ea1902014-10-06 16:44:50 -07002916void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002917{
2918 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2919 shader, bufsize, length, source);
2920
Geoff Langbfdea662014-07-23 14:16:32 -04002921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002922 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002923 {
Geoff Langb1196682014-07-23 13:47:29 -04002924 if (bufsize < 0)
2925 {
2926 context->recordError(gl::Error(GL_INVALID_VALUE));
2927 return;
2928 }
2929
Geoff Langbfdea662014-07-23 14:16:32 -04002930 gl::Shader *shaderObject = context->getShader(shader);
2931
2932 if (!shaderObject)
2933 {
Geoff Langb1196682014-07-23 13:47:29 -04002934 context->recordError(gl::Error(GL_INVALID_OPERATION));
2935 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002936 }
2937
Tibor den Ouden97049c62014-10-06 21:39:16 +02002938 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2939 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002940 }
2941}
2942
Kenneth Russell67ea1902014-10-06 16:44:50 -07002943const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002944{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002945 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002946
Geoff Langbfdea662014-07-23 14:16:32 -04002947 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002948
Geoff Langbfdea662014-07-23 14:16:32 -04002949 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002950 {
Geoff Langbfdea662014-07-23 14:16:32 -04002951 case GL_VENDOR:
2952 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002953
Geoff Langbfdea662014-07-23 14:16:32 -04002954 case GL_RENDERER:
2955 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002956
Geoff Langbfdea662014-07-23 14:16:32 -04002957 case GL_VERSION:
2958 if (context->getClientVersion() == 2)
2959 {
2960 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2961 }
2962 else
2963 {
2964 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2965 }
Geoff Langb1196682014-07-23 13:47:29 -04002966
Geoff Langbfdea662014-07-23 14:16:32 -04002967 case GL_SHADING_LANGUAGE_VERSION:
2968 if (context->getClientVersion() == 2)
2969 {
2970 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2971 }
2972 else
2973 {
2974 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2975 }
Geoff Langb1196682014-07-23 13:47:29 -04002976
Geoff Langbfdea662014-07-23 14:16:32 -04002977 case GL_EXTENSIONS:
2978 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002979
Geoff Langbfdea662014-07-23 14:16:32 -04002980 default:
Geoff Langb1196682014-07-23 13:47:29 -04002981 if (context)
2982 {
2983 context->recordError(gl::Error(GL_INVALID_ENUM));
2984 }
2985 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002986 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002987}
2988
Kenneth Russell67ea1902014-10-06 16:44:50 -07002989void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002990{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002991 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 +00002992
Geoff Langbfdea662014-07-23 14:16:32 -04002993 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002994 if (context)
2995 {
2996 gl::Texture *texture = context->getTargetTexture(target);
2997
2998 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002999 {
Geoff Langb1196682014-07-23 13:47:29 -04003000 context->recordError(gl::Error(GL_INVALID_ENUM));
3001 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003002 }
Geoff Langbfdea662014-07-23 14:16:32 -04003003
3004 switch (pname)
3005 {
3006 case GL_TEXTURE_MAG_FILTER:
3007 *params = (GLfloat)texture->getSamplerState().magFilter;
3008 break;
3009 case GL_TEXTURE_MIN_FILTER:
3010 *params = (GLfloat)texture->getSamplerState().minFilter;
3011 break;
3012 case GL_TEXTURE_WRAP_S:
3013 *params = (GLfloat)texture->getSamplerState().wrapS;
3014 break;
3015 case GL_TEXTURE_WRAP_T:
3016 *params = (GLfloat)texture->getSamplerState().wrapT;
3017 break;
3018 case GL_TEXTURE_WRAP_R:
3019 if (context->getClientVersion() < 3)
3020 {
Geoff Langb1196682014-07-23 13:47:29 -04003021 context->recordError(gl::Error(GL_INVALID_ENUM));
3022 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003023 }
3024 *params = (GLfloat)texture->getSamplerState().wrapR;
3025 break;
3026 case GL_TEXTURE_IMMUTABLE_FORMAT:
3027 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3028 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3029 break;
3030 case GL_TEXTURE_IMMUTABLE_LEVELS:
3031 if (context->getClientVersion() < 3)
3032 {
Geoff Langb1196682014-07-23 13:47:29 -04003033 context->recordError(gl::Error(GL_INVALID_ENUM));
3034 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003035 }
3036 *params = (GLfloat)texture->immutableLevelCount();
3037 break;
3038 case GL_TEXTURE_USAGE_ANGLE:
3039 *params = (GLfloat)texture->getUsage();
3040 break;
3041 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3042 if (!context->getExtensions().textureFilterAnisotropic)
3043 {
Geoff Langb1196682014-07-23 13:47:29 -04003044 context->recordError(gl::Error(GL_INVALID_ENUM));
3045 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003046 }
3047 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3048 break;
3049 case GL_TEXTURE_SWIZZLE_R:
3050 if (context->getClientVersion() < 3)
3051 {
Geoff Langb1196682014-07-23 13:47:29 -04003052 context->recordError(gl::Error(GL_INVALID_ENUM));
3053 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003054 }
3055 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3056 break;
3057 case GL_TEXTURE_SWIZZLE_G:
3058 if (context->getClientVersion() < 3)
3059 {
Geoff Langb1196682014-07-23 13:47:29 -04003060 context->recordError(gl::Error(GL_INVALID_ENUM));
3061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003062 }
3063 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3064 break;
3065 case GL_TEXTURE_SWIZZLE_B:
3066 if (context->getClientVersion() < 3)
3067 {
Geoff Langb1196682014-07-23 13:47:29 -04003068 context->recordError(gl::Error(GL_INVALID_ENUM));
3069 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003070 }
3071 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3072 break;
3073 case GL_TEXTURE_SWIZZLE_A:
3074 if (context->getClientVersion() < 3)
3075 {
Geoff Langb1196682014-07-23 13:47:29 -04003076 context->recordError(gl::Error(GL_INVALID_ENUM));
3077 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003078 }
3079 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3080 break;
3081 case GL_TEXTURE_BASE_LEVEL:
3082 if (context->getClientVersion() < 3)
3083 {
Geoff Langb1196682014-07-23 13:47:29 -04003084 context->recordError(gl::Error(GL_INVALID_ENUM));
3085 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003086 }
3087 *params = (GLfloat)texture->getSamplerState().baseLevel;
3088 break;
3089 case GL_TEXTURE_MAX_LEVEL:
3090 if (context->getClientVersion() < 3)
3091 {
Geoff Langb1196682014-07-23 13:47:29 -04003092 context->recordError(gl::Error(GL_INVALID_ENUM));
3093 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003094 }
3095 *params = (GLfloat)texture->getSamplerState().maxLevel;
3096 break;
3097 case GL_TEXTURE_MIN_LOD:
3098 if (context->getClientVersion() < 3)
3099 {
Geoff Langb1196682014-07-23 13:47:29 -04003100 context->recordError(gl::Error(GL_INVALID_ENUM));
3101 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003102 }
3103 *params = texture->getSamplerState().minLod;
3104 break;
3105 case GL_TEXTURE_MAX_LOD:
3106 if (context->getClientVersion() < 3)
3107 {
Geoff Langb1196682014-07-23 13:47:29 -04003108 context->recordError(gl::Error(GL_INVALID_ENUM));
3109 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003110 }
3111 *params = texture->getSamplerState().maxLod;
3112 break;
Geoff Langb1196682014-07-23 13:47:29 -04003113
Geoff Langbfdea662014-07-23 14:16:32 -04003114 default:
Geoff Langb1196682014-07-23 13:47:29 -04003115 context->recordError(gl::Error(GL_INVALID_ENUM));
3116 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003117 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003118 }
3119}
3120
Kenneth Russell67ea1902014-10-06 16:44:50 -07003121void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003122{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003123 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 +00003124
Geoff Langbfdea662014-07-23 14:16:32 -04003125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003126 if (context)
3127 {
3128 gl::Texture *texture = context->getTargetTexture(target);
3129
3130 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003131 {
Geoff Langb1196682014-07-23 13:47:29 -04003132 context->recordError(gl::Error(GL_INVALID_ENUM));
3133 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003134 }
Geoff Langbfdea662014-07-23 14:16:32 -04003135
3136 switch (pname)
3137 {
3138 case GL_TEXTURE_MAG_FILTER:
3139 *params = texture->getSamplerState().magFilter;
3140 break;
3141 case GL_TEXTURE_MIN_FILTER:
3142 *params = texture->getSamplerState().minFilter;
3143 break;
3144 case GL_TEXTURE_WRAP_S:
3145 *params = texture->getSamplerState().wrapS;
3146 break;
3147 case GL_TEXTURE_WRAP_T:
3148 *params = texture->getSamplerState().wrapT;
3149 break;
3150 case GL_TEXTURE_WRAP_R:
3151 if (context->getClientVersion() < 3)
3152 {
Geoff Langb1196682014-07-23 13:47:29 -04003153 context->recordError(gl::Error(GL_INVALID_ENUM));
3154 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003155 }
3156 *params = texture->getSamplerState().wrapR;
3157 break;
3158 case GL_TEXTURE_IMMUTABLE_FORMAT:
3159 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3160 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3161 break;
3162 case GL_TEXTURE_IMMUTABLE_LEVELS:
3163 if (context->getClientVersion() < 3)
3164 {
Geoff Langb1196682014-07-23 13:47:29 -04003165 context->recordError(gl::Error(GL_INVALID_ENUM));
3166 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003167 }
Jamie Madill6948e302014-10-20 17:04:33 -04003168 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003169 break;
3170 case GL_TEXTURE_USAGE_ANGLE:
3171 *params = texture->getUsage();
3172 break;
3173 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3174 if (!context->getExtensions().textureFilterAnisotropic)
3175 {
Geoff Langb1196682014-07-23 13:47:29 -04003176 context->recordError(gl::Error(GL_INVALID_ENUM));
3177 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003178 }
3179 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3180 break;
3181 case GL_TEXTURE_SWIZZLE_R:
3182 if (context->getClientVersion() < 3)
3183 {
Geoff Langb1196682014-07-23 13:47:29 -04003184 context->recordError(gl::Error(GL_INVALID_ENUM));
3185 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003186 }
3187 *params = texture->getSamplerState().swizzleRed;
3188 break;
3189 case GL_TEXTURE_SWIZZLE_G:
3190 if (context->getClientVersion() < 3)
3191 {
Geoff Langb1196682014-07-23 13:47:29 -04003192 context->recordError(gl::Error(GL_INVALID_ENUM));
3193 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003194 }
3195 *params = texture->getSamplerState().swizzleGreen;
3196 break;
3197 case GL_TEXTURE_SWIZZLE_B:
3198 if (context->getClientVersion() < 3)
3199 {
Geoff Langb1196682014-07-23 13:47:29 -04003200 context->recordError(gl::Error(GL_INVALID_ENUM));
3201 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003202 }
3203 *params = texture->getSamplerState().swizzleBlue;
3204 break;
3205 case GL_TEXTURE_SWIZZLE_A:
3206 if (context->getClientVersion() < 3)
3207 {
Geoff Langb1196682014-07-23 13:47:29 -04003208 context->recordError(gl::Error(GL_INVALID_ENUM));
3209 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003210 }
3211 *params = texture->getSamplerState().swizzleAlpha;
3212 break;
3213 case GL_TEXTURE_BASE_LEVEL:
3214 if (context->getClientVersion() < 3)
3215 {
Geoff Langb1196682014-07-23 13:47:29 -04003216 context->recordError(gl::Error(GL_INVALID_ENUM));
3217 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003218 }
3219 *params = texture->getSamplerState().baseLevel;
3220 break;
3221 case GL_TEXTURE_MAX_LEVEL:
3222 if (context->getClientVersion() < 3)
3223 {
Geoff Langb1196682014-07-23 13:47:29 -04003224 context->recordError(gl::Error(GL_INVALID_ENUM));
3225 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003226 }
3227 *params = texture->getSamplerState().maxLevel;
3228 break;
3229 case GL_TEXTURE_MIN_LOD:
3230 if (context->getClientVersion() < 3)
3231 {
Geoff Langb1196682014-07-23 13:47:29 -04003232 context->recordError(gl::Error(GL_INVALID_ENUM));
3233 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003234 }
3235 *params = (GLint)texture->getSamplerState().minLod;
3236 break;
3237 case GL_TEXTURE_MAX_LOD:
3238 if (context->getClientVersion() < 3)
3239 {
Geoff Langb1196682014-07-23 13:47:29 -04003240 context->recordError(gl::Error(GL_INVALID_ENUM));
3241 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003242 }
3243 *params = (GLint)texture->getSamplerState().maxLod;
3244 break;
Geoff Langb1196682014-07-23 13:47:29 -04003245
Geoff Langbfdea662014-07-23 14:16:32 -04003246 default:
Geoff Langb1196682014-07-23 13:47:29 -04003247 context->recordError(gl::Error(GL_INVALID_ENUM));
3248 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003249 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003250 }
3251}
3252
Kenneth Russell67ea1902014-10-06 16:44:50 -07003253void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003254{
3255 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3256 program, location, bufSize, params);
3257
Geoff Langbfdea662014-07-23 14:16:32 -04003258 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003259 if (context)
3260 {
Jamie Madill0063c512014-08-25 15:47:53 -04003261 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003262 {
Jamie Madill0063c512014-08-25 15:47:53 -04003263 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003264 }
3265
Jamie Madilla502c742014-08-28 17:19:13 -04003266 gl::Program *programObject = context->getProgram(program);
3267 ASSERT(programObject);
3268 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003269 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003270
Jamie Madill99a1e982014-08-25 15:47:54 -04003271 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003272 }
3273}
3274
Kenneth Russell67ea1902014-10-06 16:44:50 -07003275void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003276{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003277 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003278
Geoff Langbfdea662014-07-23 14:16:32 -04003279 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003280 if (context)
3281 {
Jamie Madill0063c512014-08-25 15:47:53 -04003282 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003283 {
Jamie Madill0063c512014-08-25 15:47:53 -04003284 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003285 }
Geoff Langbfdea662014-07-23 14:16:32 -04003286
Jamie Madilla502c742014-08-28 17:19:13 -04003287 gl::Program *programObject = context->getProgram(program);
3288 ASSERT(programObject);
3289 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003290 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003291
Jamie Madill99a1e982014-08-25 15:47:54 -04003292 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003293 }
3294}
3295
Kenneth Russell67ea1902014-10-06 16:44:50 -07003296void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003297{
Geoff Langbfdea662014-07-23 14:16:32 -04003298 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003299 program, location, bufSize, params);
3300
Geoff Langbfdea662014-07-23 14:16:32 -04003301 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003302 if (context)
3303 {
Jamie Madill0063c512014-08-25 15:47:53 -04003304 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003305 {
Jamie Madill0063c512014-08-25 15:47:53 -04003306 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003307 }
3308
Jamie Madilla502c742014-08-28 17:19:13 -04003309 gl::Program *programObject = context->getProgram(program);
3310 ASSERT(programObject);
3311 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003312 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003313
Jamie Madill99a1e982014-08-25 15:47:54 -04003314 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003315 }
3316}
3317
Kenneth Russell67ea1902014-10-06 16:44:50 -07003318void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003319{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003320 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003321
Geoff Langbfdea662014-07-23 14:16:32 -04003322 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003323 if (context)
3324 {
Jamie Madill0063c512014-08-25 15:47:53 -04003325 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003326 {
Jamie Madill0063c512014-08-25 15:47:53 -04003327 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003328 }
Geoff Langbfdea662014-07-23 14:16:32 -04003329
Jamie Madilla502c742014-08-28 17:19:13 -04003330 gl::Program *programObject = context->getProgram(program);
3331 ASSERT(programObject);
3332 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003333 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003334
Jamie Madill99a1e982014-08-25 15:47:54 -04003335 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003336 }
3337}
3338
Kenneth Russell67ea1902014-10-06 16:44:50 -07003339GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003340{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003341 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342
Geoff Langbfdea662014-07-23 14:16:32 -04003343 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003344 if (context)
3345 {
Geoff Langb1196682014-07-23 13:47:29 -04003346 if (strstr(name, "gl_") == name)
3347 {
3348 return -1;
3349 }
3350
Geoff Langbfdea662014-07-23 14:16:32 -04003351 gl::Program *programObject = context->getProgram(program);
3352
3353 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003354 {
Geoff Langbfdea662014-07-23 14:16:32 -04003355 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003356 {
Geoff Langb1196682014-07-23 13:47:29 -04003357 context->recordError(gl::Error(GL_INVALID_OPERATION));
3358 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003359 }
Geoff Langbfdea662014-07-23 14:16:32 -04003360 else
3361 {
Geoff Langb1196682014-07-23 13:47:29 -04003362 context->recordError(gl::Error(GL_INVALID_VALUE));
3363 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003364 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003365 }
Geoff Langbfdea662014-07-23 14:16:32 -04003366
3367 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3368 if (!programObject->isLinked() || !programBinary)
3369 {
Geoff Langb1196682014-07-23 13:47:29 -04003370 context->recordError(gl::Error(GL_INVALID_OPERATION));
3371 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003372 }
3373
3374 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003375 }
3376
3377 return -1;
3378}
3379
Kenneth Russell67ea1902014-10-06 16:44:50 -07003380void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003381{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003382 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003383
Geoff Langbfdea662014-07-23 14:16:32 -04003384 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003385 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003386 {
Geoff Langbfdea662014-07-23 14:16:32 -04003387 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003388 {
Geoff Langb1196682014-07-23 13:47:29 -04003389 context->recordError(gl::Error(GL_INVALID_VALUE));
3390 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003391 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003392
Geoff Langbfdea662014-07-23 14:16:32 -04003393 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003394 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003395 {
3396 return;
3397 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003398
Geoff Langbfdea662014-07-23 14:16:32 -04003399 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3400 {
3401 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3402 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003403 {
Geoff Langbfdea662014-07-23 14:16:32 -04003404 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003405 }
3406 }
Geoff Langbfdea662014-07-23 14:16:32 -04003407 else
3408 {
3409 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3410 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003411 }
3412}
3413
Kenneth Russell67ea1902014-10-06 16:44:50 -07003414void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003415{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003416 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003417
Geoff Langbfdea662014-07-23 14:16:32 -04003418 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003419 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003420 {
Geoff Langbfdea662014-07-23 14:16:32 -04003421 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003422 {
Geoff Langb1196682014-07-23 13:47:29 -04003423 context->recordError(gl::Error(GL_INVALID_VALUE));
3424 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003425 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003426
Geoff Langbfdea662014-07-23 14:16:32 -04003427 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003428
Geoff Langb1196682014-07-23 13:47:29 -04003429 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003430 {
3431 return;
3432 }
Jamie Madillaff71502013-07-02 11:57:05 -04003433
Geoff Langbfdea662014-07-23 14:16:32 -04003434 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3435 {
3436 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3437 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003438 {
Geoff Langbfdea662014-07-23 14:16:32 -04003439 float currentValue = currentValueData.FloatValues[i];
3440 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003441 }
3442 }
Geoff Langbfdea662014-07-23 14:16:32 -04003443 else
3444 {
3445 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3446 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003447 }
3448}
3449
Kenneth Russell67ea1902014-10-06 16:44:50 -07003450void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003451{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003452 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003453
Geoff Langbfdea662014-07-23 14:16:32 -04003454 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003455 if (context)
3456 {
3457 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003458 {
Geoff Langb1196682014-07-23 13:47:29 -04003459 context->recordError(gl::Error(GL_INVALID_VALUE));
3460 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003461 }
Geoff Langbfdea662014-07-23 14:16:32 -04003462
3463 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3464 {
Geoff Langb1196682014-07-23 13:47:29 -04003465 context->recordError(gl::Error(GL_INVALID_ENUM));
3466 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003467 }
3468
3469 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003470 }
3471}
3472
Kenneth Russell67ea1902014-10-06 16:44:50 -07003473void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003474{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003475 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003476
Geoff Langbfdea662014-07-23 14:16:32 -04003477 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003478 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003479 {
Geoff Langb1196682014-07-23 13:47:29 -04003480 switch (mode)
3481 {
3482 case GL_FASTEST:
3483 case GL_NICEST:
3484 case GL_DONT_CARE:
3485 break;
3486
3487 default:
3488 context->recordError(gl::Error(GL_INVALID_ENUM));
3489 return;
3490 }
3491
3492 switch (target)
3493 {
3494 case GL_GENERATE_MIPMAP_HINT:
3495 context->getState().setGenerateMipmapHint(mode);
3496 break;
3497
3498 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3499 context->getState().setFragmentShaderDerivativeHint(mode);
3500 break;
3501
3502 default:
3503 context->recordError(gl::Error(GL_INVALID_ENUM));
3504 return;
3505 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003506 }
3507}
3508
Kenneth Russell67ea1902014-10-06 16:44:50 -07003509GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003510{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003511 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003512
Geoff Langbfdea662014-07-23 14:16:32 -04003513 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003514 if (context && buffer)
3515 {
3516 gl::Buffer *bufferObject = context->getBuffer(buffer);
3517
3518 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003519 {
Geoff Langbfdea662014-07-23 14:16:32 -04003520 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 }
3522 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003523
3524 return GL_FALSE;
3525}
3526
Kenneth Russell67ea1902014-10-06 16:44:50 -07003527GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003528{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003529 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003530
Geoff Langbfdea662014-07-23 14:16:32 -04003531 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003532 if (context)
3533 {
3534 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003535 {
Geoff Langb1196682014-07-23 13:47:29 -04003536 context->recordError(gl::Error(GL_INVALID_ENUM));
3537 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003538 }
Geoff Langbfdea662014-07-23 14:16:32 -04003539
3540 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003541 }
3542
3543 return false;
3544}
3545
Kenneth Russell67ea1902014-10-06 16:44:50 -07003546GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003548 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003549
Geoff Langbfdea662014-07-23 14:16:32 -04003550 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003551 if (context)
3552 {
3553 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3554
3555 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003556 {
Geoff Langbfdea662014-07-23 14:16:32 -04003557 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003558 }
Geoff Langbfdea662014-07-23 14:16:32 -04003559
3560 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003561 }
3562
3563 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003564}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003565
Kenneth Russell67ea1902014-10-06 16:44:50 -07003566GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003567{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003568 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003569
Geoff Langbfdea662014-07-23 14:16:32 -04003570 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003571 if (context && framebuffer)
3572 {
3573 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3574
3575 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003576 {
Geoff Langbfdea662014-07-23 14:16:32 -04003577 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003578 }
3579 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003580
3581 return GL_FALSE;
3582}
3583
Kenneth Russell67ea1902014-10-06 16:44:50 -07003584GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003586 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003587
Geoff Langbfdea662014-07-23 14:16:32 -04003588 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003589 if (context && program)
3590 {
3591 gl::Program *programObject = context->getProgram(program);
3592
3593 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594 {
Geoff Langbfdea662014-07-23 14:16:32 -04003595 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003596 }
3597 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003598
3599 return GL_FALSE;
3600}
3601
Kenneth Russell67ea1902014-10-06 16:44:50 -07003602GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003603{
3604 EVENT("(GLuint id = %d)", id);
3605
Geoff Langbfdea662014-07-23 14:16:32 -04003606 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003607 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003608 {
Geoff Langbfdea662014-07-23 14:16:32 -04003609 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003610 }
3611
3612 return GL_FALSE;
3613}
3614
Kenneth Russell67ea1902014-10-06 16:44:50 -07003615GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003616{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003617 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003618
Geoff Langbfdea662014-07-23 14:16:32 -04003619 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003620 if (context && renderbuffer)
3621 {
3622 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3623
3624 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003625 {
Geoff Langbfdea662014-07-23 14:16:32 -04003626 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003627 }
3628 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003629
3630 return GL_FALSE;
3631}
3632
Kenneth Russell67ea1902014-10-06 16:44:50 -07003633GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003634{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003635 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003636
Geoff Langbfdea662014-07-23 14:16:32 -04003637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003638 if (context && shader)
3639 {
3640 gl::Shader *shaderObject = context->getShader(shader);
3641
3642 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003643 {
Geoff Langbfdea662014-07-23 14:16:32 -04003644 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645 }
3646 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003647
3648 return GL_FALSE;
3649}
3650
Kenneth Russell67ea1902014-10-06 16:44:50 -07003651GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003652{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003653 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003654
Geoff Langbfdea662014-07-23 14:16:32 -04003655 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003656 if (context && texture)
3657 {
3658 gl::Texture *textureObject = context->getTexture(texture);
3659
3660 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661 {
Geoff Langbfdea662014-07-23 14:16:32 -04003662 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003663 }
3664 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003665
3666 return GL_FALSE;
3667}
3668
Kenneth Russell67ea1902014-10-06 16:44:50 -07003669void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003671 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003672
Geoff Langbfdea662014-07-23 14:16:32 -04003673 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003674 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003675 {
Geoff Langb1196682014-07-23 13:47:29 -04003676 if (width <= 0.0f)
3677 {
3678 context->recordError(gl::Error(GL_INVALID_VALUE));
3679 return;
3680 }
3681
Geoff Langbfdea662014-07-23 14:16:32 -04003682 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003683 }
3684}
3685
Kenneth Russell67ea1902014-10-06 16:44:50 -07003686void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003687{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003688 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003689
Geoff Langbfdea662014-07-23 14:16:32 -04003690 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003691 if (context)
3692 {
3693 gl::Program *programObject = context->getProgram(program);
3694
3695 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003696 {
Geoff Langbfdea662014-07-23 14:16:32 -04003697 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003698 {
Geoff Langb1196682014-07-23 13:47:29 -04003699 context->recordError(gl::Error(GL_INVALID_OPERATION));
3700 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003701 }
Geoff Langbfdea662014-07-23 14:16:32 -04003702 else
3703 {
Geoff Langb1196682014-07-23 13:47:29 -04003704 context->recordError(gl::Error(GL_INVALID_VALUE));
3705 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003706 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707 }
Geoff Langbfdea662014-07-23 14:16:32 -04003708
Geoff Langb543aff2014-09-30 14:52:54 -04003709 gl::Error error = context->linkProgram(program);
3710 if (error.isError())
3711 {
3712 context->recordError(error);
3713 return;
3714 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003715 }
3716}
3717
Kenneth Russell67ea1902014-10-06 16:44:50 -07003718void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003719{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003720 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003721
Geoff Langbfdea662014-07-23 14:16:32 -04003722 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003723 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724 {
Geoff Langbfdea662014-07-23 14:16:32 -04003725 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003726 {
Geoff Langbfdea662014-07-23 14:16:32 -04003727 case GL_UNPACK_ALIGNMENT:
3728 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003729 {
Geoff Langb1196682014-07-23 13:47:29 -04003730 context->recordError(gl::Error(GL_INVALID_VALUE));
3731 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003732 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003733
Geoff Langbfdea662014-07-23 14:16:32 -04003734 context->getState().setUnpackAlignment(param);
3735 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003736
Geoff Langbfdea662014-07-23 14:16:32 -04003737 case GL_PACK_ALIGNMENT:
3738 if (param != 1 && param != 2 && param != 4 && param != 8)
3739 {
Geoff Langb1196682014-07-23 13:47:29 -04003740 context->recordError(gl::Error(GL_INVALID_VALUE));
3741 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003742 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003743
Geoff Langbfdea662014-07-23 14:16:32 -04003744 context->getState().setPackAlignment(param);
3745 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003746
Geoff Langbfdea662014-07-23 14:16:32 -04003747 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3748 context->getState().setPackReverseRowOrder(param != 0);
3749 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003750
Geoff Langbfdea662014-07-23 14:16:32 -04003751 case GL_UNPACK_IMAGE_HEIGHT:
3752 case GL_UNPACK_SKIP_IMAGES:
3753 case GL_UNPACK_ROW_LENGTH:
3754 case GL_UNPACK_SKIP_ROWS:
3755 case GL_UNPACK_SKIP_PIXELS:
3756 case GL_PACK_ROW_LENGTH:
3757 case GL_PACK_SKIP_ROWS:
3758 case GL_PACK_SKIP_PIXELS:
3759 if (context->getClientVersion() < 3)
3760 {
Geoff Langb1196682014-07-23 13:47:29 -04003761 context->recordError(gl::Error(GL_INVALID_ENUM));
3762 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003763 }
Geoff Langbfdea662014-07-23 14:16:32 -04003764 UNIMPLEMENTED();
3765 break;
3766
3767 default:
Geoff Langb1196682014-07-23 13:47:29 -04003768 context->recordError(gl::Error(GL_INVALID_ENUM));
3769 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003770 }
3771 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003772}
3773
Kenneth Russell67ea1902014-10-06 16:44:50 -07003774void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003775{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003776 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003777
Geoff Langbfdea662014-07-23 14:16:32 -04003778 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003779 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003780 {
Geoff Langbfdea662014-07-23 14:16:32 -04003781 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003782 }
3783}
3784
Kenneth Russell67ea1902014-10-06 16:44:50 -07003785void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003786 GLenum format, GLenum type, GLsizei bufSize,
3787 GLvoid *data)
3788{
3789 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3790 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3791 x, y, width, height, format, type, bufSize, data);
3792
Geoff Langbfdea662014-07-23 14:16:32 -04003793 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003794 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003795 {
Geoff Langb1196682014-07-23 13:47:29 -04003796 if (width < 0 || height < 0 || bufSize < 0)
3797 {
3798 context->recordError(gl::Error(GL_INVALID_VALUE));
3799 return;
3800 }
3801
Geoff Langbfdea662014-07-23 14:16:32 -04003802 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3803 format, type, &bufSize, data))
3804 {
3805 return;
3806 }
3807
Geoff Lang63d2fc72014-07-25 14:51:41 -04003808 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3809 if (error.isError())
3810 {
3811 context->recordError(error);
3812 return;
3813 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003814 }
3815}
3816
Kenneth Russell67ea1902014-10-06 16:44:50 -07003817void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003818 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003819{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003820 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003821 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003822 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003823
Geoff Langbfdea662014-07-23 14:16:32 -04003824 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003825 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003826 {
Geoff Langb1196682014-07-23 13:47:29 -04003827 if (width < 0 || height < 0)
3828 {
3829 context->recordError(gl::Error(GL_INVALID_VALUE));
3830 return;
3831 }
3832
Geoff Langbfdea662014-07-23 14:16:32 -04003833 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3834 format, type, NULL, pixels))
3835 {
3836 return;
3837 }
3838
Geoff Lang63d2fc72014-07-25 14:51:41 -04003839 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3840 if (error.isError())
3841 {
3842 context->recordError(error);
3843 return;
3844 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003845 }
3846}
3847
Kenneth Russell67ea1902014-10-06 16:44:50 -07003848void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003849{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003850 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003851
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003852 gl::Context *context = gl::getNonLostContext();
3853
3854 if (context)
3855 {
3856 context->releaseShaderCompiler();
3857 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858}
3859
Kenneth Russell67ea1902014-10-06 16:44:50 -07003860void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003862 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 +00003863 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003864
Geoff Langbfdea662014-07-23 14:16:32 -04003865 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003866 if (context)
3867 {
3868 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3869 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003870 {
Geoff Langbfdea662014-07-23 14:16:32 -04003871 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003872 }
Geoff Langbfdea662014-07-23 14:16:32 -04003873
3874 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003875 }
3876}
3877
Kenneth Russell67ea1902014-10-06 16:44:50 -07003878void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003879{
3880 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3881}
3882
Kenneth Russell67ea1902014-10-06 16:44:50 -07003883void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003884{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003885 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003886
Geoff Langbfdea662014-07-23 14:16:32 -04003887 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003888
Geoff Langbfdea662014-07-23 14:16:32 -04003889 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003890 {
Geoff Langbfdea662014-07-23 14:16:32 -04003891 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003892 }
3893}
3894
Kenneth Russell67ea1902014-10-06 16:44:50 -07003895void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003896{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003897 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003898
Geoff Langbfdea662014-07-23 14:16:32 -04003899 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003900 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003901 {
Geoff Langb1196682014-07-23 13:47:29 -04003902 if (condition != GL_ALL_COMPLETED_NV)
3903 {
3904 context->recordError(gl::Error(GL_INVALID_ENUM));
3905 return;
3906 }
3907
Geoff Langbfdea662014-07-23 14:16:32 -04003908 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3909
3910 if (fenceObject == NULL)
3911 {
Geoff Langb1196682014-07-23 13:47:29 -04003912 context->recordError(gl::Error(GL_INVALID_OPERATION));
3913 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003914 }
3915
Geoff Lang882033e2014-09-30 11:26:07 -04003916 gl::Error error = fenceObject->setFence(condition);
3917 if (error.isError())
3918 {
3919 context->recordError(error);
3920 return;
3921 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003922 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003923}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003924
Kenneth Russell67ea1902014-10-06 16:44:50 -07003925void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003926{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003927 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 +00003928
Geoff Langbfdea662014-07-23 14:16:32 -04003929 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003930 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003931 {
Geoff Langb1196682014-07-23 13:47:29 -04003932 if (width < 0 || height < 0)
3933 {
3934 context->recordError(gl::Error(GL_INVALID_VALUE));
3935 return;
3936 }
3937
Geoff Langbfdea662014-07-23 14:16:32 -04003938 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003939 }
3940}
3941
Kenneth Russell67ea1902014-10-06 16:44:50 -07003942void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003943{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003944 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003945 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003946 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003947
Geoff Lang900013c2014-07-07 11:32:19 -04003948 gl::Context* context = gl::getNonLostContext();
3949 if (context)
3950 {
3951 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3952 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3953 {
Geoff Langb1196682014-07-23 13:47:29 -04003954 context->recordError(gl::Error(GL_INVALID_ENUM));
3955 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003956 }
3957
3958 // No binary shader formats are supported.
3959 UNIMPLEMENTED();
3960 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003961}
3962
Kenneth Russell67ea1902014-10-06 16:44:50 -07003963void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003964{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003965 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 +00003966 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003967
Geoff Langbfdea662014-07-23 14:16:32 -04003968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003969 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003970 {
Geoff Langb1196682014-07-23 13:47:29 -04003971 if (count < 0)
3972 {
3973 context->recordError(gl::Error(GL_INVALID_VALUE));
3974 return;
3975 }
3976
Geoff Langbfdea662014-07-23 14:16:32 -04003977 gl::Shader *shaderObject = context->getShader(shader);
3978
3979 if (!shaderObject)
3980 {
3981 if (context->getProgram(shader))
3982 {
Geoff Langb1196682014-07-23 13:47:29 -04003983 context->recordError(gl::Error(GL_INVALID_OPERATION));
3984 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003985 }
3986 else
3987 {
Geoff Langb1196682014-07-23 13:47:29 -04003988 context->recordError(gl::Error(GL_INVALID_VALUE));
3989 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003990 }
3991 }
3992
3993 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003994 }
3995}
3996
Kenneth Russell67ea1902014-10-06 16:44:50 -07003997void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003998{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003999 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004000}
4001
Kenneth Russell67ea1902014-10-06 16:44:50 -07004002void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004003{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004004 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 +00004005
Geoff Langbfdea662014-07-23 14:16:32 -04004006 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004007 if (context)
4008 {
Geoff Langb1196682014-07-23 13:47:29 -04004009 switch (face)
4010 {
4011 case GL_FRONT:
4012 case GL_BACK:
4013 case GL_FRONT_AND_BACK:
4014 break;
4015
4016 default:
4017 context->recordError(gl::Error(GL_INVALID_ENUM));
4018 return;
4019 }
4020
4021 switch (func)
4022 {
4023 case GL_NEVER:
4024 case GL_ALWAYS:
4025 case GL_LESS:
4026 case GL_LEQUAL:
4027 case GL_EQUAL:
4028 case GL_GEQUAL:
4029 case GL_GREATER:
4030 case GL_NOTEQUAL:
4031 break;
4032
4033 default:
4034 context->recordError(gl::Error(GL_INVALID_ENUM));
4035 return;
4036 }
4037
Geoff Langbfdea662014-07-23 14:16:32 -04004038 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4039 {
4040 context->getState().setStencilParams(func, ref, mask);
4041 }
4042
4043 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4044 {
4045 context->getState().setStencilBackParams(func, ref, mask);
4046 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004047 }
4048}
4049
Kenneth Russell67ea1902014-10-06 16:44:50 -07004050void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004051{
4052 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4053}
4054
Kenneth Russell67ea1902014-10-06 16:44:50 -07004055void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004057 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004058
Geoff Langbfdea662014-07-23 14:16:32 -04004059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004061 {
Geoff Langb1196682014-07-23 13:47:29 -04004062 switch (face)
4063 {
4064 case GL_FRONT:
4065 case GL_BACK:
4066 case GL_FRONT_AND_BACK:
4067 break;
4068
4069 default:
4070 context->recordError(gl::Error(GL_INVALID_ENUM));
4071 return;
4072 }
4073
Geoff Langbfdea662014-07-23 14:16:32 -04004074 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4075 {
4076 context->getState().setStencilWritemask(mask);
4077 }
4078
4079 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4080 {
4081 context->getState().setStencilBackWritemask(mask);
4082 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004083 }
4084}
4085
Kenneth Russell67ea1902014-10-06 16:44:50 -07004086void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004087{
4088 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4089}
4090
Kenneth Russell67ea1902014-10-06 16:44:50 -07004091void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004092{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004093 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 +00004094 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004095
Geoff Langbfdea662014-07-23 14:16:32 -04004096 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004097 if (context)
4098 {
Geoff Langb1196682014-07-23 13:47:29 -04004099 switch (face)
4100 {
4101 case GL_FRONT:
4102 case GL_BACK:
4103 case GL_FRONT_AND_BACK:
4104 break;
4105
4106 default:
4107 context->recordError(gl::Error(GL_INVALID_ENUM));
4108 return;
4109 }
4110
4111 switch (fail)
4112 {
4113 case GL_ZERO:
4114 case GL_KEEP:
4115 case GL_REPLACE:
4116 case GL_INCR:
4117 case GL_DECR:
4118 case GL_INVERT:
4119 case GL_INCR_WRAP:
4120 case GL_DECR_WRAP:
4121 break;
4122
4123 default:
4124 context->recordError(gl::Error(GL_INVALID_ENUM));
4125 return;
4126 }
4127
4128 switch (zfail)
4129 {
4130 case GL_ZERO:
4131 case GL_KEEP:
4132 case GL_REPLACE:
4133 case GL_INCR:
4134 case GL_DECR:
4135 case GL_INVERT:
4136 case GL_INCR_WRAP:
4137 case GL_DECR_WRAP:
4138 break;
4139
4140 default:
4141 context->recordError(gl::Error(GL_INVALID_ENUM));
4142 return;
4143 }
4144
4145 switch (zpass)
4146 {
4147 case GL_ZERO:
4148 case GL_KEEP:
4149 case GL_REPLACE:
4150 case GL_INCR:
4151 case GL_DECR:
4152 case GL_INVERT:
4153 case GL_INCR_WRAP:
4154 case GL_DECR_WRAP:
4155 break;
4156
4157 default:
4158 context->recordError(gl::Error(GL_INVALID_ENUM));
4159 return;
4160 }
4161
Geoff Langbfdea662014-07-23 14:16:32 -04004162 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4163 {
4164 context->getState().setStencilOperations(fail, zfail, zpass);
4165 }
4166
4167 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4168 {
4169 context->getState().setStencilBackOperations(fail, zfail, zpass);
4170 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004171 }
4172}
4173
Kenneth Russell67ea1902014-10-06 16:44:50 -07004174GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004175{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004176 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004177
Geoff Langbfdea662014-07-23 14:16:32 -04004178 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004179 if (context)
4180 {
4181 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4182
4183 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004184 {
Geoff Langb1196682014-07-23 13:47:29 -04004185 context->recordError(gl::Error(GL_INVALID_OPERATION));
4186 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004187 }
Geoff Langbfdea662014-07-23 14:16:32 -04004188
4189 if (fenceObject->isFence() != GL_TRUE)
4190 {
Geoff Langb1196682014-07-23 13:47:29 -04004191 context->recordError(gl::Error(GL_INVALID_OPERATION));
4192 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004193 }
4194
Geoff Lang882033e2014-09-30 11:26:07 -04004195 GLboolean result;
4196 gl::Error error = fenceObject->testFence(&result);
4197 if (error.isError())
4198 {
4199 context->recordError(error);
4200 return GL_TRUE;
4201 }
4202
4203 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004204 }
Geoff Langbfdea662014-07-23 14:16:32 -04004205
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004206 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004207}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004208
Kenneth Russell67ea1902014-10-06 16:44:50 -07004209void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004210 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004211{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004212 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004213 "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 +00004214 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004215
Geoff Langbfdea662014-07-23 14:16:32 -04004216 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004217 if (context)
4218 {
4219 if (context->getClientVersion() < 3 &&
4220 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4221 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004222 {
Geoff Langbfdea662014-07-23 14:16:32 -04004223 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004224 }
Geoff Langbfdea662014-07-23 14:16:32 -04004225
4226 if (context->getClientVersion() >= 3 &&
4227 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4228 0, 0, 0, width, height, 1, border, format, type, pixels))
4229 {
4230 return;
4231 }
4232
4233 switch (target)
4234 {
4235 case GL_TEXTURE_2D:
4236 {
4237 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004238 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4239 if (error.isError())
4240 {
4241 context->recordError(error);
4242 return;
4243 }
Geoff Langbfdea662014-07-23 14:16:32 -04004244 }
4245 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004246
Geoff Langbfdea662014-07-23 14:16:32 -04004247 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004248 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004249 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004250 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004251 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004252 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4253 {
4254 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004255 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004256 if (error.isError())
4257 {
4258 context->recordError(error);
4259 return;
4260 }
Geoff Langbfdea662014-07-23 14:16:32 -04004261 }
4262 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004263
Geoff Langbfdea662014-07-23 14:16:32 -04004264 default: UNREACHABLE();
4265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004266 }
4267}
4268
Kenneth Russell67ea1902014-10-06 16:44:50 -07004269void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004270{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004271 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4272
Geoff Langbfdea662014-07-23 14:16:32 -04004273 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004274 if (context)
4275 {
4276 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004277 {
Geoff Langbfdea662014-07-23 14:16:32 -04004278 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004279 }
Geoff Langbfdea662014-07-23 14:16:32 -04004280
4281 gl::Texture *texture = context->getTargetTexture(target);
4282
4283 if (!texture)
4284 {
Geoff Langb1196682014-07-23 13:47:29 -04004285 context->recordError(gl::Error(GL_INVALID_ENUM));
4286 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004287 }
4288
4289 switch (pname)
4290 {
4291 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4292 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4293 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4294 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4295 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4296 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4297 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4298 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4299 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4300 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4301 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4302 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4303 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4304 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4305 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4306 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4307 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4308 default: UNREACHABLE(); break;
4309 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004310 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004311}
4312
Kenneth Russell67ea1902014-10-06 16:44:50 -07004313void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004314{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004315 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004316}
4317
Kenneth Russell67ea1902014-10-06 16:44:50 -07004318void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004319{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004320 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004321
Geoff Langbfdea662014-07-23 14:16:32 -04004322 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004323 if (context)
4324 {
4325 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004326 {
Geoff Langbfdea662014-07-23 14:16:32 -04004327 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004328 }
Geoff Langbfdea662014-07-23 14:16:32 -04004329
4330 gl::Texture *texture = context->getTargetTexture(target);
4331
4332 if (!texture)
4333 {
Geoff Langb1196682014-07-23 13:47:29 -04004334 context->recordError(gl::Error(GL_INVALID_ENUM));
4335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004336 }
4337
4338 switch (pname)
4339 {
4340 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4341 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4342 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4343 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4344 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4345 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4346 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4347 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4348 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4349 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4350 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4351 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4352 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4353 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4354 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4355 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4356 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4357 default: UNREACHABLE(); break;
4358 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004359 }
4360}
4361
Kenneth Russell67ea1902014-10-06 16:44:50 -07004362void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004363{
4364 glTexParameteri(target, pname, *params);
4365}
4366
Kenneth Russell67ea1902014-10-06 16:44:50 -07004367void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004368{
4369 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4370 target, levels, internalformat, width, height);
4371
Geoff Langbfdea662014-07-23 14:16:32 -04004372 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004373 if (context)
4374 {
4375 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004376 {
Geoff Langb1196682014-07-23 13:47:29 -04004377 context->recordError(gl::Error(GL_INVALID_OPERATION));
4378 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004379 }
Geoff Langbfdea662014-07-23 14:16:32 -04004380
4381 if (context->getClientVersion() < 3 &&
4382 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4383 {
4384 return;
4385 }
4386
4387 if (context->getClientVersion() >= 3 &&
4388 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4389 {
4390 return;
4391 }
4392
4393 switch (target)
4394 {
4395 case GL_TEXTURE_2D:
4396 {
4397 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004398 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4399 if (error.isError())
4400 {
4401 context->recordError(error);
4402 return;
4403 }
Geoff Langbfdea662014-07-23 14:16:32 -04004404 }
4405 break;
4406
4407 case GL_TEXTURE_CUBE_MAP:
4408 {
4409 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004410 gl::Error error = textureCube->storage(levels, internalformat, width);
4411 if (error.isError())
4412 {
4413 context->recordError(error);
4414 return;
4415 }
Geoff Langbfdea662014-07-23 14:16:32 -04004416 }
4417 break;
4418
4419 default:
Geoff Langb1196682014-07-23 13:47:29 -04004420 context->recordError(gl::Error(GL_INVALID_ENUM));
4421 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004422 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004423 }
4424}
4425
Kenneth Russell67ea1902014-10-06 16:44:50 -07004426void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004427 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004428{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004429 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004430 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004431 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004432 target, level, xoffset, yoffset, width, height, format, type, pixels);
4433
Geoff Langbfdea662014-07-23 14:16:32 -04004434 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004435 if (context)
4436 {
4437 if (context->getClientVersion() < 3 &&
4438 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4439 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004440 {
Geoff Langbfdea662014-07-23 14:16:32 -04004441 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004442 }
Geoff Langbfdea662014-07-23 14:16:32 -04004443
4444 if (context->getClientVersion() >= 3 &&
4445 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4446 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4447 {
4448 return;
4449 }
4450
4451 // Zero sized uploads are valid but no-ops
4452 if (width == 0 || height == 0)
4453 {
4454 return;
4455 }
4456
4457 switch (target)
4458 {
4459 case GL_TEXTURE_2D:
4460 {
4461 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004462 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4463 if (error.isError())
4464 {
4465 context->recordError(error);
4466 return;
4467 }
Geoff Langbfdea662014-07-23 14:16:32 -04004468 }
4469 break;
4470
4471 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4472 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4473 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4474 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4475 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4476 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4477 {
4478 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004479 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4480 if (error.isError())
4481 {
4482 context->recordError(error);
4483 return;
4484 }
Geoff Langbfdea662014-07-23 14:16:32 -04004485 }
4486 break;
4487
4488 default:
4489 UNREACHABLE();
4490 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004491 }
4492}
4493
Kenneth Russell67ea1902014-10-06 16:44:50 -07004494void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004495{
4496 glUniform1fv(location, 1, &x);
4497}
4498
Kenneth Russell67ea1902014-10-06 16:44:50 -07004499void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004500{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004501 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004502
Geoff Langbfdea662014-07-23 14:16:32 -04004503 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004504 if (context)
4505 {
4506 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004507 {
Geoff Langbfdea662014-07-23 14:16:32 -04004508 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004509 }
Geoff Langbfdea662014-07-23 14:16:32 -04004510
4511 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4512 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004513 }
4514}
4515
Kenneth Russell67ea1902014-10-06 16:44:50 -07004516void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004517{
4518 glUniform1iv(location, 1, &x);
4519}
4520
Kenneth Russell67ea1902014-10-06 16:44:50 -07004521void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004522{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004523 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004524
Geoff Langbfdea662014-07-23 14:16:32 -04004525 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004526 if (context)
4527 {
4528 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004529 {
Geoff Langbfdea662014-07-23 14:16:32 -04004530 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004531 }
Geoff Langbfdea662014-07-23 14:16:32 -04004532
4533 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4534 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004535 }
4536}
4537
Kenneth Russell67ea1902014-10-06 16:44:50 -07004538void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004539{
4540 GLfloat xy[2] = {x, y};
4541
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004542 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004543}
4544
Kenneth Russell67ea1902014-10-06 16:44:50 -07004545void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004546{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004547 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004548
Geoff Langbfdea662014-07-23 14:16:32 -04004549 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004550 if (context)
4551 {
4552 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004553 {
Geoff Langbfdea662014-07-23 14:16:32 -04004554 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004555 }
Geoff Langbfdea662014-07-23 14:16:32 -04004556
4557 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4558 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559 }
4560}
4561
Kenneth Russell67ea1902014-10-06 16:44:50 -07004562void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004563{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004564 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004565
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004566 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004567}
4568
Kenneth Russell67ea1902014-10-06 16:44:50 -07004569void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004571 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004572
Geoff Langbfdea662014-07-23 14:16:32 -04004573 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004574 if (context)
4575 {
4576 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004577 {
Geoff Langbfdea662014-07-23 14:16:32 -04004578 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004579 }
Geoff Langbfdea662014-07-23 14:16:32 -04004580
4581 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4582 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004583 }
4584}
4585
Kenneth Russell67ea1902014-10-06 16:44:50 -07004586void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004587{
4588 GLfloat xyz[3] = {x, y, z};
4589
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004590 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004591}
4592
Kenneth Russell67ea1902014-10-06 16:44:50 -07004593void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004594{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004595 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004596
Geoff Langbfdea662014-07-23 14:16:32 -04004597 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004598 if (context)
4599 {
4600 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004601 {
Geoff Langbfdea662014-07-23 14:16:32 -04004602 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004603 }
Geoff Langbfdea662014-07-23 14:16:32 -04004604
4605 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4606 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004607 }
4608}
4609
Kenneth Russell67ea1902014-10-06 16:44:50 -07004610void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004611{
4612 GLint xyz[3] = {x, y, z};
4613
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004614 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004615}
4616
Kenneth Russell67ea1902014-10-06 16:44:50 -07004617void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004618{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004619 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004620
Geoff Langbfdea662014-07-23 14:16:32 -04004621 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004622 if (context)
4623 {
4624 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004625 {
Geoff Langbfdea662014-07-23 14:16:32 -04004626 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004627 }
Geoff Langbfdea662014-07-23 14:16:32 -04004628
4629 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4630 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004631 }
4632}
4633
Kenneth Russell67ea1902014-10-06 16:44:50 -07004634void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004635{
4636 GLfloat xyzw[4] = {x, y, z, w};
4637
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004638 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004639}
4640
Kenneth Russell67ea1902014-10-06 16:44:50 -07004641void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004642{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004643 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004644
Geoff Langbfdea662014-07-23 14:16:32 -04004645 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004646 if (context)
4647 {
4648 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004649 {
Geoff Langbfdea662014-07-23 14:16:32 -04004650 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004651 }
Geoff Langbfdea662014-07-23 14:16:32 -04004652
4653 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4654 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655 }
4656}
4657
Kenneth Russell67ea1902014-10-06 16:44:50 -07004658void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659{
4660 GLint xyzw[4] = {x, y, z, w};
4661
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004662 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004663}
4664
Kenneth Russell67ea1902014-10-06 16:44:50 -07004665void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004667 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004668
Geoff Langbfdea662014-07-23 14:16:32 -04004669 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004670 if (context)
4671 {
4672 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004673 {
Geoff Langbfdea662014-07-23 14:16:32 -04004674 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004675 }
Geoff Langbfdea662014-07-23 14:16:32 -04004676
4677 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4678 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004679 }
4680}
4681
Kenneth Russell67ea1902014-10-06 16:44:50 -07004682void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004683{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004684 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004685 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004686
Geoff Langbfdea662014-07-23 14:16:32 -04004687 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004688 if (context)
4689 {
4690 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004691 {
Geoff Langbfdea662014-07-23 14:16:32 -04004692 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004693 }
Geoff Langbfdea662014-07-23 14:16:32 -04004694
4695 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4696 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004697 }
4698}
4699
Kenneth Russell67ea1902014-10-06 16:44:50 -07004700void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004702 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004703 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004704
Geoff Langbfdea662014-07-23 14:16:32 -04004705 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004706 if (context)
4707 {
4708 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004709 {
Geoff Langbfdea662014-07-23 14:16:32 -04004710 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711 }
Geoff Langbfdea662014-07-23 14:16:32 -04004712
4713 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4714 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004715 }
4716}
4717
Kenneth Russell67ea1902014-10-06 16:44:50 -07004718void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004720 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004721 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004722
Geoff Langbfdea662014-07-23 14:16:32 -04004723 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004724 if (context)
4725 {
4726 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004727 {
Geoff Langbfdea662014-07-23 14:16:32 -04004728 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004729 }
Geoff Langbfdea662014-07-23 14:16:32 -04004730
4731 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4732 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004733 }
4734}
4735
Kenneth Russell67ea1902014-10-06 16:44:50 -07004736void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004737{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004738 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004739
Geoff Langbfdea662014-07-23 14:16:32 -04004740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004741 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004742 {
Geoff Langbfdea662014-07-23 14:16:32 -04004743 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004744
Geoff Langbfdea662014-07-23 14:16:32 -04004745 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004746 {
Geoff Langbfdea662014-07-23 14:16:32 -04004747 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004748 {
Geoff Langb1196682014-07-23 13:47:29 -04004749 context->recordError(gl::Error(GL_INVALID_OPERATION));
4750 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004751 }
Geoff Langbfdea662014-07-23 14:16:32 -04004752 else
4753 {
Geoff Langb1196682014-07-23 13:47:29 -04004754 context->recordError(gl::Error(GL_INVALID_VALUE));
4755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004756 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757 }
Geoff Langbfdea662014-07-23 14:16:32 -04004758
4759 if (program != 0 && !programObject->isLinked())
4760 {
Geoff Langb1196682014-07-23 13:47:29 -04004761 context->recordError(gl::Error(GL_INVALID_OPERATION));
4762 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004763 }
4764
4765 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004766 }
4767}
4768
Kenneth Russell67ea1902014-10-06 16:44:50 -07004769void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004770{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004771 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772
Geoff Langbfdea662014-07-23 14:16:32 -04004773 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004774 if (context)
4775 {
4776 gl::Program *programObject = context->getProgram(program);
4777
4778 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004779 {
Geoff Langbfdea662014-07-23 14:16:32 -04004780 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004781 {
Geoff Langb1196682014-07-23 13:47:29 -04004782 context->recordError(gl::Error(GL_INVALID_OPERATION));
4783 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004784 }
Geoff Langbfdea662014-07-23 14:16:32 -04004785 else
4786 {
Geoff Langb1196682014-07-23 13:47:29 -04004787 context->recordError(gl::Error(GL_INVALID_VALUE));
4788 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004789 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004790 }
Geoff Langbfdea662014-07-23 14:16:32 -04004791
Brandon Jones43a53e22014-08-28 16:23:22 -07004792 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004793 }
4794}
4795
Kenneth Russell67ea1902014-10-06 16:44:50 -07004796void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004797{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004798 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004799
Geoff Langbfdea662014-07-23 14:16:32 -04004800 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004801 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004802 {
Geoff Langb1196682014-07-23 13:47:29 -04004803 if (index >= gl::MAX_VERTEX_ATTRIBS)
4804 {
4805 context->recordError(gl::Error(GL_INVALID_VALUE));
4806 return;
4807 }
4808
Geoff Langbfdea662014-07-23 14:16:32 -04004809 GLfloat vals[4] = { x, 0, 0, 1 };
4810 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004811 }
4812}
4813
Kenneth Russell67ea1902014-10-06 16:44:50 -07004814void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004815{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004816 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004817
Geoff Langbfdea662014-07-23 14:16:32 -04004818 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004819 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004820 {
Geoff Langb1196682014-07-23 13:47:29 -04004821 if (index >= gl::MAX_VERTEX_ATTRIBS)
4822 {
4823 context->recordError(gl::Error(GL_INVALID_VALUE));
4824 return;
4825 }
4826
Geoff Langbfdea662014-07-23 14:16:32 -04004827 GLfloat vals[4] = { values[0], 0, 0, 1 };
4828 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004829 }
4830}
4831
Kenneth Russell67ea1902014-10-06 16:44:50 -07004832void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004833{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004834 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004835
Geoff Langbfdea662014-07-23 14:16:32 -04004836 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004837 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004838 {
Geoff Langb1196682014-07-23 13:47:29 -04004839 if (index >= gl::MAX_VERTEX_ATTRIBS)
4840 {
4841 context->recordError(gl::Error(GL_INVALID_VALUE));
4842 return;
4843 }
4844
Geoff Langbfdea662014-07-23 14:16:32 -04004845 GLfloat vals[4] = { x, y, 0, 1 };
4846 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004847 }
4848}
4849
Kenneth Russell67ea1902014-10-06 16:44:50 -07004850void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004851{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004852 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004853
Geoff Langbfdea662014-07-23 14:16:32 -04004854 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004855 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004856 {
Geoff Langb1196682014-07-23 13:47:29 -04004857 if (index >= gl::MAX_VERTEX_ATTRIBS)
4858 {
4859 context->recordError(gl::Error(GL_INVALID_VALUE));
4860 return;
4861 }
4862
Geoff Langbfdea662014-07-23 14:16:32 -04004863 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4864 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004865 }
4866}
4867
Kenneth Russell67ea1902014-10-06 16:44:50 -07004868void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004869{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004870 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 +00004871
Geoff Langbfdea662014-07-23 14:16:32 -04004872 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004873 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004874 {
Geoff Langb1196682014-07-23 13:47:29 -04004875 if (index >= gl::MAX_VERTEX_ATTRIBS)
4876 {
4877 context->recordError(gl::Error(GL_INVALID_VALUE));
4878 return;
4879 }
4880
Geoff Langbfdea662014-07-23 14:16:32 -04004881 GLfloat vals[4] = { x, y, z, 1 };
4882 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004883 }
4884}
4885
Kenneth Russell67ea1902014-10-06 16:44:50 -07004886void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004887{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004888 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004889
Geoff Langbfdea662014-07-23 14:16:32 -04004890 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004891 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004892 {
Geoff Langb1196682014-07-23 13:47:29 -04004893 if (index >= gl::MAX_VERTEX_ATTRIBS)
4894 {
4895 context->recordError(gl::Error(GL_INVALID_VALUE));
4896 return;
4897 }
4898
Geoff Langbfdea662014-07-23 14:16:32 -04004899 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4900 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004901 }
4902}
4903
Kenneth Russell67ea1902014-10-06 16:44:50 -07004904void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004905{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004906 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 +00004907
Geoff Langbfdea662014-07-23 14:16:32 -04004908 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004909 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004910 {
Geoff Langb1196682014-07-23 13:47:29 -04004911 if (index >= gl::MAX_VERTEX_ATTRIBS)
4912 {
4913 context->recordError(gl::Error(GL_INVALID_VALUE));
4914 return;
4915 }
4916
Geoff Langbfdea662014-07-23 14:16:32 -04004917 GLfloat vals[4] = { x, y, z, w };
4918 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004919 }
4920}
4921
Kenneth Russell67ea1902014-10-06 16:44:50 -07004922void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004923{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004924 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004925
Geoff Langbfdea662014-07-23 14:16:32 -04004926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004927 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004928 {
Geoff Langb1196682014-07-23 13:47:29 -04004929 if (index >= gl::MAX_VERTEX_ATTRIBS)
4930 {
4931 context->recordError(gl::Error(GL_INVALID_VALUE));
4932 return;
4933 }
4934
Geoff Langbfdea662014-07-23 14:16:32 -04004935 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004936 }
4937}
4938
Kenneth Russell67ea1902014-10-06 16:44:50 -07004939void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004940{
4941 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4942
Geoff Langbfdea662014-07-23 14:16:32 -04004943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004944 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004945 {
Geoff Langb1196682014-07-23 13:47:29 -04004946 if (index >= gl::MAX_VERTEX_ATTRIBS)
4947 {
4948 context->recordError(gl::Error(GL_INVALID_VALUE));
4949 return;
4950 }
4951
Geoff Langbfdea662014-07-23 14:16:32 -04004952 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004953 }
4954}
4955
Kenneth Russell67ea1902014-10-06 16:44:50 -07004956void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004957{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004958 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004959 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004960 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004961
Geoff Langbfdea662014-07-23 14:16:32 -04004962 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004963 if (context)
4964 {
Geoff Langb1196682014-07-23 13:47:29 -04004965 if (index >= gl::MAX_VERTEX_ATTRIBS)
4966 {
4967 context->recordError(gl::Error(GL_INVALID_VALUE));
4968 return;
4969 }
4970
4971 if (size < 1 || size > 4)
4972 {
4973 context->recordError(gl::Error(GL_INVALID_VALUE));
4974 return;
4975 }
4976
4977 switch (type)
4978 {
4979 case GL_BYTE:
4980 case GL_UNSIGNED_BYTE:
4981 case GL_SHORT:
4982 case GL_UNSIGNED_SHORT:
4983 case GL_FIXED:
4984 case GL_FLOAT:
4985 break;
4986
4987 case GL_HALF_FLOAT:
4988 case GL_INT:
4989 case GL_UNSIGNED_INT:
4990 case GL_INT_2_10_10_10_REV:
4991 case GL_UNSIGNED_INT_2_10_10_10_REV:
4992 if (context->getClientVersion() < 3)
4993 {
4994 context->recordError(gl::Error(GL_INVALID_ENUM));
4995 return;
4996 }
4997 break;
4998
4999 default:
5000 context->recordError(gl::Error(GL_INVALID_ENUM));
5001 return;
5002 }
5003
5004 if (stride < 0)
5005 {
5006 context->recordError(gl::Error(GL_INVALID_VALUE));
5007 return;
5008 }
5009
5010 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5011 {
5012 context->recordError(gl::Error(GL_INVALID_OPERATION));
5013 return;
5014 }
5015
Geoff Langbfdea662014-07-23 14:16:32 -04005016 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5017 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5018 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5019 // and the pointer argument is not NULL.
5020 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005021 {
Geoff Langb1196682014-07-23 13:47:29 -04005022 context->recordError(gl::Error(GL_INVALID_OPERATION));
5023 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005024 }
5025
Geoff Langbfdea662014-07-23 14:16:32 -04005026 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5027 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005028 }
5029}
5030
Kenneth Russell67ea1902014-10-06 16:44:50 -07005031void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005032{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005033 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 +00005034
Geoff Langbfdea662014-07-23 14:16:32 -04005035 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005036 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005037 {
Geoff Langb1196682014-07-23 13:47:29 -04005038 if (width < 0 || height < 0)
5039 {
5040 context->recordError(gl::Error(GL_INVALID_VALUE));
5041 return;
5042 }
5043
Geoff Langbfdea662014-07-23 14:16:32 -04005044 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005045 }
5046}
5047
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005048// OpenGL ES 3.0 functions
5049
Kenneth Russell67ea1902014-10-06 16:44:50 -07005050void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005051{
5052 EVENT("(GLenum mode = 0x%X)", mode);
5053
Geoff Langbfdea662014-07-23 14:16:32 -04005054 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005055 if (context)
5056 {
5057 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005058 {
Geoff Langb1196682014-07-23 13:47:29 -04005059 context->recordError(gl::Error(GL_INVALID_OPERATION));
5060 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005061 }
Geoff Langbfdea662014-07-23 14:16:32 -04005062
5063 // glReadBuffer
5064 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005065 }
5066}
5067
Kenneth Russell67ea1902014-10-06 16:44:50 -07005068void 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 +00005069{
5070 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5071 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5072
Geoff Langbfdea662014-07-23 14:16:32 -04005073 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005074 if (context)
5075 {
5076 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005077 {
Geoff Langb1196682014-07-23 13:47:29 -04005078 context->recordError(gl::Error(GL_INVALID_OPERATION));
5079 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005080 }
Geoff Langbfdea662014-07-23 14:16:32 -04005081
5082 // glDrawRangeElements
5083 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005084 }
5085}
5086
Kenneth Russell67ea1902014-10-06 16:44:50 -07005087void 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 +00005088{
5089 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5090 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5091 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5092 target, level, internalformat, width, height, depth, border, format, type, pixels);
5093
Geoff Langbfdea662014-07-23 14:16:32 -04005094 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005095 if (context)
5096 {
5097 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005098 {
Geoff Langb1196682014-07-23 13:47:29 -04005099 context->recordError(gl::Error(GL_INVALID_OPERATION));
5100 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005101 }
Geoff Langbfdea662014-07-23 14:16:32 -04005102
5103 // validateES3TexImageFormat sets the error code if there is an error
5104 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5105 0, 0, 0, width, height, depth, border, format, type, pixels))
5106 {
5107 return;
5108 }
5109
5110 switch(target)
5111 {
5112 case GL_TEXTURE_3D:
5113 {
5114 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005115 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5116 if (error.isError())
5117 {
5118 context->recordError(error);
5119 return;
5120 }
Geoff Langbfdea662014-07-23 14:16:32 -04005121 }
5122 break;
5123
5124 case GL_TEXTURE_2D_ARRAY:
5125 {
5126 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005127 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5128 if (error.isError())
5129 {
5130 context->recordError(error);
5131 return;
5132 }
Geoff Langbfdea662014-07-23 14:16:32 -04005133 }
5134 break;
5135
5136 default:
Geoff Langb1196682014-07-23 13:47:29 -04005137 context->recordError(gl::Error(GL_INVALID_ENUM));
5138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005139 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005140 }
5141}
5142
Kenneth Russell67ea1902014-10-06 16:44:50 -07005143void 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 +00005144{
5145 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5146 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5147 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5148 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5149
Geoff Langbfdea662014-07-23 14:16:32 -04005150 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005151 if (context)
5152 {
5153 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005154 {
Geoff Langb1196682014-07-23 13:47:29 -04005155 context->recordError(gl::Error(GL_INVALID_OPERATION));
5156 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005157 }
Geoff Langbfdea662014-07-23 14:16:32 -04005158
5159 // validateES3TexImageFormat sets the error code if there is an error
5160 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5161 xoffset, yoffset, zoffset, width, height, depth, 0,
5162 format, type, pixels))
5163 {
5164 return;
5165 }
5166
5167 // Zero sized uploads are valid but no-ops
5168 if (width == 0 || height == 0 || depth == 0)
5169 {
5170 return;
5171 }
5172
5173 switch(target)
5174 {
5175 case GL_TEXTURE_3D:
5176 {
5177 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005178 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5179 if (error.isError())
5180 {
5181 context->recordError(error);
5182 return;
5183 }
Geoff Langbfdea662014-07-23 14:16:32 -04005184 }
5185 break;
5186
5187 case GL_TEXTURE_2D_ARRAY:
5188 {
5189 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005190 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5191 if (error.isError())
5192 {
5193 context->recordError(error);
5194 return;
5195 }
Geoff Langbfdea662014-07-23 14:16:32 -04005196 }
5197 break;
5198
5199 default:
Geoff Langb1196682014-07-23 13:47:29 -04005200 context->recordError(gl::Error(GL_INVALID_ENUM));
5201 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005202 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005203 }
5204}
5205
Kenneth Russell67ea1902014-10-06 16:44:50 -07005206void 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 +00005207{
5208 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5209 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5210 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5211
Geoff Langbfdea662014-07-23 14:16:32 -04005212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005213 if (context)
5214 {
5215 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005216 {
Geoff Langb1196682014-07-23 13:47:29 -04005217 context->recordError(gl::Error(GL_INVALID_OPERATION));
5218 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005219 }
Geoff Langbfdea662014-07-23 14:16:32 -04005220
5221 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5222 x, y, width, height, 0))
5223 {
5224 return;
5225 }
5226
5227 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5228 gl::Texture *texture = NULL;
5229 switch (target)
5230 {
5231 case GL_TEXTURE_3D:
5232 texture = context->getTexture3D();
5233 break;
5234
5235 case GL_TEXTURE_2D_ARRAY:
5236 texture = context->getTexture2DArray();
5237 break;
5238
5239 default:
Geoff Langb1196682014-07-23 13:47:29 -04005240 context->recordError(gl::Error(GL_INVALID_ENUM));
5241 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005242 }
5243
Geoff Langef7b0162014-09-04 13:29:23 -04005244 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5245 if (error.isError())
5246 {
5247 context->recordError(error);
5248 return;
5249 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005250 }
5251}
5252
Kenneth Russell67ea1902014-10-06 16:44:50 -07005253void 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 +00005254{
Geoff Langeef52cc2013-10-16 15:07:39 -04005255 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 +00005256 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5257 "const GLvoid* data = 0x%0.8p)",
5258 target, level, internalformat, width, height, depth, border, imageSize, data);
5259
Geoff Langbfdea662014-07-23 14:16:32 -04005260 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005261 if (context)
5262 {
5263 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005264 {
Geoff Langb1196682014-07-23 13:47:29 -04005265 context->recordError(gl::Error(GL_INVALID_OPERATION));
5266 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005267 }
Geoff Langbfdea662014-07-23 14:16:32 -04005268
Geoff Lang5d601382014-07-22 15:14:06 -04005269 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5270 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005271 {
Geoff Langb1196682014-07-23 13:47:29 -04005272 context->recordError(gl::Error(GL_INVALID_VALUE));
5273 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005274 }
5275
5276 // validateES3TexImageFormat sets the error code if there is an error
5277 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5278 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5279 {
5280 return;
5281 }
5282
5283 switch(target)
5284 {
5285 case GL_TEXTURE_3D:
5286 {
5287 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005288 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005289 if (error.isError())
5290 {
5291 context->recordError(error);
5292 return;
5293 }
Geoff Langbfdea662014-07-23 14:16:32 -04005294 }
5295 break;
5296
5297 case GL_TEXTURE_2D_ARRAY:
5298 {
5299 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005300 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005301 if (error.isError())
5302 {
5303 context->recordError(error);
5304 return;
5305 }
Geoff Langbfdea662014-07-23 14:16:32 -04005306 }
5307 break;
5308
5309 default:
Geoff Langb1196682014-07-23 13:47:29 -04005310 context->recordError(gl::Error(GL_INVALID_ENUM));
5311 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005312 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005313 }
5314}
5315
Kenneth Russell67ea1902014-10-06 16:44:50 -07005316void 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 +00005317{
5318 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5319 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5320 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5321 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5322
Geoff Langbfdea662014-07-23 14:16:32 -04005323 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005324 if (context)
5325 {
5326 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005327 {
Geoff Langb1196682014-07-23 13:47:29 -04005328 context->recordError(gl::Error(GL_INVALID_OPERATION));
5329 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005330 }
Geoff Langbfdea662014-07-23 14:16:32 -04005331
Geoff Lang5d601382014-07-22 15:14:06 -04005332 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5333 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005334 {
Geoff Langb1196682014-07-23 13:47:29 -04005335 context->recordError(gl::Error(GL_INVALID_VALUE));
5336 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005337 }
5338
5339 if (!data)
5340 {
Geoff Langb1196682014-07-23 13:47:29 -04005341 context->recordError(gl::Error(GL_INVALID_VALUE));
5342 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005343 }
5344
5345 // validateES3TexImageFormat sets the error code if there is an error
5346 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5347 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5348 {
5349 return;
5350 }
5351
5352 // Zero sized uploads are valid but no-ops
5353 if (width == 0 || height == 0)
5354 {
5355 return;
5356 }
5357
5358 switch(target)
5359 {
5360 case GL_TEXTURE_3D:
5361 {
5362 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005363 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005364 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005365 if (error.isError())
5366 {
5367 context->recordError(error);
5368 return;
5369 }
Geoff Langbfdea662014-07-23 14:16:32 -04005370 }
5371 break;
5372
5373 case GL_TEXTURE_2D_ARRAY:
5374 {
5375 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005376 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005377 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005378 if (error.isError())
5379 {
5380 context->recordError(error);
5381 return;
5382 }
Geoff Langbfdea662014-07-23 14:16:32 -04005383 }
5384 break;
5385
Geoff Langb1196682014-07-23 13:47:29 -04005386 default:
5387 context->recordError(gl::Error(GL_INVALID_ENUM));
5388 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005389 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005390 }
5391}
5392
Kenneth Russell67ea1902014-10-06 16:44:50 -07005393void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005394{
5395 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5396
Geoff Langbfdea662014-07-23 14:16:32 -04005397 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005398 if (context)
5399 {
5400 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005401 {
Geoff Langb1196682014-07-23 13:47:29 -04005402 context->recordError(gl::Error(GL_INVALID_OPERATION));
5403 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005404 }
Geoff Langbfdea662014-07-23 14:16:32 -04005405
5406 if (n < 0)
5407 {
Geoff Langb1196682014-07-23 13:47:29 -04005408 context->recordError(gl::Error(GL_INVALID_VALUE));
5409 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005410 }
5411
5412 for (GLsizei i = 0; i < n; i++)
5413 {
5414 ids[i] = context->createQuery();
5415 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005416 }
5417}
5418
Kenneth Russell67ea1902014-10-06 16:44:50 -07005419void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005420{
5421 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5422
Geoff Langbfdea662014-07-23 14:16:32 -04005423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005424 if (context)
5425 {
5426 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005427 {
Geoff Langb1196682014-07-23 13:47:29 -04005428 context->recordError(gl::Error(GL_INVALID_OPERATION));
5429 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005430 }
Geoff Langbfdea662014-07-23 14:16:32 -04005431
5432 if (n < 0)
5433 {
Geoff Langb1196682014-07-23 13:47:29 -04005434 context->recordError(gl::Error(GL_INVALID_VALUE));
5435 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005436 }
5437
5438 for (GLsizei i = 0; i < n; i++)
5439 {
5440 context->deleteQuery(ids[i]);
5441 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005442 }
5443}
5444
Kenneth Russell67ea1902014-10-06 16:44:50 -07005445GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005446{
5447 EVENT("(GLuint id = %u)", id);
5448
Geoff Langbfdea662014-07-23 14:16:32 -04005449 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005450 if (context)
5451 {
5452 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005453 {
Geoff Langb1196682014-07-23 13:47:29 -04005454 context->recordError(gl::Error(GL_INVALID_OPERATION));
5455 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005456 }
Geoff Langbfdea662014-07-23 14:16:32 -04005457
5458 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005459 }
5460
5461 return GL_FALSE;
5462}
5463
Kenneth Russell67ea1902014-10-06 16:44:50 -07005464void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005465{
5466 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5467
Geoff Langbfdea662014-07-23 14:16:32 -04005468 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005469 if (context)
5470 {
5471 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005472 {
Geoff Langb1196682014-07-23 13:47:29 -04005473 context->recordError(gl::Error(GL_INVALID_OPERATION));
5474 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005475 }
Geoff Langbfdea662014-07-23 14:16:32 -04005476
5477 if (!ValidateBeginQuery(context, target, id))
5478 {
5479 return;
5480 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005481
5482 gl::Error error = context->beginQuery(target, id);
5483 if (error.isError())
5484 {
5485 context->recordError(error);
5486 return;
5487 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005488 }
5489}
5490
Kenneth Russell67ea1902014-10-06 16:44:50 -07005491void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005492{
5493 EVENT("(GLenum target = 0x%X)", target);
5494
Geoff Langbfdea662014-07-23 14:16:32 -04005495 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005496 if (context)
5497 {
5498 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005499 {
Geoff Langb1196682014-07-23 13:47:29 -04005500 context->recordError(gl::Error(GL_INVALID_OPERATION));
5501 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005502 }
Geoff Langbfdea662014-07-23 14:16:32 -04005503
5504 if (!ValidateEndQuery(context, target))
5505 {
5506 return;
5507 }
5508
Geoff Lang5aad9672014-09-08 11:10:42 -04005509 gl::Error error = context->endQuery(target);
5510 if (error.isError())
5511 {
5512 context->recordError(error);
5513 return;
5514 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005515 }
5516}
5517
Kenneth Russell67ea1902014-10-06 16:44:50 -07005518void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005519{
5520 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5521
Geoff Langbfdea662014-07-23 14:16:32 -04005522 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005523 if (context)
5524 {
5525 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005526 {
Geoff Langb1196682014-07-23 13:47:29 -04005527 context->recordError(gl::Error(GL_INVALID_OPERATION));
5528 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005529 }
Geoff Langbfdea662014-07-23 14:16:32 -04005530
5531 if (!ValidQueryType(context, target))
5532 {
Geoff Langb1196682014-07-23 13:47:29 -04005533 context->recordError(gl::Error(GL_INVALID_ENUM));
5534 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005535 }
5536
5537 switch (pname)
5538 {
5539 case GL_CURRENT_QUERY:
5540 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5541 break;
5542
5543 default:
Geoff Langb1196682014-07-23 13:47:29 -04005544 context->recordError(gl::Error(GL_INVALID_ENUM));
5545 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005546 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005547 }
5548}
5549
Kenneth Russell67ea1902014-10-06 16:44:50 -07005550void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005551{
5552 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5553
Geoff Langbfdea662014-07-23 14:16:32 -04005554 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005555 if (context)
5556 {
5557 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005558 {
Geoff Langb1196682014-07-23 13:47:29 -04005559 context->recordError(gl::Error(GL_INVALID_OPERATION));
5560 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005561 }
Geoff Langbfdea662014-07-23 14:16:32 -04005562
5563 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5564
5565 if (!queryObject)
5566 {
Geoff Langb1196682014-07-23 13:47:29 -04005567 context->recordError(gl::Error(GL_INVALID_OPERATION));
5568 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005569 }
5570
5571 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5572 {
Geoff Langb1196682014-07-23 13:47:29 -04005573 context->recordError(gl::Error(GL_INVALID_OPERATION));
5574 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005575 }
5576
5577 switch(pname)
5578 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005579 case GL_QUERY_RESULT_EXT:
5580 {
5581 gl::Error error = queryObject->getResult(params);
5582 if (error.isError())
5583 {
5584 context->recordError(error);
5585 return;
5586 }
5587 }
Geoff Langbfdea662014-07-23 14:16:32 -04005588 break;
Geoff Langb1196682014-07-23 13:47:29 -04005589
Geoff Lang5aad9672014-09-08 11:10:42 -04005590 case GL_QUERY_RESULT_AVAILABLE_EXT:
5591 {
5592 gl::Error error = queryObject->isResultAvailable(params);
5593 if (error.isError())
5594 {
5595 context->recordError(error);
5596 return;
5597 }
5598 }
Geoff Langbfdea662014-07-23 14:16:32 -04005599 break;
Geoff Langb1196682014-07-23 13:47:29 -04005600
Geoff Langbfdea662014-07-23 14:16:32 -04005601 default:
Geoff Langb1196682014-07-23 13:47:29 -04005602 context->recordError(gl::Error(GL_INVALID_ENUM));
5603 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005604 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005605 }
5606}
5607
Kenneth Russell67ea1902014-10-06 16:44:50 -07005608GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005609{
5610 EVENT("(GLenum target = 0x%X)", target);
5611
Geoff Langbfdea662014-07-23 14:16:32 -04005612 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005613 if (context)
5614 {
5615 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005616 {
Geoff Langb1196682014-07-23 13:47:29 -04005617 context->recordError(gl::Error(GL_INVALID_OPERATION));
5618 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005619 }
Geoff Langbfdea662014-07-23 14:16:32 -04005620
5621 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005622 }
5623
5624 return GL_FALSE;
5625}
5626
Kenneth Russell67ea1902014-10-06 16:44:50 -07005627void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005628{
5629 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5630
Geoff Langbfdea662014-07-23 14:16:32 -04005631 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005632 if (context)
5633 {
5634 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005635 {
Geoff Langb1196682014-07-23 13:47:29 -04005636 context->recordError(gl::Error(GL_INVALID_OPERATION));
5637 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005638 }
Geoff Langbfdea662014-07-23 14:16:32 -04005639
5640 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005641 }
5642}
5643
Kenneth Russell67ea1902014-10-06 16:44:50 -07005644void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005645{
Geoff Langbfdea662014-07-23 14:16:32 -04005646 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005647 if (context)
5648 {
5649 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005650 {
Geoff Langb1196682014-07-23 13:47:29 -04005651 context->recordError(gl::Error(GL_INVALID_OPERATION));
5652 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005653 }
Geoff Langbfdea662014-07-23 14:16:32 -04005654
5655 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005656 }
5657}
5658
Kenneth Russell67ea1902014-10-06 16:44:50 -07005659void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005660{
5661 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5662 location, count, transpose, value);
5663
Geoff Langbfdea662014-07-23 14:16:32 -04005664 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005665 if (context)
5666 {
5667 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005668 {
Geoff Langbfdea662014-07-23 14:16:32 -04005669 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005670 }
Geoff Langbfdea662014-07-23 14:16:32 -04005671
5672 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5673 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005674 }
5675}
5676
Kenneth Russell67ea1902014-10-06 16:44:50 -07005677void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005678{
5679 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5680 location, count, transpose, value);
5681
Geoff Langbfdea662014-07-23 14:16:32 -04005682 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005683 if (context)
5684 {
5685 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005686 {
Geoff Langbfdea662014-07-23 14:16:32 -04005687 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005688 }
Geoff Langbfdea662014-07-23 14:16:32 -04005689
5690 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5691 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005692 }
5693}
5694
Kenneth Russell67ea1902014-10-06 16:44:50 -07005695void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005696{
5697 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5698 location, count, transpose, value);
5699
Geoff Langbfdea662014-07-23 14:16:32 -04005700 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005701 if (context)
5702 {
5703 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005704 {
Geoff Langbfdea662014-07-23 14:16:32 -04005705 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005706 }
Geoff Langbfdea662014-07-23 14:16:32 -04005707
5708 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5709 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005710 }
5711}
5712
Kenneth Russell67ea1902014-10-06 16:44:50 -07005713void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005714{
5715 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5716 location, count, transpose, value);
5717
Geoff Langbfdea662014-07-23 14:16:32 -04005718 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005719 if (context)
5720 {
5721 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005722 {
Geoff Langbfdea662014-07-23 14:16:32 -04005723 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005724 }
Geoff Langbfdea662014-07-23 14:16:32 -04005725
5726 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5727 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005728 }
5729}
5730
Kenneth Russell67ea1902014-10-06 16:44:50 -07005731void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005732{
5733 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5734 location, count, transpose, value);
5735
Geoff Langbfdea662014-07-23 14:16:32 -04005736 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005737 if (context)
5738 {
5739 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005740 {
Geoff Langbfdea662014-07-23 14:16:32 -04005741 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005742 }
Geoff Langbfdea662014-07-23 14:16:32 -04005743
5744 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5745 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005746 }
5747}
5748
Kenneth Russell67ea1902014-10-06 16:44:50 -07005749void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005750{
5751 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5752 location, count, transpose, value);
5753
Geoff Langbfdea662014-07-23 14:16:32 -04005754 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005755 if (context)
5756 {
5757 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005758 {
Geoff Langbfdea662014-07-23 14:16:32 -04005759 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005760 }
Geoff Langbfdea662014-07-23 14:16:32 -04005761
5762 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5763 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005764 }
5765}
5766
Kenneth Russell67ea1902014-10-06 16:44:50 -07005767void 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 +00005768{
5769 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5770 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5771 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5772
Geoff Langbfdea662014-07-23 14:16:32 -04005773 gl::Context *context = gl::getNonLostContext();
5774 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005775 {
Geoff Langbfdea662014-07-23 14:16:32 -04005776 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005777 {
Geoff Langb1196682014-07-23 13:47:29 -04005778 context->recordError(gl::Error(GL_INVALID_OPERATION));
5779 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005780 }
Geoff Langbfdea662014-07-23 14:16:32 -04005781
5782 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5783 dstX0, dstY0, dstX1, dstY1, mask, filter,
5784 false))
5785 {
5786 return;
5787 }
5788
Geoff Lang64839152014-08-26 16:23:25 -04005789 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5790 mask, filter);
5791 if (error.isError())
5792 {
5793 context->recordError(error);
5794 return;
5795 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005796 }
5797}
5798
Kenneth Russell67ea1902014-10-06 16:44:50 -07005799void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005800{
5801 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5802 target, samples, internalformat, width, height);
5803
Geoff Langbfdea662014-07-23 14:16:32 -04005804 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005805 if (context)
5806 {
5807 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005808 {
Geoff Langb1196682014-07-23 13:47:29 -04005809 context->recordError(gl::Error(GL_INVALID_OPERATION));
5810 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005811 }
Geoff Langbfdea662014-07-23 14:16:32 -04005812
5813 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5814 width, height, false))
5815 {
5816 return;
5817 }
5818
5819 context->setRenderbufferStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005820 }
5821}
5822
Kenneth Russell67ea1902014-10-06 16:44:50 -07005823void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005824{
5825 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5826 target, attachment, texture, level, layer);
5827
Geoff Langbfdea662014-07-23 14:16:32 -04005828 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005829 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005830 {
Geoff Langbfdea662014-07-23 14:16:32 -04005831 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5832 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005833 {
Geoff Langbfdea662014-07-23 14:16:32 -04005834 return;
5835 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005836
Geoff Langbfdea662014-07-23 14:16:32 -04005837 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5838 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005839
Geoff Langbfdea662014-07-23 14:16:32 -04005840 gl::Texture *textureObject = context->getTexture(texture);
5841 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005842
Geoff Langbfdea662014-07-23 14:16:32 -04005843 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5844 {
5845 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5846 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5847 }
5848 else
5849 {
5850 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005851 {
Geoff Langbfdea662014-07-23 14:16:32 -04005852 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5853 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5854 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005855 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005856 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005857 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005858}
5859
Kenneth Russell67ea1902014-10-06 16:44:50 -07005860GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005861{
5862 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5863 target, offset, length, access);
5864
Geoff Langbfdea662014-07-23 14:16:32 -04005865 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005866 if (context)
5867 {
5868 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005869 {
Geoff Langb1196682014-07-23 13:47:29 -04005870 context->recordError(gl::Error(GL_INVALID_OPERATION));
5871 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005872 }
Geoff Langbfdea662014-07-23 14:16:32 -04005873
5874 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005875 }
5876
5877 return NULL;
5878}
5879
Kenneth Russell67ea1902014-10-06 16:44:50 -07005880void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005881{
5882 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5883
Geoff Langbfdea662014-07-23 14:16:32 -04005884 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005885 if (context)
5886 {
5887 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005888 {
Geoff Langb1196682014-07-23 13:47:29 -04005889 context->recordError(gl::Error(GL_INVALID_OPERATION));
5890 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005891 }
Geoff Langbfdea662014-07-23 14:16:32 -04005892
5893 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005894 }
5895}
5896
Kenneth Russell67ea1902014-10-06 16:44:50 -07005897void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005898{
5899 EVENT("(GLuint array = %u)", array);
5900
Geoff Langbfdea662014-07-23 14:16:32 -04005901 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005902 if (context)
5903 {
5904 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005905 {
Geoff Langb1196682014-07-23 13:47:29 -04005906 context->recordError(gl::Error(GL_INVALID_OPERATION));
5907 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005908 }
Geoff Langbfdea662014-07-23 14:16:32 -04005909
5910 gl::VertexArray *vao = context->getVertexArray(array);
5911
5912 if (!vao)
5913 {
5914 // The default VAO should always exist
5915 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005916 context->recordError(gl::Error(GL_INVALID_OPERATION));
5917 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005918 }
5919
5920 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005921 }
5922}
5923
Kenneth Russell67ea1902014-10-06 16:44:50 -07005924void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005925{
5926 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5927
Geoff Langbfdea662014-07-23 14:16:32 -04005928 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005929 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005930 {
Geoff Langbfdea662014-07-23 14:16:32 -04005931 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005932 {
Geoff Langb1196682014-07-23 13:47:29 -04005933 context->recordError(gl::Error(GL_INVALID_OPERATION));
5934 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005936
Geoff Langbfdea662014-07-23 14:16:32 -04005937 if (n < 0)
5938 {
Geoff Langb1196682014-07-23 13:47:29 -04005939 context->recordError(gl::Error(GL_INVALID_VALUE));
5940 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005941 }
Jamie Madilld1028542013-07-02 11:57:04 -04005942
Geoff Langbfdea662014-07-23 14:16:32 -04005943 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5944 {
5945 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005946 {
Geoff Langbfdea662014-07-23 14:16:32 -04005947 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005948 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005949 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005950 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005951}
5952
Kenneth Russell67ea1902014-10-06 16:44:50 -07005953void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005954{
5955 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5956
Geoff Langbfdea662014-07-23 14:16:32 -04005957 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005958 if (context)
5959 {
5960 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005961 {
Geoff Langb1196682014-07-23 13:47:29 -04005962 context->recordError(gl::Error(GL_INVALID_OPERATION));
5963 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005964 }
Geoff Langbfdea662014-07-23 14:16:32 -04005965
5966 if (n < 0)
5967 {
Geoff Langb1196682014-07-23 13:47:29 -04005968 context->recordError(gl::Error(GL_INVALID_VALUE));
5969 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005970 }
5971
5972 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5973 {
5974 arrays[arrayIndex] = context->createVertexArray();
5975 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005976 }
5977}
5978
Kenneth Russell67ea1902014-10-06 16:44:50 -07005979GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005980{
5981 EVENT("(GLuint array = %u)", array);
5982
Geoff Langbfdea662014-07-23 14:16:32 -04005983 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005984 if (context)
5985 {
5986 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005987 {
Geoff Langb1196682014-07-23 13:47:29 -04005988 context->recordError(gl::Error(GL_INVALID_OPERATION));
5989 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005990 }
Geoff Langbfdea662014-07-23 14:16:32 -04005991
5992 if (array == 0)
5993 {
5994 return GL_FALSE;
5995 }
5996
5997 gl::VertexArray *vao = context->getVertexArray(array);
5998
5999 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006000 }
6001
6002 return GL_FALSE;
6003}
6004
Kenneth Russell67ea1902014-10-06 16:44:50 -07006005void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006006{
6007 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6008 target, index, data);
6009
Geoff Langbfdea662014-07-23 14:16:32 -04006010 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006011 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006012 {
Geoff Langbfdea662014-07-23 14:16:32 -04006013 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006014 {
Geoff Langb1196682014-07-23 13:47:29 -04006015 context->recordError(gl::Error(GL_INVALID_OPERATION));
6016 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006017 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006018
Geoff Lang3a61c322014-07-10 13:01:54 -04006019 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006020 switch (target)
6021 {
6022 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6023 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6024 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006025 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6026 {
Geoff Langb1196682014-07-23 13:47:29 -04006027 context->recordError(gl::Error(GL_INVALID_VALUE));
6028 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006029 }
Geoff Langbfdea662014-07-23 14:16:32 -04006030 break;
Geoff Langb1196682014-07-23 13:47:29 -04006031
Geoff Langbfdea662014-07-23 14:16:32 -04006032 case GL_UNIFORM_BUFFER_START:
6033 case GL_UNIFORM_BUFFER_SIZE:
6034 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006035 if (index >= caps.maxCombinedUniformBlocks)
6036 {
Geoff Langb1196682014-07-23 13:47:29 -04006037 context->recordError(gl::Error(GL_INVALID_VALUE));
6038 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006039 }
Geoff Langbfdea662014-07-23 14:16:32 -04006040 break;
Geoff Langb1196682014-07-23 13:47:29 -04006041
Geoff Langbfdea662014-07-23 14:16:32 -04006042 default:
Geoff Langb1196682014-07-23 13:47:29 -04006043 context->recordError(gl::Error(GL_INVALID_ENUM));
6044 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006045 }
6046
6047 if (!(context->getIndexedIntegerv(target, index, data)))
6048 {
6049 GLenum nativeType;
6050 unsigned int numParams = 0;
6051 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006052 {
6053 context->recordError(gl::Error(GL_INVALID_ENUM));
6054 return;
6055 }
Shannon Woods15934d52013-08-19 14:28:49 -04006056
Geoff Langbfdea662014-07-23 14:16:32 -04006057 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006058 {
Geoff Langbfdea662014-07-23 14:16:32 -04006059 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006060 }
Geoff Langbfdea662014-07-23 14:16:32 -04006061
6062 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006063 {
Geoff Langbfdea662014-07-23 14:16:32 -04006064 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6065 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6066 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006067
Geoff Langbfdea662014-07-23 14:16:32 -04006068 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006069
Geoff Langbfdea662014-07-23 14:16:32 -04006070 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006071 {
Geoff Langbfdea662014-07-23 14:16:32 -04006072 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6073 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006074 }
Geoff Langbfdea662014-07-23 14:16:32 -04006075
6076 delete [] int64Params;
6077 }
6078 else
6079 {
6080 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006081 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006082 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006083 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006084}
6085
Kenneth Russell67ea1902014-10-06 16:44:50 -07006086void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006087{
6088 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6089
Geoff Langbfdea662014-07-23 14:16:32 -04006090 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006091 if (context)
6092 {
6093 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006094 {
Geoff Langb1196682014-07-23 13:47:29 -04006095 context->recordError(gl::Error(GL_INVALID_OPERATION));
6096 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006097 }
Geoff Langbfdea662014-07-23 14:16:32 -04006098
6099 switch (primitiveMode)
6100 {
6101 case GL_TRIANGLES:
6102 case GL_LINES:
6103 case GL_POINTS:
6104 break;
Geoff Langb1196682014-07-23 13:47:29 -04006105
Geoff Langbfdea662014-07-23 14:16:32 -04006106 default:
Geoff Langb1196682014-07-23 13:47:29 -04006107 context->recordError(gl::Error(GL_INVALID_ENUM));
6108 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006109 }
6110
6111 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6112 ASSERT(transformFeedback != NULL);
6113
6114 if (transformFeedback->isStarted())
6115 {
Geoff Langb1196682014-07-23 13:47:29 -04006116 context->recordError(gl::Error(GL_INVALID_OPERATION));
6117 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006118 }
6119
6120 if (transformFeedback->isPaused())
6121 {
6122 transformFeedback->resume();
6123 }
6124 else
6125 {
6126 transformFeedback->start(primitiveMode);
6127 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006128 }
6129}
6130
Kenneth Russell67ea1902014-10-06 16:44:50 -07006131void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006132{
6133 EVENT("(void)");
6134
Geoff Langbfdea662014-07-23 14:16:32 -04006135 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006136 if (context)
6137 {
6138 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006139 {
Geoff Langb1196682014-07-23 13:47:29 -04006140 context->recordError(gl::Error(GL_INVALID_OPERATION));
6141 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006142 }
Geoff Langbfdea662014-07-23 14:16:32 -04006143
6144 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6145 ASSERT(transformFeedback != NULL);
6146
6147 if (!transformFeedback->isStarted())
6148 {
Geoff Langb1196682014-07-23 13:47:29 -04006149 context->recordError(gl::Error(GL_INVALID_OPERATION));
6150 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006151 }
6152
6153 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006154 }
6155}
6156
Kenneth Russell67ea1902014-10-06 16:44:50 -07006157void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006158{
6159 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6160 target, index, buffer, offset, size);
6161
Geoff Langbfdea662014-07-23 14:16:32 -04006162 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006163 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006164 {
Geoff Langbfdea662014-07-23 14:16:32 -04006165 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006166 {
Geoff Langb1196682014-07-23 13:47:29 -04006167 context->recordError(gl::Error(GL_INVALID_OPERATION));
6168 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006169 }
6170
Geoff Lang3a61c322014-07-10 13:01:54 -04006171 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006172 switch (target)
6173 {
6174 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006175 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006176 {
Geoff Langb1196682014-07-23 13:47:29 -04006177 context->recordError(gl::Error(GL_INVALID_VALUE));
6178 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006179 }
Geoff Langbfdea662014-07-23 14:16:32 -04006180 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006181
Geoff Langbfdea662014-07-23 14:16:32 -04006182 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006183 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006184 {
Geoff Langb1196682014-07-23 13:47:29 -04006185 context->recordError(gl::Error(GL_INVALID_VALUE));
6186 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006187 }
Geoff Langbfdea662014-07-23 14:16:32 -04006188 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006189
Geoff Langbfdea662014-07-23 14:16:32 -04006190 default:
Geoff Langb1196682014-07-23 13:47:29 -04006191 context->recordError(gl::Error(GL_INVALID_ENUM));
6192 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006193 }
6194
6195 if (buffer != 0 && size <= 0)
6196 {
Geoff Langb1196682014-07-23 13:47:29 -04006197 context->recordError(gl::Error(GL_INVALID_VALUE));
6198 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006199 }
6200
6201 switch (target)
6202 {
6203 case GL_TRANSFORM_FEEDBACK_BUFFER:
6204
6205 // size and offset must be a multiple of 4
6206 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006207 {
Geoff Langb1196682014-07-23 13:47:29 -04006208 context->recordError(gl::Error(GL_INVALID_VALUE));
6209 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006210 }
6211
Geoff Langbfdea662014-07-23 14:16:32 -04006212 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6213 context->bindGenericTransformFeedbackBuffer(buffer);
6214 break;
6215
6216 case GL_UNIFORM_BUFFER:
6217
6218 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006219 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006220 {
Geoff Langb1196682014-07-23 13:47:29 -04006221 context->recordError(gl::Error(GL_INVALID_VALUE));
6222 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006223 }
Geoff Langbfdea662014-07-23 14:16:32 -04006224
6225 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6226 context->bindGenericUniformBuffer(buffer);
6227 break;
6228
6229 default:
6230 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006231 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006232 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006233}
6234
Kenneth Russell67ea1902014-10-06 16:44:50 -07006235void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006236{
6237 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6238 target, index, buffer);
6239
Geoff Langbfdea662014-07-23 14:16:32 -04006240 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006241 if (context)
6242 {
6243 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006244 {
Geoff Langb1196682014-07-23 13:47:29 -04006245 context->recordError(gl::Error(GL_INVALID_OPERATION));
6246 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006247 }
Geoff Langbfdea662014-07-23 14:16:32 -04006248
Geoff Lang3a61c322014-07-10 13:01:54 -04006249 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006250 switch (target)
6251 {
6252 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006253 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006254 {
Geoff Langb1196682014-07-23 13:47:29 -04006255 context->recordError(gl::Error(GL_INVALID_VALUE));
6256 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006257 }
6258 break;
6259
6260 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006261 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006262 {
Geoff Langb1196682014-07-23 13:47:29 -04006263 context->recordError(gl::Error(GL_INVALID_VALUE));
6264 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006265 }
6266 break;
6267
6268 default:
Geoff Langb1196682014-07-23 13:47:29 -04006269 context->recordError(gl::Error(GL_INVALID_ENUM));
6270 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006271 }
6272
6273 switch (target)
6274 {
6275 case GL_TRANSFORM_FEEDBACK_BUFFER:
6276 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6277 context->bindGenericTransformFeedbackBuffer(buffer);
6278 break;
6279
6280 case GL_UNIFORM_BUFFER:
6281 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6282 context->bindGenericUniformBuffer(buffer);
6283 break;
6284
6285 default:
6286 UNREACHABLE();
6287 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006288 }
6289}
6290
Kenneth Russell67ea1902014-10-06 16:44:50 -07006291void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006292{
6293 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6294 program, count, varyings, bufferMode);
6295
Geoff Langbfdea662014-07-23 14:16:32 -04006296 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006297 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006298 {
Geoff Langbfdea662014-07-23 14:16:32 -04006299 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006300 {
Geoff Langb1196682014-07-23 13:47:29 -04006301 context->recordError(gl::Error(GL_INVALID_OPERATION));
6302 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006303 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006304
Geoff Langbfdea662014-07-23 14:16:32 -04006305 if (count < 0)
6306 {
Geoff Langb1196682014-07-23 13:47:29 -04006307 context->recordError(gl::Error(GL_INVALID_VALUE));
6308 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006309 }
6310
Geoff Lang05881a02014-07-10 14:05:30 -04006311 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006312 switch (bufferMode)
6313 {
6314 case GL_INTERLEAVED_ATTRIBS:
6315 break;
6316 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006317 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006318 {
Geoff Langb1196682014-07-23 13:47:29 -04006319 context->recordError(gl::Error(GL_INVALID_VALUE));
6320 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006321 }
Geoff Langbfdea662014-07-23 14:16:32 -04006322 break;
6323 default:
Geoff Langb1196682014-07-23 13:47:29 -04006324 context->recordError(gl::Error(GL_INVALID_ENUM));
6325 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006326 }
Geoff Langbfdea662014-07-23 14:16:32 -04006327
6328 if (!gl::ValidProgram(context, program))
6329 {
6330 return;
6331 }
6332
6333 gl::Program *programObject = context->getProgram(program);
6334 ASSERT(programObject);
6335
6336 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006337 }
6338}
6339
Kenneth Russell67ea1902014-10-06 16:44:50 -07006340void 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 +00006341{
6342 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6343 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6344 program, index, bufSize, length, size, type, name);
6345
Geoff Langbfdea662014-07-23 14:16:32 -04006346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006347 if (context)
6348 {
6349 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006350 {
Geoff Langb1196682014-07-23 13:47:29 -04006351 context->recordError(gl::Error(GL_INVALID_OPERATION));
6352 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006353 }
Geoff Langbfdea662014-07-23 14:16:32 -04006354
6355 if (bufSize < 0)
6356 {
Geoff Langb1196682014-07-23 13:47:29 -04006357 context->recordError(gl::Error(GL_INVALID_VALUE));
6358 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006359 }
6360
6361 if (!gl::ValidProgram(context, program))
6362 {
6363 return;
6364 }
6365
6366 gl::Program *programObject = context->getProgram(program);
6367 ASSERT(programObject);
6368
6369 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6370 {
Geoff Langb1196682014-07-23 13:47:29 -04006371 context->recordError(gl::Error(GL_INVALID_VALUE));
6372 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006373 }
6374
6375 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006376 }
6377}
6378
Kenneth Russell67ea1902014-10-06 16:44:50 -07006379void 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 +00006380{
6381 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6382 index, size, type, stride, pointer);
6383
Geoff Langbfdea662014-07-23 14:16:32 -04006384 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006385 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006386 {
Geoff Langbfdea662014-07-23 14:16:32 -04006387 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006388 {
Geoff Langb1196682014-07-23 13:47:29 -04006389 context->recordError(gl::Error(GL_INVALID_OPERATION));
6390 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006391 }
6392
Geoff Langb1196682014-07-23 13:47:29 -04006393 if (index >= gl::MAX_VERTEX_ATTRIBS)
6394 {
6395 context->recordError(gl::Error(GL_INVALID_VALUE));
6396 return;
6397 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006398
Geoff Langb1196682014-07-23 13:47:29 -04006399 if (size < 1 || size > 4)
6400 {
6401 context->recordError(gl::Error(GL_INVALID_VALUE));
6402 return;
6403 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006404
Geoff Langb1196682014-07-23 13:47:29 -04006405 switch (type)
6406 {
6407 case GL_BYTE:
6408 case GL_UNSIGNED_BYTE:
6409 case GL_SHORT:
6410 case GL_UNSIGNED_SHORT:
6411 case GL_INT:
6412 case GL_UNSIGNED_INT:
6413 case GL_INT_2_10_10_10_REV:
6414 case GL_UNSIGNED_INT_2_10_10_10_REV:
6415 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006416
Geoff Langb1196682014-07-23 13:47:29 -04006417 default:
6418 context->recordError(gl::Error(GL_INVALID_ENUM));
6419 return;
6420 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006421
Geoff Langb1196682014-07-23 13:47:29 -04006422 if (stride < 0)
6423 {
6424 context->recordError(gl::Error(GL_INVALID_VALUE));
6425 return;
6426 }
Geoff Langbfdea662014-07-23 14:16:32 -04006427
Geoff Langb1196682014-07-23 13:47:29 -04006428 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6429 {
6430 context->recordError(gl::Error(GL_INVALID_OPERATION));
6431 return;
6432 }
6433
Geoff Langbfdea662014-07-23 14:16:32 -04006434 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6435 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6436 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6437 // and the pointer argument is not NULL.
6438 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006439 {
Geoff Langb1196682014-07-23 13:47:29 -04006440 context->recordError(gl::Error(GL_INVALID_OPERATION));
6441 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006442 }
6443
Geoff Langbfdea662014-07-23 14:16:32 -04006444 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6445 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006446 }
6447}
6448
Kenneth Russell67ea1902014-10-06 16:44:50 -07006449void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006450{
6451 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6452 index, pname, params);
6453
Geoff Langbfdea662014-07-23 14:16:32 -04006454 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006455 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006456 {
Geoff Langbfdea662014-07-23 14:16:32 -04006457 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006458 {
Geoff Langb1196682014-07-23 13:47:29 -04006459 context->recordError(gl::Error(GL_INVALID_OPERATION));
6460 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006461 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006462
Geoff Langbfdea662014-07-23 14:16:32 -04006463 if (index >= gl::MAX_VERTEX_ATTRIBS)
6464 {
Geoff Langb1196682014-07-23 13:47:29 -04006465 context->recordError(gl::Error(GL_INVALID_VALUE));
6466 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006467 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006468
Geoff Langbfdea662014-07-23 14:16:32 -04006469 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006470
Geoff Langb1196682014-07-23 13:47:29 -04006471 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006472 {
6473 return;
6474 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006475
Geoff Langbfdea662014-07-23 14:16:32 -04006476 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6477 {
6478 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6479 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006480 {
Geoff Langbfdea662014-07-23 14:16:32 -04006481 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006482 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006483 }
Geoff Langbfdea662014-07-23 14:16:32 -04006484 else
6485 {
6486 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6487 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006488 }
6489}
6490
Kenneth Russell67ea1902014-10-06 16:44:50 -07006491void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006492{
6493 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6494 index, pname, params);
6495
Geoff Langbfdea662014-07-23 14:16:32 -04006496 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006497 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006498 {
Geoff Langbfdea662014-07-23 14:16:32 -04006499 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006500 {
Geoff Langb1196682014-07-23 13:47:29 -04006501 context->recordError(gl::Error(GL_INVALID_OPERATION));
6502 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006503 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006504
Geoff Langbfdea662014-07-23 14:16:32 -04006505 if (index >= gl::MAX_VERTEX_ATTRIBS)
6506 {
Geoff Langb1196682014-07-23 13:47:29 -04006507 context->recordError(gl::Error(GL_INVALID_VALUE));
6508 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006509 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006510
Geoff Langbfdea662014-07-23 14:16:32 -04006511 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006512
Geoff Langb1196682014-07-23 13:47:29 -04006513 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006514 {
6515 return;
6516 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006517
Geoff Langbfdea662014-07-23 14:16:32 -04006518 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6519 {
6520 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6521 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006522 {
Geoff Langbfdea662014-07-23 14:16:32 -04006523 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006524 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006525 }
Geoff Langbfdea662014-07-23 14:16:32 -04006526 else
6527 {
6528 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6529 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006530 }
6531}
6532
Kenneth Russell67ea1902014-10-06 16:44:50 -07006533void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006534{
6535 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6536 index, x, y, z, w);
6537
Geoff Langbfdea662014-07-23 14:16:32 -04006538 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006539 if (context)
6540 {
6541 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006542 {
Geoff Langb1196682014-07-23 13:47:29 -04006543 context->recordError(gl::Error(GL_INVALID_OPERATION));
6544 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006545 }
Geoff Langbfdea662014-07-23 14:16:32 -04006546
6547 if (index >= gl::MAX_VERTEX_ATTRIBS)
6548 {
Geoff Langb1196682014-07-23 13:47:29 -04006549 context->recordError(gl::Error(GL_INVALID_VALUE));
6550 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006551 }
6552
6553 GLint vals[4] = { x, y, z, w };
6554 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006555 }
6556}
6557
Kenneth Russell67ea1902014-10-06 16:44:50 -07006558void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006559{
6560 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6561 index, x, y, z, w);
6562
Geoff Langbfdea662014-07-23 14:16:32 -04006563 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006564 if (context)
6565 {
6566 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006567 {
Geoff Langb1196682014-07-23 13:47:29 -04006568 context->recordError(gl::Error(GL_INVALID_OPERATION));
6569 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006570 }
Geoff Langbfdea662014-07-23 14:16:32 -04006571
6572 if (index >= gl::MAX_VERTEX_ATTRIBS)
6573 {
Geoff Langb1196682014-07-23 13:47:29 -04006574 context->recordError(gl::Error(GL_INVALID_VALUE));
6575 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006576 }
6577
6578 GLuint vals[4] = { x, y, z, w };
6579 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006580 }
6581}
6582
Kenneth Russell67ea1902014-10-06 16:44:50 -07006583void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006584{
6585 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6586
Geoff Langbfdea662014-07-23 14:16:32 -04006587 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006588 if (context)
6589 {
6590 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006591 {
Geoff Langb1196682014-07-23 13:47:29 -04006592 context->recordError(gl::Error(GL_INVALID_OPERATION));
6593 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006594 }
Geoff Langbfdea662014-07-23 14:16:32 -04006595
6596 if (index >= gl::MAX_VERTEX_ATTRIBS)
6597 {
Geoff Langb1196682014-07-23 13:47:29 -04006598 context->recordError(gl::Error(GL_INVALID_VALUE));
6599 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006600 }
6601
6602 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006603 }
6604}
6605
Kenneth Russell67ea1902014-10-06 16:44:50 -07006606void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006607{
6608 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6609
Geoff Langbfdea662014-07-23 14:16:32 -04006610 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006611 if (context)
6612 {
6613 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006614 {
Geoff Langb1196682014-07-23 13:47:29 -04006615 context->recordError(gl::Error(GL_INVALID_OPERATION));
6616 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006617 }
Geoff Langbfdea662014-07-23 14:16:32 -04006618
6619 if (index >= gl::MAX_VERTEX_ATTRIBS)
6620 {
Geoff Langb1196682014-07-23 13:47:29 -04006621 context->recordError(gl::Error(GL_INVALID_VALUE));
6622 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006623 }
6624
6625 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006626 }
6627}
6628
Kenneth Russell67ea1902014-10-06 16:44:50 -07006629void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006630{
6631 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6632 program, location, params);
6633
Geoff Langbfdea662014-07-23 14:16:32 -04006634 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006635 if (context)
6636 {
Jamie Madill0063c512014-08-25 15:47:53 -04006637 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006638 {
Jamie Madill0063c512014-08-25 15:47:53 -04006639 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006640 }
Geoff Langbfdea662014-07-23 14:16:32 -04006641
Jamie Madilla502c742014-08-28 17:19:13 -04006642 gl::Program *programObject = context->getProgram(program);
6643 ASSERT(programObject);
6644 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006645 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006646
Jamie Madill99a1e982014-08-25 15:47:54 -04006647 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006648 }
6649}
6650
Kenneth Russell67ea1902014-10-06 16:44:50 -07006651GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006652{
6653 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6654 program, name);
6655
Geoff Langbfdea662014-07-23 14:16:32 -04006656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006657 if (context)
6658 {
6659 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006660 {
Geoff Langb1196682014-07-23 13:47:29 -04006661 context->recordError(gl::Error(GL_INVALID_OPERATION));
6662 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006663 }
Geoff Langbfdea662014-07-23 14:16:32 -04006664
6665 if (program == 0)
6666 {
Geoff Langb1196682014-07-23 13:47:29 -04006667 context->recordError(gl::Error(GL_INVALID_VALUE));
6668 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006669 }
6670
6671 gl::Program *programObject = context->getProgram(program);
6672
6673 if (!programObject || !programObject->isLinked())
6674 {
Geoff Langb1196682014-07-23 13:47:29 -04006675 context->recordError(gl::Error(GL_INVALID_OPERATION));
6676 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006677 }
6678
6679 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6680 if (!programBinary)
6681 {
Geoff Langb1196682014-07-23 13:47:29 -04006682 context->recordError(gl::Error(GL_INVALID_OPERATION));
6683 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006684 }
6685
6686 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006687 }
6688
6689 return 0;
6690}
6691
Kenneth Russell67ea1902014-10-06 16:44:50 -07006692void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006693{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006694 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006695}
6696
Kenneth Russell67ea1902014-10-06 16:44:50 -07006697void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006698{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006699 const GLuint xy[] = { v0, v1 };
6700 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006701}
6702
Kenneth Russell67ea1902014-10-06 16:44:50 -07006703void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006704{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006705 const GLuint xyz[] = { v0, v1, v2 };
6706 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006707}
6708
Kenneth Russell67ea1902014-10-06 16:44:50 -07006709void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006710{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006711 const GLuint xyzw[] = { v0, v1, v2, v3 };
6712 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006713}
6714
Kenneth Russell67ea1902014-10-06 16:44:50 -07006715void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006716{
6717 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6718 location, count, value);
6719
Geoff Langbfdea662014-07-23 14:16:32 -04006720 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006721 if (context)
6722 {
6723 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006724 {
Geoff Langbfdea662014-07-23 14:16:32 -04006725 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006726 }
Geoff Langbfdea662014-07-23 14:16:32 -04006727
6728 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6729 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006730 }
6731}
6732
Kenneth Russell67ea1902014-10-06 16:44:50 -07006733void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006734{
6735 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6736 location, count, value);
6737
Geoff Langbfdea662014-07-23 14:16:32 -04006738 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006739 if (context)
6740 {
6741 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006742 {
Geoff Langbfdea662014-07-23 14:16:32 -04006743 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006744 }
Geoff Langbfdea662014-07-23 14:16:32 -04006745
6746 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6747 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006748 }
6749}
6750
Kenneth Russell67ea1902014-10-06 16:44:50 -07006751void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006752{
6753 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6754 location, count, value);
6755
Geoff Langbfdea662014-07-23 14:16:32 -04006756 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006757 if (context)
6758 {
6759 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006760 {
Geoff Langbfdea662014-07-23 14:16:32 -04006761 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006762 }
Geoff Langbfdea662014-07-23 14:16:32 -04006763
6764 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6765 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006766 }
6767}
6768
Kenneth Russell67ea1902014-10-06 16:44:50 -07006769void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006770{
6771 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6772 location, count, value);
6773
Geoff Langbfdea662014-07-23 14:16:32 -04006774 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006775 if (context)
6776 {
6777 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006778 {
Geoff Langbfdea662014-07-23 14:16:32 -04006779 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006780 }
Geoff Langbfdea662014-07-23 14:16:32 -04006781
6782 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6783 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006784 }
6785}
6786
Kenneth Russell67ea1902014-10-06 16:44:50 -07006787void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006788{
6789 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6790 buffer, drawbuffer, value);
6791
Geoff Langbfdea662014-07-23 14:16:32 -04006792 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006793 if (context)
6794 {
6795 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006796 {
Geoff Langbfdea662014-07-23 14:16:32 -04006797 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006798 }
Geoff Langbfdea662014-07-23 14:16:32 -04006799
6800 switch (buffer)
6801 {
6802 case GL_COLOR:
6803 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6804 {
Geoff Langb1196682014-07-23 13:47:29 -04006805 context->recordError(gl::Error(GL_INVALID_VALUE));
6806 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006807 }
6808 break;
Geoff Langb1196682014-07-23 13:47:29 -04006809
Geoff Langbfdea662014-07-23 14:16:32 -04006810 case GL_STENCIL:
6811 if (drawbuffer != 0)
6812 {
Geoff Langb1196682014-07-23 13:47:29 -04006813 context->recordError(gl::Error(GL_INVALID_VALUE));
6814 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006815 }
6816 break;
Geoff Langb1196682014-07-23 13:47:29 -04006817
Geoff Langbfdea662014-07-23 14:16:32 -04006818 default:
Geoff Langb1196682014-07-23 13:47:29 -04006819 context->recordError(gl::Error(GL_INVALID_ENUM));
6820 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006821 }
6822
Geoff Langcc79b8c2014-07-25 13:48:02 -04006823 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6824 if (error.isError())
6825 {
6826 context->recordError(error);
6827 return;
6828 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006829 }
6830}
6831
Kenneth Russell67ea1902014-10-06 16:44:50 -07006832void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006833{
6834 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6835 buffer, drawbuffer, value);
6836
Geoff Langbfdea662014-07-23 14:16:32 -04006837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006838 if (context)
6839 {
6840 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006841 {
Geoff Langbfdea662014-07-23 14:16:32 -04006842 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006843 }
Geoff Langbfdea662014-07-23 14:16:32 -04006844
6845 switch (buffer)
6846 {
6847 case GL_COLOR:
6848 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6849 {
Geoff Langb1196682014-07-23 13:47:29 -04006850 context->recordError(gl::Error(GL_INVALID_VALUE));
6851 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006852 }
6853 break;
Geoff Langb1196682014-07-23 13:47:29 -04006854
Geoff Langbfdea662014-07-23 14:16:32 -04006855 default:
Geoff Langb1196682014-07-23 13:47:29 -04006856 context->recordError(gl::Error(GL_INVALID_ENUM));
6857 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006858 }
6859
Geoff Langcc79b8c2014-07-25 13:48:02 -04006860 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6861 if (error.isError())
6862 {
6863 context->recordError(error);
6864 return;
6865 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006866 }
6867}
6868
Kenneth Russell67ea1902014-10-06 16:44:50 -07006869void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006870{
6871 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6872 buffer, drawbuffer, value);
6873
Geoff Langbfdea662014-07-23 14:16:32 -04006874 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006875 if (context)
6876 {
6877 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006878 {
Geoff Langbfdea662014-07-23 14:16:32 -04006879 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006880 }
Geoff Langbfdea662014-07-23 14:16:32 -04006881
6882 switch (buffer)
6883 {
6884 case GL_COLOR:
6885 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6886 {
Geoff Langb1196682014-07-23 13:47:29 -04006887 context->recordError(gl::Error(GL_INVALID_VALUE));
6888 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006889 }
6890 break;
Geoff Langb1196682014-07-23 13:47:29 -04006891
Geoff Langbfdea662014-07-23 14:16:32 -04006892 case GL_DEPTH:
6893 if (drawbuffer != 0)
6894 {
Geoff Langb1196682014-07-23 13:47:29 -04006895 context->recordError(gl::Error(GL_INVALID_VALUE));
6896 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006897 }
6898 break;
Geoff Langb1196682014-07-23 13:47:29 -04006899
Geoff Langbfdea662014-07-23 14:16:32 -04006900 default:
Geoff Langb1196682014-07-23 13:47:29 -04006901 context->recordError(gl::Error(GL_INVALID_ENUM));
6902 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006903 }
6904
Geoff Langcc79b8c2014-07-25 13:48:02 -04006905 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6906 if (error.isError())
6907 {
6908 context->recordError(error);
6909 return;
6910 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006911 }
6912}
6913
Kenneth Russell67ea1902014-10-06 16:44:50 -07006914void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006915{
6916 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6917 buffer, drawbuffer, depth, stencil);
6918
Geoff Langbfdea662014-07-23 14:16:32 -04006919 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006920 if (context)
6921 {
6922 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006923 {
Geoff Langbfdea662014-07-23 14:16:32 -04006924 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006925 }
Geoff Langbfdea662014-07-23 14:16:32 -04006926
6927 switch (buffer)
6928 {
6929 case GL_DEPTH_STENCIL:
6930 if (drawbuffer != 0)
6931 {
Geoff Langb1196682014-07-23 13:47:29 -04006932 context->recordError(gl::Error(GL_INVALID_VALUE));
6933 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006934 }
6935 break;
Geoff Langb1196682014-07-23 13:47:29 -04006936
Geoff Langbfdea662014-07-23 14:16:32 -04006937 default:
Geoff Langb1196682014-07-23 13:47:29 -04006938 context->recordError(gl::Error(GL_INVALID_ENUM));
6939 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006940 }
6941
Geoff Langcc79b8c2014-07-25 13:48:02 -04006942 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6943 if (error.isError())
6944 {
6945 context->recordError(error);
6946 return;
6947 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006948 }
6949}
6950
Kenneth Russell67ea1902014-10-06 16:44:50 -07006951const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006952{
6953 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6954
Geoff Langbfdea662014-07-23 14:16:32 -04006955 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006956 if (context)
6957 {
6958 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006959 {
Geoff Langb1196682014-07-23 13:47:29 -04006960 context->recordError(gl::Error(GL_INVALID_OPERATION));
6961 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006962 }
Geoff Langbfdea662014-07-23 14:16:32 -04006963
6964 if (name != GL_EXTENSIONS)
6965 {
Geoff Langb1196682014-07-23 13:47:29 -04006966 context->recordError(gl::Error(GL_INVALID_ENUM));
6967 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006968 }
6969
6970 if (index >= context->getExtensionStringCount())
6971 {
Geoff Langb1196682014-07-23 13:47:29 -04006972 context->recordError(gl::Error(GL_INVALID_VALUE));
6973 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006974 }
6975
6976 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006977 }
6978
6979 return NULL;
6980}
6981
Kenneth Russell67ea1902014-10-06 16:44:50 -07006982void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006983{
6984 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6985 readTarget, writeTarget, readOffset, writeOffset, size);
6986
Geoff Langbfdea662014-07-23 14:16:32 -04006987 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006988 if (context)
6989 {
6990 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006991 {
Geoff Langb1196682014-07-23 13:47:29 -04006992 context->recordError(gl::Error(GL_INVALID_OPERATION));
6993 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006994 }
Geoff Langbfdea662014-07-23 14:16:32 -04006995
Jamie Madill24e83192014-10-20 11:00:53 -04006996 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04006997 {
Geoff Langb1196682014-07-23 13:47:29 -04006998 context->recordError(gl::Error(GL_INVALID_ENUM));
6999 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007000 }
7001
7002 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
7003 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
7004
7005 if (!readBuffer || !writeBuffer)
7006 {
Geoff Langb1196682014-07-23 13:47:29 -04007007 context->recordError(gl::Error(GL_INVALID_OPERATION));
7008 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007009 }
7010
Jamie Madillcfaaf722014-07-31 10:47:54 -04007011 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04007012 if (readBuffer->isMapped() || writeBuffer->isMapped())
7013 {
Geoff Langb1196682014-07-23 13:47:29 -04007014 context->recordError(gl::Error(GL_INVALID_OPERATION));
7015 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007016 }
7017
7018 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7019 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7020 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7021 {
Geoff Langb1196682014-07-23 13:47:29 -04007022 context->recordError(gl::Error(GL_INVALID_VALUE));
7023 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007024 }
7025
Kenneth Russell67ea1902014-10-06 16:44:50 -07007026 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007027 {
Geoff Langb1196682014-07-23 13:47:29 -04007028 context->recordError(gl::Error(GL_INVALID_VALUE));
7029 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007030 }
7031
Geoff Langbfdea662014-07-23 14:16:32 -04007032 // if size is zero, the copy is a successful no-op
7033 if (size > 0)
7034 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007035 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7036 if (error.isError())
7037 {
7038 context->recordError(error);
7039 return;
7040 }
Geoff Langbfdea662014-07-23 14:16:32 -04007041 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007042 }
7043}
7044
Kenneth Russell67ea1902014-10-06 16:44:50 -07007045void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007046{
7047 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7048 program, uniformCount, uniformNames, uniformIndices);
7049
Geoff Langbfdea662014-07-23 14:16:32 -04007050 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007051 if (context)
7052 {
7053 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007054 {
Geoff Langb1196682014-07-23 13:47:29 -04007055 context->recordError(gl::Error(GL_INVALID_OPERATION));
7056 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007057 }
7058
7059 if (uniformCount < 0)
7060 {
Geoff Langb1196682014-07-23 13:47:29 -04007061 context->recordError(gl::Error(GL_INVALID_VALUE));
7062 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007063 }
7064
7065 gl::Program *programObject = context->getProgram(program);
7066
7067 if (!programObject)
7068 {
7069 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007070 {
Geoff Langb1196682014-07-23 13:47:29 -04007071 context->recordError(gl::Error(GL_INVALID_OPERATION));
7072 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007073 }
Geoff Langbfdea662014-07-23 14:16:32 -04007074 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007075 {
Geoff Langb1196682014-07-23 13:47:29 -04007076 context->recordError(gl::Error(GL_INVALID_VALUE));
7077 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007078 }
Geoff Langbfdea662014-07-23 14:16:32 -04007079 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007080
Geoff Langbfdea662014-07-23 14:16:32 -04007081 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7082 if (!programObject->isLinked() || !programBinary)
7083 {
7084 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007085 {
Geoff Langbfdea662014-07-23 14:16:32 -04007086 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007087 }
7088 }
Geoff Langbfdea662014-07-23 14:16:32 -04007089 else
7090 {
7091 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7092 {
7093 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7094 }
7095 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007096 }
7097}
7098
Kenneth Russell67ea1902014-10-06 16:44:50 -07007099void 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 +00007100{
7101 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7102 program, uniformCount, uniformIndices, pname, params);
7103
Geoff Langbfdea662014-07-23 14:16:32 -04007104 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007105 if (context)
7106 {
7107 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007108 {
Geoff Langb1196682014-07-23 13:47:29 -04007109 context->recordError(gl::Error(GL_INVALID_OPERATION));
7110 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007111 }
7112
7113 if (uniformCount < 0)
7114 {
Geoff Langb1196682014-07-23 13:47:29 -04007115 context->recordError(gl::Error(GL_INVALID_VALUE));
7116 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007117 }
7118
7119 gl::Program *programObject = context->getProgram(program);
7120
7121 if (!programObject)
7122 {
7123 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007124 {
Geoff Langb1196682014-07-23 13:47:29 -04007125 context->recordError(gl::Error(GL_INVALID_OPERATION));
7126 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007127 }
Geoff Langbfdea662014-07-23 14:16:32 -04007128 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007129 {
Geoff Langb1196682014-07-23 13:47:29 -04007130 context->recordError(gl::Error(GL_INVALID_VALUE));
7131 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007132 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007133 }
Geoff Langbfdea662014-07-23 14:16:32 -04007134
7135 switch (pname)
7136 {
7137 case GL_UNIFORM_TYPE:
7138 case GL_UNIFORM_SIZE:
7139 case GL_UNIFORM_NAME_LENGTH:
7140 case GL_UNIFORM_BLOCK_INDEX:
7141 case GL_UNIFORM_OFFSET:
7142 case GL_UNIFORM_ARRAY_STRIDE:
7143 case GL_UNIFORM_MATRIX_STRIDE:
7144 case GL_UNIFORM_IS_ROW_MAJOR:
7145 break;
Geoff Langb1196682014-07-23 13:47:29 -04007146
Geoff Langbfdea662014-07-23 14:16:32 -04007147 default:
Geoff Langb1196682014-07-23 13:47:29 -04007148 context->recordError(gl::Error(GL_INVALID_ENUM));
7149 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007150 }
7151
7152 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7153
7154 if (!programBinary && uniformCount > 0)
7155 {
Geoff Langb1196682014-07-23 13:47:29 -04007156 context->recordError(gl::Error(GL_INVALID_VALUE));
7157 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007158 }
7159
7160 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7161 {
7162 const GLuint index = uniformIndices[uniformId];
7163
7164 if (index >= (GLuint)programBinary->getActiveUniformCount())
7165 {
Geoff Langb1196682014-07-23 13:47:29 -04007166 context->recordError(gl::Error(GL_INVALID_VALUE));
7167 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007168 }
7169 }
7170
7171 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7172 {
7173 const GLuint index = uniformIndices[uniformId];
7174 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7175 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007176 }
7177}
7178
Kenneth Russell67ea1902014-10-06 16:44:50 -07007179GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007180{
7181 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7182
Geoff Langbfdea662014-07-23 14:16:32 -04007183 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007184 if (context)
7185 {
7186 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007187 {
Geoff Langb1196682014-07-23 13:47:29 -04007188 context->recordError(gl::Error(GL_INVALID_OPERATION));
7189 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007190 }
7191
7192 gl::Program *programObject = context->getProgram(program);
7193
7194 if (!programObject)
7195 {
7196 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007197 {
Geoff Langb1196682014-07-23 13:47:29 -04007198 context->recordError(gl::Error(GL_INVALID_OPERATION));
7199 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007200 }
Geoff Langbfdea662014-07-23 14:16:32 -04007201 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007202 {
Geoff Langb1196682014-07-23 13:47:29 -04007203 context->recordError(gl::Error(GL_INVALID_VALUE));
7204 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007205 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007206 }
Geoff Langbfdea662014-07-23 14:16:32 -04007207
7208 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7209 if (!programBinary)
7210 {
7211 return GL_INVALID_INDEX;
7212 }
7213
7214 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007215 }
7216
7217 return 0;
7218}
7219
Kenneth Russell67ea1902014-10-06 16:44:50 -07007220void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007221{
7222 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7223 program, uniformBlockIndex, pname, params);
7224
Geoff Langbfdea662014-07-23 14:16:32 -04007225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007226 if (context)
7227 {
7228 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007229 {
Geoff Langb1196682014-07-23 13:47:29 -04007230 context->recordError(gl::Error(GL_INVALID_OPERATION));
7231 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007232 }
7233 gl::Program *programObject = context->getProgram(program);
7234
7235 if (!programObject)
7236 {
7237 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007238 {
Geoff Langb1196682014-07-23 13:47:29 -04007239 context->recordError(gl::Error(GL_INVALID_OPERATION));
7240 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007241 }
Geoff Langbfdea662014-07-23 14:16:32 -04007242 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007243 {
Geoff Langb1196682014-07-23 13:47:29 -04007244 context->recordError(gl::Error(GL_INVALID_VALUE));
7245 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007246 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007247 }
Geoff Langbfdea662014-07-23 14:16:32 -04007248
7249 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7250
7251 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7252 {
Geoff Langb1196682014-07-23 13:47:29 -04007253 context->recordError(gl::Error(GL_INVALID_VALUE));
7254 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007255 }
7256
7257 switch (pname)
7258 {
7259 case GL_UNIFORM_BLOCK_BINDING:
7260 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7261 break;
7262
7263 case GL_UNIFORM_BLOCK_DATA_SIZE:
7264 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7265 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7266 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7267 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7268 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7269 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7270 break;
7271
7272 default:
Geoff Langb1196682014-07-23 13:47:29 -04007273 context->recordError(gl::Error(GL_INVALID_ENUM));
7274 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007275 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007276 }
7277}
7278
Kenneth Russell67ea1902014-10-06 16:44:50 -07007279void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007280{
7281 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7282 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7283
Geoff Langbfdea662014-07-23 14:16:32 -04007284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007285 if (context)
7286 {
7287 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007288 {
Geoff Langb1196682014-07-23 13:47:29 -04007289 context->recordError(gl::Error(GL_INVALID_OPERATION));
7290 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007291 }
7292
7293 gl::Program *programObject = context->getProgram(program);
7294
7295 if (!programObject)
7296 {
7297 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007298 {
Geoff Langb1196682014-07-23 13:47:29 -04007299 context->recordError(gl::Error(GL_INVALID_OPERATION));
7300 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007301 }
Geoff Langbfdea662014-07-23 14:16:32 -04007302 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007303 {
Geoff Langb1196682014-07-23 13:47:29 -04007304 context->recordError(gl::Error(GL_INVALID_VALUE));
7305 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007306 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007307 }
Geoff Langbfdea662014-07-23 14:16:32 -04007308
7309 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7310
7311 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7312 {
Geoff Langb1196682014-07-23 13:47:29 -04007313 context->recordError(gl::Error(GL_INVALID_VALUE));
7314 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007315 }
7316
7317 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007318 }
7319}
7320
Kenneth Russell67ea1902014-10-06 16:44:50 -07007321void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007322{
7323 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7324 program, uniformBlockIndex, uniformBlockBinding);
7325
Geoff Langbfdea662014-07-23 14:16:32 -04007326 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007327 if (context)
7328 {
7329 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007330 {
Geoff Langb1196682014-07-23 13:47:29 -04007331 context->recordError(gl::Error(GL_INVALID_OPERATION));
7332 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007333 }
7334
Geoff Lang3a61c322014-07-10 13:01:54 -04007335 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007336 {
Geoff Langb1196682014-07-23 13:47:29 -04007337 context->recordError(gl::Error(GL_INVALID_VALUE));
7338 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007339 }
7340
7341 gl::Program *programObject = context->getProgram(program);
7342
7343 if (!programObject)
7344 {
7345 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007346 {
Geoff Langb1196682014-07-23 13:47:29 -04007347 context->recordError(gl::Error(GL_INVALID_OPERATION));
7348 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007349 }
Geoff Langbfdea662014-07-23 14:16:32 -04007350 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007351 {
Geoff Langb1196682014-07-23 13:47:29 -04007352 context->recordError(gl::Error(GL_INVALID_VALUE));
7353 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007354 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007355 }
Geoff Langbfdea662014-07-23 14:16:32 -04007356
7357 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7358
7359 // if never linked, there won't be any uniform blocks
7360 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7361 {
Geoff Langb1196682014-07-23 13:47:29 -04007362 context->recordError(gl::Error(GL_INVALID_VALUE));
7363 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007364 }
7365
7366 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007367 }
7368}
7369
Kenneth Russell67ea1902014-10-06 16:44:50 -07007370void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007371{
7372 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7373 mode, first, count, instanceCount);
7374
Geoff Langbfdea662014-07-23 14:16:32 -04007375 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007376 if (context)
7377 {
7378 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007379 {
Geoff Langb1196682014-07-23 13:47:29 -04007380 context->recordError(gl::Error(GL_INVALID_OPERATION));
7381 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007382 }
Geoff Langbfdea662014-07-23 14:16:32 -04007383
7384 // glDrawArraysInstanced
7385 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007386 }
7387}
7388
Kenneth Russell67ea1902014-10-06 16:44:50 -07007389void 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 +00007390{
7391 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7392 mode, count, type, indices, instanceCount);
7393
Geoff Langbfdea662014-07-23 14:16:32 -04007394 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007395 if (context)
7396 {
7397 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007398 {
Geoff Langb1196682014-07-23 13:47:29 -04007399 context->recordError(gl::Error(GL_INVALID_OPERATION));
7400 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007401 }
Geoff Langbfdea662014-07-23 14:16:32 -04007402
7403 // glDrawElementsInstanced
7404 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007405 }
7406}
7407
Kenneth Russell67ea1902014-10-06 16:44:50 -07007408GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007409{
7410 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7411
Geoff Langbfdea662014-07-23 14:16:32 -04007412 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007413 if (context)
7414 {
7415 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007416 {
Geoff Langb1196682014-07-23 13:47:29 -04007417 context->recordError(gl::Error(GL_INVALID_OPERATION));
7418 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007419 }
Geoff Langbfdea662014-07-23 14:16:32 -04007420
7421 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7422 {
Geoff Langb1196682014-07-23 13:47:29 -04007423 context->recordError(gl::Error(GL_INVALID_ENUM));
7424 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007425 }
7426
7427 if (flags != 0)
7428 {
Geoff Langb1196682014-07-23 13:47:29 -04007429 context->recordError(gl::Error(GL_INVALID_VALUE));
7430 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007431 }
7432
Geoff Lang882033e2014-09-30 11:26:07 -04007433 GLsync fenceSync = context->createFenceSync();
7434
7435 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7436 gl::Error error = fenceSyncObject->set(condition);
7437 if (error.isError())
7438 {
7439 context->deleteFenceSync(fenceSync);
7440 context->recordError(error);
7441 return NULL;
7442 }
7443
7444 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007445 }
7446
7447 return NULL;
7448}
7449
Kenneth Russell67ea1902014-10-06 16:44:50 -07007450GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007451{
7452 EVENT("(GLsync sync = 0x%0.8p)", sync);
7453
Geoff Langbfdea662014-07-23 14:16:32 -04007454 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007455 if (context)
7456 {
7457 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007458 {
Geoff Langb1196682014-07-23 13:47:29 -04007459 context->recordError(gl::Error(GL_INVALID_OPERATION));
7460 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007461 }
Geoff Langbfdea662014-07-23 14:16:32 -04007462
7463 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007464 }
7465
7466 return GL_FALSE;
7467}
7468
Kenneth Russell67ea1902014-10-06 16:44:50 -07007469void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007470{
7471 EVENT("(GLsync sync = 0x%0.8p)", sync);
7472
Geoff Langbfdea662014-07-23 14:16:32 -04007473 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007474 if (context)
7475 {
7476 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007477 {
Geoff Langb1196682014-07-23 13:47:29 -04007478 context->recordError(gl::Error(GL_INVALID_OPERATION));
7479 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007480 }
Geoff Langbfdea662014-07-23 14:16:32 -04007481
7482 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7483 {
Geoff Langb1196682014-07-23 13:47:29 -04007484 context->recordError(gl::Error(GL_INVALID_VALUE));
7485 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007486 }
7487
7488 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007489 }
7490}
7491
Kenneth Russell67ea1902014-10-06 16:44:50 -07007492GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007493{
7494 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7495 sync, flags, timeout);
7496
Geoff Langbfdea662014-07-23 14:16:32 -04007497 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007498 if (context)
7499 {
7500 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007501 {
Geoff Langb1196682014-07-23 13:47:29 -04007502 context->recordError(gl::Error(GL_INVALID_OPERATION));
7503 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007504 }
Geoff Langbfdea662014-07-23 14:16:32 -04007505
7506 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7507 {
Geoff Langb1196682014-07-23 13:47:29 -04007508 context->recordError(gl::Error(GL_INVALID_VALUE));
7509 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007510 }
7511
7512 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7513
7514 if (!fenceSync)
7515 {
Geoff Langb1196682014-07-23 13:47:29 -04007516 context->recordError(gl::Error(GL_INVALID_VALUE));
7517 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007518 }
7519
Geoff Lang882033e2014-09-30 11:26:07 -04007520 GLenum result = GL_WAIT_FAILED;
7521 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7522 if (error.isError())
7523 {
7524 context->recordError(error);
7525 return GL_WAIT_FAILED;
7526 }
7527
7528 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007529 }
7530
7531 return GL_FALSE;
7532}
7533
Kenneth Russell67ea1902014-10-06 16:44:50 -07007534void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007535{
7536 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7537 sync, flags, timeout);
7538
Geoff Langbfdea662014-07-23 14:16:32 -04007539 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007540 if (context)
7541 {
7542 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007543 {
Geoff Langb1196682014-07-23 13:47:29 -04007544 context->recordError(gl::Error(GL_INVALID_OPERATION));
7545 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007546 }
Geoff Langbfdea662014-07-23 14:16:32 -04007547
7548 if (flags != 0)
7549 {
Geoff Langb1196682014-07-23 13:47:29 -04007550 context->recordError(gl::Error(GL_INVALID_VALUE));
7551 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007552 }
7553
7554 if (timeout != GL_TIMEOUT_IGNORED)
7555 {
Geoff Langb1196682014-07-23 13:47:29 -04007556 context->recordError(gl::Error(GL_INVALID_VALUE));
7557 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007558 }
7559
7560 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7561
7562 if (!fenceSync)
7563 {
Geoff Langb1196682014-07-23 13:47:29 -04007564 context->recordError(gl::Error(GL_INVALID_VALUE));
7565 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007566 }
7567
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007568 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007569 if (error.isError())
7570 {
7571 context->recordError(error);
7572 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007573 }
7574}
7575
Kenneth Russell67ea1902014-10-06 16:44:50 -07007576void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007577{
7578 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7579 pname, params);
7580
Geoff Langbfdea662014-07-23 14:16:32 -04007581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007582 if (context)
7583 {
7584 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007585 {
Geoff Langb1196682014-07-23 13:47:29 -04007586 context->recordError(gl::Error(GL_INVALID_OPERATION));
7587 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007588 }
Geoff Langbfdea662014-07-23 14:16:32 -04007589
7590 GLenum nativeType;
7591 unsigned int numParams = 0;
7592 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7593 {
7594 return;
7595 }
7596
7597 if (nativeType == GL_INT_64_ANGLEX)
7598 {
7599 context->getInteger64v(pname, params);
7600 }
7601 else
7602 {
7603 CastStateValues(context, nativeType, pname, numParams, params);
7604 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007605 }
7606}
7607
Kenneth Russell67ea1902014-10-06 16:44:50 -07007608void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007609{
7610 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7611 sync, pname, bufSize, length, values);
7612
Geoff Langbfdea662014-07-23 14:16:32 -04007613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007614 if (context)
7615 {
7616 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007617 {
Geoff Langb1196682014-07-23 13:47:29 -04007618 context->recordError(gl::Error(GL_INVALID_OPERATION));
7619 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007620 }
Geoff Langbfdea662014-07-23 14:16:32 -04007621
7622 if (bufSize < 0)
7623 {
Geoff Langb1196682014-07-23 13:47:29 -04007624 context->recordError(gl::Error(GL_INVALID_VALUE));
7625 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007626 }
7627
7628 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7629
7630 if (!fenceSync)
7631 {
Geoff Langb1196682014-07-23 13:47:29 -04007632 context->recordError(gl::Error(GL_INVALID_VALUE));
7633 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007634 }
7635
7636 switch (pname)
7637 {
7638 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007639 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7640 case GL_SYNC_FLAGS: values[0] = 0; break;
7641
Geoff Lang882033e2014-09-30 11:26:07 -04007642 case GL_SYNC_STATUS:
7643 {
7644 gl::Error error = fenceSync->getStatus(values);
7645 if (error.isError())
7646 {
7647 context->recordError(error);
7648 return;
7649 }
7650 break;
7651 }
7652
Geoff Langbfdea662014-07-23 14:16:32 -04007653 default:
Geoff Langb1196682014-07-23 13:47:29 -04007654 context->recordError(gl::Error(GL_INVALID_ENUM));
7655 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007656 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007657 }
7658}
7659
Kenneth Russell67ea1902014-10-06 16:44:50 -07007660void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007661{
7662 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7663 target, index, data);
7664
Geoff Langbfdea662014-07-23 14:16:32 -04007665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007666 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007667 {
Geoff Langbfdea662014-07-23 14:16:32 -04007668 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007669 {
Geoff Langb1196682014-07-23 13:47:29 -04007670 context->recordError(gl::Error(GL_INVALID_OPERATION));
7671 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007672 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007673
Geoff Lang3a61c322014-07-10 13:01:54 -04007674 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007675 switch (target)
7676 {
7677 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7678 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7679 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007680 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7681 {
Geoff Langb1196682014-07-23 13:47:29 -04007682 context->recordError(gl::Error(GL_INVALID_VALUE));
7683 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007684 }
Geoff Langbfdea662014-07-23 14:16:32 -04007685 break;
Geoff Langb1196682014-07-23 13:47:29 -04007686
Geoff Langbfdea662014-07-23 14:16:32 -04007687 case GL_UNIFORM_BUFFER_START:
7688 case GL_UNIFORM_BUFFER_SIZE:
7689 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007690 if (index >= caps.maxUniformBufferBindings)
7691 {
Geoff Langb1196682014-07-23 13:47:29 -04007692 context->recordError(gl::Error(GL_INVALID_VALUE));
7693 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007694 }
Geoff Langbfdea662014-07-23 14:16:32 -04007695 break;
Geoff Langb1196682014-07-23 13:47:29 -04007696
Geoff Langbfdea662014-07-23 14:16:32 -04007697 default:
Geoff Langb1196682014-07-23 13:47:29 -04007698 context->recordError(gl::Error(GL_INVALID_ENUM));
7699 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007700 }
7701
7702 if (!(context->getIndexedInteger64v(target, index, data)))
7703 {
7704 GLenum nativeType;
7705 unsigned int numParams = 0;
7706 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007707 {
7708 context->recordError(gl::Error(GL_INVALID_ENUM));
7709 return;
7710 }
Shannon Woods15934d52013-08-19 14:28:49 -04007711
Geoff Langbfdea662014-07-23 14:16:32 -04007712 if (numParams == 0)
7713 return; // it is known that pname is valid, but there are no parameters to return
7714
7715 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007716 {
Geoff Langbfdea662014-07-23 14:16:32 -04007717 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007718
Geoff Langbfdea662014-07-23 14:16:32 -04007719 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007720
Geoff Langbfdea662014-07-23 14:16:32 -04007721 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007722 {
Geoff Langbfdea662014-07-23 14:16:32 -04007723 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007724 }
Geoff Langbfdea662014-07-23 14:16:32 -04007725
7726 delete [] intParams;
7727 }
7728 else
7729 {
7730 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007731 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007732 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007733 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007734}
7735
Kenneth Russell67ea1902014-10-06 16:44:50 -07007736void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007737{
7738 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7739 target, pname, params);
7740
Geoff Langbfdea662014-07-23 14:16:32 -04007741 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007742 if (context)
7743 {
7744 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007745 {
Geoff Langb1196682014-07-23 13:47:29 -04007746 context->recordError(gl::Error(GL_INVALID_OPERATION));
7747 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007748 }
Geoff Langbfdea662014-07-23 14:16:32 -04007749
7750 if (!gl::ValidBufferTarget(context, target))
7751 {
Geoff Langb1196682014-07-23 13:47:29 -04007752 context->recordError(gl::Error(GL_INVALID_ENUM));
7753 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007754 }
7755
7756 if (!gl::ValidBufferParameter(context, pname))
7757 {
Geoff Langb1196682014-07-23 13:47:29 -04007758 context->recordError(gl::Error(GL_INVALID_ENUM));
7759 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007760 }
7761
7762 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7763
7764 if (!buffer)
7765 {
7766 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007767 context->recordError(gl::Error(GL_INVALID_OPERATION));
7768 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007769 }
7770
7771 switch (pname)
7772 {
7773 case GL_BUFFER_USAGE:
7774 *params = static_cast<GLint64>(buffer->getUsage());
7775 break;
7776 case GL_BUFFER_SIZE:
7777 *params = buffer->getSize();
7778 break;
7779 case GL_BUFFER_ACCESS_FLAGS:
7780 *params = static_cast<GLint64>(buffer->getAccessFlags());
7781 break;
7782 case GL_BUFFER_MAPPED:
7783 *params = static_cast<GLint64>(buffer->isMapped());
7784 break;
7785 case GL_BUFFER_MAP_OFFSET:
7786 *params = buffer->getMapOffset();
7787 break;
7788 case GL_BUFFER_MAP_LENGTH:
7789 *params = buffer->getMapLength();
7790 break;
7791 default: UNREACHABLE(); break;
7792 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007793 }
7794}
7795
Kenneth Russell67ea1902014-10-06 16:44:50 -07007796void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007797{
7798 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7799
Geoff Langbfdea662014-07-23 14:16:32 -04007800 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007801 if (context)
7802 {
7803 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804 {
Geoff Langb1196682014-07-23 13:47:29 -04007805 context->recordError(gl::Error(GL_INVALID_OPERATION));
7806 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007807 }
Geoff Langbfdea662014-07-23 14:16:32 -04007808
7809 if (count < 0)
7810 {
Geoff Langb1196682014-07-23 13:47:29 -04007811 context->recordError(gl::Error(GL_INVALID_VALUE));
7812 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007813 }
7814
7815 for (int i = 0; i < count; i++)
7816 {
7817 samplers[i] = context->createSampler();
7818 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007819 }
7820}
7821
Kenneth Russell67ea1902014-10-06 16:44:50 -07007822void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007823{
7824 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7825
Geoff Langbfdea662014-07-23 14:16:32 -04007826 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007827 if (context)
7828 {
7829 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830 {
Geoff Langb1196682014-07-23 13:47:29 -04007831 context->recordError(gl::Error(GL_INVALID_OPERATION));
7832 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007833 }
Geoff Langbfdea662014-07-23 14:16:32 -04007834
7835 if (count < 0)
7836 {
Geoff Langb1196682014-07-23 13:47:29 -04007837 context->recordError(gl::Error(GL_INVALID_VALUE));
7838 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007839 }
7840
7841 for (int i = 0; i < count; i++)
7842 {
7843 context->deleteSampler(samplers[i]);
7844 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007845 }
7846}
7847
Kenneth Russell67ea1902014-10-06 16:44:50 -07007848GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007849{
7850 EVENT("(GLuint sampler = %u)", sampler);
7851
Geoff Langbfdea662014-07-23 14:16:32 -04007852 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007853 if (context)
7854 {
7855 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007856 {
Geoff Langb1196682014-07-23 13:47:29 -04007857 context->recordError(gl::Error(GL_INVALID_OPERATION));
7858 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007859 }
Geoff Langbfdea662014-07-23 14:16:32 -04007860
7861 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007862 }
7863
7864 return GL_FALSE;
7865}
7866
Kenneth Russell67ea1902014-10-06 16:44:50 -07007867void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007868{
7869 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7870
Geoff Langbfdea662014-07-23 14:16:32 -04007871 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007872 if (context)
7873 {
7874 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007875 {
Geoff Langb1196682014-07-23 13:47:29 -04007876 context->recordError(gl::Error(GL_INVALID_OPERATION));
7877 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007878 }
Geoff Langbfdea662014-07-23 14:16:32 -04007879
7880 if (sampler != 0 && !context->isSampler(sampler))
7881 {
Geoff Langb1196682014-07-23 13:47:29 -04007882 context->recordError(gl::Error(GL_INVALID_OPERATION));
7883 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007884 }
7885
Geoff Lang3a61c322014-07-10 13:01:54 -04007886 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007887 {
Geoff Langb1196682014-07-23 13:47:29 -04007888 context->recordError(gl::Error(GL_INVALID_VALUE));
7889 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007890 }
7891
7892 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007893 }
7894}
7895
Kenneth Russell67ea1902014-10-06 16:44:50 -07007896void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007897{
7898 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7899
Geoff Langbfdea662014-07-23 14:16:32 -04007900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007901 if (context)
7902 {
7903 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007904 {
Geoff Langb1196682014-07-23 13:47:29 -04007905 context->recordError(gl::Error(GL_INVALID_OPERATION));
7906 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007907 }
Geoff Langbfdea662014-07-23 14:16:32 -04007908
Geoff Langb1196682014-07-23 13:47:29 -04007909 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007910 {
7911 return;
7912 }
7913
7914 if (!gl::ValidateTexParamParameters(context, pname, param))
7915 {
7916 return;
7917 }
7918
7919 if (!context->isSampler(sampler))
7920 {
Geoff Langb1196682014-07-23 13:47:29 -04007921 context->recordError(gl::Error(GL_INVALID_OPERATION));
7922 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007923 }
7924
7925 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007926 }
7927}
7928
Kenneth Russell67ea1902014-10-06 16:44:50 -07007929void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007930{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007931 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007932}
7933
Kenneth Russell67ea1902014-10-06 16:44:50 -07007934void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007935{
7936 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7937
Geoff Langbfdea662014-07-23 14:16:32 -04007938 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007939 if (context)
7940 {
7941 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007942 {
Geoff Langb1196682014-07-23 13:47:29 -04007943 context->recordError(gl::Error(GL_INVALID_OPERATION));
7944 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007945 }
Geoff Langbfdea662014-07-23 14:16:32 -04007946
Geoff Langb1196682014-07-23 13:47:29 -04007947 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007948 {
7949 return;
7950 }
7951
7952 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7953 {
7954 return;
7955 }
7956
7957 if (!context->isSampler(sampler))
7958 {
Geoff Langb1196682014-07-23 13:47:29 -04007959 context->recordError(gl::Error(GL_INVALID_OPERATION));
7960 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007961 }
7962
7963 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007964 }
7965}
7966
Kenneth Russell67ea1902014-10-06 16:44:50 -07007967void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007968{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007969 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007970}
7971
Kenneth Russell67ea1902014-10-06 16:44:50 -07007972void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007973{
7974 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7975
Geoff Langbfdea662014-07-23 14:16:32 -04007976 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007977 if (context)
7978 {
7979 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980 {
Geoff Langb1196682014-07-23 13:47:29 -04007981 context->recordError(gl::Error(GL_INVALID_OPERATION));
7982 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007983 }
Geoff Langbfdea662014-07-23 14:16:32 -04007984
Geoff Langb1196682014-07-23 13:47:29 -04007985 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007986 {
7987 return;
7988 }
7989
7990 if (!context->isSampler(sampler))
7991 {
Geoff Langb1196682014-07-23 13:47:29 -04007992 context->recordError(gl::Error(GL_INVALID_OPERATION));
7993 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007994 }
7995
7996 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007997 }
7998}
7999
Kenneth Russell67ea1902014-10-06 16:44:50 -07008000void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008001{
8002 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
8003
Geoff Langbfdea662014-07-23 14:16:32 -04008004 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008005 if (context)
8006 {
8007 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008008 {
Geoff Langb1196682014-07-23 13:47:29 -04008009 context->recordError(gl::Error(GL_INVALID_OPERATION));
8010 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008011 }
Geoff Langbfdea662014-07-23 14:16:32 -04008012
Geoff Langb1196682014-07-23 13:47:29 -04008013 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008014 {
8015 return;
8016 }
8017
8018 if (!context->isSampler(sampler))
8019 {
Geoff Langb1196682014-07-23 13:47:29 -04008020 context->recordError(gl::Error(GL_INVALID_OPERATION));
8021 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008022 }
8023
8024 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008025 }
8026}
8027
Kenneth Russell67ea1902014-10-06 16:44:50 -07008028void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008029{
8030 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8031
Geoff Langbfdea662014-07-23 14:16:32 -04008032 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008033 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008034 {
Geoff Langbfdea662014-07-23 14:16:32 -04008035 if (context->getClientVersion() < 3)
8036 {
Geoff Langb1196682014-07-23 13:47:29 -04008037 context->recordError(gl::Error(GL_INVALID_OPERATION));
8038 return;
8039 }
8040
8041 if (index >= gl::MAX_VERTEX_ATTRIBS)
8042 {
8043 context->recordError(gl::Error(GL_INVALID_VALUE));
8044 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008045 }
8046
8047 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008048 }
8049}
8050
Kenneth Russell67ea1902014-10-06 16:44:50 -07008051void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008052{
8053 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8054
Geoff Langbfdea662014-07-23 14:16:32 -04008055 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008056 if (context)
8057 {
8058 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008059 {
Geoff Langb1196682014-07-23 13:47:29 -04008060 context->recordError(gl::Error(GL_INVALID_OPERATION));
8061 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008062 }
Geoff Langbfdea662014-07-23 14:16:32 -04008063
8064 switch (target)
8065 {
8066 case GL_TRANSFORM_FEEDBACK:
8067 {
8068 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8069 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8070 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8071 {
Geoff Langb1196682014-07-23 13:47:29 -04008072 context->recordError(gl::Error(GL_INVALID_OPERATION));
8073 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008074 }
8075
8076 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8077 if (context->getTransformFeedback(id) == NULL)
8078 {
Geoff Langb1196682014-07-23 13:47:29 -04008079 context->recordError(gl::Error(GL_INVALID_OPERATION));
8080 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008081 }
8082
8083 context->bindTransformFeedback(id);
8084 }
8085 break;
8086
8087 default:
Geoff Langb1196682014-07-23 13:47:29 -04008088 context->recordError(gl::Error(GL_INVALID_ENUM));
8089 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008090 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008091 }
8092}
8093
Kenneth Russell67ea1902014-10-06 16:44:50 -07008094void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008095{
8096 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8097
Geoff Langbfdea662014-07-23 14:16:32 -04008098 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008099 if (context)
8100 {
8101 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008102 {
Geoff Langb1196682014-07-23 13:47:29 -04008103 context->recordError(gl::Error(GL_INVALID_OPERATION));
8104 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008105 }
Geoff Langbfdea662014-07-23 14:16:32 -04008106
8107 for (int i = 0; i < n; i++)
8108 {
8109 context->deleteTransformFeedback(ids[i]);
8110 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008111 }
8112}
8113
Kenneth Russell67ea1902014-10-06 16:44:50 -07008114void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008115{
8116 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8117
Geoff Langbfdea662014-07-23 14:16:32 -04008118 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008119 if (context)
8120 {
8121 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008122 {
Geoff Langb1196682014-07-23 13:47:29 -04008123 context->recordError(gl::Error(GL_INVALID_OPERATION));
8124 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008125 }
Geoff Langbfdea662014-07-23 14:16:32 -04008126
8127 for (int i = 0; i < n; i++)
8128 {
8129 ids[i] = context->createTransformFeedback();
8130 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008131 }
8132}
8133
Kenneth Russell67ea1902014-10-06 16:44:50 -07008134GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008135{
8136 EVENT("(GLuint id = %u)", id);
8137
Geoff Langbfdea662014-07-23 14:16:32 -04008138 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008139 if (context)
8140 {
8141 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008142 {
Geoff Langb1196682014-07-23 13:47:29 -04008143 context->recordError(gl::Error(GL_INVALID_OPERATION));
8144 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008145 }
Geoff Langbfdea662014-07-23 14:16:32 -04008146
8147 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008148 }
8149
8150 return GL_FALSE;
8151}
8152
Kenneth Russell67ea1902014-10-06 16:44:50 -07008153void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008154{
8155 EVENT("(void)");
8156
Geoff Langbfdea662014-07-23 14:16:32 -04008157 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008158 if (context)
8159 {
8160 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008161 {
Geoff Langb1196682014-07-23 13:47:29 -04008162 context->recordError(gl::Error(GL_INVALID_OPERATION));
8163 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008164 }
Geoff Langbfdea662014-07-23 14:16:32 -04008165
8166 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8167 ASSERT(transformFeedback != NULL);
8168
8169 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8170 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8171 {
Geoff Langb1196682014-07-23 13:47:29 -04008172 context->recordError(gl::Error(GL_INVALID_OPERATION));
8173 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008174 }
8175
8176 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008177 }
8178}
8179
Kenneth Russell67ea1902014-10-06 16:44:50 -07008180void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008181{
8182 EVENT("(void)");
8183
Geoff Langbfdea662014-07-23 14:16:32 -04008184 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008185 if (context)
8186 {
8187 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008188 {
Geoff Langb1196682014-07-23 13:47:29 -04008189 context->recordError(gl::Error(GL_INVALID_OPERATION));
8190 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008191 }
Geoff Langbfdea662014-07-23 14:16:32 -04008192
8193 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8194 ASSERT(transformFeedback != NULL);
8195
8196 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8197 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8198 {
Geoff Langb1196682014-07-23 13:47:29 -04008199 context->recordError(gl::Error(GL_INVALID_OPERATION));
8200 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008201 }
8202
8203 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008204 }
8205}
8206
Kenneth Russell67ea1902014-10-06 16:44:50 -07008207void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008208{
8209 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8210 program, bufSize, length, binaryFormat, binary);
8211
Geoff Langbfdea662014-07-23 14:16:32 -04008212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008213 if (context)
8214 {
8215 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008216 {
Geoff Langb1196682014-07-23 13:47:29 -04008217 context->recordError(gl::Error(GL_INVALID_OPERATION));
8218 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008219 }
Geoff Langbfdea662014-07-23 14:16:32 -04008220
8221 // glGetProgramBinary
8222 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008223 }
8224}
8225
Kenneth Russell67ea1902014-10-06 16:44:50 -07008226void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008227{
8228 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8229 program, binaryFormat, binary, length);
8230
Geoff Langbfdea662014-07-23 14:16:32 -04008231 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008232 if (context)
8233 {
8234 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008235 {
Geoff Langb1196682014-07-23 13:47:29 -04008236 context->recordError(gl::Error(GL_INVALID_OPERATION));
8237 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008238 }
Geoff Langbfdea662014-07-23 14:16:32 -04008239
8240 // glProgramBinary
8241 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008242 }
8243}
8244
Kenneth Russell67ea1902014-10-06 16:44:50 -07008245void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008246{
8247 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8248 program, pname, value);
8249
Geoff Langbfdea662014-07-23 14:16:32 -04008250 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008251 if (context)
8252 {
8253 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008254 {
Geoff Langb1196682014-07-23 13:47:29 -04008255 context->recordError(gl::Error(GL_INVALID_OPERATION));
8256 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008257 }
Geoff Langbfdea662014-07-23 14:16:32 -04008258
8259 // glProgramParameteri
8260 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008261 }
8262}
8263
Kenneth Russell67ea1902014-10-06 16:44:50 -07008264void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008265{
8266 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8267 target, numAttachments, attachments);
8268
Geoff Langbfdea662014-07-23 14:16:32 -04008269 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008270 if (context)
8271 {
8272 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008273 {
Geoff Langb1196682014-07-23 13:47:29 -04008274 context->recordError(gl::Error(GL_INVALID_OPERATION));
8275 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008276 }
Geoff Langbfdea662014-07-23 14:16:32 -04008277
8278 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8279 {
8280 return;
8281 }
8282
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008283 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8284 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8285 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008286 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8287 if (error.isError())
8288 {
8289 context->recordError(error);
8290 return;
8291 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008292 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008293 }
8294}
8295
Kenneth Russell67ea1902014-10-06 16:44:50 -07008296void 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 +00008297{
8298 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8299 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8300 target, numAttachments, attachments, x, y, width, height);
8301
Geoff Langbfdea662014-07-23 14:16:32 -04008302 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008303 if (context)
8304 {
8305 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008306 {
Geoff Langb1196682014-07-23 13:47:29 -04008307 context->recordError(gl::Error(GL_INVALID_OPERATION));
8308 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008309 }
Geoff Langbfdea662014-07-23 14:16:32 -04008310
8311 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8312 {
8313 return;
8314 }
8315
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008316 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8317 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8318 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008319 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8320 if (error.isError())
8321 {
8322 context->recordError(error);
8323 return;
8324 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008325 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008326 }
8327}
8328
Kenneth Russell67ea1902014-10-06 16:44:50 -07008329void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008330{
8331 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8332 target, levels, internalformat, width, height);
8333
Geoff Langbfdea662014-07-23 14:16:32 -04008334 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008335 if (context)
8336 {
8337 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008338 {
Geoff Langb1196682014-07-23 13:47:29 -04008339 context->recordError(gl::Error(GL_INVALID_OPERATION));
8340 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008341 }
Geoff Langbfdea662014-07-23 14:16:32 -04008342
8343 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8344 {
8345 return;
8346 }
8347
8348 switch (target)
8349 {
8350 case GL_TEXTURE_2D:
8351 {
8352 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008353 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8354 if (error.isError())
8355 {
8356 context->recordError(error);
8357 return;
8358 }
Geoff Langbfdea662014-07-23 14:16:32 -04008359 }
8360 break;
8361
8362 case GL_TEXTURE_CUBE_MAP:
8363 {
8364 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008365 gl::Error error = textureCube->storage(levels, internalformat, width);
8366 if (error.isError())
8367 {
8368 context->recordError(error);
8369 return;
8370 }
Geoff Langbfdea662014-07-23 14:16:32 -04008371 }
8372 break;
8373
8374 default:
Geoff Langb1196682014-07-23 13:47:29 -04008375 context->recordError(gl::Error(GL_INVALID_ENUM));
8376 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008377 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008378 }
8379}
8380
Kenneth Russell67ea1902014-10-06 16:44:50 -07008381void 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 +00008382{
8383 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8384 "GLsizei height = %d, GLsizei depth = %d)",
8385 target, levels, internalformat, width, height, depth);
8386
Geoff Langbfdea662014-07-23 14:16:32 -04008387 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008388 if (context)
8389 {
8390 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008391 {
Geoff Langb1196682014-07-23 13:47:29 -04008392 context->recordError(gl::Error(GL_INVALID_OPERATION));
8393 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008394 }
Geoff Langbfdea662014-07-23 14:16:32 -04008395
8396 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8397 {
8398 return;
8399 }
8400
8401 switch (target)
8402 {
8403 case GL_TEXTURE_3D:
8404 {
8405 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008406 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8407 if (error.isError())
8408 {
8409 context->recordError(error);
8410 return;
8411 }
Geoff Langbfdea662014-07-23 14:16:32 -04008412 }
8413 break;
8414
8415 case GL_TEXTURE_2D_ARRAY:
8416 {
8417 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008418 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8419 if (error.isError())
8420 {
8421 context->recordError(error);
8422 return;
8423 }
Geoff Langbfdea662014-07-23 14:16:32 -04008424 }
8425 break;
8426
8427 default:
8428 UNREACHABLE();
8429 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008430 }
8431}
8432
Kenneth Russell67ea1902014-10-06 16:44:50 -07008433void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008434{
8435 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8436 "GLint* params = 0x%0.8p)",
8437 target, internalformat, pname, bufSize, params);
8438
Geoff Langbfdea662014-07-23 14:16:32 -04008439 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008440 if (context)
8441 {
8442 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008443 {
Geoff Langb1196682014-07-23 13:47:29 -04008444 context->recordError(gl::Error(GL_INVALID_OPERATION));
8445 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008446 }
Geoff Langbfdea662014-07-23 14:16:32 -04008447
8448 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8449 if (!formatCaps.renderable)
8450 {
Geoff Langb1196682014-07-23 13:47:29 -04008451 context->recordError(gl::Error(GL_INVALID_ENUM));
8452 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008453 }
8454
8455 if (target != GL_RENDERBUFFER)
8456 {
Geoff Langb1196682014-07-23 13:47:29 -04008457 context->recordError(gl::Error(GL_INVALID_ENUM));
8458 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008459 }
8460
8461 if (bufSize < 0)
8462 {
Geoff Langb1196682014-07-23 13:47:29 -04008463 context->recordError(gl::Error(GL_INVALID_VALUE));
8464 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008465 }
8466
8467 switch (pname)
8468 {
8469 case GL_NUM_SAMPLE_COUNTS:
8470 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008471 {
8472 *params = formatCaps.sampleCounts.size();
8473 }
Geoff Langbfdea662014-07-23 14:16:32 -04008474 break;
Geoff Langb1196682014-07-23 13:47:29 -04008475
Geoff Langbfdea662014-07-23 14:16:32 -04008476 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008477 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008478 break;
Geoff Langb1196682014-07-23 13:47:29 -04008479
Geoff Langbfdea662014-07-23 14:16:32 -04008480 default:
Geoff Langb1196682014-07-23 13:47:29 -04008481 context->recordError(gl::Error(GL_INVALID_ENUM));
8482 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008483 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008484 }
8485}
8486
8487// Extension functions
8488
Kenneth Russell67ea1902014-10-06 16:44:50 -07008489void 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 +00008490 GLbitfield mask, GLenum filter)
8491{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008492 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008493 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8494 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8495 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8496
Geoff Langbfdea662014-07-23 14:16:32 -04008497 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008498 if (context)
8499 {
8500 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8501 dstX0, dstY0, dstX1, dstY1, mask, filter,
8502 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008503 {
Geoff Langbfdea662014-07-23 14:16:32 -04008504 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008505 }
Geoff Langbfdea662014-07-23 14:16:32 -04008506
Geoff Lang64839152014-08-26 16:23:25 -04008507 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8508 mask, filter);
8509 if (error.isError())
8510 {
8511 context->recordError(error);
8512 return;
8513 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008514 }
8515}
8516
Kenneth Russell67ea1902014-10-06 16:44:50 -07008517void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008518 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008519{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008520 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008521 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008522 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008523 target, level, internalformat, width, height, depth, border, format, type, pixels);
8524
Geoff Langbfdea662014-07-23 14:16:32 -04008525 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008526}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008527
Kenneth Russell67ea1902014-10-06 16:44:50 -07008528void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008529 GLenum *binaryFormat, void *binary)
8530{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008531 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 +00008532 program, bufSize, length, binaryFormat, binary);
8533
Geoff Langbfdea662014-07-23 14:16:32 -04008534 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008535 if (context)
8536 {
8537 gl::Program *programObject = context->getProgram(program);
8538
8539 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008540 {
Geoff Langb1196682014-07-23 13:47:29 -04008541 context->recordError(gl::Error(GL_INVALID_OPERATION));
8542 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008543 }
Geoff Langbfdea662014-07-23 14:16:32 -04008544
8545 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8546
8547 if (!programBinary)
8548 {
Geoff Langb1196682014-07-23 13:47:29 -04008549 context->recordError(gl::Error(GL_INVALID_OPERATION));
8550 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008551 }
8552
Geoff Langb543aff2014-09-30 14:52:54 -04008553 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8554 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008555 {
Geoff Langb543aff2014-09-30 14:52:54 -04008556 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008557 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008558 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008559 }
8560}
8561
Kenneth Russell67ea1902014-10-06 16:44:50 -07008562void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008563 const void *binary, GLint length)
8564{
8565 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8566 program, binaryFormat, binary, length);
8567
Geoff Langbfdea662014-07-23 14:16:32 -04008568 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008569 if (context)
8570 {
Geoff Lang900013c2014-07-07 11:32:19 -04008571 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8572 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008573 {
Geoff Langb1196682014-07-23 13:47:29 -04008574 context->recordError(gl::Error(GL_INVALID_ENUM));
8575 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008576 }
Geoff Langbfdea662014-07-23 14:16:32 -04008577
8578 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008579 if (!programObject)
8580 {
Geoff Langb1196682014-07-23 13:47:29 -04008581 context->recordError(gl::Error(GL_INVALID_OPERATION));
8582 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008583 }
8584
Geoff Langb543aff2014-09-30 14:52:54 -04008585 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8586 if (error.isError())
8587 {
8588 context->recordError(error);
8589 return;
8590 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008591 }
8592}
8593
Kenneth Russell67ea1902014-10-06 16:44:50 -07008594void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008595{
8596 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8597
Geoff Langbfdea662014-07-23 14:16:32 -04008598 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008599 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008600 {
Geoff Langbfdea662014-07-23 14:16:32 -04008601 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008602 {
Geoff Langb1196682014-07-23 13:47:29 -04008603 context->recordError(gl::Error(GL_INVALID_VALUE));
8604 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008605 }
8606
8607 if (context->getState().getDrawFramebuffer()->id() == 0)
8608 {
8609 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008610 {
Geoff Langb1196682014-07-23 13:47:29 -04008611 context->recordError(gl::Error(GL_INVALID_OPERATION));
8612 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008613 }
8614
Geoff Langbfdea662014-07-23 14:16:32 -04008615 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008616 {
Geoff Langb1196682014-07-23 13:47:29 -04008617 context->recordError(gl::Error(GL_INVALID_OPERATION));
8618 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008619 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008620 }
Geoff Langbfdea662014-07-23 14:16:32 -04008621 else
8622 {
8623 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8624 {
8625 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8626 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8627 {
Geoff Langb1196682014-07-23 13:47:29 -04008628 context->recordError(gl::Error(GL_INVALID_OPERATION));
8629 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008630 }
8631 }
8632 }
8633
8634 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
8635
8636 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8637 {
8638 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8639 }
8640
8641 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8642 {
8643 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8644 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008645 }
8646}
8647
Kenneth Russell67ea1902014-10-06 16:44:50 -07008648void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008649{
8650 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8651
Geoff Langbfdea662014-07-23 14:16:32 -04008652 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008653 if (context)
8654 {
8655 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008656 {
Geoff Langb1196682014-07-23 13:47:29 -04008657 context->recordError(gl::Error(GL_INVALID_ENUM));
8658 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008659 }
Geoff Langbfdea662014-07-23 14:16:32 -04008660
8661 if (pname != GL_BUFFER_MAP_POINTER)
8662 {
Geoff Langb1196682014-07-23 13:47:29 -04008663 context->recordError(gl::Error(GL_INVALID_ENUM));
8664 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008665 }
8666
8667 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8668
8669 if (!buffer || !buffer->isMapped())
8670 {
8671 *params = NULL;
8672 }
8673 else
8674 {
8675 *params = buffer->getMapPointer();
8676 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008677 }
8678}
8679
Kenneth Russell67ea1902014-10-06 16:44:50 -07008680void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008681{
8682 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8683
Geoff Langbfdea662014-07-23 14:16:32 -04008684 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008685 if (context)
8686 {
8687 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008688 {
Geoff Langb1196682014-07-23 13:47:29 -04008689 context->recordError(gl::Error(GL_INVALID_ENUM));
8690 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008691 }
Geoff Langbfdea662014-07-23 14:16:32 -04008692
8693 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8694
8695 if (buffer == NULL)
8696 {
Geoff Langb1196682014-07-23 13:47:29 -04008697 context->recordError(gl::Error(GL_INVALID_OPERATION));
8698 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008699 }
8700
8701 if (access != GL_WRITE_ONLY_OES)
8702 {
Geoff Langb1196682014-07-23 13:47:29 -04008703 context->recordError(gl::Error(GL_INVALID_ENUM));
8704 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008705 }
8706
8707 if (buffer->isMapped())
8708 {
Geoff Langb1196682014-07-23 13:47:29 -04008709 context->recordError(gl::Error(GL_INVALID_OPERATION));
8710 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008711 }
8712
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008713 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8714 if (error.isError())
8715 {
8716 context->recordError(error);
8717 return NULL;
8718 }
8719
8720 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008721 }
8722
8723 return NULL;
8724}
8725
Kenneth Russell67ea1902014-10-06 16:44:50 -07008726GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008727{
8728 EVENT("(GLenum target = 0x%X)", target);
8729
Geoff Langbfdea662014-07-23 14:16:32 -04008730 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008731 if (context)
8732 {
8733 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008734 {
Geoff Langb1196682014-07-23 13:47:29 -04008735 context->recordError(gl::Error(GL_INVALID_ENUM));
8736 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008737 }
Geoff Langbfdea662014-07-23 14:16:32 -04008738
8739 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8740
8741 if (buffer == NULL || !buffer->isMapped())
8742 {
Geoff Langb1196682014-07-23 13:47:29 -04008743 context->recordError(gl::Error(GL_INVALID_OPERATION));
8744 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008745 }
8746
8747 // TODO: detect if we had corruption. if so, throw an error and return false.
8748
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008749 gl::Error error = buffer->unmap();
8750 if (error.isError())
8751 {
8752 context->recordError(error);
8753 return GL_FALSE;
8754 }
Geoff Langbfdea662014-07-23 14:16:32 -04008755
8756 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008757 }
8758
8759 return GL_FALSE;
8760}
8761
Kenneth Russell67ea1902014-10-06 16:44:50 -07008762void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008763{
8764 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8765 target, offset, length, access);
8766
Geoff Langbfdea662014-07-23 14:16:32 -04008767 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008768 if (context)
8769 {
8770 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008771 {
Geoff Langb1196682014-07-23 13:47:29 -04008772 context->recordError(gl::Error(GL_INVALID_ENUM));
8773 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008774 }
Geoff Langbfdea662014-07-23 14:16:32 -04008775
8776 if (offset < 0 || length < 0)
8777 {
Geoff Langb1196682014-07-23 13:47:29 -04008778 context->recordError(gl::Error(GL_INVALID_VALUE));
8779 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008780 }
8781
8782 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8783
8784 if (buffer == NULL)
8785 {
Geoff Langb1196682014-07-23 13:47:29 -04008786 context->recordError(gl::Error(GL_INVALID_OPERATION));
8787 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008788 }
8789
8790 // Check for buffer overflow
8791 size_t offsetSize = static_cast<size_t>(offset);
8792 size_t lengthSize = static_cast<size_t>(length);
8793
8794 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8795 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8796 {
Geoff Langb1196682014-07-23 13:47:29 -04008797 context->recordError(gl::Error(GL_INVALID_VALUE));
8798 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008799 }
8800
8801 // Check for invalid bits in the mask
8802 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8803 GL_MAP_WRITE_BIT |
8804 GL_MAP_INVALIDATE_RANGE_BIT |
8805 GL_MAP_INVALIDATE_BUFFER_BIT |
8806 GL_MAP_FLUSH_EXPLICIT_BIT |
8807 GL_MAP_UNSYNCHRONIZED_BIT;
8808
8809 if (access & ~(allAccessBits))
8810 {
Geoff Langb1196682014-07-23 13:47:29 -04008811 context->recordError(gl::Error(GL_INVALID_VALUE));
8812 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008813 }
8814
8815 if (length == 0 || buffer->isMapped())
8816 {
Geoff Langb1196682014-07-23 13:47:29 -04008817 context->recordError(gl::Error(GL_INVALID_OPERATION));
8818 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008819 }
8820
8821 // Check for invalid bit combinations
8822 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8823 {
Geoff Langb1196682014-07-23 13:47:29 -04008824 context->recordError(gl::Error(GL_INVALID_OPERATION));
8825 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008826 }
8827
8828 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8829 GL_MAP_INVALIDATE_BUFFER_BIT |
8830 GL_MAP_UNSYNCHRONIZED_BIT;
8831
8832 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8833 {
Geoff Langb1196682014-07-23 13:47:29 -04008834 context->recordError(gl::Error(GL_INVALID_OPERATION));
8835 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008836 }
8837
8838 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8839 {
Geoff Langb1196682014-07-23 13:47:29 -04008840 context->recordError(gl::Error(GL_INVALID_OPERATION));
8841 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008842 }
8843
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008844 gl::Error error = buffer->mapRange(offset, length, access);
8845 if (error.isError())
8846 {
8847 context->recordError(error);
8848 return NULL;
8849 }
8850
8851 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008852 }
8853
8854 return NULL;
8855}
8856
Kenneth Russell67ea1902014-10-06 16:44:50 -07008857void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008858{
8859 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8860
Geoff Langbfdea662014-07-23 14:16:32 -04008861 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008862 if (context)
8863 {
8864 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008865 {
Geoff Langb1196682014-07-23 13:47:29 -04008866 context->recordError(gl::Error(GL_INVALID_VALUE));
8867 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008868 }
Geoff Langbfdea662014-07-23 14:16:32 -04008869
8870 if (!gl::ValidBufferTarget(context, target))
8871 {
Geoff Langb1196682014-07-23 13:47:29 -04008872 context->recordError(gl::Error(GL_INVALID_ENUM));
8873 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008874 }
8875
8876 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8877
8878 if (buffer == NULL)
8879 {
Geoff Langb1196682014-07-23 13:47:29 -04008880 context->recordError(gl::Error(GL_INVALID_OPERATION));
8881 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008882 }
8883
8884 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8885 {
Geoff Langb1196682014-07-23 13:47:29 -04008886 context->recordError(gl::Error(GL_INVALID_OPERATION));
8887 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008888 }
8889
8890 // Check for buffer overflow
8891 size_t offsetSize = static_cast<size_t>(offset);
8892 size_t lengthSize = static_cast<size_t>(length);
8893
8894 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8895 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8896 {
Geoff Langb1196682014-07-23 13:47:29 -04008897 context->recordError(gl::Error(GL_INVALID_VALUE));
8898 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008899 }
8900
8901 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008902 }
8903}
8904
Kenneth Russell67ea1902014-10-06 16:44:50 -07008905__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008906{
8907 struct Extension
8908 {
8909 const char *name;
8910 __eglMustCastToProperFunctionPointerType address;
8911 };
8912
8913 static const Extension glExtensions[] =
8914 {
8915 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008916 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008917 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008918 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8919 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8920 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8921 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8922 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8923 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8924 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008925 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008926 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008927 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8928 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8929 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8930 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008931 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8932 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8933 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8934 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8935 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8936 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8937 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008938 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008939 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8940 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8941 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008942 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008943 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8944 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8945 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008946 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8947 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8948 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008949
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008950 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008951 {
8952 if (strcmp(procname, glExtensions[ext].name) == 0)
8953 {
8954 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8955 }
8956 }
8957
8958 return NULL;
8959}
8960
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008961// Non-public functions used by EGL
8962
Kenneth Russell67ea1902014-10-06 16:44:50 -07008963bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008964{
8965 EVENT("(egl::Surface* surface = 0x%0.8p)",
8966 surface);
8967
Geoff Langbfdea662014-07-23 14:16:32 -04008968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008969 if (context)
8970 {
8971 gl::Texture2D *textureObject = context->getTexture2D();
8972 ASSERT(textureObject != NULL);
8973
8974 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008975 {
Geoff Langbfdea662014-07-23 14:16:32 -04008976 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008977 }
Geoff Langbfdea662014-07-23 14:16:32 -04008978
8979 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008980 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008981
8982 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008983}
8984
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008985}