blob: c0592686edc803d4970cff5de25cc72b0ea0ea57 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
Jamie Madill48faf802014-11-06 15:27:22 -0500624
625 return framebuffer->completeness(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000626 }
627
628 return 0;
629}
630
Kenneth Russell67ea1902014-10-06 16:44:50 -0700631void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000632{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000633 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000634
Geoff Langbfdea662014-07-23 14:16:32 -0400635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400636 if (context)
637 {
638 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -0500639 ASSERT(framebufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -0400640
Jamie Madill48faf802014-11-06 15:27:22 -0500641 if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000642 {
Geoff Langb1196682014-07-23 13:47:29 -0400643 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
644 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000645 }
Geoff Langbfdea662014-07-23 14:16:32 -0400646
647 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
648 {
Geoff Langb1196682014-07-23 13:47:29 -0400649 context->recordError(gl::Error(GL_INVALID_VALUE));
650 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400651 }
652
Geoff Langcc79b8c2014-07-25 13:48:02 -0400653 gl::Error error = context->clear(mask);
654 if (error.isError())
655 {
656 context->recordError(error);
657 return;
658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000659 }
660}
661
Kenneth Russell67ea1902014-10-06 16:44:50 -0700662void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000664 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000665 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000666
Geoff Langbfdea662014-07-23 14:16:32 -0400667 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400668 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 {
Geoff Langbfdea662014-07-23 14:16:32 -0400670 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 }
672}
673
Kenneth Russell67ea1902014-10-06 16:44:50 -0700674void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000676 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000677
Geoff Langbfdea662014-07-23 14:16:32 -0400678 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400679 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 {
Geoff Langbfdea662014-07-23 14:16:32 -0400681 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000682 }
683}
684
Kenneth Russell67ea1902014-10-06 16:44:50 -0700685void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000687 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000688
Geoff Langbfdea662014-07-23 14:16:32 -0400689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400690 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 {
Geoff Langbfdea662014-07-23 14:16:32 -0400692 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000693 }
694}
695
Kenneth Russell67ea1902014-10-06 16:44:50 -0700696void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000697{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000698 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000699 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000700
Geoff Langbfdea662014-07-23 14:16:32 -0400701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400702 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 {
Geoff Langbfdea662014-07-23 14:16:32 -0400704 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000705 }
706}
707
Kenneth Russell67ea1902014-10-06 16:44:50 -0700708void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000710 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000711
Geoff Langbfdea662014-07-23 14:16:32 -0400712 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400713 if (context)
714 {
715 gl::Shader *shaderObject = context->getShader(shader);
716
717 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langbfdea662014-07-23 14:16:32 -0400719 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000720 {
Geoff Langb1196682014-07-23 13:47:29 -0400721 context->recordError(gl::Error(GL_INVALID_OPERATION));
722 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000723 }
Geoff Langbfdea662014-07-23 14:16:32 -0400724 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000725 {
Geoff Langb1196682014-07-23 13:47:29 -0400726 context->recordError(gl::Error(GL_INVALID_VALUE));
727 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000728 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000729 }
Geoff Langbfdea662014-07-23 14:16:32 -0400730
Jamie Madill245d3602014-11-13 10:03:30 -0500731 shaderObject->compile(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000732 }
Geoff Langbfdea662014-07-23 14:16:32 -0400733}
734
Kenneth Russell67ea1902014-10-06 16:44:50 -0700735void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400736 GLint border, GLsizei imageSize, const GLvoid* data)
737{
738 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
739 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
740 target, level, internalformat, width, height, border, imageSize, data);
741
742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000744 {
Geoff Langbfdea662014-07-23 14:16:32 -0400745 if (context->getClientVersion() < 3 &&
746 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
747 0, 0, width, height, border, GL_NONE, GL_NONE, data))
748 {
749 return;
750 }
751
752 if (context->getClientVersion() >= 3 &&
753 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
754 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
755 {
756 return;
757 }
758
Geoff Lang5d601382014-07-22 15:14:06 -0400759 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
760 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400761 {
Geoff Langb1196682014-07-23 13:47:29 -0400762 context->recordError(gl::Error(GL_INVALID_VALUE));
763 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400764 }
765
766 switch (target)
767 {
768 case GL_TEXTURE_2D:
769 {
770 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400771 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400772 if (error.isError())
773 {
774 context->recordError(error);
775 return;
776 }
Geoff Langbfdea662014-07-23 14:16:32 -0400777 }
778 break;
779
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
784 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
785 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
786 {
787 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400788 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400789 if (error.isError())
790 {
791 context->recordError(error);
792 return;
793 }
Geoff Langbfdea662014-07-23 14:16:32 -0400794 }
795 break;
796
797 default:
Geoff Langb1196682014-07-23 13:47:29 -0400798 context->recordError(gl::Error(GL_INVALID_ENUM));
799 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400800 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000801 }
802}
803
Kenneth Russell67ea1902014-10-06 16:44:50 -0700804void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000805 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000806{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000807 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000808 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000809 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000810 target, level, xoffset, yoffset, width, height, format, imageSize, data);
811
Geoff Langbfdea662014-07-23 14:16:32 -0400812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400813 if (context)
814 {
815 if (context->getClientVersion() < 3 &&
816 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
817 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 {
Geoff Langbfdea662014-07-23 14:16:32 -0400819 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000820 }
Geoff Langbfdea662014-07-23 14:16:32 -0400821
822 if (context->getClientVersion() >= 3 &&
823 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
824 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
825 {
826 return;
827 }
828
Geoff Lang5d601382014-07-22 15:14:06 -0400829 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
830 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400831 {
Geoff Langb1196682014-07-23 13:47:29 -0400832 context->recordError(gl::Error(GL_INVALID_VALUE));
833 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400834 }
835
836 switch (target)
837 {
838 case GL_TEXTURE_2D:
839 {
840 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400841 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400842 if (error.isError())
843 {
844 context->recordError(error);
845 return;
846 }
Geoff Langbfdea662014-07-23 14:16:32 -0400847 }
848 break;
849
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
854 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
855 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
856 {
857 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400858 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400859 if (error.isError())
860 {
861 context->recordError(error);
862 return;
863 }
Geoff Langbfdea662014-07-23 14:16:32 -0400864 }
865 break;
866
867 default:
Geoff Langb1196682014-07-23 13:47:29 -0400868 context->recordError(gl::Error(GL_INVALID_ENUM));
869 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400870 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000871 }
872}
873
Kenneth Russell67ea1902014-10-06 16:44:50 -0700874void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000876 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000877 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000878 target, level, internalformat, x, y, width, height, border);
879
Geoff Langbfdea662014-07-23 14:16:32 -0400880 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400881 if (context)
882 {
883 if (context->getClientVersion() < 3 &&
884 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
885 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 {
Geoff Langbfdea662014-07-23 14:16:32 -0400887 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000888 }
Geoff Langbfdea662014-07-23 14:16:32 -0400889
890 if (context->getClientVersion() >= 3 &&
891 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
892 0, 0, 0, x, y, width, height, border))
893 {
894 return;
895 }
896
897 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
898
899 switch (target)
900 {
901 case GL_TEXTURE_2D:
902 {
903 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400904 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
905 if (error.isError())
906 {
907 context->recordError(error);
908 return;
909 }
Geoff Langbfdea662014-07-23 14:16:32 -0400910 }
911 break;
912
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
917 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
918 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
919 {
920 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400921 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
922 if (error.isError())
923 {
924 context->recordError(error);
925 return;
926 }
Geoff Langbfdea662014-07-23 14:16:32 -0400927 }
928 break;
929
Geoff Langb1196682014-07-23 13:47:29 -0400930 default:
931 context->recordError(gl::Error(GL_INVALID_ENUM));
932 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400933 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000934 }
935}
936
Kenneth Russell67ea1902014-10-06 16:44:50 -0700937void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000938{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000939 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000940 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000941 target, level, xoffset, yoffset, x, y, width, height);
942
Geoff Langbfdea662014-07-23 14:16:32 -0400943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400944 if (context)
945 {
946 if (context->getClientVersion() < 3 &&
947 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
948 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 {
Geoff Langbfdea662014-07-23 14:16:32 -0400950 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000951 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000952
Geoff Langbfdea662014-07-23 14:16:32 -0400953 if (context->getClientVersion() >= 3 &&
954 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
955 xoffset, yoffset, 0, x, y, width, height, 0))
956 {
957 return;
958 }
959
960 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
961
962 switch (target)
963 {
964 case GL_TEXTURE_2D:
965 {
966 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400967 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
968 if (error.isError())
969 {
970 context->recordError(error);
971 return;
972 }
Geoff Langbfdea662014-07-23 14:16:32 -0400973 }
974 break;
975
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
980 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
981 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
982 {
983 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400984 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
985 if (error.isError())
986 {
987 context->recordError(error);
988 return;
989 }
Geoff Langbfdea662014-07-23 14:16:32 -0400990 }
991 break;
992
993 default:
Geoff Langb1196682014-07-23 13:47:29 -0400994 context->recordError(gl::Error(GL_INVALID_ENUM));
995 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400996 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000997 }
998}
999
Kenneth Russell67ea1902014-10-06 16:44:50 -07001000GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001002 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001003
Geoff Langbfdea662014-07-23 14:16:32 -04001004 gl::Context *context = gl::getNonLostContext();
1005 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 {
Geoff Langbfdea662014-07-23 14:16:32 -04001007 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001008 }
1009
1010 return 0;
1011}
1012
Kenneth Russell67ea1902014-10-06 16:44:50 -07001013GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001015 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001016
Geoff Langbfdea662014-07-23 14:16:32 -04001017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001018 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001019 {
Geoff Langbfdea662014-07-23 14:16:32 -04001020 switch (type)
1021 {
1022 case GL_FRAGMENT_SHADER:
1023 case GL_VERTEX_SHADER:
1024 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001025
Geoff Langbfdea662014-07-23 14:16:32 -04001026 default:
Geoff Langb1196682014-07-23 13:47:29 -04001027 context->recordError(gl::Error(GL_INVALID_ENUM));
1028 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001029 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001030 }
1031
1032 return 0;
1033}
1034
Kenneth Russell67ea1902014-10-06 16:44:50 -07001035void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001037 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001038
Geoff Langb1196682014-07-23 13:47:29 -04001039 gl::Context *context = gl::getNonLostContext();
1040 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001043 {
Geoff Langb1196682014-07-23 13:47:29 -04001044 case GL_FRONT:
1045 case GL_BACK:
1046 case GL_FRONT_AND_BACK:
1047 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001048
Geoff Langb1196682014-07-23 13:47:29 -04001049 default:
1050 context->recordError(gl::Error(GL_INVALID_ENUM));
1051 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001052 }
Geoff Langb1196682014-07-23 13:47:29 -04001053
1054 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001055 }
1056}
1057
Kenneth Russell67ea1902014-10-06 16:44:50 -07001058void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001060 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001061
Geoff Langbfdea662014-07-23 14:16:32 -04001062 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001063 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001064 {
Geoff Langb1196682014-07-23 13:47:29 -04001065 if (n < 0)
1066 {
1067 context->recordError(gl::Error(GL_INVALID_VALUE));
1068 return;
1069 }
1070
Geoff Langbfdea662014-07-23 14:16:32 -04001071 for (int i = 0; i < n; i++)
1072 {
1073 context->deleteBuffer(buffers[i]);
1074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001075 }
1076}
1077
Kenneth Russell67ea1902014-10-06 16:44:50 -07001078void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001080 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001081
Geoff Langbfdea662014-07-23 14:16:32 -04001082 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001083 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001084 {
Geoff Langb1196682014-07-23 13:47:29 -04001085 if (n < 0)
1086 {
1087 context->recordError(gl::Error(GL_INVALID_VALUE));
1088 return;
1089 }
1090
Geoff Langbfdea662014-07-23 14:16:32 -04001091 for (int i = 0; i < n; i++)
1092 {
1093 context->deleteFenceNV(fences[i]);
1094 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001095 }
1096}
1097
Kenneth Russell67ea1902014-10-06 16:44:50 -07001098void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001100 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001101
Geoff Langbfdea662014-07-23 14:16:32 -04001102 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001103 if (context)
1104 {
Geoff Langb1196682014-07-23 13:47:29 -04001105 if (n < 0)
1106 {
1107 context->recordError(gl::Error(GL_INVALID_VALUE));
1108 return;
1109 }
1110
Geoff Langbfdea662014-07-23 14:16:32 -04001111 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 {
Geoff Langbfdea662014-07-23 14:16:32 -04001115 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001116 }
1117 }
1118 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001119}
1120
Kenneth Russell67ea1902014-10-06 16:44:50 -07001121void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001123 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001124
Geoff Langbfdea662014-07-23 14:16:32 -04001125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001126 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001127 {
Geoff Langb1196682014-07-23 13:47:29 -04001128 if (program == 0)
1129 {
1130 return;
1131 }
1132
Geoff Langbfdea662014-07-23 14:16:32 -04001133 if (!context->getProgram(program))
1134 {
1135 if(context->getShader(program))
1136 {
Geoff Langb1196682014-07-23 13:47:29 -04001137 context->recordError(gl::Error(GL_INVALID_OPERATION));
1138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001139 }
1140 else
1141 {
Geoff Langb1196682014-07-23 13:47:29 -04001142 context->recordError(gl::Error(GL_INVALID_VALUE));
1143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001144 }
1145 }
1146
1147 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001148 }
1149}
1150
Kenneth Russell67ea1902014-10-06 16:44:50 -07001151void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001152{
1153 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1154
Geoff Langbfdea662014-07-23 14:16:32 -04001155 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001156 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001157 {
Geoff Langb1196682014-07-23 13:47:29 -04001158 if (n < 0)
1159 {
1160 context->recordError(gl::Error(GL_INVALID_VALUE));
1161 return;
1162 }
1163
Geoff Langbfdea662014-07-23 14:16:32 -04001164 for (int i = 0; i < n; i++)
1165 {
1166 context->deleteQuery(ids[i]);
1167 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001168 }
1169}
1170
Kenneth Russell67ea1902014-10-06 16:44:50 -07001171void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001173 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001174
Geoff Langbfdea662014-07-23 14:16:32 -04001175 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001176 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001177 {
Geoff Langb1196682014-07-23 13:47:29 -04001178 if (n < 0)
1179 {
1180 context->recordError(gl::Error(GL_INVALID_VALUE));
1181 return;
1182 }
1183
Geoff Langbfdea662014-07-23 14:16:32 -04001184 for (int i = 0; i < n; i++)
1185 {
1186 context->deleteRenderbuffer(renderbuffers[i]);
1187 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001188 }
1189}
1190
Kenneth Russell67ea1902014-10-06 16:44:50 -07001191void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001193 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001194
Geoff Langbfdea662014-07-23 14:16:32 -04001195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001196 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001197 {
Geoff Langb1196682014-07-23 13:47:29 -04001198 if (shader == 0)
1199 {
1200 return;
1201 }
1202
Geoff Langbfdea662014-07-23 14:16:32 -04001203 if (!context->getShader(shader))
1204 {
1205 if(context->getProgram(shader))
1206 {
Geoff Langb1196682014-07-23 13:47:29 -04001207 context->recordError(gl::Error(GL_INVALID_OPERATION));
1208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001209 }
1210 else
1211 {
Geoff Langb1196682014-07-23 13:47:29 -04001212 context->recordError(gl::Error(GL_INVALID_VALUE));
1213 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001214 }
1215 }
1216
1217 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001218 }
1219}
1220
Kenneth Russell67ea1902014-10-06 16:44:50 -07001221void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001223 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001224
Geoff Langbfdea662014-07-23 14:16:32 -04001225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001226 if (context)
1227 {
Geoff Langb1196682014-07-23 13:47:29 -04001228 if (n < 0)
1229 {
1230 context->recordError(gl::Error(GL_INVALID_VALUE));
1231 return;
1232 }
1233
Geoff Langbfdea662014-07-23 14:16:32 -04001234 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 {
Geoff Langbfdea662014-07-23 14:16:32 -04001238 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001239 }
1240 }
1241 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001242}
1243
Kenneth Russell67ea1902014-10-06 16:44:50 -07001244void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001246 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001247
Geoff Langbfdea662014-07-23 14:16:32 -04001248 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001249 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001250 {
Geoff Langb1196682014-07-23 13:47:29 -04001251 switch (func)
1252 {
1253 case GL_NEVER:
1254 case GL_ALWAYS:
1255 case GL_LESS:
1256 case GL_LEQUAL:
1257 case GL_EQUAL:
1258 case GL_GREATER:
1259 case GL_GEQUAL:
1260 case GL_NOTEQUAL:
1261 context->getState().setDepthFunc(func);
1262 break;
1263
1264 default:
1265 context->recordError(gl::Error(GL_INVALID_ENUM));
1266 return;
1267 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001268 }
1269}
1270
Kenneth Russell67ea1902014-10-06 16:44:50 -07001271void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001273 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001274
Geoff Langbfdea662014-07-23 14:16:32 -04001275 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001276 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 {
Geoff Langbfdea662014-07-23 14:16:32 -04001278 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001279 }
1280}
1281
Kenneth Russell67ea1902014-10-06 16:44:50 -07001282void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001284 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001285
Geoff Langbfdea662014-07-23 14:16:32 -04001286 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001287 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 {
Geoff Langbfdea662014-07-23 14:16:32 -04001289 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001290 }
1291}
1292
Kenneth Russell67ea1902014-10-06 16:44:50 -07001293void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001295 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001296
Geoff Langbfdea662014-07-23 14:16:32 -04001297 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001298 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001299 {
Geoff Langbfdea662014-07-23 14:16:32 -04001300 gl::Program *programObject = context->getProgram(program);
1301 gl::Shader *shaderObject = context->getShader(shader);
1302
1303 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001304 {
Geoff Langbfdea662014-07-23 14:16:32 -04001305 gl::Shader *shaderByProgramHandle;
1306 shaderByProgramHandle = context->getShader(program);
1307 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001308 {
Geoff Langb1196682014-07-23 13:47:29 -04001309 context->recordError(gl::Error(GL_INVALID_VALUE));
1310 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001311 }
Geoff Langbfdea662014-07-23 14:16:32 -04001312 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001313 {
Geoff Langb1196682014-07-23 13:47:29 -04001314 context->recordError(gl::Error(GL_INVALID_OPERATION));
1315 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001317 }
Geoff Langbfdea662014-07-23 14:16:32 -04001318
1319 if (!shaderObject)
1320 {
1321 gl::Program *programByShaderHandle = context->getProgram(shader);
1322 if (!programByShaderHandle)
1323 {
Geoff Langb1196682014-07-23 13:47:29 -04001324 context->recordError(gl::Error(GL_INVALID_VALUE));
1325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001326 }
1327 else
1328 {
Geoff Langb1196682014-07-23 13:47:29 -04001329 context->recordError(gl::Error(GL_INVALID_OPERATION));
1330 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001331 }
1332 }
1333
1334 if (!programObject->detachShader(shaderObject))
1335 {
Geoff Langb1196682014-07-23 13:47:29 -04001336 context->recordError(gl::Error(GL_INVALID_OPERATION));
1337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001338 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001339 }
1340}
1341
Kenneth Russell67ea1902014-10-06 16:44:50 -07001342void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001344 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001345
Geoff Langbfdea662014-07-23 14:16:32 -04001346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001347 if (context)
1348 {
1349 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001350 {
Geoff Langb1196682014-07-23 13:47:29 -04001351 context->recordError(gl::Error(GL_INVALID_ENUM));
1352 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001353 }
Geoff Langbfdea662014-07-23 14:16:32 -04001354
1355 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001356 }
1357}
1358
Kenneth Russell67ea1902014-10-06 16:44:50 -07001359void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001361 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001362
Geoff Langbfdea662014-07-23 14:16:32 -04001363 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001364 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001365 {
Geoff Langb1196682014-07-23 13:47:29 -04001366 if (index >= gl::MAX_VERTEX_ATTRIBS)
1367 {
1368 context->recordError(gl::Error(GL_INVALID_VALUE));
1369 return;
1370 }
1371
Geoff Langbfdea662014-07-23 14:16:32 -04001372 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001373 }
1374}
1375
Kenneth Russell67ea1902014-10-06 16:44:50 -07001376void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001378 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001379
Geoff Langbfdea662014-07-23 14:16:32 -04001380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001381 if (context)
1382 {
Jamie Madill2b976812014-08-25 15:47:49 -04001383 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 {
Geoff Langbfdea662014-07-23 14:16:32 -04001385 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001386 }
Geoff Langbfdea662014-07-23 14:16:32 -04001387
Geoff Langc77e8c32014-09-08 16:28:24 -04001388 gl::Error error = context->drawArrays(mode, first, count, 0);
1389 if (error.isError())
1390 {
1391 context->recordError(error);
1392 return;
1393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001394 }
1395}
1396
Kenneth Russell67ea1902014-10-06 16:44:50 -07001397void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001398{
1399 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1400
Geoff Langbfdea662014-07-23 14:16:32 -04001401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001402 if (context)
1403 {
Geoff Lang87a93302014-09-16 13:29:43 -04001404 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 {
Geoff Langbfdea662014-07-23 14:16:32 -04001406 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001407 }
Geoff Langbfdea662014-07-23 14:16:32 -04001408
Geoff Langc77e8c32014-09-08 16:28:24 -04001409 gl::Error error = context->drawArrays(mode, first, count, primcount);
1410 if (error.isError())
1411 {
1412 context->recordError(error);
1413 return;
1414 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001415 }
1416}
1417
Kenneth Russell67ea1902014-10-06 16:44:50 -07001418void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001419{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001420 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001421 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001422
Geoff Langbfdea662014-07-23 14:16:32 -04001423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001424 if (context)
1425 {
Jamie Madill2b976812014-08-25 15:47:49 -04001426 rx::RangeUI indexRange;
1427 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 {
Geoff Langbfdea662014-07-23 14:16:32 -04001429 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001430 }
Geoff Langbfdea662014-07-23 14:16:32 -04001431
Geoff Langc77e8c32014-09-08 16:28:24 -04001432 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1433 if (error.isError())
1434 {
1435 context->recordError(error);
1436 return;
1437 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001438 }
1439}
1440
Kenneth Russell67ea1902014-10-06 16:44:50 -07001441void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001442{
1443 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1444 mode, count, type, indices, primcount);
1445
Geoff Langbfdea662014-07-23 14:16:32 -04001446 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001447 if (context)
1448 {
Jamie Madill2b976812014-08-25 15:47:49 -04001449 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001450 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 {
Geoff Langbfdea662014-07-23 14:16:32 -04001452 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001453 }
Geoff Langbfdea662014-07-23 14:16:32 -04001454
Geoff Langc77e8c32014-09-08 16:28:24 -04001455 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1456 if (error.isError())
1457 {
1458 context->recordError(error);
1459 return;
1460 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001461 }
1462}
1463
Kenneth Russell67ea1902014-10-06 16:44:50 -07001464void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001466 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001467
Geoff Langbfdea662014-07-23 14:16:32 -04001468 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001469 if (context)
1470 {
1471 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001472 {
Geoff Langb1196682014-07-23 13:47:29 -04001473 context->recordError(gl::Error(GL_INVALID_ENUM));
1474 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001475 }
Geoff Langbfdea662014-07-23 14:16:32 -04001476
1477 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001478 }
1479}
1480
Kenneth Russell67ea1902014-10-06 16:44:50 -07001481void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001483 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001484
Geoff Langbfdea662014-07-23 14:16:32 -04001485 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001486 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001487 {
Geoff Langb1196682014-07-23 13:47:29 -04001488 if (index >= gl::MAX_VERTEX_ATTRIBS)
1489 {
1490 context->recordError(gl::Error(GL_INVALID_VALUE));
1491 return;
1492 }
1493
Geoff Langbfdea662014-07-23 14:16:32 -04001494 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001495 }
1496}
1497
Kenneth Russell67ea1902014-10-06 16:44:50 -07001498void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001499{
1500 EVENT("GLenum target = 0x%X)", target);
1501
Geoff Langbfdea662014-07-23 14:16:32 -04001502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001503 if (context)
1504 {
1505 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 {
Geoff Langbfdea662014-07-23 14:16:32 -04001507 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001508 }
Geoff Langbfdea662014-07-23 14:16:32 -04001509
Geoff Lang5aad9672014-09-08 11:10:42 -04001510 gl::Error error = context->endQuery(target);
1511 if (error.isError())
1512 {
1513 context->recordError(error);
1514 return;
1515 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001516 }
1517}
1518
Kenneth Russell67ea1902014-10-06 16:44:50 -07001519void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001521 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001522
Geoff Langbfdea662014-07-23 14:16:32 -04001523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001524 if (context)
1525 {
1526 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1527
1528 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001529 {
Geoff Langb1196682014-07-23 13:47:29 -04001530 context->recordError(gl::Error(GL_INVALID_OPERATION));
1531 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001532 }
Geoff Langbfdea662014-07-23 14:16:32 -04001533
1534 if (fenceObject->isFence() != GL_TRUE)
1535 {
Geoff Langb1196682014-07-23 13:47:29 -04001536 context->recordError(gl::Error(GL_INVALID_OPERATION));
1537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001538 }
1539
1540 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001541 }
1542}
1543
Kenneth Russell67ea1902014-10-06 16:44:50 -07001544void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001546 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547
Geoff Langbfdea662014-07-23 14:16:32 -04001548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001549 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001550 {
Geoff Lang26298562014-10-01 10:49:03 -04001551 gl::Error error = context->sync(true);
1552 if (error.isError())
1553 {
1554 context->recordError(error);
1555 return;
1556 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557 }
1558}
1559
Kenneth Russell67ea1902014-10-06 16:44:50 -07001560void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001562 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001563
Geoff Langbfdea662014-07-23 14:16:32 -04001564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001565 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001566 {
Geoff Lang26298562014-10-01 10:49:03 -04001567 gl::Error error = context->sync(false);
1568 if (error.isError())
1569 {
1570 context->recordError(error);
1571 return;
1572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573 }
1574}
1575
Kenneth Russell67ea1902014-10-06 16:44:50 -07001576void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001578 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001579 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001580
Geoff Langbfdea662014-07-23 14:16:32 -04001581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001582 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583 {
Geoff Langb1196682014-07-23 13:47:29 -04001584 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1585 {
1586 context->recordError(gl::Error(GL_INVALID_ENUM));
1587 return;
1588 }
1589
Geoff Langbfdea662014-07-23 14:16:32 -04001590 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1591 {
1592 return;
1593 }
1594
1595 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1596 ASSERT(framebuffer);
1597
Geoff Langab75a052014-10-15 12:56:37 -04001598 if (renderbuffer != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001599 {
Geoff Langab75a052014-10-15 12:56:37 -04001600 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
1601 framebuffer->setRenderbufferAttachment(attachment, renderbufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -04001602 }
1603 else
1604 {
Geoff Langab75a052014-10-15 12:56:37 -04001605 framebuffer->setNULLAttachment(attachment);
Geoff Langbfdea662014-07-23 14:16:32 -04001606 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001607 }
1608}
1609
Kenneth Russell67ea1902014-10-06 16:44:50 -07001610void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001611{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001612 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001613 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001614
Geoff Langbfdea662014-07-23 14:16:32 -04001615 gl::Context *context = gl::getNonLostContext();
1616 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001617 {
Geoff Langbfdea662014-07-23 14:16:32 -04001618 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 {
Geoff Langbfdea662014-07-23 14:16:32 -04001620 return;
1621 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001622
Geoff Langbfdea662014-07-23 14:16:32 -04001623 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05001624 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625
Geoff Langab75a052014-10-15 12:56:37 -04001626 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001627 {
Geoff Langab75a052014-10-15 12:56:37 -04001628 gl::Texture *textureObj = context->getTexture(texture);
1629 gl::ImageIndex index(textarget, level, gl::ImageIndex::ENTIRE_LEVEL);
1630 framebuffer->setTextureAttachment(attachment, textureObj, index);
Geoff Langbfdea662014-07-23 14:16:32 -04001631 }
1632 else
1633 {
Geoff Langab75a052014-10-15 12:56:37 -04001634 framebuffer->setNULLAttachment(attachment);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001635 }
1636 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001637}
1638
Kenneth Russell67ea1902014-10-06 16:44:50 -07001639void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001640{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001641 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001642
Geoff Langb1196682014-07-23 13:47:29 -04001643 gl::Context *context = gl::getNonLostContext();
1644 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001645 {
Geoff Langb1196682014-07-23 13:47:29 -04001646 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001647 {
Geoff Langb1196682014-07-23 13:47:29 -04001648 case GL_CW:
1649 case GL_CCW:
1650 context->getState().setFrontFace(mode);
1651 break;
1652 default:
1653 context->recordError(gl::Error(GL_INVALID_ENUM));
1654 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001656 }
1657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langbfdea662014-07-23 14:16:32 -04001663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 if (n < 0)
1667 {
1668 context->recordError(gl::Error(GL_INVALID_VALUE));
1669 return;
1670 }
1671
Geoff Langbfdea662014-07-23 14:16:32 -04001672 for (int i = 0; i < n; i++)
1673 {
1674 buffers[i] = context->createBuffer();
1675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
1685 {
1686 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001687 {
Geoff Langb1196682014-07-23 13:47:29 -04001688 context->recordError(gl::Error(GL_INVALID_ENUM));
1689 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001690 }
Geoff Langbfdea662014-07-23 14:16:32 -04001691
1692 gl::Texture *texture = context->getTargetTexture(target);
1693
1694 if (texture == NULL)
1695 {
Geoff Langb1196682014-07-23 13:47:29 -04001696 context->recordError(gl::Error(GL_INVALID_OPERATION));
1697 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001698 }
1699
1700 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1701 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001702 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001703
1704 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1705 // unsized formats or that are color renderable and filterable. Since we do not track if
1706 // the texture was created with sized or unsized format (only sized formats are stored),
1707 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1708 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1709 // textures since they're the only texture format that can be created with unsized formats
1710 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1711 // was the last version to use add them.
1712 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1713 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1714 internalFormat == GL_ALPHA8_EXT;
1715
Geoff Lang5d601382014-07-22 15:14:06 -04001716 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1717 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001718 {
Geoff Langb1196682014-07-23 13:47:29 -04001719 context->recordError(gl::Error(GL_INVALID_OPERATION));
1720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001721 }
1722
1723 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001724 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001725 {
Geoff Langb1196682014-07-23 13:47:29 -04001726 context->recordError(gl::Error(GL_INVALID_OPERATION));
1727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001728 }
1729
1730 // Non-power of 2 ES2 check
1731 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1732 {
1733 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001734 context->recordError(gl::Error(GL_INVALID_OPERATION));
1735 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001736 }
1737
1738 // Cube completeness check
1739 if (target == GL_TEXTURE_CUBE_MAP)
1740 {
1741 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1742 if (!textureCube->isCubeComplete())
1743 {
Geoff Langb1196682014-07-23 13:47:29 -04001744 context->recordError(gl::Error(GL_INVALID_OPERATION));
1745 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001746 }
1747 }
1748
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001749 gl::Error error = texture->generateMipmaps();
1750 if (error.isError())
1751 {
1752 context->recordError(error);
1753 return;
1754 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001755 }
1756}
1757
Kenneth Russell67ea1902014-10-06 16:44:50 -07001758void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001760 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001761
Geoff Langbfdea662014-07-23 14:16:32 -04001762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001763 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001764 {
Geoff Langb1196682014-07-23 13:47:29 -04001765 if (n < 0)
1766 {
1767 context->recordError(gl::Error(GL_INVALID_VALUE));
1768 return;
1769 }
1770
Geoff Langbfdea662014-07-23 14:16:32 -04001771 for (int i = 0; i < n; i++)
1772 {
1773 fences[i] = context->createFenceNV();
1774 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001775 }
1776}
1777
Kenneth Russell67ea1902014-10-06 16:44:50 -07001778void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001779{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001780 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001781
Geoff Langbfdea662014-07-23 14:16:32 -04001782 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001783 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001784 {
Geoff Langb1196682014-07-23 13:47:29 -04001785 if (n < 0)
1786 {
1787 context->recordError(gl::Error(GL_INVALID_VALUE));
1788 return;
1789 }
1790
Geoff Langbfdea662014-07-23 14:16:32 -04001791 for (int i = 0; i < n; i++)
1792 {
1793 framebuffers[i] = context->createFramebuffer();
1794 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001795 }
1796}
1797
Kenneth Russell67ea1902014-10-06 16:44:50 -07001798void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001799{
1800 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1801
Geoff Langbfdea662014-07-23 14:16:32 -04001802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001803 if (context)
1804 {
1805 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001806 {
Geoff Langb1196682014-07-23 13:47:29 -04001807 context->recordError(gl::Error(GL_INVALID_VALUE));
1808 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001809 }
Geoff Langbfdea662014-07-23 14:16:32 -04001810
1811 for (GLsizei i = 0; i < n; i++)
1812 {
1813 ids[i] = context->createQuery();
1814 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001815 }
1816}
1817
Kenneth Russell67ea1902014-10-06 16:44:50 -07001818void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001819{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001820 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001821
Geoff Langbfdea662014-07-23 14:16:32 -04001822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001823 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001824 {
Geoff Langb1196682014-07-23 13:47:29 -04001825 if (n < 0)
1826 {
1827 context->recordError(gl::Error(GL_INVALID_VALUE));
1828 return;
1829 }
1830
Geoff Langbfdea662014-07-23 14:16:32 -04001831 for (int i = 0; i < n; i++)
1832 {
1833 renderbuffers[i] = context->createRenderbuffer();
1834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835 }
1836}
1837
Kenneth Russell67ea1902014-10-06 16:44:50 -07001838void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001840 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001841
Geoff Langbfdea662014-07-23 14:16:32 -04001842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001843 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844 {
Geoff Langb1196682014-07-23 13:47:29 -04001845 if (n < 0)
1846 {
1847 context->recordError(gl::Error(GL_INVALID_VALUE));
1848 return;
1849 }
1850
Geoff Langbfdea662014-07-23 14:16:32 -04001851 for (int i = 0; i < n; i++)
1852 {
1853 textures[i] = context->createTexture();
1854 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001855 }
1856}
1857
Kenneth Russell67ea1902014-10-06 16:44:50 -07001858void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001860 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001861 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862 program, index, bufsize, length, size, type, name);
1863
Geoff Langbfdea662014-07-23 14:16:32 -04001864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001865 if (context)
1866 {
Geoff Langb1196682014-07-23 13:47:29 -04001867 if (bufsize < 0)
1868 {
1869 context->recordError(gl::Error(GL_INVALID_VALUE));
1870 return;
1871 }
1872
Geoff Langbfdea662014-07-23 14:16:32 -04001873 gl::Program *programObject = context->getProgram(program);
1874
1875 if (!programObject)
1876 {
1877 if (context->getShader(program))
1878 {
Geoff Langb1196682014-07-23 13:47:29 -04001879 context->recordError(gl::Error(GL_INVALID_OPERATION));
1880 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001881 }
1882 else
1883 {
Geoff Langb1196682014-07-23 13:47:29 -04001884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001886 }
1887 }
1888
1889 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001890 {
Geoff Langb1196682014-07-23 13:47:29 -04001891 context->recordError(gl::Error(GL_INVALID_VALUE));
1892 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001893 }
1894
Geoff Langbfdea662014-07-23 14:16:32 -04001895 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001896 }
1897}
1898
Kenneth Russell67ea1902014-10-06 16:44:50 -07001899void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001901 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001902 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001903 program, index, bufsize, length, size, type, name);
1904
Geoff Langbfdea662014-07-23 14:16:32 -04001905
1906 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001907 if (context)
1908 {
Geoff Langb1196682014-07-23 13:47:29 -04001909 if (bufsize < 0)
1910 {
1911 context->recordError(gl::Error(GL_INVALID_VALUE));
1912 return;
1913 }
1914
Geoff Langbfdea662014-07-23 14:16:32 -04001915 gl::Program *programObject = context->getProgram(program);
1916
1917 if (!programObject)
1918 {
1919 if (context->getShader(program))
1920 {
Geoff Langb1196682014-07-23 13:47:29 -04001921 context->recordError(gl::Error(GL_INVALID_OPERATION));
1922 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001923 }
1924 else
1925 {
Geoff Langb1196682014-07-23 13:47:29 -04001926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001928 }
1929 }
1930
1931 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001932 {
Geoff Langb1196682014-07-23 13:47:29 -04001933 context->recordError(gl::Error(GL_INVALID_VALUE));
1934 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001935 }
1936
Geoff Langbfdea662014-07-23 14:16:32 -04001937 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001938 }
1939}
1940
Kenneth Russell67ea1902014-10-06 16:44:50 -07001941void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001942{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001943 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001944 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001945
Geoff Langbfdea662014-07-23 14:16:32 -04001946 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001947 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001948 {
Geoff Langb1196682014-07-23 13:47:29 -04001949 if (maxcount < 0)
1950 {
1951 context->recordError(gl::Error(GL_INVALID_VALUE));
1952 return;
1953 }
1954
Geoff Langbfdea662014-07-23 14:16:32 -04001955 gl::Program *programObject = context->getProgram(program);
1956
1957 if (!programObject)
1958 {
1959 if (context->getShader(program))
1960 {
Geoff Langb1196682014-07-23 13:47:29 -04001961 context->recordError(gl::Error(GL_INVALID_OPERATION));
1962 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001963 }
1964 else
1965 {
Geoff Langb1196682014-07-23 13:47:29 -04001966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001968 }
1969 }
1970
1971 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001972 }
1973}
1974
Kenneth Russell67ea1902014-10-06 16:44:50 -07001975GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001976{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001977 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001978
Geoff Langbfdea662014-07-23 14:16:32 -04001979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001980 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001981 {
Geoff Langbfdea662014-07-23 14:16:32 -04001982 gl::Program *programObject = context->getProgram(program);
1983
1984 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001985 {
Geoff Langbfdea662014-07-23 14:16:32 -04001986 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001987 {
Geoff Langb1196682014-07-23 13:47:29 -04001988 context->recordError(gl::Error(GL_INVALID_OPERATION));
1989 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001990 }
Geoff Langbfdea662014-07-23 14:16:32 -04001991 else
1992 {
Geoff Langb1196682014-07-23 13:47:29 -04001993 context->recordError(gl::Error(GL_INVALID_VALUE));
1994 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04001995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 }
Geoff Langbfdea662014-07-23 14:16:32 -04001997
1998 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
1999 if (!programObject->isLinked() || !programBinary)
2000 {
Geoff Langb1196682014-07-23 13:47:29 -04002001 context->recordError(gl::Error(GL_INVALID_OPERATION));
2002 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002003 }
2004
2005 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002006 }
2007
2008 return -1;
2009}
2010
Kenneth Russell67ea1902014-10-06 16:44:50 -07002011void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002013 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002014
Geoff Langbfdea662014-07-23 14:16:32 -04002015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002016 if (context)
2017 {
2018 GLenum nativeType;
2019 unsigned int numParams = 0;
2020 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 {
Geoff Langbfdea662014-07-23 14:16:32 -04002022 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002023 }
Geoff Langbfdea662014-07-23 14:16:32 -04002024
2025 if (nativeType == GL_BOOL)
2026 {
2027 context->getBooleanv(pname, params);
2028 }
2029 else
2030 {
2031 CastStateValues(context, nativeType, pname, numParams, params);
2032 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002033 }
2034}
2035
Kenneth Russell67ea1902014-10-06 16:44:50 -07002036void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002037{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002038 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002039
Geoff Langbfdea662014-07-23 14:16:32 -04002040 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002041 if (context)
2042 {
2043 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002044 {
Geoff Langb1196682014-07-23 13:47:29 -04002045 context->recordError(gl::Error(GL_INVALID_ENUM));
2046 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002047 }
Geoff Langbfdea662014-07-23 14:16:32 -04002048
2049 if (!gl::ValidBufferParameter(context, pname))
2050 {
Geoff Langb1196682014-07-23 13:47:29 -04002051 context->recordError(gl::Error(GL_INVALID_ENUM));
2052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002053 }
2054
2055 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2056
2057 if (!buffer)
2058 {
2059 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_OPERATION));
2061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002062 }
2063
2064 switch (pname)
2065 {
2066 case GL_BUFFER_USAGE:
2067 *params = static_cast<GLint>(buffer->getUsage());
2068 break;
2069 case GL_BUFFER_SIZE:
2070 *params = gl::clampCast<GLint>(buffer->getSize());
2071 break;
2072 case GL_BUFFER_ACCESS_FLAGS:
2073 *params = buffer->getAccessFlags();
2074 break;
2075 case GL_BUFFER_MAPPED:
2076 *params = static_cast<GLint>(buffer->isMapped());
2077 break;
2078 case GL_BUFFER_MAP_OFFSET:
2079 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2080 break;
2081 case GL_BUFFER_MAP_LENGTH:
2082 *params = gl::clampCast<GLint>(buffer->getMapLength());
2083 break;
2084 default: UNREACHABLE(); break;
2085 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002086 }
2087}
2088
Kenneth Russell67ea1902014-10-06 16:44:50 -07002089GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002090{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002091 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002092
2093 gl::Context *context = gl::getContext();
2094
2095 if (context)
2096 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002097 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002098 }
2099
2100 return GL_NO_ERROR;
2101}
2102
Kenneth Russell67ea1902014-10-06 16:44:50 -07002103void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002104{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002105 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002106
Geoff Langbfdea662014-07-23 14:16:32 -04002107 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002108 if (context)
2109 {
2110 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2111
2112 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002113 {
Geoff Langb1196682014-07-23 13:47:29 -04002114 context->recordError(gl::Error(GL_INVALID_OPERATION));
2115 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002116 }
Geoff Langbfdea662014-07-23 14:16:32 -04002117
2118 if (fenceObject->isFence() != GL_TRUE)
2119 {
Geoff Langb1196682014-07-23 13:47:29 -04002120 context->recordError(gl::Error(GL_INVALID_OPERATION));
2121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002122 }
2123
2124 switch (pname)
2125 {
2126 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002127 {
2128 // GL_NV_fence spec:
2129 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2130 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2131 GLboolean status = GL_TRUE;
2132 if (fenceObject->getStatus() != GL_TRUE)
2133 {
2134 gl::Error error = fenceObject->testFence(&status);
2135 if (error.isError())
2136 {
2137 context->recordError(error);
2138 return;
2139 }
2140 }
2141 *params = status;
2142 break;
2143 }
2144
Geoff Langbfdea662014-07-23 14:16:32 -04002145 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002146 {
2147 *params = fenceObject->getCondition();
2148 break;
2149 }
Geoff Langbfdea662014-07-23 14:16:32 -04002150
Geoff Langb1196682014-07-23 13:47:29 -04002151 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002152 {
2153 context->recordError(gl::Error(GL_INVALID_ENUM));
2154 return;
2155 }
Geoff Lang882033e2014-09-30 11:26:07 -04002156 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002157 }
2158}
2159
Kenneth Russell67ea1902014-10-06 16:44:50 -07002160void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002161{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002162 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002163
Geoff Langbfdea662014-07-23 14:16:32 -04002164 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002165 if (context)
2166 {
2167 GLenum nativeType;
2168 unsigned int numParams = 0;
2169 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002170 {
Geoff Langbfdea662014-07-23 14:16:32 -04002171 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002172 }
Geoff Langbfdea662014-07-23 14:16:32 -04002173
2174 if (nativeType == GL_FLOAT)
2175 {
2176 context->getFloatv(pname, params);
2177 }
2178 else
2179 {
2180 CastStateValues(context, nativeType, pname, numParams, params);
2181 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002182 }
2183}
2184
Kenneth Russell67ea1902014-10-06 16:44:50 -07002185void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002186{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002187 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002188 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002189
Geoff Langbfdea662014-07-23 14:16:32 -04002190 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002191 if (context)
2192 {
2193 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002194 {
Geoff Langb1196682014-07-23 13:47:29 -04002195 context->recordError(gl::Error(GL_INVALID_ENUM));
2196 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002197 }
2198
2199 int clientVersion = context->getClientVersion();
2200
2201 switch (pname)
2202 {
2203 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2204 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2205 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2206 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2207 break;
Geoff Langb1196682014-07-23 13:47:29 -04002208
Geoff Langbfdea662014-07-23 14:16:32 -04002209 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2210 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002211 {
Geoff Langb1196682014-07-23 13:47:29 -04002212 context->recordError(gl::Error(GL_INVALID_ENUM));
2213 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002214 }
Geoff Langbfdea662014-07-23 14:16:32 -04002215 break;
Geoff Langb1196682014-07-23 13:47:29 -04002216
Geoff Langbfdea662014-07-23 14:16:32 -04002217 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2218 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2220 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2221 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2222 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2223 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2224 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2225 if (clientVersion < 3)
2226 {
Geoff Langb1196682014-07-23 13:47:29 -04002227 context->recordError(gl::Error(GL_INVALID_ENUM));
2228 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002229 }
2230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 default:
Geoff Langb1196682014-07-23 13:47:29 -04002233 context->recordError(gl::Error(GL_INVALID_ENUM));
2234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002235 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002236
Geoff Langbfdea662014-07-23 14:16:32 -04002237 // Determine if the attachment is a valid enum
2238 switch (attachment)
2239 {
2240 case GL_BACK:
2241 case GL_FRONT:
2242 case GL_DEPTH:
2243 case GL_STENCIL:
2244 case GL_DEPTH_STENCIL_ATTACHMENT:
2245 if (clientVersion < 3)
2246 {
Geoff Langb1196682014-07-23 13:47:29 -04002247 context->recordError(gl::Error(GL_INVALID_ENUM));
2248 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002249 }
2250 break;
2251
2252 case GL_DEPTH_ATTACHMENT:
2253 case GL_STENCIL_ATTACHMENT:
2254 break;
2255
2256 default:
2257 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2258 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2259 {
Geoff Langb1196682014-07-23 13:47:29 -04002260 context->recordError(gl::Error(GL_INVALID_ENUM));
2261 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002262 }
2263 break;
2264 }
2265
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002266 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05002267 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04002268
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002269 if (framebuffer->id() == 0)
Geoff Langbfdea662014-07-23 14:16:32 -04002270 {
2271 if (clientVersion < 3)
2272 {
Geoff Langb1196682014-07-23 13:47:29 -04002273 context->recordError(gl::Error(GL_INVALID_OPERATION));
2274 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002275 }
2276
2277 switch (attachment)
2278 {
2279 case GL_BACK:
2280 case GL_DEPTH:
2281 case GL_STENCIL:
2282 break;
Geoff Langb1196682014-07-23 13:47:29 -04002283
Geoff Langbfdea662014-07-23 14:16:32 -04002284 default:
Geoff Langb1196682014-07-23 13:47:29 -04002285 context->recordError(gl::Error(GL_INVALID_OPERATION));
2286 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002287 }
2288 }
2289 else
2290 {
2291 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2292 {
2293 // Valid attachment query
2294 }
2295 else
2296 {
2297 switch (attachment)
2298 {
2299 case GL_DEPTH_ATTACHMENT:
2300 case GL_STENCIL_ATTACHMENT:
2301 break;
Geoff Langb1196682014-07-23 13:47:29 -04002302
Geoff Langbfdea662014-07-23 14:16:32 -04002303 case GL_DEPTH_STENCIL_ATTACHMENT:
2304 if (framebuffer->hasValidDepthStencil())
2305 {
Geoff Langb1196682014-07-23 13:47:29 -04002306 context->recordError(gl::Error(GL_INVALID_OPERATION));
2307 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002308 }
2309 break;
Geoff Langb1196682014-07-23 13:47:29 -04002310
Geoff Langbfdea662014-07-23 14:16:32 -04002311 default:
Geoff Langb1196682014-07-23 13:47:29 -04002312 context->recordError(gl::Error(GL_INVALID_OPERATION));
2313 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002314 }
2315 }
2316 }
2317
Geoff Langbfdea662014-07-23 14:16:32 -04002318 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
Geoff Langbfdea662014-07-23 14:16:32 -04002319 if (attachmentObject)
2320 {
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002321 ASSERT(attachmentObject->type() == GL_RENDERBUFFER ||
2322 attachmentObject->type() == GL_TEXTURE ||
2323 attachmentObject->type() == GL_FRAMEBUFFER_DEFAULT);
Jamie Madill1e3fa742014-06-16 10:34:00 -04002324
Geoff Lang646559f2013-08-15 11:08:15 -04002325 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002326 {
Geoff Lang646559f2013-08-15 11:08:15 -04002327 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002328 *params = attachmentObject->type();
Geoff Langbfdea662014-07-23 14:16:32 -04002329 break;
2330
Geoff Lang646559f2013-08-15 11:08:15 -04002331 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002332 if (attachmentObject->type() != GL_RENDERBUFFER && attachmentObject->type() != GL_TEXTURE)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002333 {
Geoff Langb1196682014-07-23 13:47:29 -04002334 context->recordError(gl::Error(GL_INVALID_ENUM));
2335 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002336 }
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002337 *params = attachmentObject->id();
Geoff Langbfdea662014-07-23 14:16:32 -04002338 break;
2339
2340 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002341 if (attachmentObject->type() != GL_TEXTURE)
Geoff Langbfdea662014-07-23 14:16:32 -04002342 {
Geoff Langb1196682014-07-23 13:47:29 -04002343 context->recordError(gl::Error(GL_INVALID_ENUM));
2344 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002345 }
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002346 *params = attachmentObject->mipLevel();
Geoff Langbfdea662014-07-23 14:16:32 -04002347 break;
2348
2349 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002350 if (attachmentObject->type() != GL_TEXTURE)
Geoff Langbfdea662014-07-23 14:16:32 -04002351 {
Geoff Langb1196682014-07-23 13:47:29 -04002352 context->recordError(gl::Error(GL_INVALID_ENUM));
2353 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002354 }
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002355 *params = attachmentObject->cubeMapFace();
Geoff Langbfdea662014-07-23 14:16:32 -04002356 break;
2357
2358 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2359 *params = attachmentObject->getRedSize();
2360 break;
2361
2362 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2363 *params = attachmentObject->getGreenSize();
2364 break;
2365
2366 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2367 *params = attachmentObject->getBlueSize();
2368 break;
2369
2370 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2371 *params = attachmentObject->getAlphaSize();
2372 break;
2373
2374 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2375 *params = attachmentObject->getDepthSize();
2376 break;
2377
2378 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2379 *params = attachmentObject->getStencilSize();
2380 break;
2381
2382 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002383 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002384 {
Geoff Langb1196682014-07-23 13:47:29 -04002385 context->recordError(gl::Error(GL_INVALID_OPERATION));
2386 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002387 }
2388 *params = attachmentObject->getComponentType();
2389 break;
2390
2391 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2392 *params = attachmentObject->getColorEncoding();
2393 break;
2394
2395 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002396 if (attachmentObject->type() != GL_TEXTURE)
Geoff Langbfdea662014-07-23 14:16:32 -04002397 {
Geoff Langb1196682014-07-23 13:47:29 -04002398 context->recordError(gl::Error(GL_INVALID_ENUM));
2399 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002400 }
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002401 *params = attachmentObject->layer();
Geoff Langbfdea662014-07-23 14:16:32 -04002402 break;
2403
2404 default:
2405 UNREACHABLE();
2406 break;
2407 }
2408 }
Geoff Lang6a1e6b92014-11-06 10:42:45 -05002409 else
2410 {
2411 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2412 // is NONE, then querying any other pname will generate INVALID_ENUM.
2413
2414 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2415 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2416 // INVALID_OPERATION for all other pnames
2417
2418 switch (pname)
2419 {
2420 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2421 *params = GL_NONE;
2422 break;
2423
2424 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2425 if (clientVersion < 3)
2426 {
2427 context->recordError(gl::Error(GL_INVALID_ENUM));
2428 return;
2429 }
2430 *params = 0;
2431 break;
2432
2433 default:
2434 if (clientVersion < 3)
2435 {
2436 context->recordError(gl::Error(GL_INVALID_ENUM));
2437 return;
2438 }
2439 else
2440 {
2441 context->recordError(gl::Error(GL_INVALID_OPERATION));
2442 return;
2443 }
2444 }
2445 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002446 }
2447}
2448
Kenneth Russell67ea1902014-10-06 16:44:50 -07002449GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002450{
2451 EVENT("()");
2452
Geoff Langbfdea662014-07-23 14:16:32 -04002453 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002454
Geoff Langbfdea662014-07-23 14:16:32 -04002455 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002456 {
Geoff Langbfdea662014-07-23 14:16:32 -04002457 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002458 }
Geoff Langbfdea662014-07-23 14:16:32 -04002459
2460 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002461}
2462
Kenneth Russell67ea1902014-10-06 16:44:50 -07002463void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002464{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002465 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002466
Geoff Langbfdea662014-07-23 14:16:32 -04002467 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002468 if (context)
2469 {
2470 GLenum nativeType;
2471 unsigned int numParams = 0;
2472
2473 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002474 {
Geoff Langbfdea662014-07-23 14:16:32 -04002475 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002476 }
Geoff Langbfdea662014-07-23 14:16:32 -04002477
2478 if (nativeType == GL_INT)
2479 {
2480 context->getIntegerv(pname, params);
2481 }
2482 else
2483 {
2484 CastStateValues(context, nativeType, pname, numParams, params);
2485 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002486 }
2487}
2488
Kenneth Russell67ea1902014-10-06 16:44:50 -07002489void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002490{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002491 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002492
Geoff Langbfdea662014-07-23 14:16:32 -04002493 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002494 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002495 {
Geoff Langbfdea662014-07-23 14:16:32 -04002496 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002497
Geoff Langbfdea662014-07-23 14:16:32 -04002498 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002499 {
Geoff Langb1196682014-07-23 13:47:29 -04002500 context->recordError(gl::Error(GL_INVALID_VALUE));
2501 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002502 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002503
Geoff Langbfdea662014-07-23 14:16:32 -04002504 if (context->getClientVersion() < 3)
2505 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002506 switch (pname)
2507 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002508 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002509 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002510 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002511 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002512 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002513 context->recordError(gl::Error(GL_INVALID_ENUM));
2514 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002515 }
2516 }
Geoff Langbfdea662014-07-23 14:16:32 -04002517
2518 switch (pname)
2519 {
2520 case GL_DELETE_STATUS:
2521 *params = programObject->isFlaggedForDeletion();
2522 return;
2523 case GL_LINK_STATUS:
2524 *params = programObject->isLinked();
2525 return;
2526 case GL_VALIDATE_STATUS:
2527 *params = programObject->isValidated();
2528 return;
2529 case GL_INFO_LOG_LENGTH:
2530 *params = programObject->getInfoLogLength();
2531 return;
2532 case GL_ATTACHED_SHADERS:
2533 *params = programObject->getAttachedShadersCount();
2534 return;
2535 case GL_ACTIVE_ATTRIBUTES:
2536 *params = programObject->getActiveAttributeCount();
2537 return;
2538 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2539 *params = programObject->getActiveAttributeMaxLength();
2540 return;
2541 case GL_ACTIVE_UNIFORMS:
2542 *params = programObject->getActiveUniformCount();
2543 return;
2544 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2545 *params = programObject->getActiveUniformMaxLength();
2546 return;
2547 case GL_PROGRAM_BINARY_LENGTH_OES:
2548 *params = programObject->getProgramBinaryLength();
2549 return;
2550 case GL_ACTIVE_UNIFORM_BLOCKS:
2551 *params = programObject->getActiveUniformBlockCount();
2552 return;
2553 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2554 *params = programObject->getActiveUniformBlockMaxLength();
2555 break;
2556 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2557 *params = programObject->getTransformFeedbackBufferMode();
2558 break;
2559 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2560 *params = programObject->getTransformFeedbackVaryingCount();
2561 break;
2562 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2563 *params = programObject->getTransformFeedbackVaryingMaxLength();
2564 break;
Geoff Langb1196682014-07-23 13:47:29 -04002565
Geoff Langbfdea662014-07-23 14:16:32 -04002566 default:
Geoff Langb1196682014-07-23 13:47:29 -04002567 context->recordError(gl::Error(GL_INVALID_ENUM));
2568 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002569 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002570 }
2571}
2572
Kenneth Russell67ea1902014-10-06 16:44:50 -07002573void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002574{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002575 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 +00002576 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002577
Geoff Langbfdea662014-07-23 14:16:32 -04002578 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002579 if (context)
2580 {
Geoff Langb1196682014-07-23 13:47:29 -04002581 if (bufsize < 0)
2582 {
2583 context->recordError(gl::Error(GL_INVALID_VALUE));
2584 return;
2585 }
2586
Geoff Langbfdea662014-07-23 14:16:32 -04002587 gl::Program *programObject = context->getProgram(program);
2588
2589 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002590 {
Geoff Langb1196682014-07-23 13:47:29 -04002591 context->recordError(gl::Error(GL_INVALID_VALUE));
2592 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002593 }
2594
Geoff Langbfdea662014-07-23 14:16:32 -04002595 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002596 }
2597}
2598
Kenneth Russell67ea1902014-10-06 16:44:50 -07002599void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002600{
2601 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2602
Geoff Langbfdea662014-07-23 14:16:32 -04002603 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002604 if (context)
2605 {
2606 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002607 {
Geoff Langb1196682014-07-23 13:47:29 -04002608 context->recordError(gl::Error(GL_INVALID_ENUM));
2609 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002610 }
Geoff Langbfdea662014-07-23 14:16:32 -04002611
2612 switch (pname)
2613 {
2614 case GL_CURRENT_QUERY_EXT:
2615 params[0] = context->getState().getActiveQueryId(target);
2616 break;
2617
2618 default:
Geoff Langb1196682014-07-23 13:47:29 -04002619 context->recordError(gl::Error(GL_INVALID_ENUM));
2620 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002621 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002622 }
2623}
2624
Kenneth Russell67ea1902014-10-06 16:44:50 -07002625void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002626{
2627 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2628
Geoff Langbfdea662014-07-23 14:16:32 -04002629 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002630 if (context)
2631 {
2632 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2633
2634 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002635 {
Geoff Langb1196682014-07-23 13:47:29 -04002636 context->recordError(gl::Error(GL_INVALID_OPERATION));
2637 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002638 }
Geoff Langbfdea662014-07-23 14:16:32 -04002639
2640 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2641 {
Geoff Langb1196682014-07-23 13:47:29 -04002642 context->recordError(gl::Error(GL_INVALID_OPERATION));
2643 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002644 }
2645
2646 switch(pname)
2647 {
2648 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002649 {
2650 gl::Error error = queryObject->getResult(params);
2651 if (error.isError())
2652 {
2653 context->recordError(error);
2654 return;
2655 }
2656 }
Geoff Langbfdea662014-07-23 14:16:32 -04002657 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002658
Geoff Langbfdea662014-07-23 14:16:32 -04002659 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002660 {
2661 gl::Error error = queryObject->isResultAvailable(params);
2662 if (error.isError())
2663 {
2664 context->recordError(error);
2665 return;
2666 }
2667 }
Geoff Langbfdea662014-07-23 14:16:32 -04002668 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002669
Geoff Langbfdea662014-07-23 14:16:32 -04002670 default:
Geoff Langb1196682014-07-23 13:47:29 -04002671 context->recordError(gl::Error(GL_INVALID_ENUM));
2672 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002673 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002674 }
2675}
2676
Kenneth Russell67ea1902014-10-06 16:44:50 -07002677void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002678{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002679 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 +00002680
Geoff Langbfdea662014-07-23 14:16:32 -04002681 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002682 if (context)
2683 {
2684 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002685 {
Geoff Langb1196682014-07-23 13:47:29 -04002686 context->recordError(gl::Error(GL_INVALID_ENUM));
2687 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002688 }
Geoff Langbfdea662014-07-23 14:16:32 -04002689
2690 if (context->getState().getRenderbufferId() == 0)
2691 {
Geoff Langb1196682014-07-23 13:47:29 -04002692 context->recordError(gl::Error(GL_INVALID_OPERATION));
2693 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002694 }
2695
2696 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2697
2698 switch (pname)
2699 {
2700 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2701 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2702 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2703 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2704 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2705 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2706 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2707 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2708 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002709
Geoff Langbfdea662014-07-23 14:16:32 -04002710 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2711 if (!context->getExtensions().framebufferMultisample)
2712 {
Geoff Langb1196682014-07-23 13:47:29 -04002713 context->recordError(gl::Error(GL_INVALID_ENUM));
2714 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002715 }
2716 *params = renderbuffer->getSamples();
2717 break;
Geoff Langb1196682014-07-23 13:47:29 -04002718
Geoff Langbfdea662014-07-23 14:16:32 -04002719 default:
Geoff Langb1196682014-07-23 13:47:29 -04002720 context->recordError(gl::Error(GL_INVALID_ENUM));
2721 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002722 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002723 }
2724}
2725
Kenneth Russell67ea1902014-10-06 16:44:50 -07002726void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002727{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002728 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002729
Geoff Langbfdea662014-07-23 14:16:32 -04002730 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002731 if (context)
2732 {
2733 gl::Shader *shaderObject = context->getShader(shader);
2734
2735 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002736 {
Geoff Langb1196682014-07-23 13:47:29 -04002737 context->recordError(gl::Error(GL_INVALID_VALUE));
2738 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002739 }
Geoff Langbfdea662014-07-23 14:16:32 -04002740
2741 switch (pname)
2742 {
2743 case GL_SHADER_TYPE:
2744 *params = shaderObject->getType();
2745 return;
2746 case GL_DELETE_STATUS:
2747 *params = shaderObject->isFlaggedForDeletion();
2748 return;
2749 case GL_COMPILE_STATUS:
2750 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2751 return;
2752 case GL_INFO_LOG_LENGTH:
2753 *params = shaderObject->getInfoLogLength();
2754 return;
2755 case GL_SHADER_SOURCE_LENGTH:
2756 *params = shaderObject->getSourceLength();
2757 return;
2758 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2759 *params = shaderObject->getTranslatedSourceLength();
2760 return;
Geoff Langb1196682014-07-23 13:47:29 -04002761
Geoff Langbfdea662014-07-23 14:16:32 -04002762 default:
Geoff Langb1196682014-07-23 13:47:29 -04002763 context->recordError(gl::Error(GL_INVALID_ENUM));
2764 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002765 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002766 }
2767}
2768
Kenneth Russell67ea1902014-10-06 16:44:50 -07002769void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002770{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002771 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 +00002772 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002773
Geoff Langbfdea662014-07-23 14:16:32 -04002774 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002775 if (context)
2776 {
Geoff Langb1196682014-07-23 13:47:29 -04002777 if (bufsize < 0)
2778 {
2779 context->recordError(gl::Error(GL_INVALID_VALUE));
2780 return;
2781 }
2782
Geoff Langbfdea662014-07-23 14:16:32 -04002783 gl::Shader *shaderObject = context->getShader(shader);
2784
2785 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002786 {
Geoff Langb1196682014-07-23 13:47:29 -04002787 context->recordError(gl::Error(GL_INVALID_VALUE));
2788 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002789 }
2790
Geoff Langbfdea662014-07-23 14:16:32 -04002791 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002792 }
2793}
2794
Kenneth Russell67ea1902014-10-06 16:44:50 -07002795void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002796{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002797 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 +00002798 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002799
Geoff Langb1196682014-07-23 13:47:29 -04002800 gl::Context *context = gl::getNonLostContext();
2801 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002802 {
Geoff Langb1196682014-07-23 13:47:29 -04002803 switch (shadertype)
2804 {
2805 case GL_VERTEX_SHADER:
2806 case GL_FRAGMENT_SHADER:
2807 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002808
Geoff Langb1196682014-07-23 13:47:29 -04002809 default:
2810 context->recordError(gl::Error(GL_INVALID_ENUM));
2811 return;
2812 }
2813
2814 switch (precisiontype)
2815 {
2816 case GL_LOW_FLOAT:
2817 case GL_MEDIUM_FLOAT:
2818 case GL_HIGH_FLOAT:
2819 // Assume IEEE 754 precision
2820 range[0] = 127;
2821 range[1] = 127;
2822 *precision = 23;
2823 break;
2824
2825 case GL_LOW_INT:
2826 case GL_MEDIUM_INT:
2827 case GL_HIGH_INT:
2828 // Some (most) hardware only supports single-precision floating-point numbers,
2829 // which can accurately represent integers up to +/-16777216
2830 range[0] = 24;
2831 range[1] = 24;
2832 *precision = 0;
2833 break;
2834
2835 default:
2836 context->recordError(gl::Error(GL_INVALID_ENUM));
2837 return;
2838 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002839 }
2840}
2841
Kenneth Russell67ea1902014-10-06 16:44:50 -07002842void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002843{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002844 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 +00002845 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002846
Geoff Langbfdea662014-07-23 14:16:32 -04002847 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002848 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002849 {
Geoff Langb1196682014-07-23 13:47:29 -04002850 if (bufsize < 0)
2851 {
2852 context->recordError(gl::Error(GL_INVALID_VALUE));
2853 return;
2854 }
2855
Geoff Langbfdea662014-07-23 14:16:32 -04002856 gl::Shader *shaderObject = context->getShader(shader);
2857
2858 if (!shaderObject)
2859 {
Geoff Langb1196682014-07-23 13:47:29 -04002860 context->recordError(gl::Error(GL_INVALID_OPERATION));
2861 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002862 }
2863
2864 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002865 }
2866}
2867
Kenneth Russell67ea1902014-10-06 16:44:50 -07002868void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002869{
2870 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2871 shader, bufsize, length, source);
2872
Geoff Langbfdea662014-07-23 14:16:32 -04002873 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002874 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002875 {
Geoff Langb1196682014-07-23 13:47:29 -04002876 if (bufsize < 0)
2877 {
2878 context->recordError(gl::Error(GL_INVALID_VALUE));
2879 return;
2880 }
2881
Geoff Langbfdea662014-07-23 14:16:32 -04002882 gl::Shader *shaderObject = context->getShader(shader);
2883
2884 if (!shaderObject)
2885 {
Geoff Langb1196682014-07-23 13:47:29 -04002886 context->recordError(gl::Error(GL_INVALID_OPERATION));
2887 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002888 }
2889
Tibor den Ouden97049c62014-10-06 21:39:16 +02002890 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2891 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002892 }
2893}
2894
Kenneth Russell67ea1902014-10-06 16:44:50 -07002895const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002896{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002897 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002898
Geoff Langbfdea662014-07-23 14:16:32 -04002899 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002900
Geoff Langbfdea662014-07-23 14:16:32 -04002901 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002902 {
Geoff Langbfdea662014-07-23 14:16:32 -04002903 case GL_VENDOR:
2904 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002905
Geoff Langbfdea662014-07-23 14:16:32 -04002906 case GL_RENDERER:
2907 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002908
Geoff Langbfdea662014-07-23 14:16:32 -04002909 case GL_VERSION:
2910 if (context->getClientVersion() == 2)
2911 {
2912 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2913 }
2914 else
2915 {
2916 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2917 }
Geoff Langb1196682014-07-23 13:47:29 -04002918
Geoff Langbfdea662014-07-23 14:16:32 -04002919 case GL_SHADING_LANGUAGE_VERSION:
2920 if (context->getClientVersion() == 2)
2921 {
2922 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2923 }
2924 else
2925 {
2926 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2927 }
Geoff Langb1196682014-07-23 13:47:29 -04002928
Geoff Langbfdea662014-07-23 14:16:32 -04002929 case GL_EXTENSIONS:
2930 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002931
Geoff Langbfdea662014-07-23 14:16:32 -04002932 default:
Geoff Langb1196682014-07-23 13:47:29 -04002933 if (context)
2934 {
2935 context->recordError(gl::Error(GL_INVALID_ENUM));
2936 }
2937 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002938 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002939}
2940
Kenneth Russell67ea1902014-10-06 16:44:50 -07002941void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002942{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002943 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 +00002944
Geoff Langbfdea662014-07-23 14:16:32 -04002945 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002946 if (context)
2947 {
2948 gl::Texture *texture = context->getTargetTexture(target);
2949
2950 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002951 {
Geoff Langb1196682014-07-23 13:47:29 -04002952 context->recordError(gl::Error(GL_INVALID_ENUM));
2953 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002954 }
Geoff Langbfdea662014-07-23 14:16:32 -04002955
2956 switch (pname)
2957 {
2958 case GL_TEXTURE_MAG_FILTER:
2959 *params = (GLfloat)texture->getSamplerState().magFilter;
2960 break;
2961 case GL_TEXTURE_MIN_FILTER:
2962 *params = (GLfloat)texture->getSamplerState().minFilter;
2963 break;
2964 case GL_TEXTURE_WRAP_S:
2965 *params = (GLfloat)texture->getSamplerState().wrapS;
2966 break;
2967 case GL_TEXTURE_WRAP_T:
2968 *params = (GLfloat)texture->getSamplerState().wrapT;
2969 break;
2970 case GL_TEXTURE_WRAP_R:
2971 if (context->getClientVersion() < 3)
2972 {
Geoff Langb1196682014-07-23 13:47:29 -04002973 context->recordError(gl::Error(GL_INVALID_ENUM));
2974 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002975 }
2976 *params = (GLfloat)texture->getSamplerState().wrapR;
2977 break;
2978 case GL_TEXTURE_IMMUTABLE_FORMAT:
2979 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
2980 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
2981 break;
2982 case GL_TEXTURE_IMMUTABLE_LEVELS:
2983 if (context->getClientVersion() < 3)
2984 {
Geoff Langb1196682014-07-23 13:47:29 -04002985 context->recordError(gl::Error(GL_INVALID_ENUM));
2986 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002987 }
2988 *params = (GLfloat)texture->immutableLevelCount();
2989 break;
2990 case GL_TEXTURE_USAGE_ANGLE:
2991 *params = (GLfloat)texture->getUsage();
2992 break;
2993 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
2994 if (!context->getExtensions().textureFilterAnisotropic)
2995 {
Geoff Langb1196682014-07-23 13:47:29 -04002996 context->recordError(gl::Error(GL_INVALID_ENUM));
2997 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002998 }
2999 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3000 break;
3001 case GL_TEXTURE_SWIZZLE_R:
3002 if (context->getClientVersion() < 3)
3003 {
Geoff Langb1196682014-07-23 13:47:29 -04003004 context->recordError(gl::Error(GL_INVALID_ENUM));
3005 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003006 }
3007 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3008 break;
3009 case GL_TEXTURE_SWIZZLE_G:
3010 if (context->getClientVersion() < 3)
3011 {
Geoff Langb1196682014-07-23 13:47:29 -04003012 context->recordError(gl::Error(GL_INVALID_ENUM));
3013 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003014 }
3015 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3016 break;
3017 case GL_TEXTURE_SWIZZLE_B:
3018 if (context->getClientVersion() < 3)
3019 {
Geoff Langb1196682014-07-23 13:47:29 -04003020 context->recordError(gl::Error(GL_INVALID_ENUM));
3021 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003022 }
3023 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3024 break;
3025 case GL_TEXTURE_SWIZZLE_A:
3026 if (context->getClientVersion() < 3)
3027 {
Geoff Langb1196682014-07-23 13:47:29 -04003028 context->recordError(gl::Error(GL_INVALID_ENUM));
3029 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003030 }
3031 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3032 break;
3033 case GL_TEXTURE_BASE_LEVEL:
3034 if (context->getClientVersion() < 3)
3035 {
Geoff Langb1196682014-07-23 13:47:29 -04003036 context->recordError(gl::Error(GL_INVALID_ENUM));
3037 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003038 }
3039 *params = (GLfloat)texture->getSamplerState().baseLevel;
3040 break;
3041 case GL_TEXTURE_MAX_LEVEL:
3042 if (context->getClientVersion() < 3)
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().maxLevel;
3048 break;
3049 case GL_TEXTURE_MIN_LOD:
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 = texture->getSamplerState().minLod;
3056 break;
3057 case GL_TEXTURE_MAX_LOD:
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 = texture->getSamplerState().maxLod;
3064 break;
Geoff Langb1196682014-07-23 13:47:29 -04003065
Geoff Langbfdea662014-07-23 14:16:32 -04003066 default:
Geoff Langb1196682014-07-23 13:47:29 -04003067 context->recordError(gl::Error(GL_INVALID_ENUM));
3068 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003069 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003070 }
3071}
3072
Kenneth Russell67ea1902014-10-06 16:44:50 -07003073void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003074{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003075 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 +00003076
Geoff Langbfdea662014-07-23 14:16:32 -04003077 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003078 if (context)
3079 {
3080 gl::Texture *texture = context->getTargetTexture(target);
3081
3082 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003083 {
Geoff Langb1196682014-07-23 13:47:29 -04003084 context->recordError(gl::Error(GL_INVALID_ENUM));
3085 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003086 }
Geoff Langbfdea662014-07-23 14:16:32 -04003087
3088 switch (pname)
3089 {
3090 case GL_TEXTURE_MAG_FILTER:
3091 *params = texture->getSamplerState().magFilter;
3092 break;
3093 case GL_TEXTURE_MIN_FILTER:
3094 *params = texture->getSamplerState().minFilter;
3095 break;
3096 case GL_TEXTURE_WRAP_S:
3097 *params = texture->getSamplerState().wrapS;
3098 break;
3099 case GL_TEXTURE_WRAP_T:
3100 *params = texture->getSamplerState().wrapT;
3101 break;
3102 case GL_TEXTURE_WRAP_R:
3103 if (context->getClientVersion() < 3)
3104 {
Geoff Langb1196682014-07-23 13:47:29 -04003105 context->recordError(gl::Error(GL_INVALID_ENUM));
3106 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003107 }
3108 *params = texture->getSamplerState().wrapR;
3109 break;
3110 case GL_TEXTURE_IMMUTABLE_FORMAT:
3111 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3112 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3113 break;
3114 case GL_TEXTURE_IMMUTABLE_LEVELS:
3115 if (context->getClientVersion() < 3)
3116 {
Geoff Langb1196682014-07-23 13:47:29 -04003117 context->recordError(gl::Error(GL_INVALID_ENUM));
3118 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003119 }
Jamie Madill6948e302014-10-20 17:04:33 -04003120 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003121 break;
3122 case GL_TEXTURE_USAGE_ANGLE:
3123 *params = texture->getUsage();
3124 break;
3125 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3126 if (!context->getExtensions().textureFilterAnisotropic)
3127 {
Geoff Langb1196682014-07-23 13:47:29 -04003128 context->recordError(gl::Error(GL_INVALID_ENUM));
3129 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003130 }
3131 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3132 break;
3133 case GL_TEXTURE_SWIZZLE_R:
3134 if (context->getClientVersion() < 3)
3135 {
Geoff Langb1196682014-07-23 13:47:29 -04003136 context->recordError(gl::Error(GL_INVALID_ENUM));
3137 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003138 }
3139 *params = texture->getSamplerState().swizzleRed;
3140 break;
3141 case GL_TEXTURE_SWIZZLE_G:
3142 if (context->getClientVersion() < 3)
3143 {
Geoff Langb1196682014-07-23 13:47:29 -04003144 context->recordError(gl::Error(GL_INVALID_ENUM));
3145 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003146 }
3147 *params = texture->getSamplerState().swizzleGreen;
3148 break;
3149 case GL_TEXTURE_SWIZZLE_B:
3150 if (context->getClientVersion() < 3)
3151 {
Geoff Langb1196682014-07-23 13:47:29 -04003152 context->recordError(gl::Error(GL_INVALID_ENUM));
3153 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003154 }
3155 *params = texture->getSamplerState().swizzleBlue;
3156 break;
3157 case GL_TEXTURE_SWIZZLE_A:
3158 if (context->getClientVersion() < 3)
3159 {
Geoff Langb1196682014-07-23 13:47:29 -04003160 context->recordError(gl::Error(GL_INVALID_ENUM));
3161 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003162 }
3163 *params = texture->getSamplerState().swizzleAlpha;
3164 break;
3165 case GL_TEXTURE_BASE_LEVEL:
3166 if (context->getClientVersion() < 3)
3167 {
Geoff Langb1196682014-07-23 13:47:29 -04003168 context->recordError(gl::Error(GL_INVALID_ENUM));
3169 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003170 }
3171 *params = texture->getSamplerState().baseLevel;
3172 break;
3173 case GL_TEXTURE_MAX_LEVEL:
3174 if (context->getClientVersion() < 3)
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 = texture->getSamplerState().maxLevel;
3180 break;
3181 case GL_TEXTURE_MIN_LOD:
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 = (GLint)texture->getSamplerState().minLod;
3188 break;
3189 case GL_TEXTURE_MAX_LOD:
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 = (GLint)texture->getSamplerState().maxLod;
3196 break;
Geoff Langb1196682014-07-23 13:47:29 -04003197
Geoff Langbfdea662014-07-23 14:16:32 -04003198 default:
Geoff Langb1196682014-07-23 13:47:29 -04003199 context->recordError(gl::Error(GL_INVALID_ENUM));
3200 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003201 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003202 }
3203}
3204
Kenneth Russell67ea1902014-10-06 16:44:50 -07003205void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003206{
3207 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3208 program, location, bufSize, params);
3209
Geoff Langbfdea662014-07-23 14:16:32 -04003210 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003211 if (context)
3212 {
Jamie Madill0063c512014-08-25 15:47:53 -04003213 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003214 {
Jamie Madill0063c512014-08-25 15:47:53 -04003215 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003216 }
3217
Jamie Madilla502c742014-08-28 17:19:13 -04003218 gl::Program *programObject = context->getProgram(program);
3219 ASSERT(programObject);
3220 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003221 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003222
Jamie Madill99a1e982014-08-25 15:47:54 -04003223 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003224 }
3225}
3226
Kenneth Russell67ea1902014-10-06 16:44:50 -07003227void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003228{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003229 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003230
Geoff Langbfdea662014-07-23 14:16:32 -04003231 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003232 if (context)
3233 {
Jamie Madill0063c512014-08-25 15:47:53 -04003234 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003235 {
Jamie Madill0063c512014-08-25 15:47:53 -04003236 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003237 }
Geoff Langbfdea662014-07-23 14:16:32 -04003238
Jamie Madilla502c742014-08-28 17:19:13 -04003239 gl::Program *programObject = context->getProgram(program);
3240 ASSERT(programObject);
3241 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003242 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003243
Jamie Madill99a1e982014-08-25 15:47:54 -04003244 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003245 }
3246}
3247
Kenneth Russell67ea1902014-10-06 16:44:50 -07003248void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003249{
Geoff Langbfdea662014-07-23 14:16:32 -04003250 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003251 program, location, bufSize, params);
3252
Geoff Langbfdea662014-07-23 14:16:32 -04003253 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003254 if (context)
3255 {
Jamie Madill0063c512014-08-25 15:47:53 -04003256 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003257 {
Jamie Madill0063c512014-08-25 15:47:53 -04003258 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003259 }
3260
Jamie Madilla502c742014-08-28 17:19:13 -04003261 gl::Program *programObject = context->getProgram(program);
3262 ASSERT(programObject);
3263 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003264 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003265
Jamie Madill99a1e982014-08-25 15:47:54 -04003266 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003267 }
3268}
3269
Kenneth Russell67ea1902014-10-06 16:44:50 -07003270void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003271{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003272 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003273
Geoff Langbfdea662014-07-23 14:16:32 -04003274 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003275 if (context)
3276 {
Jamie Madill0063c512014-08-25 15:47:53 -04003277 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003278 {
Jamie Madill0063c512014-08-25 15:47:53 -04003279 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003280 }
Geoff Langbfdea662014-07-23 14:16:32 -04003281
Jamie Madilla502c742014-08-28 17:19:13 -04003282 gl::Program *programObject = context->getProgram(program);
3283 ASSERT(programObject);
3284 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003285 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003286
Jamie Madill99a1e982014-08-25 15:47:54 -04003287 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003288 }
3289}
3290
Kenneth Russell67ea1902014-10-06 16:44:50 -07003291GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003293 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003294
Geoff Langbfdea662014-07-23 14:16:32 -04003295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003296 if (context)
3297 {
Geoff Langb1196682014-07-23 13:47:29 -04003298 if (strstr(name, "gl_") == name)
3299 {
3300 return -1;
3301 }
3302
Geoff Langbfdea662014-07-23 14:16:32 -04003303 gl::Program *programObject = context->getProgram(program);
3304
3305 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003306 {
Geoff Langbfdea662014-07-23 14:16:32 -04003307 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003308 {
Geoff Langb1196682014-07-23 13:47:29 -04003309 context->recordError(gl::Error(GL_INVALID_OPERATION));
3310 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003311 }
Geoff Langbfdea662014-07-23 14:16:32 -04003312 else
3313 {
Geoff Langb1196682014-07-23 13:47:29 -04003314 context->recordError(gl::Error(GL_INVALID_VALUE));
3315 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003317 }
Geoff Langbfdea662014-07-23 14:16:32 -04003318
3319 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3320 if (!programObject->isLinked() || !programBinary)
3321 {
Geoff Langb1196682014-07-23 13:47:29 -04003322 context->recordError(gl::Error(GL_INVALID_OPERATION));
3323 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003324 }
3325
3326 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003327 }
3328
3329 return -1;
3330}
3331
Kenneth Russell67ea1902014-10-06 16:44:50 -07003332void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003333{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003334 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003335
Geoff Langbfdea662014-07-23 14:16:32 -04003336 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003337 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003338 {
Geoff Langbfdea662014-07-23 14:16:32 -04003339 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003340 {
Geoff Langb1196682014-07-23 13:47:29 -04003341 context->recordError(gl::Error(GL_INVALID_VALUE));
3342 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003343 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003344
Geoff Langbfdea662014-07-23 14:16:32 -04003345 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003346 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003347 {
3348 return;
3349 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003350
Geoff Langbfdea662014-07-23 14:16:32 -04003351 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3352 {
3353 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3354 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003355 {
Geoff Langbfdea662014-07-23 14:16:32 -04003356 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003357 }
3358 }
Geoff Langbfdea662014-07-23 14:16:32 -04003359 else
3360 {
3361 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3362 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003363 }
3364}
3365
Kenneth Russell67ea1902014-10-06 16:44:50 -07003366void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003367{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003368 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003369
Geoff Langbfdea662014-07-23 14:16:32 -04003370 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003371 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003372 {
Geoff Langbfdea662014-07-23 14:16:32 -04003373 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003374 {
Geoff Langb1196682014-07-23 13:47:29 -04003375 context->recordError(gl::Error(GL_INVALID_VALUE));
3376 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003377 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003378
Geoff Langbfdea662014-07-23 14:16:32 -04003379 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003380
Geoff Langb1196682014-07-23 13:47:29 -04003381 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003382 {
3383 return;
3384 }
Jamie Madillaff71502013-07-02 11:57:05 -04003385
Geoff Langbfdea662014-07-23 14:16:32 -04003386 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3387 {
3388 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3389 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003390 {
Geoff Langbfdea662014-07-23 14:16:32 -04003391 float currentValue = currentValueData.FloatValues[i];
3392 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003393 }
3394 }
Geoff Langbfdea662014-07-23 14:16:32 -04003395 else
3396 {
3397 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3398 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003399 }
3400}
3401
Kenneth Russell67ea1902014-10-06 16:44:50 -07003402void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003403{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003404 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003405
Geoff Langbfdea662014-07-23 14:16:32 -04003406 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003407 if (context)
3408 {
3409 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003410 {
Geoff Langb1196682014-07-23 13:47:29 -04003411 context->recordError(gl::Error(GL_INVALID_VALUE));
3412 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003413 }
Geoff Langbfdea662014-07-23 14:16:32 -04003414
3415 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3416 {
Geoff Langb1196682014-07-23 13:47:29 -04003417 context->recordError(gl::Error(GL_INVALID_ENUM));
3418 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003419 }
3420
3421 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003422 }
3423}
3424
Kenneth Russell67ea1902014-10-06 16:44:50 -07003425void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003426{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003427 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003428
Geoff Langbfdea662014-07-23 14:16:32 -04003429 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003430 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003431 {
Geoff Langb1196682014-07-23 13:47:29 -04003432 switch (mode)
3433 {
3434 case GL_FASTEST:
3435 case GL_NICEST:
3436 case GL_DONT_CARE:
3437 break;
3438
3439 default:
3440 context->recordError(gl::Error(GL_INVALID_ENUM));
3441 return;
3442 }
3443
3444 switch (target)
3445 {
3446 case GL_GENERATE_MIPMAP_HINT:
3447 context->getState().setGenerateMipmapHint(mode);
3448 break;
3449
3450 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3451 context->getState().setFragmentShaderDerivativeHint(mode);
3452 break;
3453
3454 default:
3455 context->recordError(gl::Error(GL_INVALID_ENUM));
3456 return;
3457 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003458 }
3459}
3460
Kenneth Russell67ea1902014-10-06 16:44:50 -07003461GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003463 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003464
Geoff Langbfdea662014-07-23 14:16:32 -04003465 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003466 if (context && buffer)
3467 {
3468 gl::Buffer *bufferObject = context->getBuffer(buffer);
3469
3470 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003471 {
Geoff Langbfdea662014-07-23 14:16:32 -04003472 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003473 }
3474 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003475
3476 return GL_FALSE;
3477}
3478
Kenneth Russell67ea1902014-10-06 16:44:50 -07003479GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003481 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003482
Geoff Langbfdea662014-07-23 14:16:32 -04003483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003484 if (context)
3485 {
3486 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003487 {
Geoff Langb1196682014-07-23 13:47:29 -04003488 context->recordError(gl::Error(GL_INVALID_ENUM));
3489 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003490 }
Geoff Langbfdea662014-07-23 14:16:32 -04003491
3492 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003493 }
3494
3495 return false;
3496}
3497
Kenneth Russell67ea1902014-10-06 16:44:50 -07003498GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003499{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003500 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003501
Geoff Langbfdea662014-07-23 14:16:32 -04003502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003503 if (context)
3504 {
3505 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3506
3507 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003508 {
Geoff Langbfdea662014-07-23 14:16:32 -04003509 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003510 }
Geoff Langbfdea662014-07-23 14:16:32 -04003511
3512 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003513 }
3514
3515 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003516}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003517
Kenneth Russell67ea1902014-10-06 16:44:50 -07003518GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003519{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003520 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521
Geoff Langbfdea662014-07-23 14:16:32 -04003522 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003523 if (context && framebuffer)
3524 {
3525 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3526
3527 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003528 {
Geoff Langbfdea662014-07-23 14:16:32 -04003529 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003530 }
3531 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003532
3533 return GL_FALSE;
3534}
3535
Kenneth Russell67ea1902014-10-06 16:44:50 -07003536GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003538 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003539
Geoff Langbfdea662014-07-23 14:16:32 -04003540 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003541 if (context && program)
3542 {
3543 gl::Program *programObject = context->getProgram(program);
3544
3545 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003546 {
Geoff Langbfdea662014-07-23 14:16:32 -04003547 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003548 }
3549 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550
3551 return GL_FALSE;
3552}
3553
Kenneth Russell67ea1902014-10-06 16:44:50 -07003554GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003555{
3556 EVENT("(GLuint id = %d)", id);
3557
Geoff Langbfdea662014-07-23 14:16:32 -04003558 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003559 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003560 {
Geoff Langbfdea662014-07-23 14:16:32 -04003561 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003562 }
3563
3564 return GL_FALSE;
3565}
3566
Kenneth Russell67ea1902014-10-06 16:44:50 -07003567GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003568{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003569 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003570
Geoff Langbfdea662014-07-23 14:16:32 -04003571 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003572 if (context && renderbuffer)
3573 {
3574 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3575
3576 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003577 {
Geoff Langbfdea662014-07-23 14:16:32 -04003578 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003579 }
3580 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003581
3582 return GL_FALSE;
3583}
3584
Kenneth Russell67ea1902014-10-06 16:44:50 -07003585GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003586{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003587 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003588
Geoff Langbfdea662014-07-23 14:16:32 -04003589 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003590 if (context && shader)
3591 {
3592 gl::Shader *shaderObject = context->getShader(shader);
3593
3594 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003595 {
Geoff Langbfdea662014-07-23 14:16:32 -04003596 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003597 }
3598 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003599
3600 return GL_FALSE;
3601}
3602
Kenneth Russell67ea1902014-10-06 16:44:50 -07003603GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003604{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003605 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003606
Geoff Langbfdea662014-07-23 14:16:32 -04003607 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003608 if (context && texture)
3609 {
3610 gl::Texture *textureObject = context->getTexture(texture);
3611
3612 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003613 {
Geoff Langbfdea662014-07-23 14:16:32 -04003614 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003615 }
3616 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003617
3618 return GL_FALSE;
3619}
3620
Kenneth Russell67ea1902014-10-06 16:44:50 -07003621void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003622{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003623 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003624
Geoff Langbfdea662014-07-23 14:16:32 -04003625 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003626 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003627 {
Geoff Langb1196682014-07-23 13:47:29 -04003628 if (width <= 0.0f)
3629 {
3630 context->recordError(gl::Error(GL_INVALID_VALUE));
3631 return;
3632 }
3633
Geoff Langbfdea662014-07-23 14:16:32 -04003634 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003635 }
3636}
3637
Kenneth Russell67ea1902014-10-06 16:44:50 -07003638void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003639{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003640 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003641
Geoff Langbfdea662014-07-23 14:16:32 -04003642 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003643 if (context)
3644 {
3645 gl::Program *programObject = context->getProgram(program);
3646
3647 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003648 {
Geoff Langbfdea662014-07-23 14:16:32 -04003649 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003650 {
Geoff Langb1196682014-07-23 13:47:29 -04003651 context->recordError(gl::Error(GL_INVALID_OPERATION));
3652 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003653 }
Geoff Langbfdea662014-07-23 14:16:32 -04003654 else
3655 {
Geoff Langb1196682014-07-23 13:47:29 -04003656 context->recordError(gl::Error(GL_INVALID_VALUE));
3657 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003659 }
Geoff Langbfdea662014-07-23 14:16:32 -04003660
Geoff Langb543aff2014-09-30 14:52:54 -04003661 gl::Error error = context->linkProgram(program);
3662 if (error.isError())
3663 {
3664 context->recordError(error);
3665 return;
3666 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003667 }
3668}
3669
Kenneth Russell67ea1902014-10-06 16:44:50 -07003670void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003671{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003672 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003673
Geoff Langbfdea662014-07-23 14:16:32 -04003674 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003675 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003676 {
Geoff Langbfdea662014-07-23 14:16:32 -04003677 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003678 {
Geoff Langbfdea662014-07-23 14:16:32 -04003679 case GL_UNPACK_ALIGNMENT:
3680 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003681 {
Geoff Langb1196682014-07-23 13:47:29 -04003682 context->recordError(gl::Error(GL_INVALID_VALUE));
3683 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003684 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003685
Geoff Langbfdea662014-07-23 14:16:32 -04003686 context->getState().setUnpackAlignment(param);
3687 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003688
Geoff Langbfdea662014-07-23 14:16:32 -04003689 case GL_PACK_ALIGNMENT:
3690 if (param != 1 && param != 2 && param != 4 && param != 8)
3691 {
Geoff Langb1196682014-07-23 13:47:29 -04003692 context->recordError(gl::Error(GL_INVALID_VALUE));
3693 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003694 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003695
Geoff Langbfdea662014-07-23 14:16:32 -04003696 context->getState().setPackAlignment(param);
3697 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003698
Geoff Langbfdea662014-07-23 14:16:32 -04003699 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3700 context->getState().setPackReverseRowOrder(param != 0);
3701 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003702
Geoff Langbfdea662014-07-23 14:16:32 -04003703 case GL_UNPACK_IMAGE_HEIGHT:
3704 case GL_UNPACK_SKIP_IMAGES:
3705 case GL_UNPACK_ROW_LENGTH:
3706 case GL_UNPACK_SKIP_ROWS:
3707 case GL_UNPACK_SKIP_PIXELS:
3708 case GL_PACK_ROW_LENGTH:
3709 case GL_PACK_SKIP_ROWS:
3710 case GL_PACK_SKIP_PIXELS:
3711 if (context->getClientVersion() < 3)
3712 {
Geoff Langb1196682014-07-23 13:47:29 -04003713 context->recordError(gl::Error(GL_INVALID_ENUM));
3714 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003715 }
Geoff Langbfdea662014-07-23 14:16:32 -04003716 UNIMPLEMENTED();
3717 break;
3718
3719 default:
Geoff Langb1196682014-07-23 13:47:29 -04003720 context->recordError(gl::Error(GL_INVALID_ENUM));
3721 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003722 }
3723 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724}
3725
Kenneth Russell67ea1902014-10-06 16:44:50 -07003726void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003727{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003728 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003729
Geoff Langbfdea662014-07-23 14:16:32 -04003730 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003731 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003732 {
Geoff Langbfdea662014-07-23 14:16:32 -04003733 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003734 }
3735}
3736
Kenneth Russell67ea1902014-10-06 16:44:50 -07003737void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003738 GLenum format, GLenum type, GLsizei bufSize,
3739 GLvoid *data)
3740{
3741 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3742 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3743 x, y, width, height, format, type, bufSize, data);
3744
Geoff Langbfdea662014-07-23 14:16:32 -04003745 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003746 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003747 {
Geoff Langb1196682014-07-23 13:47:29 -04003748 if (width < 0 || height < 0 || bufSize < 0)
3749 {
3750 context->recordError(gl::Error(GL_INVALID_VALUE));
3751 return;
3752 }
3753
Geoff Langbfdea662014-07-23 14:16:32 -04003754 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3755 format, type, &bufSize, data))
3756 {
3757 return;
3758 }
3759
Geoff Lang63d2fc72014-07-25 14:51:41 -04003760 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3761 if (error.isError())
3762 {
3763 context->recordError(error);
3764 return;
3765 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003766 }
3767}
3768
Kenneth Russell67ea1902014-10-06 16:44:50 -07003769void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003770 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003771{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003772 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003773 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003774 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003775
Geoff Langbfdea662014-07-23 14:16:32 -04003776 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003777 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003778 {
Geoff Langb1196682014-07-23 13:47:29 -04003779 if (width < 0 || height < 0)
3780 {
3781 context->recordError(gl::Error(GL_INVALID_VALUE));
3782 return;
3783 }
3784
Geoff Langbfdea662014-07-23 14:16:32 -04003785 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3786 format, type, NULL, pixels))
3787 {
3788 return;
3789 }
3790
Geoff Lang63d2fc72014-07-25 14:51:41 -04003791 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3792 if (error.isError())
3793 {
3794 context->recordError(error);
3795 return;
3796 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003797 }
3798}
3799
Kenneth Russell67ea1902014-10-06 16:44:50 -07003800void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003801{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003802 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003803
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003804 gl::Context *context = gl::getNonLostContext();
3805
3806 if (context)
3807 {
3808 context->releaseShaderCompiler();
3809 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003810}
3811
Kenneth Russell67ea1902014-10-06 16:44:50 -07003812void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003813{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003814 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 +00003815 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003816
Geoff Langbfdea662014-07-23 14:16:32 -04003817 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003818 if (context)
3819 {
Corentin Walleze0902642014-11-04 12:32:15 -08003820 if (!ValidateRenderbufferStorageParametersANGLE(context, target, samples, internalformat,
3821 width, height))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003822 {
Geoff Langbfdea662014-07-23 14:16:32 -04003823 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003824 }
Geoff Langbfdea662014-07-23 14:16:32 -04003825
Shannon Woodse2632d22014-10-17 13:08:51 -04003826 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
Geoff Langbafefdf2014-10-10 14:26:35 -04003827 gl::Error error = renderbuffer->setStorage(width, height, internalformat, samples);
3828 if (error.isError())
3829 {
3830 context->recordError(error);
3831 return;
3832 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003833 }
3834}
3835
Kenneth Russell67ea1902014-10-06 16:44:50 -07003836void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003837{
3838 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3839}
3840
Kenneth Russell67ea1902014-10-06 16:44:50 -07003841void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003842{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003843 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003844
Geoff Langbfdea662014-07-23 14:16:32 -04003845 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003846
Geoff Langbfdea662014-07-23 14:16:32 -04003847 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003848 {
Geoff Langbfdea662014-07-23 14:16:32 -04003849 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850 }
3851}
3852
Kenneth Russell67ea1902014-10-06 16:44:50 -07003853void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003854{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003855 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003856
Geoff Langbfdea662014-07-23 14:16:32 -04003857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003858 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003859 {
Geoff Langb1196682014-07-23 13:47:29 -04003860 if (condition != GL_ALL_COMPLETED_NV)
3861 {
3862 context->recordError(gl::Error(GL_INVALID_ENUM));
3863 return;
3864 }
3865
Geoff Langbfdea662014-07-23 14:16:32 -04003866 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3867
3868 if (fenceObject == NULL)
3869 {
Geoff Langb1196682014-07-23 13:47:29 -04003870 context->recordError(gl::Error(GL_INVALID_OPERATION));
3871 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003872 }
3873
Geoff Lang882033e2014-09-30 11:26:07 -04003874 gl::Error error = fenceObject->setFence(condition);
3875 if (error.isError())
3876 {
3877 context->recordError(error);
3878 return;
3879 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003880 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003881}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003882
Kenneth Russell67ea1902014-10-06 16:44:50 -07003883void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003884{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003885 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 +00003886
Geoff Langbfdea662014-07-23 14:16:32 -04003887 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003888 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003889 {
Geoff Langb1196682014-07-23 13:47:29 -04003890 if (width < 0 || height < 0)
3891 {
3892 context->recordError(gl::Error(GL_INVALID_VALUE));
3893 return;
3894 }
3895
Geoff Langbfdea662014-07-23 14:16:32 -04003896 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003897 }
3898}
3899
Kenneth Russell67ea1902014-10-06 16:44:50 -07003900void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003901{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003902 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003903 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003904 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003905
Geoff Lang900013c2014-07-07 11:32:19 -04003906 gl::Context* context = gl::getNonLostContext();
3907 if (context)
3908 {
3909 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3910 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3911 {
Geoff Langb1196682014-07-23 13:47:29 -04003912 context->recordError(gl::Error(GL_INVALID_ENUM));
3913 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003914 }
3915
3916 // No binary shader formats are supported.
3917 UNIMPLEMENTED();
3918 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003919}
3920
Kenneth Russell67ea1902014-10-06 16:44:50 -07003921void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003922{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003923 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 +00003924 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003925
Geoff Langbfdea662014-07-23 14:16:32 -04003926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003927 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003928 {
Geoff Langb1196682014-07-23 13:47:29 -04003929 if (count < 0)
3930 {
3931 context->recordError(gl::Error(GL_INVALID_VALUE));
3932 return;
3933 }
3934
Geoff Langbfdea662014-07-23 14:16:32 -04003935 gl::Shader *shaderObject = context->getShader(shader);
3936
3937 if (!shaderObject)
3938 {
3939 if (context->getProgram(shader))
3940 {
Geoff Langb1196682014-07-23 13:47:29 -04003941 context->recordError(gl::Error(GL_INVALID_OPERATION));
3942 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003943 }
3944 else
3945 {
Geoff Langb1196682014-07-23 13:47:29 -04003946 context->recordError(gl::Error(GL_INVALID_VALUE));
3947 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003948 }
3949 }
3950
3951 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003952 }
3953}
3954
Kenneth Russell67ea1902014-10-06 16:44:50 -07003955void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003956{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003957 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003958}
3959
Kenneth Russell67ea1902014-10-06 16:44:50 -07003960void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003961{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003962 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 +00003963
Geoff Langbfdea662014-07-23 14:16:32 -04003964 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003965 if (context)
3966 {
Geoff Langb1196682014-07-23 13:47:29 -04003967 switch (face)
3968 {
3969 case GL_FRONT:
3970 case GL_BACK:
3971 case GL_FRONT_AND_BACK:
3972 break;
3973
3974 default:
3975 context->recordError(gl::Error(GL_INVALID_ENUM));
3976 return;
3977 }
3978
3979 switch (func)
3980 {
3981 case GL_NEVER:
3982 case GL_ALWAYS:
3983 case GL_LESS:
3984 case GL_LEQUAL:
3985 case GL_EQUAL:
3986 case GL_GEQUAL:
3987 case GL_GREATER:
3988 case GL_NOTEQUAL:
3989 break;
3990
3991 default:
3992 context->recordError(gl::Error(GL_INVALID_ENUM));
3993 return;
3994 }
3995
Geoff Langbfdea662014-07-23 14:16:32 -04003996 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
3997 {
3998 context->getState().setStencilParams(func, ref, mask);
3999 }
4000
4001 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4002 {
4003 context->getState().setStencilBackParams(func, ref, mask);
4004 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004005 }
4006}
4007
Kenneth Russell67ea1902014-10-06 16:44:50 -07004008void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009{
4010 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4011}
4012
Kenneth Russell67ea1902014-10-06 16:44:50 -07004013void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004015 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004016
Geoff Langbfdea662014-07-23 14:16:32 -04004017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004018 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004019 {
Geoff Langb1196682014-07-23 13:47:29 -04004020 switch (face)
4021 {
4022 case GL_FRONT:
4023 case GL_BACK:
4024 case GL_FRONT_AND_BACK:
4025 break;
4026
4027 default:
4028 context->recordError(gl::Error(GL_INVALID_ENUM));
4029 return;
4030 }
4031
Geoff Langbfdea662014-07-23 14:16:32 -04004032 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4033 {
4034 context->getState().setStencilWritemask(mask);
4035 }
4036
4037 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4038 {
4039 context->getState().setStencilBackWritemask(mask);
4040 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004041 }
4042}
4043
Kenneth Russell67ea1902014-10-06 16:44:50 -07004044void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004045{
4046 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4047}
4048
Kenneth Russell67ea1902014-10-06 16:44:50 -07004049void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004050{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004051 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 +00004052 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004053
Geoff Langbfdea662014-07-23 14:16:32 -04004054 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004055 if (context)
4056 {
Geoff Langb1196682014-07-23 13:47:29 -04004057 switch (face)
4058 {
4059 case GL_FRONT:
4060 case GL_BACK:
4061 case GL_FRONT_AND_BACK:
4062 break;
4063
4064 default:
4065 context->recordError(gl::Error(GL_INVALID_ENUM));
4066 return;
4067 }
4068
4069 switch (fail)
4070 {
4071 case GL_ZERO:
4072 case GL_KEEP:
4073 case GL_REPLACE:
4074 case GL_INCR:
4075 case GL_DECR:
4076 case GL_INVERT:
4077 case GL_INCR_WRAP:
4078 case GL_DECR_WRAP:
4079 break;
4080
4081 default:
4082 context->recordError(gl::Error(GL_INVALID_ENUM));
4083 return;
4084 }
4085
4086 switch (zfail)
4087 {
4088 case GL_ZERO:
4089 case GL_KEEP:
4090 case GL_REPLACE:
4091 case GL_INCR:
4092 case GL_DECR:
4093 case GL_INVERT:
4094 case GL_INCR_WRAP:
4095 case GL_DECR_WRAP:
4096 break;
4097
4098 default:
4099 context->recordError(gl::Error(GL_INVALID_ENUM));
4100 return;
4101 }
4102
4103 switch (zpass)
4104 {
4105 case GL_ZERO:
4106 case GL_KEEP:
4107 case GL_REPLACE:
4108 case GL_INCR:
4109 case GL_DECR:
4110 case GL_INVERT:
4111 case GL_INCR_WRAP:
4112 case GL_DECR_WRAP:
4113 break;
4114
4115 default:
4116 context->recordError(gl::Error(GL_INVALID_ENUM));
4117 return;
4118 }
4119
Geoff Langbfdea662014-07-23 14:16:32 -04004120 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4121 {
4122 context->getState().setStencilOperations(fail, zfail, zpass);
4123 }
4124
4125 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4126 {
4127 context->getState().setStencilBackOperations(fail, zfail, zpass);
4128 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004129 }
4130}
4131
Kenneth Russell67ea1902014-10-06 16:44:50 -07004132GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004133{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004134 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004135
Geoff Langbfdea662014-07-23 14:16:32 -04004136 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004137 if (context)
4138 {
4139 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4140
4141 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004142 {
Geoff Langb1196682014-07-23 13:47:29 -04004143 context->recordError(gl::Error(GL_INVALID_OPERATION));
4144 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004145 }
Geoff Langbfdea662014-07-23 14:16:32 -04004146
4147 if (fenceObject->isFence() != GL_TRUE)
4148 {
Geoff Langb1196682014-07-23 13:47:29 -04004149 context->recordError(gl::Error(GL_INVALID_OPERATION));
4150 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004151 }
4152
Geoff Lang882033e2014-09-30 11:26:07 -04004153 GLboolean result;
4154 gl::Error error = fenceObject->testFence(&result);
4155 if (error.isError())
4156 {
4157 context->recordError(error);
4158 return GL_TRUE;
4159 }
4160
4161 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004162 }
Geoff Langbfdea662014-07-23 14:16:32 -04004163
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004164 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004165}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004166
Kenneth Russell67ea1902014-10-06 16:44:50 -07004167void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004168 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004169{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004170 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004171 "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 +00004172 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004173
Geoff Langbfdea662014-07-23 14:16:32 -04004174 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004175 if (context)
4176 {
4177 if (context->getClientVersion() < 3 &&
4178 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4179 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004180 {
Geoff Langbfdea662014-07-23 14:16:32 -04004181 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004182 }
Geoff Langbfdea662014-07-23 14:16:32 -04004183
4184 if (context->getClientVersion() >= 3 &&
4185 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4186 0, 0, 0, width, height, 1, border, format, type, pixels))
4187 {
4188 return;
4189 }
4190
4191 switch (target)
4192 {
4193 case GL_TEXTURE_2D:
4194 {
4195 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004196 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4197 if (error.isError())
4198 {
4199 context->recordError(error);
4200 return;
4201 }
Geoff Langbfdea662014-07-23 14:16:32 -04004202 }
4203 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004204
Geoff Langbfdea662014-07-23 14:16:32 -04004205 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004206 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004207 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004208 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004209 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004210 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4211 {
4212 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004213 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004214 if (error.isError())
4215 {
4216 context->recordError(error);
4217 return;
4218 }
Geoff Langbfdea662014-07-23 14:16:32 -04004219 }
4220 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004221
Geoff Langbfdea662014-07-23 14:16:32 -04004222 default: UNREACHABLE();
4223 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004224 }
4225}
4226
Kenneth Russell67ea1902014-10-06 16:44:50 -07004227void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004228{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004229 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4230
Geoff Langbfdea662014-07-23 14:16:32 -04004231 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004232 if (context)
4233 {
4234 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004235 {
Geoff Langbfdea662014-07-23 14:16:32 -04004236 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004237 }
Geoff Langbfdea662014-07-23 14:16:32 -04004238
4239 gl::Texture *texture = context->getTargetTexture(target);
4240
4241 if (!texture)
4242 {
Geoff Langb1196682014-07-23 13:47:29 -04004243 context->recordError(gl::Error(GL_INVALID_ENUM));
4244 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004245 }
4246
4247 switch (pname)
4248 {
4249 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4250 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4251 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4252 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4253 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4254 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4255 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4256 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4257 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4258 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4259 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4260 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4261 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4262 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4263 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4264 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4265 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4266 default: UNREACHABLE(); break;
4267 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004268 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004269}
4270
Kenneth Russell67ea1902014-10-06 16:44:50 -07004271void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004272{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004273 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004274}
4275
Kenneth Russell67ea1902014-10-06 16:44:50 -07004276void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004277{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004278 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004279
Geoff Langbfdea662014-07-23 14:16:32 -04004280 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004281 if (context)
4282 {
4283 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004284 {
Geoff Langbfdea662014-07-23 14:16:32 -04004285 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004286 }
Geoff Langbfdea662014-07-23 14:16:32 -04004287
4288 gl::Texture *texture = context->getTargetTexture(target);
4289
4290 if (!texture)
4291 {
Geoff Langb1196682014-07-23 13:47:29 -04004292 context->recordError(gl::Error(GL_INVALID_ENUM));
4293 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004294 }
4295
4296 switch (pname)
4297 {
4298 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4299 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4300 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4301 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4302 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4303 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4304 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4305 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4306 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4307 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4308 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4309 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4310 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4311 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4312 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4313 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4314 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4315 default: UNREACHABLE(); break;
4316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004317 }
4318}
4319
Kenneth Russell67ea1902014-10-06 16:44:50 -07004320void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004321{
4322 glTexParameteri(target, pname, *params);
4323}
4324
Kenneth Russell67ea1902014-10-06 16:44:50 -07004325void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004326{
4327 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4328 target, levels, internalformat, width, height);
4329
Geoff Langbfdea662014-07-23 14:16:32 -04004330 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004331 if (context)
4332 {
4333 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004334 {
Geoff Langb1196682014-07-23 13:47:29 -04004335 context->recordError(gl::Error(GL_INVALID_OPERATION));
4336 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004337 }
Geoff Langbfdea662014-07-23 14:16:32 -04004338
4339 if (context->getClientVersion() < 3 &&
4340 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4341 {
4342 return;
4343 }
4344
4345 if (context->getClientVersion() >= 3 &&
4346 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4347 {
4348 return;
4349 }
4350
4351 switch (target)
4352 {
4353 case GL_TEXTURE_2D:
4354 {
4355 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004356 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4357 if (error.isError())
4358 {
4359 context->recordError(error);
4360 return;
4361 }
Geoff Langbfdea662014-07-23 14:16:32 -04004362 }
4363 break;
4364
4365 case GL_TEXTURE_CUBE_MAP:
4366 {
4367 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004368 gl::Error error = textureCube->storage(levels, internalformat, width);
4369 if (error.isError())
4370 {
4371 context->recordError(error);
4372 return;
4373 }
Geoff Langbfdea662014-07-23 14:16:32 -04004374 }
4375 break;
4376
4377 default:
Geoff Langb1196682014-07-23 13:47:29 -04004378 context->recordError(gl::Error(GL_INVALID_ENUM));
4379 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004380 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004381 }
4382}
4383
Kenneth Russell67ea1902014-10-06 16:44:50 -07004384void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004385 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004386{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004387 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004388 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004389 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004390 target, level, xoffset, yoffset, width, height, format, type, pixels);
4391
Geoff Langbfdea662014-07-23 14:16:32 -04004392 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004393 if (context)
4394 {
4395 if (context->getClientVersion() < 3 &&
4396 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4397 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004398 {
Geoff Langbfdea662014-07-23 14:16:32 -04004399 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004400 }
Geoff Langbfdea662014-07-23 14:16:32 -04004401
4402 if (context->getClientVersion() >= 3 &&
4403 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4404 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4405 {
4406 return;
4407 }
4408
4409 // Zero sized uploads are valid but no-ops
4410 if (width == 0 || height == 0)
4411 {
4412 return;
4413 }
4414
4415 switch (target)
4416 {
4417 case GL_TEXTURE_2D:
4418 {
4419 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004420 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4421 if (error.isError())
4422 {
4423 context->recordError(error);
4424 return;
4425 }
Geoff Langbfdea662014-07-23 14:16:32 -04004426 }
4427 break;
4428
4429 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4430 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4431 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4432 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4433 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4434 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4435 {
4436 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004437 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4438 if (error.isError())
4439 {
4440 context->recordError(error);
4441 return;
4442 }
Geoff Langbfdea662014-07-23 14:16:32 -04004443 }
4444 break;
4445
4446 default:
4447 UNREACHABLE();
4448 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004449 }
4450}
4451
Kenneth Russell67ea1902014-10-06 16:44:50 -07004452void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004453{
4454 glUniform1fv(location, 1, &x);
4455}
4456
Kenneth Russell67ea1902014-10-06 16:44:50 -07004457void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004458{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004459 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004460
Geoff Langbfdea662014-07-23 14:16:32 -04004461 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004462 if (context)
4463 {
4464 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004465 {
Geoff Langbfdea662014-07-23 14:16:32 -04004466 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004467 }
Geoff Langbfdea662014-07-23 14:16:32 -04004468
4469 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4470 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004471 }
4472}
4473
Kenneth Russell67ea1902014-10-06 16:44:50 -07004474void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004475{
4476 glUniform1iv(location, 1, &x);
4477}
4478
Kenneth Russell67ea1902014-10-06 16:44:50 -07004479void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004481 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004482
Geoff Langbfdea662014-07-23 14:16:32 -04004483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004484 if (context)
4485 {
4486 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004487 {
Geoff Langbfdea662014-07-23 14:16:32 -04004488 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004489 }
Geoff Langbfdea662014-07-23 14:16:32 -04004490
4491 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4492 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004493 }
4494}
4495
Kenneth Russell67ea1902014-10-06 16:44:50 -07004496void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004497{
4498 GLfloat xy[2] = {x, y};
4499
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004500 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501}
4502
Kenneth Russell67ea1902014-10-06 16:44:50 -07004503void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004504{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004505 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004506
Geoff Langbfdea662014-07-23 14:16:32 -04004507 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004508 if (context)
4509 {
4510 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004511 {
Geoff Langbfdea662014-07-23 14:16:32 -04004512 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004513 }
Geoff Langbfdea662014-07-23 14:16:32 -04004514
4515 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4516 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004517 }
4518}
4519
Kenneth Russell67ea1902014-10-06 16:44:50 -07004520void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004522 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004524 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004525}
4526
Kenneth Russell67ea1902014-10-06 16:44:50 -07004527void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004529 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004530
Geoff Langbfdea662014-07-23 14:16:32 -04004531 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004532 if (context)
4533 {
4534 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004535 {
Geoff Langbfdea662014-07-23 14:16:32 -04004536 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004537 }
Geoff Langbfdea662014-07-23 14:16:32 -04004538
4539 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4540 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004541 }
4542}
4543
Kenneth Russell67ea1902014-10-06 16:44:50 -07004544void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545{
4546 GLfloat xyz[3] = {x, y, z};
4547
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004548 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004549}
4550
Kenneth Russell67ea1902014-10-06 16:44:50 -07004551void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004552{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004553 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004554
Geoff Langbfdea662014-07-23 14:16:32 -04004555 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004556 if (context)
4557 {
4558 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559 {
Geoff Langbfdea662014-07-23 14:16:32 -04004560 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004561 }
Geoff Langbfdea662014-07-23 14:16:32 -04004562
4563 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4564 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004565 }
4566}
4567
Kenneth Russell67ea1902014-10-06 16:44:50 -07004568void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004569{
4570 GLint xyz[3] = {x, y, z};
4571
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004572 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004573}
4574
Kenneth Russell67ea1902014-10-06 16:44:50 -07004575void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004576{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004577 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004578
Geoff Langbfdea662014-07-23 14:16:32 -04004579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004580 if (context)
4581 {
4582 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004583 {
Geoff Langbfdea662014-07-23 14:16:32 -04004584 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004585 }
Geoff Langbfdea662014-07-23 14:16:32 -04004586
4587 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4588 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004589 }
4590}
4591
Kenneth Russell67ea1902014-10-06 16:44:50 -07004592void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593{
4594 GLfloat xyzw[4] = {x, y, z, w};
4595
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004596 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004597}
4598
Kenneth Russell67ea1902014-10-06 16:44:50 -07004599void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004600{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004601 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004602
Geoff Langbfdea662014-07-23 14:16:32 -04004603 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004604 if (context)
4605 {
4606 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004607 {
Geoff Langbfdea662014-07-23 14:16:32 -04004608 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609 }
Geoff Langbfdea662014-07-23 14:16:32 -04004610
4611 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4612 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004613 }
4614}
4615
Kenneth Russell67ea1902014-10-06 16:44:50 -07004616void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004617{
4618 GLint xyzw[4] = {x, y, z, w};
4619
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004620 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004621}
4622
Kenneth Russell67ea1902014-10-06 16:44:50 -07004623void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004624{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004625 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004626
Geoff Langbfdea662014-07-23 14:16:32 -04004627 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004628 if (context)
4629 {
4630 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004631 {
Geoff Langbfdea662014-07-23 14:16:32 -04004632 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004633 }
Geoff Langbfdea662014-07-23 14:16:32 -04004634
4635 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4636 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004637 }
4638}
4639
Kenneth Russell67ea1902014-10-06 16:44:50 -07004640void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004642 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004643 location, count, transpose, value);
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 (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
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->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655 }
4656}
4657
Kenneth Russell67ea1902014-10-06 16:44:50 -07004658void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004660 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004661 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662
Geoff Langbfdea662014-07-23 14:16:32 -04004663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004664 if (context)
4665 {
4666 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004667 {
Geoff Langbfdea662014-07-23 14:16:32 -04004668 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004669 }
Geoff Langbfdea662014-07-23 14:16:32 -04004670
4671 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4672 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004673 }
4674}
4675
Kenneth Russell67ea1902014-10-06 16:44:50 -07004676void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004677{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004678 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004679 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680
Geoff Langbfdea662014-07-23 14:16:32 -04004681 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004682 if (context)
4683 {
4684 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004685 {
Geoff Langbfdea662014-07-23 14:16:32 -04004686 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004687 }
Geoff Langbfdea662014-07-23 14:16:32 -04004688
4689 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4690 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004691 }
4692}
4693
Kenneth Russell67ea1902014-10-06 16:44:50 -07004694void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004695{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004696 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004697
Geoff Langbfdea662014-07-23 14:16:32 -04004698 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004699 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004700 {
Geoff Langbfdea662014-07-23 14:16:32 -04004701 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004702
Geoff Langbfdea662014-07-23 14:16:32 -04004703 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004704 {
Geoff Langbfdea662014-07-23 14:16:32 -04004705 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004706 {
Geoff Langb1196682014-07-23 13:47:29 -04004707 context->recordError(gl::Error(GL_INVALID_OPERATION));
4708 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004709 }
Geoff Langbfdea662014-07-23 14:16:32 -04004710 else
4711 {
Geoff Langb1196682014-07-23 13:47:29 -04004712 context->recordError(gl::Error(GL_INVALID_VALUE));
4713 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004714 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004715 }
Geoff Langbfdea662014-07-23 14:16:32 -04004716
4717 if (program != 0 && !programObject->isLinked())
4718 {
Geoff Langb1196682014-07-23 13:47:29 -04004719 context->recordError(gl::Error(GL_INVALID_OPERATION));
4720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004721 }
4722
4723 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004724 }
4725}
4726
Kenneth Russell67ea1902014-10-06 16:44:50 -07004727void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004728{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004729 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004730
Geoff Langbfdea662014-07-23 14:16:32 -04004731 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004732 if (context)
4733 {
4734 gl::Program *programObject = context->getProgram(program);
4735
4736 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004737 {
Geoff Langbfdea662014-07-23 14:16:32 -04004738 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004739 {
Geoff Langb1196682014-07-23 13:47:29 -04004740 context->recordError(gl::Error(GL_INVALID_OPERATION));
4741 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004742 }
Geoff Langbfdea662014-07-23 14:16:32 -04004743 else
4744 {
Geoff Langb1196682014-07-23 13:47:29 -04004745 context->recordError(gl::Error(GL_INVALID_VALUE));
4746 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004747 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004748 }
Geoff Langbfdea662014-07-23 14:16:32 -04004749
Brandon Jones43a53e22014-08-28 16:23:22 -07004750 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004751 }
4752}
4753
Kenneth Russell67ea1902014-10-06 16:44:50 -07004754void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004755{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004756 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757
Geoff Langbfdea662014-07-23 14:16:32 -04004758 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004759 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004760 {
Geoff Langb1196682014-07-23 13:47:29 -04004761 if (index >= gl::MAX_VERTEX_ATTRIBS)
4762 {
4763 context->recordError(gl::Error(GL_INVALID_VALUE));
4764 return;
4765 }
4766
Geoff Langbfdea662014-07-23 14:16:32 -04004767 GLfloat vals[4] = { x, 0, 0, 1 };
4768 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004769 }
4770}
4771
Kenneth Russell67ea1902014-10-06 16:44:50 -07004772void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004773{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004774 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004775
Geoff Langbfdea662014-07-23 14:16:32 -04004776 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004777 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004778 {
Geoff Langb1196682014-07-23 13:47:29 -04004779 if (index >= gl::MAX_VERTEX_ATTRIBS)
4780 {
4781 context->recordError(gl::Error(GL_INVALID_VALUE));
4782 return;
4783 }
4784
Geoff Langbfdea662014-07-23 14:16:32 -04004785 GLfloat vals[4] = { values[0], 0, 0, 1 };
4786 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004787 }
4788}
4789
Kenneth Russell67ea1902014-10-06 16:44:50 -07004790void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004791{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004792 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004793
Geoff Langbfdea662014-07-23 14:16:32 -04004794 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004795 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004796 {
Geoff Langb1196682014-07-23 13:47:29 -04004797 if (index >= gl::MAX_VERTEX_ATTRIBS)
4798 {
4799 context->recordError(gl::Error(GL_INVALID_VALUE));
4800 return;
4801 }
4802
Geoff Langbfdea662014-07-23 14:16:32 -04004803 GLfloat vals[4] = { x, y, 0, 1 };
4804 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004805 }
4806}
4807
Kenneth Russell67ea1902014-10-06 16:44:50 -07004808void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004810 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004811
Geoff Langbfdea662014-07-23 14:16:32 -04004812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004813 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004814 {
Geoff Langb1196682014-07-23 13:47:29 -04004815 if (index >= gl::MAX_VERTEX_ATTRIBS)
4816 {
4817 context->recordError(gl::Error(GL_INVALID_VALUE));
4818 return;
4819 }
4820
Geoff Langbfdea662014-07-23 14:16:32 -04004821 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4822 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004823 }
4824}
4825
Kenneth Russell67ea1902014-10-06 16:44:50 -07004826void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004827{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004828 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 +00004829
Geoff Langbfdea662014-07-23 14:16:32 -04004830 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004831 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004832 {
Geoff Langb1196682014-07-23 13:47:29 -04004833 if (index >= gl::MAX_VERTEX_ATTRIBS)
4834 {
4835 context->recordError(gl::Error(GL_INVALID_VALUE));
4836 return;
4837 }
4838
Geoff Langbfdea662014-07-23 14:16:32 -04004839 GLfloat vals[4] = { x, y, z, 1 };
4840 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004841 }
4842}
4843
Kenneth Russell67ea1902014-10-06 16:44:50 -07004844void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004845{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004846 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004847
Geoff Langbfdea662014-07-23 14:16:32 -04004848 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004849 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004850 {
Geoff Langb1196682014-07-23 13:47:29 -04004851 if (index >= gl::MAX_VERTEX_ATTRIBS)
4852 {
4853 context->recordError(gl::Error(GL_INVALID_VALUE));
4854 return;
4855 }
4856
Geoff Langbfdea662014-07-23 14:16:32 -04004857 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4858 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004859 }
4860}
4861
Kenneth Russell67ea1902014-10-06 16:44:50 -07004862void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004863{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004864 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 +00004865
Geoff Langbfdea662014-07-23 14:16:32 -04004866 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004867 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004868 {
Geoff Langb1196682014-07-23 13:47:29 -04004869 if (index >= gl::MAX_VERTEX_ATTRIBS)
4870 {
4871 context->recordError(gl::Error(GL_INVALID_VALUE));
4872 return;
4873 }
4874
Geoff Langbfdea662014-07-23 14:16:32 -04004875 GLfloat vals[4] = { x, y, z, w };
4876 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004877 }
4878}
4879
Kenneth Russell67ea1902014-10-06 16:44:50 -07004880void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004881{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004882 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004883
Geoff Langbfdea662014-07-23 14:16:32 -04004884 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004885 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004886 {
Geoff Langb1196682014-07-23 13:47:29 -04004887 if (index >= gl::MAX_VERTEX_ATTRIBS)
4888 {
4889 context->recordError(gl::Error(GL_INVALID_VALUE));
4890 return;
4891 }
4892
Geoff Langbfdea662014-07-23 14:16:32 -04004893 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004894 }
4895}
4896
Kenneth Russell67ea1902014-10-06 16:44:50 -07004897void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004898{
4899 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4900
Geoff Langbfdea662014-07-23 14:16:32 -04004901 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004902 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004903 {
Geoff Langb1196682014-07-23 13:47:29 -04004904 if (index >= gl::MAX_VERTEX_ATTRIBS)
4905 {
4906 context->recordError(gl::Error(GL_INVALID_VALUE));
4907 return;
4908 }
4909
Geoff Langbfdea662014-07-23 14:16:32 -04004910 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004911 }
4912}
4913
Kenneth Russell67ea1902014-10-06 16:44:50 -07004914void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004916 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004917 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004918 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004919
Geoff Langbfdea662014-07-23 14:16:32 -04004920 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004921 if (context)
4922 {
Geoff Langb1196682014-07-23 13:47:29 -04004923 if (index >= gl::MAX_VERTEX_ATTRIBS)
4924 {
4925 context->recordError(gl::Error(GL_INVALID_VALUE));
4926 return;
4927 }
4928
4929 if (size < 1 || size > 4)
4930 {
4931 context->recordError(gl::Error(GL_INVALID_VALUE));
4932 return;
4933 }
4934
4935 switch (type)
4936 {
4937 case GL_BYTE:
4938 case GL_UNSIGNED_BYTE:
4939 case GL_SHORT:
4940 case GL_UNSIGNED_SHORT:
4941 case GL_FIXED:
4942 case GL_FLOAT:
4943 break;
4944
4945 case GL_HALF_FLOAT:
4946 case GL_INT:
4947 case GL_UNSIGNED_INT:
4948 case GL_INT_2_10_10_10_REV:
4949 case GL_UNSIGNED_INT_2_10_10_10_REV:
4950 if (context->getClientVersion() < 3)
4951 {
4952 context->recordError(gl::Error(GL_INVALID_ENUM));
4953 return;
4954 }
4955 break;
4956
4957 default:
4958 context->recordError(gl::Error(GL_INVALID_ENUM));
4959 return;
4960 }
4961
4962 if (stride < 0)
4963 {
4964 context->recordError(gl::Error(GL_INVALID_VALUE));
4965 return;
4966 }
4967
4968 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
4969 {
4970 context->recordError(gl::Error(GL_INVALID_OPERATION));
4971 return;
4972 }
4973
Geoff Langbfdea662014-07-23 14:16:32 -04004974 // [OpenGL ES 3.0.2] Section 2.8 page 24:
4975 // An INVALID_OPERATION error is generated when a non-zero vertex array object
4976 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
4977 // and the pointer argument is not NULL.
4978 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00004979 {
Geoff Langb1196682014-07-23 13:47:29 -04004980 context->recordError(gl::Error(GL_INVALID_OPERATION));
4981 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00004982 }
4983
Geoff Langbfdea662014-07-23 14:16:32 -04004984 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
4985 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004986 }
4987}
4988
Kenneth Russell67ea1902014-10-06 16:44:50 -07004989void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004990{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004991 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 +00004992
Geoff Langbfdea662014-07-23 14:16:32 -04004993 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004994 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004995 {
Geoff Langb1196682014-07-23 13:47:29 -04004996 if (width < 0 || height < 0)
4997 {
4998 context->recordError(gl::Error(GL_INVALID_VALUE));
4999 return;
5000 }
5001
Geoff Langbfdea662014-07-23 14:16:32 -04005002 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005003 }
5004}
5005
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005006// OpenGL ES 3.0 functions
5007
Kenneth Russell67ea1902014-10-06 16:44:50 -07005008void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005009{
5010 EVENT("(GLenum mode = 0x%X)", mode);
5011
Geoff Langbfdea662014-07-23 14:16:32 -04005012 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005013 if (context)
5014 {
5015 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005016 {
Geoff Langb1196682014-07-23 13:47:29 -04005017 context->recordError(gl::Error(GL_INVALID_OPERATION));
5018 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005019 }
Geoff Langbfdea662014-07-23 14:16:32 -04005020
5021 // glReadBuffer
5022 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005023 }
5024}
5025
Kenneth Russell67ea1902014-10-06 16:44:50 -07005026void 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 +00005027{
5028 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5029 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5030
Geoff Langbfdea662014-07-23 14:16:32 -04005031 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005032 if (context)
5033 {
5034 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005035 {
Geoff Langb1196682014-07-23 13:47:29 -04005036 context->recordError(gl::Error(GL_INVALID_OPERATION));
5037 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005038 }
Geoff Langbfdea662014-07-23 14:16:32 -04005039
5040 // glDrawRangeElements
5041 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005042 }
5043}
5044
Kenneth Russell67ea1902014-10-06 16:44:50 -07005045void 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 +00005046{
5047 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5048 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5049 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5050 target, level, internalformat, width, height, depth, border, format, type, pixels);
5051
Geoff Langbfdea662014-07-23 14:16:32 -04005052 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005053 if (context)
5054 {
5055 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005056 {
Geoff Langb1196682014-07-23 13:47:29 -04005057 context->recordError(gl::Error(GL_INVALID_OPERATION));
5058 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005059 }
Geoff Langbfdea662014-07-23 14:16:32 -04005060
5061 // validateES3TexImageFormat sets the error code if there is an error
5062 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5063 0, 0, 0, width, height, depth, border, format, type, pixels))
5064 {
5065 return;
5066 }
5067
5068 switch(target)
5069 {
5070 case GL_TEXTURE_3D:
5071 {
5072 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005073 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5074 if (error.isError())
5075 {
5076 context->recordError(error);
5077 return;
5078 }
Geoff Langbfdea662014-07-23 14:16:32 -04005079 }
5080 break;
5081
5082 case GL_TEXTURE_2D_ARRAY:
5083 {
5084 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005085 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5086 if (error.isError())
5087 {
5088 context->recordError(error);
5089 return;
5090 }
Geoff Langbfdea662014-07-23 14:16:32 -04005091 }
5092 break;
5093
5094 default:
Geoff Langb1196682014-07-23 13:47:29 -04005095 context->recordError(gl::Error(GL_INVALID_ENUM));
5096 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005097 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005098 }
5099}
5100
Kenneth Russell67ea1902014-10-06 16:44:50 -07005101void 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 +00005102{
5103 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5104 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5105 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5106 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5107
Geoff Langbfdea662014-07-23 14:16:32 -04005108 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005109 if (context)
5110 {
5111 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005112 {
Geoff Langb1196682014-07-23 13:47:29 -04005113 context->recordError(gl::Error(GL_INVALID_OPERATION));
5114 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005115 }
Geoff Langbfdea662014-07-23 14:16:32 -04005116
5117 // validateES3TexImageFormat sets the error code if there is an error
5118 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5119 xoffset, yoffset, zoffset, width, height, depth, 0,
5120 format, type, pixels))
5121 {
5122 return;
5123 }
5124
5125 // Zero sized uploads are valid but no-ops
5126 if (width == 0 || height == 0 || depth == 0)
5127 {
5128 return;
5129 }
5130
5131 switch(target)
5132 {
5133 case GL_TEXTURE_3D:
5134 {
5135 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005136 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5137 if (error.isError())
5138 {
5139 context->recordError(error);
5140 return;
5141 }
Geoff Langbfdea662014-07-23 14:16:32 -04005142 }
5143 break;
5144
5145 case GL_TEXTURE_2D_ARRAY:
5146 {
5147 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005148 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5149 if (error.isError())
5150 {
5151 context->recordError(error);
5152 return;
5153 }
Geoff Langbfdea662014-07-23 14:16:32 -04005154 }
5155 break;
5156
5157 default:
Geoff Langb1196682014-07-23 13:47:29 -04005158 context->recordError(gl::Error(GL_INVALID_ENUM));
5159 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005160 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005161 }
5162}
5163
Kenneth Russell67ea1902014-10-06 16:44:50 -07005164void 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 +00005165{
5166 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5167 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5168 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5169
Geoff Langbfdea662014-07-23 14:16:32 -04005170 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005171 if (context)
5172 {
5173 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005174 {
Geoff Langb1196682014-07-23 13:47:29 -04005175 context->recordError(gl::Error(GL_INVALID_OPERATION));
5176 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005177 }
Geoff Langbfdea662014-07-23 14:16:32 -04005178
5179 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5180 x, y, width, height, 0))
5181 {
5182 return;
5183 }
5184
5185 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5186 gl::Texture *texture = NULL;
5187 switch (target)
5188 {
5189 case GL_TEXTURE_3D:
5190 texture = context->getTexture3D();
5191 break;
5192
5193 case GL_TEXTURE_2D_ARRAY:
5194 texture = context->getTexture2DArray();
5195 break;
5196
5197 default:
Geoff Langb1196682014-07-23 13:47:29 -04005198 context->recordError(gl::Error(GL_INVALID_ENUM));
5199 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005200 }
5201
Geoff Langef7b0162014-09-04 13:29:23 -04005202 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5203 if (error.isError())
5204 {
5205 context->recordError(error);
5206 return;
5207 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005208 }
5209}
5210
Kenneth Russell67ea1902014-10-06 16:44:50 -07005211void 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 +00005212{
Geoff Langeef52cc2013-10-16 15:07:39 -04005213 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 +00005214 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5215 "const GLvoid* data = 0x%0.8p)",
5216 target, level, internalformat, width, height, depth, border, imageSize, data);
5217
Geoff Langbfdea662014-07-23 14:16:32 -04005218 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005219 if (context)
5220 {
5221 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005222 {
Geoff Langb1196682014-07-23 13:47:29 -04005223 context->recordError(gl::Error(GL_INVALID_OPERATION));
5224 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005225 }
Geoff Langbfdea662014-07-23 14:16:32 -04005226
Geoff Lang5d601382014-07-22 15:14:06 -04005227 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5228 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005229 {
Geoff Langb1196682014-07-23 13:47:29 -04005230 context->recordError(gl::Error(GL_INVALID_VALUE));
5231 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005232 }
5233
5234 // validateES3TexImageFormat sets the error code if there is an error
5235 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5236 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5237 {
5238 return;
5239 }
5240
5241 switch(target)
5242 {
5243 case GL_TEXTURE_3D:
5244 {
5245 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005246 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005247 if (error.isError())
5248 {
5249 context->recordError(error);
5250 return;
5251 }
Geoff Langbfdea662014-07-23 14:16:32 -04005252 }
5253 break;
5254
5255 case GL_TEXTURE_2D_ARRAY:
5256 {
5257 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005258 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005259 if (error.isError())
5260 {
5261 context->recordError(error);
5262 return;
5263 }
Geoff Langbfdea662014-07-23 14:16:32 -04005264 }
5265 break;
5266
5267 default:
Geoff Langb1196682014-07-23 13:47:29 -04005268 context->recordError(gl::Error(GL_INVALID_ENUM));
5269 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005270 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005271 }
5272}
5273
Kenneth Russell67ea1902014-10-06 16:44:50 -07005274void 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 +00005275{
5276 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5277 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5278 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5279 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5280
Geoff Langbfdea662014-07-23 14:16:32 -04005281 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005282 if (context)
5283 {
5284 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005285 {
Geoff Langb1196682014-07-23 13:47:29 -04005286 context->recordError(gl::Error(GL_INVALID_OPERATION));
5287 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005288 }
Geoff Langbfdea662014-07-23 14:16:32 -04005289
Geoff Lang5d601382014-07-22 15:14:06 -04005290 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5291 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005292 {
Geoff Langb1196682014-07-23 13:47:29 -04005293 context->recordError(gl::Error(GL_INVALID_VALUE));
5294 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005295 }
5296
5297 if (!data)
5298 {
Geoff Langb1196682014-07-23 13:47:29 -04005299 context->recordError(gl::Error(GL_INVALID_VALUE));
5300 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005301 }
5302
5303 // validateES3TexImageFormat sets the error code if there is an error
5304 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5305 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5306 {
5307 return;
5308 }
5309
5310 // Zero sized uploads are valid but no-ops
5311 if (width == 0 || height == 0)
5312 {
5313 return;
5314 }
5315
5316 switch(target)
5317 {
5318 case GL_TEXTURE_3D:
5319 {
5320 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005321 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005322 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005323 if (error.isError())
5324 {
5325 context->recordError(error);
5326 return;
5327 }
Geoff Langbfdea662014-07-23 14:16:32 -04005328 }
5329 break;
5330
5331 case GL_TEXTURE_2D_ARRAY:
5332 {
5333 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005334 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005335 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005336 if (error.isError())
5337 {
5338 context->recordError(error);
5339 return;
5340 }
Geoff Langbfdea662014-07-23 14:16:32 -04005341 }
5342 break;
5343
Geoff Langb1196682014-07-23 13:47:29 -04005344 default:
5345 context->recordError(gl::Error(GL_INVALID_ENUM));
5346 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005347 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005348 }
5349}
5350
Kenneth Russell67ea1902014-10-06 16:44:50 -07005351void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005352{
5353 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5354
Geoff Langbfdea662014-07-23 14:16:32 -04005355 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005356 if (context)
5357 {
5358 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005359 {
Geoff Langb1196682014-07-23 13:47:29 -04005360 context->recordError(gl::Error(GL_INVALID_OPERATION));
5361 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005362 }
Geoff Langbfdea662014-07-23 14:16:32 -04005363
5364 if (n < 0)
5365 {
Geoff Langb1196682014-07-23 13:47:29 -04005366 context->recordError(gl::Error(GL_INVALID_VALUE));
5367 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005368 }
5369
5370 for (GLsizei i = 0; i < n; i++)
5371 {
5372 ids[i] = context->createQuery();
5373 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005374 }
5375}
5376
Kenneth Russell67ea1902014-10-06 16:44:50 -07005377void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005378{
5379 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5380
Geoff Langbfdea662014-07-23 14:16:32 -04005381 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005382 if (context)
5383 {
5384 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005385 {
Geoff Langb1196682014-07-23 13:47:29 -04005386 context->recordError(gl::Error(GL_INVALID_OPERATION));
5387 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005388 }
Geoff Langbfdea662014-07-23 14:16:32 -04005389
5390 if (n < 0)
5391 {
Geoff Langb1196682014-07-23 13:47:29 -04005392 context->recordError(gl::Error(GL_INVALID_VALUE));
5393 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005394 }
5395
5396 for (GLsizei i = 0; i < n; i++)
5397 {
5398 context->deleteQuery(ids[i]);
5399 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005400 }
5401}
5402
Kenneth Russell67ea1902014-10-06 16:44:50 -07005403GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005404{
5405 EVENT("(GLuint id = %u)", id);
5406
Geoff Langbfdea662014-07-23 14:16:32 -04005407 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005408 if (context)
5409 {
5410 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005411 {
Geoff Langb1196682014-07-23 13:47:29 -04005412 context->recordError(gl::Error(GL_INVALID_OPERATION));
5413 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005414 }
Geoff Langbfdea662014-07-23 14:16:32 -04005415
5416 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005417 }
5418
5419 return GL_FALSE;
5420}
5421
Kenneth Russell67ea1902014-10-06 16:44:50 -07005422void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005423{
5424 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5425
Geoff Langbfdea662014-07-23 14:16:32 -04005426 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005427 if (context)
5428 {
5429 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005430 {
Geoff Langb1196682014-07-23 13:47:29 -04005431 context->recordError(gl::Error(GL_INVALID_OPERATION));
5432 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005433 }
Geoff Langbfdea662014-07-23 14:16:32 -04005434
5435 if (!ValidateBeginQuery(context, target, id))
5436 {
5437 return;
5438 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005439
5440 gl::Error error = context->beginQuery(target, id);
5441 if (error.isError())
5442 {
5443 context->recordError(error);
5444 return;
5445 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005446 }
5447}
5448
Kenneth Russell67ea1902014-10-06 16:44:50 -07005449void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005450{
5451 EVENT("(GLenum target = 0x%X)", target);
5452
Geoff Langbfdea662014-07-23 14:16:32 -04005453 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005454 if (context)
5455 {
5456 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005457 {
Geoff Langb1196682014-07-23 13:47:29 -04005458 context->recordError(gl::Error(GL_INVALID_OPERATION));
5459 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005460 }
Geoff Langbfdea662014-07-23 14:16:32 -04005461
5462 if (!ValidateEndQuery(context, target))
5463 {
5464 return;
5465 }
5466
Geoff Lang5aad9672014-09-08 11:10:42 -04005467 gl::Error error = context->endQuery(target);
5468 if (error.isError())
5469 {
5470 context->recordError(error);
5471 return;
5472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005473 }
5474}
5475
Kenneth Russell67ea1902014-10-06 16:44:50 -07005476void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005477{
5478 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5479
Geoff Langbfdea662014-07-23 14:16:32 -04005480 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005481 if (context)
5482 {
5483 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005484 {
Geoff Langb1196682014-07-23 13:47:29 -04005485 context->recordError(gl::Error(GL_INVALID_OPERATION));
5486 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005487 }
Geoff Langbfdea662014-07-23 14:16:32 -04005488
5489 if (!ValidQueryType(context, target))
5490 {
Geoff Langb1196682014-07-23 13:47:29 -04005491 context->recordError(gl::Error(GL_INVALID_ENUM));
5492 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005493 }
5494
5495 switch (pname)
5496 {
5497 case GL_CURRENT_QUERY:
5498 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5499 break;
5500
5501 default:
Geoff Langb1196682014-07-23 13:47:29 -04005502 context->recordError(gl::Error(GL_INVALID_ENUM));
5503 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005504 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005505 }
5506}
5507
Kenneth Russell67ea1902014-10-06 16:44:50 -07005508void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005509{
5510 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5511
Geoff Langbfdea662014-07-23 14:16:32 -04005512 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005513 if (context)
5514 {
5515 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005516 {
Geoff Langb1196682014-07-23 13:47:29 -04005517 context->recordError(gl::Error(GL_INVALID_OPERATION));
5518 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005519 }
Geoff Langbfdea662014-07-23 14:16:32 -04005520
5521 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5522
5523 if (!queryObject)
5524 {
Geoff Langb1196682014-07-23 13:47:29 -04005525 context->recordError(gl::Error(GL_INVALID_OPERATION));
5526 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005527 }
5528
5529 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5530 {
Geoff Langb1196682014-07-23 13:47:29 -04005531 context->recordError(gl::Error(GL_INVALID_OPERATION));
5532 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005533 }
5534
5535 switch(pname)
5536 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005537 case GL_QUERY_RESULT_EXT:
5538 {
5539 gl::Error error = queryObject->getResult(params);
5540 if (error.isError())
5541 {
5542 context->recordError(error);
5543 return;
5544 }
5545 }
Geoff Langbfdea662014-07-23 14:16:32 -04005546 break;
Geoff Langb1196682014-07-23 13:47:29 -04005547
Geoff Lang5aad9672014-09-08 11:10:42 -04005548 case GL_QUERY_RESULT_AVAILABLE_EXT:
5549 {
5550 gl::Error error = queryObject->isResultAvailable(params);
5551 if (error.isError())
5552 {
5553 context->recordError(error);
5554 return;
5555 }
5556 }
Geoff Langbfdea662014-07-23 14:16:32 -04005557 break;
Geoff Langb1196682014-07-23 13:47:29 -04005558
Geoff Langbfdea662014-07-23 14:16:32 -04005559 default:
Geoff Langb1196682014-07-23 13:47:29 -04005560 context->recordError(gl::Error(GL_INVALID_ENUM));
5561 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005562 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005563 }
5564}
5565
Kenneth Russell67ea1902014-10-06 16:44:50 -07005566GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005567{
5568 EVENT("(GLenum target = 0x%X)", target);
5569
Geoff Langbfdea662014-07-23 14:16:32 -04005570 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005571 if (context)
5572 {
5573 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005574 {
Geoff Langb1196682014-07-23 13:47:29 -04005575 context->recordError(gl::Error(GL_INVALID_OPERATION));
5576 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005577 }
Geoff Langbfdea662014-07-23 14:16:32 -04005578
5579 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005580 }
5581
5582 return GL_FALSE;
5583}
5584
Kenneth Russell67ea1902014-10-06 16:44:50 -07005585void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005586{
5587 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5588
Geoff Langbfdea662014-07-23 14:16:32 -04005589 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005590 if (context)
5591 {
5592 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005593 {
Geoff Langb1196682014-07-23 13:47:29 -04005594 context->recordError(gl::Error(GL_INVALID_OPERATION));
5595 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005596 }
Geoff Langbfdea662014-07-23 14:16:32 -04005597
5598 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005599 }
5600}
5601
Kenneth Russell67ea1902014-10-06 16:44:50 -07005602void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005603{
Geoff Langbfdea662014-07-23 14:16:32 -04005604 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005605 if (context)
5606 {
5607 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005608 {
Geoff Langb1196682014-07-23 13:47:29 -04005609 context->recordError(gl::Error(GL_INVALID_OPERATION));
5610 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005611 }
Geoff Langbfdea662014-07-23 14:16:32 -04005612
5613 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005614 }
5615}
5616
Kenneth Russell67ea1902014-10-06 16:44:50 -07005617void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005618{
5619 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5620 location, count, transpose, value);
5621
Geoff Langbfdea662014-07-23 14:16:32 -04005622 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005623 if (context)
5624 {
5625 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005626 {
Geoff Langbfdea662014-07-23 14:16:32 -04005627 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005628 }
Geoff Langbfdea662014-07-23 14:16:32 -04005629
5630 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5631 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005632 }
5633}
5634
Kenneth Russell67ea1902014-10-06 16:44:50 -07005635void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005636{
5637 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5638 location, count, transpose, value);
5639
Geoff Langbfdea662014-07-23 14:16:32 -04005640 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005641 if (context)
5642 {
5643 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005644 {
Geoff Langbfdea662014-07-23 14:16:32 -04005645 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005646 }
Geoff Langbfdea662014-07-23 14:16:32 -04005647
5648 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5649 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005650 }
5651}
5652
Kenneth Russell67ea1902014-10-06 16:44:50 -07005653void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005654{
5655 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5656 location, count, transpose, value);
5657
Geoff Langbfdea662014-07-23 14:16:32 -04005658 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005659 if (context)
5660 {
5661 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005662 {
Geoff Langbfdea662014-07-23 14:16:32 -04005663 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005664 }
Geoff Langbfdea662014-07-23 14:16:32 -04005665
5666 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5667 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005668 }
5669}
5670
Kenneth Russell67ea1902014-10-06 16:44:50 -07005671void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005672{
5673 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5674 location, count, transpose, value);
5675
Geoff Langbfdea662014-07-23 14:16:32 -04005676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005677 if (context)
5678 {
5679 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005680 {
Geoff Langbfdea662014-07-23 14:16:32 -04005681 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005682 }
Geoff Langbfdea662014-07-23 14:16:32 -04005683
5684 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5685 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005686 }
5687}
5688
Kenneth Russell67ea1902014-10-06 16:44:50 -07005689void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005690{
5691 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5692 location, count, transpose, value);
5693
Geoff Langbfdea662014-07-23 14:16:32 -04005694 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005695 if (context)
5696 {
5697 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005698 {
Geoff Langbfdea662014-07-23 14:16:32 -04005699 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005700 }
Geoff Langbfdea662014-07-23 14:16:32 -04005701
5702 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5703 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005704 }
5705}
5706
Kenneth Russell67ea1902014-10-06 16:44:50 -07005707void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005708{
5709 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5710 location, count, transpose, value);
5711
Geoff Langbfdea662014-07-23 14:16:32 -04005712 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005713 if (context)
5714 {
5715 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005716 {
Geoff Langbfdea662014-07-23 14:16:32 -04005717 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005718 }
Geoff Langbfdea662014-07-23 14:16:32 -04005719
5720 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5721 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005722 }
5723}
5724
Kenneth Russell67ea1902014-10-06 16:44:50 -07005725void 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 +00005726{
5727 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5728 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5729 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5730
Geoff Langbfdea662014-07-23 14:16:32 -04005731 gl::Context *context = gl::getNonLostContext();
5732 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005733 {
Geoff Langbfdea662014-07-23 14:16:32 -04005734 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005735 {
Geoff Langb1196682014-07-23 13:47:29 -04005736 context->recordError(gl::Error(GL_INVALID_OPERATION));
5737 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005738 }
Geoff Langbfdea662014-07-23 14:16:32 -04005739
5740 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5741 dstX0, dstY0, dstX1, dstY1, mask, filter,
5742 false))
5743 {
5744 return;
5745 }
5746
Geoff Lang64839152014-08-26 16:23:25 -04005747 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5748 mask, filter);
5749 if (error.isError())
5750 {
5751 context->recordError(error);
5752 return;
5753 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005754 }
5755}
5756
Kenneth Russell67ea1902014-10-06 16:44:50 -07005757void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005758{
5759 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5760 target, samples, internalformat, width, height);
5761
Geoff Langbfdea662014-07-23 14:16:32 -04005762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005763 if (context)
5764 {
5765 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005766 {
Geoff Langb1196682014-07-23 13:47:29 -04005767 context->recordError(gl::Error(GL_INVALID_OPERATION));
5768 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005769 }
Geoff Langbfdea662014-07-23 14:16:32 -04005770
Corentin Walleze0902642014-11-04 12:32:15 -08005771 if (!ValidateES3RenderbufferStorageParameters(context, target, samples, internalformat, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005772 {
5773 return;
5774 }
5775
Shannon Woodse2632d22014-10-17 13:08:51 -04005776 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5777 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005778 }
5779}
5780
Kenneth Russell67ea1902014-10-06 16:44:50 -07005781void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005782{
5783 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5784 target, attachment, texture, level, layer);
5785
Geoff Langbfdea662014-07-23 14:16:32 -04005786 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005787 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005788 {
Geoff Langbfdea662014-07-23 14:16:32 -04005789 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5790 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005791 {
Geoff Langbfdea662014-07-23 14:16:32 -04005792 return;
5793 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005794
Geoff Langbfdea662014-07-23 14:16:32 -04005795 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5796 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005797
Geoff Langab75a052014-10-15 12:56:37 -04005798 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04005799 {
Geoff Langab75a052014-10-15 12:56:37 -04005800 gl::Texture *textureObject = context->getTexture(texture);
5801 gl::ImageIndex index(textureObject->getTarget(), level, layer);
5802 framebuffer->setTextureAttachment(attachment, textureObject, index);
Geoff Langbfdea662014-07-23 14:16:32 -04005803 }
5804 else
5805 {
Geoff Langab75a052014-10-15 12:56:37 -04005806 framebuffer->setNULLAttachment(attachment);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005808 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005809}
5810
Kenneth Russell67ea1902014-10-06 16:44:50 -07005811GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005812{
5813 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5814 target, offset, length, access);
5815
Geoff Langbfdea662014-07-23 14:16:32 -04005816 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005817 if (context)
5818 {
5819 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005820 {
Geoff Langb1196682014-07-23 13:47:29 -04005821 context->recordError(gl::Error(GL_INVALID_OPERATION));
5822 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005823 }
Geoff Langbfdea662014-07-23 14:16:32 -04005824
5825 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005826 }
5827
5828 return NULL;
5829}
5830
Kenneth Russell67ea1902014-10-06 16:44:50 -07005831void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005832{
5833 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5834
Geoff Langbfdea662014-07-23 14:16:32 -04005835 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005836 if (context)
5837 {
5838 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005839 {
Geoff Langb1196682014-07-23 13:47:29 -04005840 context->recordError(gl::Error(GL_INVALID_OPERATION));
5841 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005842 }
Geoff Langbfdea662014-07-23 14:16:32 -04005843
5844 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005845 }
5846}
5847
Kenneth Russell67ea1902014-10-06 16:44:50 -07005848void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005849{
5850 EVENT("(GLuint array = %u)", array);
5851
Geoff Langbfdea662014-07-23 14:16:32 -04005852 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005853 if (context)
5854 {
5855 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005856 {
Geoff Langb1196682014-07-23 13:47:29 -04005857 context->recordError(gl::Error(GL_INVALID_OPERATION));
5858 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005859 }
Geoff Langbfdea662014-07-23 14:16:32 -04005860
5861 gl::VertexArray *vao = context->getVertexArray(array);
5862
5863 if (!vao)
5864 {
5865 // The default VAO should always exist
5866 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005867 context->recordError(gl::Error(GL_INVALID_OPERATION));
5868 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005869 }
5870
5871 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005872 }
5873}
5874
Kenneth Russell67ea1902014-10-06 16:44:50 -07005875void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005876{
5877 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5878
Geoff Langbfdea662014-07-23 14:16:32 -04005879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005880 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005881 {
Geoff Langbfdea662014-07-23 14:16:32 -04005882 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005883 {
Geoff Langb1196682014-07-23 13:47:29 -04005884 context->recordError(gl::Error(GL_INVALID_OPERATION));
5885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005886 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005887
Geoff Langbfdea662014-07-23 14:16:32 -04005888 if (n < 0)
5889 {
Geoff Langb1196682014-07-23 13:47:29 -04005890 context->recordError(gl::Error(GL_INVALID_VALUE));
5891 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005892 }
Jamie Madilld1028542013-07-02 11:57:04 -04005893
Geoff Langbfdea662014-07-23 14:16:32 -04005894 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5895 {
5896 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005897 {
Geoff Langbfdea662014-07-23 14:16:32 -04005898 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005899 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005900 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005901 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005902}
5903
Kenneth Russell67ea1902014-10-06 16:44:50 -07005904void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005905{
5906 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5907
Geoff Langbfdea662014-07-23 14:16:32 -04005908 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005909 if (context)
5910 {
5911 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005912 {
Geoff Langb1196682014-07-23 13:47:29 -04005913 context->recordError(gl::Error(GL_INVALID_OPERATION));
5914 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005915 }
Geoff Langbfdea662014-07-23 14:16:32 -04005916
5917 if (n < 0)
5918 {
Geoff Langb1196682014-07-23 13:47:29 -04005919 context->recordError(gl::Error(GL_INVALID_VALUE));
5920 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005921 }
5922
5923 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5924 {
5925 arrays[arrayIndex] = context->createVertexArray();
5926 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005927 }
5928}
5929
Kenneth Russell67ea1902014-10-06 16:44:50 -07005930GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005931{
5932 EVENT("(GLuint array = %u)", array);
5933
Geoff Langbfdea662014-07-23 14:16:32 -04005934 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005935 if (context)
5936 {
5937 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005938 {
Geoff Langb1196682014-07-23 13:47:29 -04005939 context->recordError(gl::Error(GL_INVALID_OPERATION));
5940 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005941 }
Geoff Langbfdea662014-07-23 14:16:32 -04005942
5943 if (array == 0)
5944 {
5945 return GL_FALSE;
5946 }
5947
5948 gl::VertexArray *vao = context->getVertexArray(array);
5949
5950 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005951 }
5952
5953 return GL_FALSE;
5954}
5955
Kenneth Russell67ea1902014-10-06 16:44:50 -07005956void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005957{
5958 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
5959 target, index, data);
5960
Geoff Langbfdea662014-07-23 14:16:32 -04005961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005962 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005963 {
Geoff Langbfdea662014-07-23 14:16:32 -04005964 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005965 {
Geoff Langb1196682014-07-23 13:47:29 -04005966 context->recordError(gl::Error(GL_INVALID_OPERATION));
5967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005968 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005969
Geoff Lang3a61c322014-07-10 13:01:54 -04005970 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04005971 switch (target)
5972 {
5973 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
5974 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
5975 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04005976 if (index >= caps.maxTransformFeedbackSeparateAttributes)
5977 {
Geoff Langb1196682014-07-23 13:47:29 -04005978 context->recordError(gl::Error(GL_INVALID_VALUE));
5979 return;
Geoff Lang05881a02014-07-10 14:05:30 -04005980 }
Geoff Langbfdea662014-07-23 14:16:32 -04005981 break;
Geoff Langb1196682014-07-23 13:47:29 -04005982
Geoff Langbfdea662014-07-23 14:16:32 -04005983 case GL_UNIFORM_BUFFER_START:
5984 case GL_UNIFORM_BUFFER_SIZE:
5985 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04005986 if (index >= caps.maxCombinedUniformBlocks)
5987 {
Geoff Langb1196682014-07-23 13:47:29 -04005988 context->recordError(gl::Error(GL_INVALID_VALUE));
5989 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04005990 }
Geoff Langbfdea662014-07-23 14:16:32 -04005991 break;
Geoff Langb1196682014-07-23 13:47:29 -04005992
Geoff Langbfdea662014-07-23 14:16:32 -04005993 default:
Geoff Langb1196682014-07-23 13:47:29 -04005994 context->recordError(gl::Error(GL_INVALID_ENUM));
5995 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005996 }
5997
5998 if (!(context->getIndexedIntegerv(target, index, data)))
5999 {
6000 GLenum nativeType;
6001 unsigned int numParams = 0;
6002 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006003 {
6004 context->recordError(gl::Error(GL_INVALID_ENUM));
6005 return;
6006 }
Shannon Woods15934d52013-08-19 14:28:49 -04006007
Geoff Langbfdea662014-07-23 14:16:32 -04006008 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006009 {
Geoff Langbfdea662014-07-23 14:16:32 -04006010 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006011 }
Geoff Langbfdea662014-07-23 14:16:32 -04006012
6013 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006014 {
Geoff Langbfdea662014-07-23 14:16:32 -04006015 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6016 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6017 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006018
Geoff Langbfdea662014-07-23 14:16:32 -04006019 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006020
Geoff Langbfdea662014-07-23 14:16:32 -04006021 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006022 {
Geoff Langbfdea662014-07-23 14:16:32 -04006023 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6024 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006025 }
Geoff Langbfdea662014-07-23 14:16:32 -04006026
6027 delete [] int64Params;
6028 }
6029 else
6030 {
6031 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006032 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006033 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006034 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006035}
6036
Kenneth Russell67ea1902014-10-06 16:44:50 -07006037void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006038{
6039 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6040
Geoff Langbfdea662014-07-23 14:16:32 -04006041 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006042 if (context)
6043 {
6044 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006045 {
Geoff Langb1196682014-07-23 13:47:29 -04006046 context->recordError(gl::Error(GL_INVALID_OPERATION));
6047 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006048 }
Geoff Langbfdea662014-07-23 14:16:32 -04006049
6050 switch (primitiveMode)
6051 {
6052 case GL_TRIANGLES:
6053 case GL_LINES:
6054 case GL_POINTS:
6055 break;
Geoff Langb1196682014-07-23 13:47:29 -04006056
Geoff Langbfdea662014-07-23 14:16:32 -04006057 default:
Geoff Langb1196682014-07-23 13:47:29 -04006058 context->recordError(gl::Error(GL_INVALID_ENUM));
6059 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006060 }
6061
6062 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6063 ASSERT(transformFeedback != NULL);
6064
6065 if (transformFeedback->isStarted())
6066 {
Geoff Langb1196682014-07-23 13:47:29 -04006067 context->recordError(gl::Error(GL_INVALID_OPERATION));
6068 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006069 }
6070
6071 if (transformFeedback->isPaused())
6072 {
6073 transformFeedback->resume();
6074 }
6075 else
6076 {
6077 transformFeedback->start(primitiveMode);
6078 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006079 }
6080}
6081
Kenneth Russell67ea1902014-10-06 16:44:50 -07006082void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006083{
6084 EVENT("(void)");
6085
Geoff Langbfdea662014-07-23 14:16:32 -04006086 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006087 if (context)
6088 {
6089 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006090 {
Geoff Langb1196682014-07-23 13:47:29 -04006091 context->recordError(gl::Error(GL_INVALID_OPERATION));
6092 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006093 }
Geoff Langbfdea662014-07-23 14:16:32 -04006094
6095 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6096 ASSERT(transformFeedback != NULL);
6097
6098 if (!transformFeedback->isStarted())
6099 {
Geoff Langb1196682014-07-23 13:47:29 -04006100 context->recordError(gl::Error(GL_INVALID_OPERATION));
6101 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006102 }
6103
6104 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006105 }
6106}
6107
Kenneth Russell67ea1902014-10-06 16:44:50 -07006108void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006109{
6110 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6111 target, index, buffer, offset, size);
6112
Geoff Langbfdea662014-07-23 14:16:32 -04006113 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006114 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006115 {
Geoff Langbfdea662014-07-23 14:16:32 -04006116 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006117 {
Geoff Langb1196682014-07-23 13:47:29 -04006118 context->recordError(gl::Error(GL_INVALID_OPERATION));
6119 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006120 }
6121
Geoff Lang3a61c322014-07-10 13:01:54 -04006122 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006123 switch (target)
6124 {
6125 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006126 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006127 {
Geoff Langb1196682014-07-23 13:47:29 -04006128 context->recordError(gl::Error(GL_INVALID_VALUE));
6129 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006130 }
Geoff Langbfdea662014-07-23 14:16:32 -04006131 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006132
Geoff Langbfdea662014-07-23 14:16:32 -04006133 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006134 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006135 {
Geoff Langb1196682014-07-23 13:47:29 -04006136 context->recordError(gl::Error(GL_INVALID_VALUE));
6137 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006138 }
Geoff Langbfdea662014-07-23 14:16:32 -04006139 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006140
Geoff Langbfdea662014-07-23 14:16:32 -04006141 default:
Geoff Langb1196682014-07-23 13:47:29 -04006142 context->recordError(gl::Error(GL_INVALID_ENUM));
6143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006144 }
6145
6146 if (buffer != 0 && size <= 0)
6147 {
Geoff Langb1196682014-07-23 13:47:29 -04006148 context->recordError(gl::Error(GL_INVALID_VALUE));
6149 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006150 }
6151
6152 switch (target)
6153 {
6154 case GL_TRANSFORM_FEEDBACK_BUFFER:
6155
6156 // size and offset must be a multiple of 4
6157 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006158 {
Geoff Langb1196682014-07-23 13:47:29 -04006159 context->recordError(gl::Error(GL_INVALID_VALUE));
6160 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006161 }
6162
Geoff Langbfdea662014-07-23 14:16:32 -04006163 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6164 context->bindGenericTransformFeedbackBuffer(buffer);
6165 break;
6166
6167 case GL_UNIFORM_BUFFER:
6168
6169 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006170 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006171 {
Geoff Langb1196682014-07-23 13:47:29 -04006172 context->recordError(gl::Error(GL_INVALID_VALUE));
6173 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006174 }
Geoff Langbfdea662014-07-23 14:16:32 -04006175
6176 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6177 context->bindGenericUniformBuffer(buffer);
6178 break;
6179
6180 default:
6181 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006182 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006183 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006184}
6185
Kenneth Russell67ea1902014-10-06 16:44:50 -07006186void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006187{
6188 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6189 target, index, buffer);
6190
Geoff Langbfdea662014-07-23 14:16:32 -04006191 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006192 if (context)
6193 {
6194 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006195 {
Geoff Langb1196682014-07-23 13:47:29 -04006196 context->recordError(gl::Error(GL_INVALID_OPERATION));
6197 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006198 }
Geoff Langbfdea662014-07-23 14:16:32 -04006199
Geoff Lang3a61c322014-07-10 13:01:54 -04006200 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006201 switch (target)
6202 {
6203 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006204 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006205 {
Geoff Langb1196682014-07-23 13:47:29 -04006206 context->recordError(gl::Error(GL_INVALID_VALUE));
6207 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006208 }
6209 break;
6210
6211 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006212 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006213 {
Geoff Langb1196682014-07-23 13:47:29 -04006214 context->recordError(gl::Error(GL_INVALID_VALUE));
6215 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006216 }
6217 break;
6218
6219 default:
Geoff Langb1196682014-07-23 13:47:29 -04006220 context->recordError(gl::Error(GL_INVALID_ENUM));
6221 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006222 }
6223
6224 switch (target)
6225 {
6226 case GL_TRANSFORM_FEEDBACK_BUFFER:
6227 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6228 context->bindGenericTransformFeedbackBuffer(buffer);
6229 break;
6230
6231 case GL_UNIFORM_BUFFER:
6232 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6233 context->bindGenericUniformBuffer(buffer);
6234 break;
6235
6236 default:
6237 UNREACHABLE();
6238 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006239 }
6240}
6241
Kenneth Russell67ea1902014-10-06 16:44:50 -07006242void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006243{
6244 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6245 program, count, varyings, bufferMode);
6246
Geoff Langbfdea662014-07-23 14:16:32 -04006247 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006248 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006249 {
Geoff Langbfdea662014-07-23 14:16:32 -04006250 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006251 {
Geoff Langb1196682014-07-23 13:47:29 -04006252 context->recordError(gl::Error(GL_INVALID_OPERATION));
6253 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006254 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006255
Geoff Langbfdea662014-07-23 14:16:32 -04006256 if (count < 0)
6257 {
Geoff Langb1196682014-07-23 13:47:29 -04006258 context->recordError(gl::Error(GL_INVALID_VALUE));
6259 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006260 }
6261
Geoff Lang05881a02014-07-10 14:05:30 -04006262 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006263 switch (bufferMode)
6264 {
6265 case GL_INTERLEAVED_ATTRIBS:
6266 break;
6267 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006268 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006269 {
Geoff Langb1196682014-07-23 13:47:29 -04006270 context->recordError(gl::Error(GL_INVALID_VALUE));
6271 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006272 }
Geoff Langbfdea662014-07-23 14:16:32 -04006273 break;
6274 default:
Geoff Langb1196682014-07-23 13:47:29 -04006275 context->recordError(gl::Error(GL_INVALID_ENUM));
6276 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006277 }
Geoff Langbfdea662014-07-23 14:16:32 -04006278
6279 if (!gl::ValidProgram(context, program))
6280 {
6281 return;
6282 }
6283
6284 gl::Program *programObject = context->getProgram(program);
6285 ASSERT(programObject);
6286
6287 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006288 }
6289}
6290
Kenneth Russell67ea1902014-10-06 16:44:50 -07006291void 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 +00006292{
6293 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6294 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6295 program, index, bufSize, length, size, type, name);
6296
Geoff Langbfdea662014-07-23 14:16:32 -04006297 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006298 if (context)
6299 {
6300 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006301 {
Geoff Langb1196682014-07-23 13:47:29 -04006302 context->recordError(gl::Error(GL_INVALID_OPERATION));
6303 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006304 }
Geoff Langbfdea662014-07-23 14:16:32 -04006305
6306 if (bufSize < 0)
6307 {
Geoff Langb1196682014-07-23 13:47:29 -04006308 context->recordError(gl::Error(GL_INVALID_VALUE));
6309 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006310 }
6311
6312 if (!gl::ValidProgram(context, program))
6313 {
6314 return;
6315 }
6316
6317 gl::Program *programObject = context->getProgram(program);
6318 ASSERT(programObject);
6319
6320 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6321 {
Geoff Langb1196682014-07-23 13:47:29 -04006322 context->recordError(gl::Error(GL_INVALID_VALUE));
6323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006324 }
6325
6326 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006327 }
6328}
6329
Kenneth Russell67ea1902014-10-06 16:44:50 -07006330void 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 +00006331{
6332 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6333 index, size, type, stride, pointer);
6334
Geoff Langbfdea662014-07-23 14:16:32 -04006335 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006336 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006337 {
Geoff Langbfdea662014-07-23 14:16:32 -04006338 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006339 {
Geoff Langb1196682014-07-23 13:47:29 -04006340 context->recordError(gl::Error(GL_INVALID_OPERATION));
6341 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006342 }
6343
Geoff Langb1196682014-07-23 13:47:29 -04006344 if (index >= gl::MAX_VERTEX_ATTRIBS)
6345 {
6346 context->recordError(gl::Error(GL_INVALID_VALUE));
6347 return;
6348 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006349
Geoff Langb1196682014-07-23 13:47:29 -04006350 if (size < 1 || size > 4)
6351 {
6352 context->recordError(gl::Error(GL_INVALID_VALUE));
6353 return;
6354 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006355
Geoff Langb1196682014-07-23 13:47:29 -04006356 switch (type)
6357 {
6358 case GL_BYTE:
6359 case GL_UNSIGNED_BYTE:
6360 case GL_SHORT:
6361 case GL_UNSIGNED_SHORT:
6362 case GL_INT:
6363 case GL_UNSIGNED_INT:
6364 case GL_INT_2_10_10_10_REV:
6365 case GL_UNSIGNED_INT_2_10_10_10_REV:
6366 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006367
Geoff Langb1196682014-07-23 13:47:29 -04006368 default:
6369 context->recordError(gl::Error(GL_INVALID_ENUM));
6370 return;
6371 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006372
Geoff Langb1196682014-07-23 13:47:29 -04006373 if (stride < 0)
6374 {
6375 context->recordError(gl::Error(GL_INVALID_VALUE));
6376 return;
6377 }
Geoff Langbfdea662014-07-23 14:16:32 -04006378
Geoff Langb1196682014-07-23 13:47:29 -04006379 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6380 {
6381 context->recordError(gl::Error(GL_INVALID_OPERATION));
6382 return;
6383 }
6384
Geoff Langbfdea662014-07-23 14:16:32 -04006385 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6386 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6387 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6388 // and the pointer argument is not NULL.
6389 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006390 {
Geoff Langb1196682014-07-23 13:47:29 -04006391 context->recordError(gl::Error(GL_INVALID_OPERATION));
6392 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006393 }
6394
Geoff Langbfdea662014-07-23 14:16:32 -04006395 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6396 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006397 }
6398}
6399
Kenneth Russell67ea1902014-10-06 16:44:50 -07006400void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006401{
6402 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6403 index, pname, params);
6404
Geoff Langbfdea662014-07-23 14:16:32 -04006405 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006406 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006407 {
Geoff Langbfdea662014-07-23 14:16:32 -04006408 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006409 {
Geoff Langb1196682014-07-23 13:47:29 -04006410 context->recordError(gl::Error(GL_INVALID_OPERATION));
6411 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006412 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006413
Geoff Langbfdea662014-07-23 14:16:32 -04006414 if (index >= gl::MAX_VERTEX_ATTRIBS)
6415 {
Geoff Langb1196682014-07-23 13:47:29 -04006416 context->recordError(gl::Error(GL_INVALID_VALUE));
6417 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006418 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006419
Geoff Langbfdea662014-07-23 14:16:32 -04006420 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006421
Geoff Langb1196682014-07-23 13:47:29 -04006422 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006423 {
6424 return;
6425 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006426
Geoff Langbfdea662014-07-23 14:16:32 -04006427 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6428 {
6429 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6430 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006431 {
Geoff Langbfdea662014-07-23 14:16:32 -04006432 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006433 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006434 }
Geoff Langbfdea662014-07-23 14:16:32 -04006435 else
6436 {
6437 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6438 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006439 }
6440}
6441
Kenneth Russell67ea1902014-10-06 16:44:50 -07006442void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006443{
6444 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6445 index, pname, params);
6446
Geoff Langbfdea662014-07-23 14:16:32 -04006447 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006448 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006449 {
Geoff Langbfdea662014-07-23 14:16:32 -04006450 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006451 {
Geoff Langb1196682014-07-23 13:47:29 -04006452 context->recordError(gl::Error(GL_INVALID_OPERATION));
6453 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006454 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006455
Geoff Langbfdea662014-07-23 14:16:32 -04006456 if (index >= gl::MAX_VERTEX_ATTRIBS)
6457 {
Geoff Langb1196682014-07-23 13:47:29 -04006458 context->recordError(gl::Error(GL_INVALID_VALUE));
6459 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006460 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006461
Geoff Langbfdea662014-07-23 14:16:32 -04006462 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006463
Geoff Langb1196682014-07-23 13:47:29 -04006464 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006465 {
6466 return;
6467 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006468
Geoff Langbfdea662014-07-23 14:16:32 -04006469 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6470 {
6471 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6472 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006473 {
Geoff Langbfdea662014-07-23 14:16:32 -04006474 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006475 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006476 }
Geoff Langbfdea662014-07-23 14:16:32 -04006477 else
6478 {
6479 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6480 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006481 }
6482}
6483
Kenneth Russell67ea1902014-10-06 16:44:50 -07006484void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006485{
6486 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6487 index, x, y, z, w);
6488
Geoff Langbfdea662014-07-23 14:16:32 -04006489 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006490 if (context)
6491 {
6492 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006493 {
Geoff Langb1196682014-07-23 13:47:29 -04006494 context->recordError(gl::Error(GL_INVALID_OPERATION));
6495 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006496 }
Geoff Langbfdea662014-07-23 14:16:32 -04006497
6498 if (index >= gl::MAX_VERTEX_ATTRIBS)
6499 {
Geoff Langb1196682014-07-23 13:47:29 -04006500 context->recordError(gl::Error(GL_INVALID_VALUE));
6501 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006502 }
6503
6504 GLint vals[4] = { x, y, z, w };
6505 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006506 }
6507}
6508
Kenneth Russell67ea1902014-10-06 16:44:50 -07006509void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006510{
6511 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6512 index, x, y, z, w);
6513
Geoff Langbfdea662014-07-23 14:16:32 -04006514 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006515 if (context)
6516 {
6517 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006518 {
Geoff Langb1196682014-07-23 13:47:29 -04006519 context->recordError(gl::Error(GL_INVALID_OPERATION));
6520 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006521 }
Geoff Langbfdea662014-07-23 14:16:32 -04006522
6523 if (index >= gl::MAX_VERTEX_ATTRIBS)
6524 {
Geoff Langb1196682014-07-23 13:47:29 -04006525 context->recordError(gl::Error(GL_INVALID_VALUE));
6526 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006527 }
6528
6529 GLuint vals[4] = { x, y, z, w };
6530 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006531 }
6532}
6533
Kenneth Russell67ea1902014-10-06 16:44:50 -07006534void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006535{
6536 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
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 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006554 }
6555}
6556
Kenneth Russell67ea1902014-10-06 16:44:50 -07006557void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006558{
6559 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6560
Geoff Langbfdea662014-07-23 14:16:32 -04006561 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006562 if (context)
6563 {
6564 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006565 {
Geoff Langb1196682014-07-23 13:47:29 -04006566 context->recordError(gl::Error(GL_INVALID_OPERATION));
6567 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006568 }
Geoff Langbfdea662014-07-23 14:16:32 -04006569
6570 if (index >= gl::MAX_VERTEX_ATTRIBS)
6571 {
Geoff Langb1196682014-07-23 13:47:29 -04006572 context->recordError(gl::Error(GL_INVALID_VALUE));
6573 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006574 }
6575
6576 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006577 }
6578}
6579
Kenneth Russell67ea1902014-10-06 16:44:50 -07006580void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006581{
6582 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6583 program, location, params);
6584
Geoff Langbfdea662014-07-23 14:16:32 -04006585 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006586 if (context)
6587 {
Jamie Madill0063c512014-08-25 15:47:53 -04006588 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006589 {
Jamie Madill0063c512014-08-25 15:47:53 -04006590 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006591 }
Geoff Langbfdea662014-07-23 14:16:32 -04006592
Jamie Madilla502c742014-08-28 17:19:13 -04006593 gl::Program *programObject = context->getProgram(program);
6594 ASSERT(programObject);
6595 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006596 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006597
Jamie Madill99a1e982014-08-25 15:47:54 -04006598 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006599 }
6600}
6601
Kenneth Russell67ea1902014-10-06 16:44:50 -07006602GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006603{
6604 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6605 program, name);
6606
Geoff Langbfdea662014-07-23 14:16:32 -04006607 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006608 if (context)
6609 {
6610 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006611 {
Geoff Langb1196682014-07-23 13:47:29 -04006612 context->recordError(gl::Error(GL_INVALID_OPERATION));
6613 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006614 }
Geoff Langbfdea662014-07-23 14:16:32 -04006615
6616 if (program == 0)
6617 {
Geoff Langb1196682014-07-23 13:47:29 -04006618 context->recordError(gl::Error(GL_INVALID_VALUE));
6619 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006620 }
6621
6622 gl::Program *programObject = context->getProgram(program);
6623
6624 if (!programObject || !programObject->isLinked())
6625 {
Geoff Langb1196682014-07-23 13:47:29 -04006626 context->recordError(gl::Error(GL_INVALID_OPERATION));
6627 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006628 }
6629
6630 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6631 if (!programBinary)
6632 {
Geoff Langb1196682014-07-23 13:47:29 -04006633 context->recordError(gl::Error(GL_INVALID_OPERATION));
6634 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006635 }
6636
6637 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006638 }
6639
6640 return 0;
6641}
6642
Kenneth Russell67ea1902014-10-06 16:44:50 -07006643void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006644{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006645 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006646}
6647
Kenneth Russell67ea1902014-10-06 16:44:50 -07006648void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006649{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006650 const GLuint xy[] = { v0, v1 };
6651 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006652}
6653
Kenneth Russell67ea1902014-10-06 16:44:50 -07006654void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006655{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006656 const GLuint xyz[] = { v0, v1, v2 };
6657 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006658}
6659
Kenneth Russell67ea1902014-10-06 16:44:50 -07006660void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006661{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006662 const GLuint xyzw[] = { v0, v1, v2, v3 };
6663 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006664}
6665
Kenneth Russell67ea1902014-10-06 16:44:50 -07006666void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006667{
6668 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6669 location, count, value);
6670
Geoff Langbfdea662014-07-23 14:16:32 -04006671 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006672 if (context)
6673 {
6674 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006675 {
Geoff Langbfdea662014-07-23 14:16:32 -04006676 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006677 }
Geoff Langbfdea662014-07-23 14:16:32 -04006678
6679 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6680 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006681 }
6682}
6683
Kenneth Russell67ea1902014-10-06 16:44:50 -07006684void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006685{
6686 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6687 location, count, value);
6688
Geoff Langbfdea662014-07-23 14:16:32 -04006689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006690 if (context)
6691 {
6692 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006693 {
Geoff Langbfdea662014-07-23 14:16:32 -04006694 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006695 }
Geoff Langbfdea662014-07-23 14:16:32 -04006696
6697 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6698 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006699 }
6700}
6701
Kenneth Russell67ea1902014-10-06 16:44:50 -07006702void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006703{
6704 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6705 location, count, value);
6706
Geoff Langbfdea662014-07-23 14:16:32 -04006707 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006708 if (context)
6709 {
6710 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006711 {
Geoff Langbfdea662014-07-23 14:16:32 -04006712 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006713 }
Geoff Langbfdea662014-07-23 14:16:32 -04006714
6715 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6716 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006717 }
6718}
6719
Kenneth Russell67ea1902014-10-06 16:44:50 -07006720void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006721{
6722 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6723 location, count, value);
6724
Geoff Langbfdea662014-07-23 14:16:32 -04006725 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006726 if (context)
6727 {
6728 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006729 {
Geoff Langbfdea662014-07-23 14:16:32 -04006730 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006731 }
Geoff Langbfdea662014-07-23 14:16:32 -04006732
6733 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6734 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006735 }
6736}
6737
Kenneth Russell67ea1902014-10-06 16:44:50 -07006738void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006739{
6740 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6741 buffer, drawbuffer, value);
6742
Geoff Langbfdea662014-07-23 14:16:32 -04006743 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006744 if (context)
6745 {
6746 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006747 {
Geoff Langbfdea662014-07-23 14:16:32 -04006748 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006749 }
Geoff Langbfdea662014-07-23 14:16:32 -04006750
6751 switch (buffer)
6752 {
6753 case GL_COLOR:
6754 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6755 {
Geoff Langb1196682014-07-23 13:47:29 -04006756 context->recordError(gl::Error(GL_INVALID_VALUE));
6757 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006758 }
6759 break;
Geoff Langb1196682014-07-23 13:47:29 -04006760
Geoff Langbfdea662014-07-23 14:16:32 -04006761 case GL_STENCIL:
6762 if (drawbuffer != 0)
6763 {
Geoff Langb1196682014-07-23 13:47:29 -04006764 context->recordError(gl::Error(GL_INVALID_VALUE));
6765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006766 }
6767 break;
Geoff Langb1196682014-07-23 13:47:29 -04006768
Geoff Langbfdea662014-07-23 14:16:32 -04006769 default:
Geoff Langb1196682014-07-23 13:47:29 -04006770 context->recordError(gl::Error(GL_INVALID_ENUM));
6771 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006772 }
6773
Geoff Langcc79b8c2014-07-25 13:48:02 -04006774 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6775 if (error.isError())
6776 {
6777 context->recordError(error);
6778 return;
6779 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006780 }
6781}
6782
Kenneth Russell67ea1902014-10-06 16:44:50 -07006783void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006784{
6785 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6786 buffer, drawbuffer, value);
6787
Geoff Langbfdea662014-07-23 14:16:32 -04006788 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006789 if (context)
6790 {
6791 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006792 {
Geoff Langbfdea662014-07-23 14:16:32 -04006793 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006794 }
Geoff Langbfdea662014-07-23 14:16:32 -04006795
6796 switch (buffer)
6797 {
6798 case GL_COLOR:
6799 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6800 {
Geoff Langb1196682014-07-23 13:47:29 -04006801 context->recordError(gl::Error(GL_INVALID_VALUE));
6802 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006803 }
6804 break;
Geoff Langb1196682014-07-23 13:47:29 -04006805
Geoff Langbfdea662014-07-23 14:16:32 -04006806 default:
Geoff Langb1196682014-07-23 13:47:29 -04006807 context->recordError(gl::Error(GL_INVALID_ENUM));
6808 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006809 }
6810
Geoff Langcc79b8c2014-07-25 13:48:02 -04006811 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6812 if (error.isError())
6813 {
6814 context->recordError(error);
6815 return;
6816 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006817 }
6818}
6819
Kenneth Russell67ea1902014-10-06 16:44:50 -07006820void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006821{
6822 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6823 buffer, drawbuffer, value);
6824
Geoff Langbfdea662014-07-23 14:16:32 -04006825 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006826 if (context)
6827 {
6828 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006829 {
Geoff Langbfdea662014-07-23 14:16:32 -04006830 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006831 }
Geoff Langbfdea662014-07-23 14:16:32 -04006832
6833 switch (buffer)
6834 {
6835 case GL_COLOR:
6836 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6837 {
Geoff Langb1196682014-07-23 13:47:29 -04006838 context->recordError(gl::Error(GL_INVALID_VALUE));
6839 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006840 }
6841 break;
Geoff Langb1196682014-07-23 13:47:29 -04006842
Geoff Langbfdea662014-07-23 14:16:32 -04006843 case GL_DEPTH:
6844 if (drawbuffer != 0)
6845 {
Geoff Langb1196682014-07-23 13:47:29 -04006846 context->recordError(gl::Error(GL_INVALID_VALUE));
6847 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006848 }
6849 break;
Geoff Langb1196682014-07-23 13:47:29 -04006850
Geoff Langbfdea662014-07-23 14:16:32 -04006851 default:
Geoff Langb1196682014-07-23 13:47:29 -04006852 context->recordError(gl::Error(GL_INVALID_ENUM));
6853 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006854 }
6855
Geoff Langcc79b8c2014-07-25 13:48:02 -04006856 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6857 if (error.isError())
6858 {
6859 context->recordError(error);
6860 return;
6861 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006862 }
6863}
6864
Kenneth Russell67ea1902014-10-06 16:44:50 -07006865void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006866{
6867 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6868 buffer, drawbuffer, depth, stencil);
6869
Geoff Langbfdea662014-07-23 14:16:32 -04006870 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006871 if (context)
6872 {
6873 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006874 {
Geoff Langbfdea662014-07-23 14:16:32 -04006875 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006876 }
Geoff Langbfdea662014-07-23 14:16:32 -04006877
6878 switch (buffer)
6879 {
6880 case GL_DEPTH_STENCIL:
6881 if (drawbuffer != 0)
6882 {
Geoff Langb1196682014-07-23 13:47:29 -04006883 context->recordError(gl::Error(GL_INVALID_VALUE));
6884 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006885 }
6886 break;
Geoff Langb1196682014-07-23 13:47:29 -04006887
Geoff Langbfdea662014-07-23 14:16:32 -04006888 default:
Geoff Langb1196682014-07-23 13:47:29 -04006889 context->recordError(gl::Error(GL_INVALID_ENUM));
6890 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006891 }
6892
Geoff Langcc79b8c2014-07-25 13:48:02 -04006893 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6894 if (error.isError())
6895 {
6896 context->recordError(error);
6897 return;
6898 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006899 }
6900}
6901
Kenneth Russell67ea1902014-10-06 16:44:50 -07006902const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006903{
6904 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6905
Geoff Langbfdea662014-07-23 14:16:32 -04006906 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006907 if (context)
6908 {
6909 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006910 {
Geoff Langb1196682014-07-23 13:47:29 -04006911 context->recordError(gl::Error(GL_INVALID_OPERATION));
6912 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006913 }
Geoff Langbfdea662014-07-23 14:16:32 -04006914
6915 if (name != GL_EXTENSIONS)
6916 {
Geoff Langb1196682014-07-23 13:47:29 -04006917 context->recordError(gl::Error(GL_INVALID_ENUM));
6918 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006919 }
6920
6921 if (index >= context->getExtensionStringCount())
6922 {
Geoff Langb1196682014-07-23 13:47:29 -04006923 context->recordError(gl::Error(GL_INVALID_VALUE));
6924 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006925 }
6926
6927 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006928 }
6929
6930 return NULL;
6931}
6932
Kenneth Russell67ea1902014-10-06 16:44:50 -07006933void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006934{
6935 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6936 readTarget, writeTarget, readOffset, writeOffset, size);
6937
Geoff Langbfdea662014-07-23 14:16:32 -04006938 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006939 if (context)
6940 {
6941 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006942 {
Geoff Langb1196682014-07-23 13:47:29 -04006943 context->recordError(gl::Error(GL_INVALID_OPERATION));
6944 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006945 }
Geoff Langbfdea662014-07-23 14:16:32 -04006946
Jamie Madill24e83192014-10-20 11:00:53 -04006947 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04006948 {
Geoff Langb1196682014-07-23 13:47:29 -04006949 context->recordError(gl::Error(GL_INVALID_ENUM));
6950 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006951 }
6952
6953 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
6954 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
6955
6956 if (!readBuffer || !writeBuffer)
6957 {
Geoff Langb1196682014-07-23 13:47:29 -04006958 context->recordError(gl::Error(GL_INVALID_OPERATION));
6959 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006960 }
6961
Jamie Madillcfaaf722014-07-31 10:47:54 -04006962 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04006963 if (readBuffer->isMapped() || writeBuffer->isMapped())
6964 {
Geoff Langb1196682014-07-23 13:47:29 -04006965 context->recordError(gl::Error(GL_INVALID_OPERATION));
6966 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006967 }
6968
6969 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
6970 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
6971 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
6972 {
Geoff Langb1196682014-07-23 13:47:29 -04006973 context->recordError(gl::Error(GL_INVALID_VALUE));
6974 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006975 }
6976
Kenneth Russell67ea1902014-10-06 16:44:50 -07006977 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04006978 {
Geoff Langb1196682014-07-23 13:47:29 -04006979 context->recordError(gl::Error(GL_INVALID_VALUE));
6980 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006981 }
6982
Geoff Langbfdea662014-07-23 14:16:32 -04006983 // if size is zero, the copy is a successful no-op
6984 if (size > 0)
6985 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04006986 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
6987 if (error.isError())
6988 {
6989 context->recordError(error);
6990 return;
6991 }
Geoff Langbfdea662014-07-23 14:16:32 -04006992 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006993 }
6994}
6995
Kenneth Russell67ea1902014-10-06 16:44:50 -07006996void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006997{
6998 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
6999 program, uniformCount, uniformNames, uniformIndices);
7000
Geoff Langbfdea662014-07-23 14:16:32 -04007001 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007002 if (context)
7003 {
7004 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007005 {
Geoff Langb1196682014-07-23 13:47:29 -04007006 context->recordError(gl::Error(GL_INVALID_OPERATION));
7007 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007008 }
7009
7010 if (uniformCount < 0)
7011 {
Geoff Langb1196682014-07-23 13:47:29 -04007012 context->recordError(gl::Error(GL_INVALID_VALUE));
7013 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007014 }
7015
7016 gl::Program *programObject = context->getProgram(program);
7017
7018 if (!programObject)
7019 {
7020 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007021 {
Geoff Langb1196682014-07-23 13:47:29 -04007022 context->recordError(gl::Error(GL_INVALID_OPERATION));
7023 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007024 }
Geoff Langbfdea662014-07-23 14:16:32 -04007025 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007026 {
Geoff Langb1196682014-07-23 13:47:29 -04007027 context->recordError(gl::Error(GL_INVALID_VALUE));
7028 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007029 }
Geoff Langbfdea662014-07-23 14:16:32 -04007030 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007031
Geoff Langbfdea662014-07-23 14:16:32 -04007032 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7033 if (!programObject->isLinked() || !programBinary)
7034 {
7035 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007036 {
Geoff Langbfdea662014-07-23 14:16:32 -04007037 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007038 }
7039 }
Geoff Langbfdea662014-07-23 14:16:32 -04007040 else
7041 {
7042 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7043 {
7044 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7045 }
7046 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007047 }
7048}
7049
Kenneth Russell67ea1902014-10-06 16:44:50 -07007050void 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 +00007051{
7052 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7053 program, uniformCount, uniformIndices, pname, params);
7054
Geoff Langbfdea662014-07-23 14:16:32 -04007055 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007056 if (context)
7057 {
7058 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007059 {
Geoff Langb1196682014-07-23 13:47:29 -04007060 context->recordError(gl::Error(GL_INVALID_OPERATION));
7061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007062 }
7063
7064 if (uniformCount < 0)
7065 {
Geoff Langb1196682014-07-23 13:47:29 -04007066 context->recordError(gl::Error(GL_INVALID_VALUE));
7067 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007068 }
7069
7070 gl::Program *programObject = context->getProgram(program);
7071
7072 if (!programObject)
7073 {
7074 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007075 {
Geoff Langb1196682014-07-23 13:47:29 -04007076 context->recordError(gl::Error(GL_INVALID_OPERATION));
7077 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007078 }
Geoff Langbfdea662014-07-23 14:16:32 -04007079 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007080 {
Geoff Langb1196682014-07-23 13:47:29 -04007081 context->recordError(gl::Error(GL_INVALID_VALUE));
7082 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007083 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007084 }
Geoff Langbfdea662014-07-23 14:16:32 -04007085
7086 switch (pname)
7087 {
7088 case GL_UNIFORM_TYPE:
7089 case GL_UNIFORM_SIZE:
7090 case GL_UNIFORM_NAME_LENGTH:
7091 case GL_UNIFORM_BLOCK_INDEX:
7092 case GL_UNIFORM_OFFSET:
7093 case GL_UNIFORM_ARRAY_STRIDE:
7094 case GL_UNIFORM_MATRIX_STRIDE:
7095 case GL_UNIFORM_IS_ROW_MAJOR:
7096 break;
Geoff Langb1196682014-07-23 13:47:29 -04007097
Geoff Langbfdea662014-07-23 14:16:32 -04007098 default:
Geoff Langb1196682014-07-23 13:47:29 -04007099 context->recordError(gl::Error(GL_INVALID_ENUM));
7100 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007101 }
7102
7103 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7104
7105 if (!programBinary && uniformCount > 0)
7106 {
Geoff Langb1196682014-07-23 13:47:29 -04007107 context->recordError(gl::Error(GL_INVALID_VALUE));
7108 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007109 }
7110
7111 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7112 {
7113 const GLuint index = uniformIndices[uniformId];
7114
7115 if (index >= (GLuint)programBinary->getActiveUniformCount())
7116 {
Geoff Langb1196682014-07-23 13:47:29 -04007117 context->recordError(gl::Error(GL_INVALID_VALUE));
7118 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007119 }
7120 }
7121
7122 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7123 {
7124 const GLuint index = uniformIndices[uniformId];
7125 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7126 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007127 }
7128}
7129
Kenneth Russell67ea1902014-10-06 16:44:50 -07007130GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007131{
7132 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7133
Geoff Langbfdea662014-07-23 14:16:32 -04007134 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007135 if (context)
7136 {
7137 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007138 {
Geoff Langb1196682014-07-23 13:47:29 -04007139 context->recordError(gl::Error(GL_INVALID_OPERATION));
7140 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007141 }
7142
7143 gl::Program *programObject = context->getProgram(program);
7144
7145 if (!programObject)
7146 {
7147 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007148 {
Geoff Langb1196682014-07-23 13:47:29 -04007149 context->recordError(gl::Error(GL_INVALID_OPERATION));
7150 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007151 }
Geoff Langbfdea662014-07-23 14:16:32 -04007152 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007153 {
Geoff Langb1196682014-07-23 13:47:29 -04007154 context->recordError(gl::Error(GL_INVALID_VALUE));
7155 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007156 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007157 }
Geoff Langbfdea662014-07-23 14:16:32 -04007158
7159 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7160 if (!programBinary)
7161 {
7162 return GL_INVALID_INDEX;
7163 }
7164
7165 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007166 }
7167
7168 return 0;
7169}
7170
Kenneth Russell67ea1902014-10-06 16:44:50 -07007171void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007172{
7173 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7174 program, uniformBlockIndex, pname, params);
7175
Geoff Langbfdea662014-07-23 14:16:32 -04007176 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007177 if (context)
7178 {
7179 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007180 {
Geoff Langb1196682014-07-23 13:47:29 -04007181 context->recordError(gl::Error(GL_INVALID_OPERATION));
7182 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007183 }
7184 gl::Program *programObject = context->getProgram(program);
7185
7186 if (!programObject)
7187 {
7188 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007189 {
Geoff Langb1196682014-07-23 13:47:29 -04007190 context->recordError(gl::Error(GL_INVALID_OPERATION));
7191 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007192 }
Geoff Langbfdea662014-07-23 14:16:32 -04007193 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007194 {
Geoff Langb1196682014-07-23 13:47:29 -04007195 context->recordError(gl::Error(GL_INVALID_VALUE));
7196 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007197 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007198 }
Geoff Langbfdea662014-07-23 14:16:32 -04007199
7200 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7201
7202 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7203 {
Geoff Langb1196682014-07-23 13:47:29 -04007204 context->recordError(gl::Error(GL_INVALID_VALUE));
7205 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007206 }
7207
7208 switch (pname)
7209 {
7210 case GL_UNIFORM_BLOCK_BINDING:
7211 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7212 break;
7213
7214 case GL_UNIFORM_BLOCK_DATA_SIZE:
7215 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7216 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7217 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7218 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7219 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7220 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7221 break;
7222
7223 default:
Geoff Langb1196682014-07-23 13:47:29 -04007224 context->recordError(gl::Error(GL_INVALID_ENUM));
7225 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007226 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007227 }
7228}
7229
Kenneth Russell67ea1902014-10-06 16:44:50 -07007230void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007231{
7232 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7233 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7234
Geoff Langbfdea662014-07-23 14:16:32 -04007235 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007236 if (context)
7237 {
7238 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007239 {
Geoff Langb1196682014-07-23 13:47:29 -04007240 context->recordError(gl::Error(GL_INVALID_OPERATION));
7241 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007242 }
7243
7244 gl::Program *programObject = context->getProgram(program);
7245
7246 if (!programObject)
7247 {
7248 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007249 {
Geoff Langb1196682014-07-23 13:47:29 -04007250 context->recordError(gl::Error(GL_INVALID_OPERATION));
7251 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007252 }
Geoff Langbfdea662014-07-23 14:16:32 -04007253 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007254 {
Geoff Langb1196682014-07-23 13:47:29 -04007255 context->recordError(gl::Error(GL_INVALID_VALUE));
7256 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007257 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007258 }
Geoff Langbfdea662014-07-23 14:16:32 -04007259
7260 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7261
7262 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7263 {
Geoff Langb1196682014-07-23 13:47:29 -04007264 context->recordError(gl::Error(GL_INVALID_VALUE));
7265 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007266 }
7267
7268 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007269 }
7270}
7271
Kenneth Russell67ea1902014-10-06 16:44:50 -07007272void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007273{
7274 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7275 program, uniformBlockIndex, uniformBlockBinding);
7276
Geoff Langbfdea662014-07-23 14:16:32 -04007277 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007278 if (context)
7279 {
7280 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007281 {
Geoff Langb1196682014-07-23 13:47:29 -04007282 context->recordError(gl::Error(GL_INVALID_OPERATION));
7283 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007284 }
7285
Geoff Lang3a61c322014-07-10 13:01:54 -04007286 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007287 {
Geoff Langb1196682014-07-23 13:47:29 -04007288 context->recordError(gl::Error(GL_INVALID_VALUE));
7289 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007290 }
7291
7292 gl::Program *programObject = context->getProgram(program);
7293
7294 if (!programObject)
7295 {
7296 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007297 {
Geoff Langb1196682014-07-23 13:47:29 -04007298 context->recordError(gl::Error(GL_INVALID_OPERATION));
7299 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007300 }
Geoff Langbfdea662014-07-23 14:16:32 -04007301 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007302 {
Geoff Langb1196682014-07-23 13:47:29 -04007303 context->recordError(gl::Error(GL_INVALID_VALUE));
7304 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007305 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007306 }
Geoff Langbfdea662014-07-23 14:16:32 -04007307
7308 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7309
7310 // if never linked, there won't be any uniform blocks
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 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007318 }
7319}
7320
Kenneth Russell67ea1902014-10-06 16:44:50 -07007321void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007322{
7323 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7324 mode, first, count, instanceCount);
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;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007333 }
Geoff Langbfdea662014-07-23 14:16:32 -04007334
7335 // glDrawArraysInstanced
7336 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007337 }
7338}
7339
Kenneth Russell67ea1902014-10-06 16:44:50 -07007340void 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 +00007341{
7342 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7343 mode, count, type, indices, instanceCount);
7344
Geoff Langbfdea662014-07-23 14:16:32 -04007345 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007346 if (context)
7347 {
7348 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007349 {
Geoff Langb1196682014-07-23 13:47:29 -04007350 context->recordError(gl::Error(GL_INVALID_OPERATION));
7351 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007352 }
Geoff Langbfdea662014-07-23 14:16:32 -04007353
7354 // glDrawElementsInstanced
7355 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007356 }
7357}
7358
Kenneth Russell67ea1902014-10-06 16:44:50 -07007359GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007360{
7361 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7362
Geoff Langbfdea662014-07-23 14:16:32 -04007363 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007364 if (context)
7365 {
7366 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007367 {
Geoff Langb1196682014-07-23 13:47:29 -04007368 context->recordError(gl::Error(GL_INVALID_OPERATION));
7369 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007370 }
Geoff Langbfdea662014-07-23 14:16:32 -04007371
7372 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7373 {
Geoff Langb1196682014-07-23 13:47:29 -04007374 context->recordError(gl::Error(GL_INVALID_ENUM));
7375 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007376 }
7377
7378 if (flags != 0)
7379 {
Geoff Langb1196682014-07-23 13:47:29 -04007380 context->recordError(gl::Error(GL_INVALID_VALUE));
7381 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007382 }
7383
Geoff Lang882033e2014-09-30 11:26:07 -04007384 GLsync fenceSync = context->createFenceSync();
7385
7386 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7387 gl::Error error = fenceSyncObject->set(condition);
7388 if (error.isError())
7389 {
7390 context->deleteFenceSync(fenceSync);
7391 context->recordError(error);
7392 return NULL;
7393 }
7394
7395 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007396 }
7397
7398 return NULL;
7399}
7400
Kenneth Russell67ea1902014-10-06 16:44:50 -07007401GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007402{
7403 EVENT("(GLsync sync = 0x%0.8p)", sync);
7404
Geoff Langbfdea662014-07-23 14:16:32 -04007405 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007406 if (context)
7407 {
7408 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007409 {
Geoff Langb1196682014-07-23 13:47:29 -04007410 context->recordError(gl::Error(GL_INVALID_OPERATION));
7411 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007412 }
Geoff Langbfdea662014-07-23 14:16:32 -04007413
7414 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007415 }
7416
7417 return GL_FALSE;
7418}
7419
Kenneth Russell67ea1902014-10-06 16:44:50 -07007420void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007421{
7422 EVENT("(GLsync sync = 0x%0.8p)", sync);
7423
Geoff Langbfdea662014-07-23 14:16:32 -04007424 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007425 if (context)
7426 {
7427 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007428 {
Geoff Langb1196682014-07-23 13:47:29 -04007429 context->recordError(gl::Error(GL_INVALID_OPERATION));
7430 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007431 }
Geoff Langbfdea662014-07-23 14:16:32 -04007432
7433 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7434 {
Geoff Langb1196682014-07-23 13:47:29 -04007435 context->recordError(gl::Error(GL_INVALID_VALUE));
7436 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007437 }
7438
7439 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007440 }
7441}
7442
Kenneth Russell67ea1902014-10-06 16:44:50 -07007443GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007444{
7445 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7446 sync, flags, timeout);
7447
Geoff Langbfdea662014-07-23 14:16:32 -04007448 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007449 if (context)
7450 {
7451 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007452 {
Geoff Langb1196682014-07-23 13:47:29 -04007453 context->recordError(gl::Error(GL_INVALID_OPERATION));
7454 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007455 }
Geoff Langbfdea662014-07-23 14:16:32 -04007456
7457 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7458 {
Geoff Langb1196682014-07-23 13:47:29 -04007459 context->recordError(gl::Error(GL_INVALID_VALUE));
7460 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007461 }
7462
7463 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7464
7465 if (!fenceSync)
7466 {
Geoff Langb1196682014-07-23 13:47:29 -04007467 context->recordError(gl::Error(GL_INVALID_VALUE));
7468 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007469 }
7470
Geoff Lang882033e2014-09-30 11:26:07 -04007471 GLenum result = GL_WAIT_FAILED;
7472 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7473 if (error.isError())
7474 {
7475 context->recordError(error);
7476 return GL_WAIT_FAILED;
7477 }
7478
7479 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007480 }
7481
7482 return GL_FALSE;
7483}
7484
Kenneth Russell67ea1902014-10-06 16:44:50 -07007485void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007486{
7487 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7488 sync, flags, timeout);
7489
Geoff Langbfdea662014-07-23 14:16:32 -04007490 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007491 if (context)
7492 {
7493 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007494 {
Geoff Langb1196682014-07-23 13:47:29 -04007495 context->recordError(gl::Error(GL_INVALID_OPERATION));
7496 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007497 }
Geoff Langbfdea662014-07-23 14:16:32 -04007498
7499 if (flags != 0)
7500 {
Geoff Langb1196682014-07-23 13:47:29 -04007501 context->recordError(gl::Error(GL_INVALID_VALUE));
7502 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007503 }
7504
7505 if (timeout != GL_TIMEOUT_IGNORED)
7506 {
Geoff Langb1196682014-07-23 13:47:29 -04007507 context->recordError(gl::Error(GL_INVALID_VALUE));
7508 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007509 }
7510
7511 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7512
7513 if (!fenceSync)
7514 {
Geoff Langb1196682014-07-23 13:47:29 -04007515 context->recordError(gl::Error(GL_INVALID_VALUE));
7516 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007517 }
7518
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007519 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007520 if (error.isError())
7521 {
7522 context->recordError(error);
7523 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007524 }
7525}
7526
Kenneth Russell67ea1902014-10-06 16:44:50 -07007527void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007528{
7529 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7530 pname, params);
7531
Geoff Langbfdea662014-07-23 14:16:32 -04007532 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007533 if (context)
7534 {
7535 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007536 {
Geoff Langb1196682014-07-23 13:47:29 -04007537 context->recordError(gl::Error(GL_INVALID_OPERATION));
7538 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007539 }
Geoff Langbfdea662014-07-23 14:16:32 -04007540
7541 GLenum nativeType;
7542 unsigned int numParams = 0;
7543 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7544 {
7545 return;
7546 }
7547
7548 if (nativeType == GL_INT_64_ANGLEX)
7549 {
7550 context->getInteger64v(pname, params);
7551 }
7552 else
7553 {
7554 CastStateValues(context, nativeType, pname, numParams, params);
7555 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007556 }
7557}
7558
Kenneth Russell67ea1902014-10-06 16:44:50 -07007559void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007560{
7561 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7562 sync, pname, bufSize, length, values);
7563
Geoff Langbfdea662014-07-23 14:16:32 -04007564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007565 if (context)
7566 {
7567 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007568 {
Geoff Langb1196682014-07-23 13:47:29 -04007569 context->recordError(gl::Error(GL_INVALID_OPERATION));
7570 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007571 }
Geoff Langbfdea662014-07-23 14:16:32 -04007572
7573 if (bufSize < 0)
7574 {
Geoff Langb1196682014-07-23 13:47:29 -04007575 context->recordError(gl::Error(GL_INVALID_VALUE));
7576 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007577 }
7578
7579 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7580
7581 if (!fenceSync)
7582 {
Geoff Langb1196682014-07-23 13:47:29 -04007583 context->recordError(gl::Error(GL_INVALID_VALUE));
7584 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007585 }
7586
7587 switch (pname)
7588 {
7589 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007590 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7591 case GL_SYNC_FLAGS: values[0] = 0; break;
7592
Geoff Lang882033e2014-09-30 11:26:07 -04007593 case GL_SYNC_STATUS:
7594 {
7595 gl::Error error = fenceSync->getStatus(values);
7596 if (error.isError())
7597 {
7598 context->recordError(error);
7599 return;
7600 }
7601 break;
7602 }
7603
Geoff Langbfdea662014-07-23 14:16:32 -04007604 default:
Geoff Langb1196682014-07-23 13:47:29 -04007605 context->recordError(gl::Error(GL_INVALID_ENUM));
7606 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007607 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007608 }
7609}
7610
Kenneth Russell67ea1902014-10-06 16:44:50 -07007611void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007612{
7613 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7614 target, index, data);
7615
Geoff Langbfdea662014-07-23 14:16:32 -04007616 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007617 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007618 {
Geoff Langbfdea662014-07-23 14:16:32 -04007619 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007620 {
Geoff Langb1196682014-07-23 13:47:29 -04007621 context->recordError(gl::Error(GL_INVALID_OPERATION));
7622 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007623 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007624
Geoff Lang3a61c322014-07-10 13:01:54 -04007625 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007626 switch (target)
7627 {
7628 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7629 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7630 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007631 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7632 {
Geoff Langb1196682014-07-23 13:47:29 -04007633 context->recordError(gl::Error(GL_INVALID_VALUE));
7634 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007635 }
Geoff Langbfdea662014-07-23 14:16:32 -04007636 break;
Geoff Langb1196682014-07-23 13:47:29 -04007637
Geoff Langbfdea662014-07-23 14:16:32 -04007638 case GL_UNIFORM_BUFFER_START:
7639 case GL_UNIFORM_BUFFER_SIZE:
7640 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007641 if (index >= caps.maxUniformBufferBindings)
7642 {
Geoff Langb1196682014-07-23 13:47:29 -04007643 context->recordError(gl::Error(GL_INVALID_VALUE));
7644 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007645 }
Geoff Langbfdea662014-07-23 14:16:32 -04007646 break;
Geoff Langb1196682014-07-23 13:47:29 -04007647
Geoff Langbfdea662014-07-23 14:16:32 -04007648 default:
Geoff Langb1196682014-07-23 13:47:29 -04007649 context->recordError(gl::Error(GL_INVALID_ENUM));
7650 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007651 }
7652
7653 if (!(context->getIndexedInteger64v(target, index, data)))
7654 {
7655 GLenum nativeType;
7656 unsigned int numParams = 0;
7657 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007658 {
7659 context->recordError(gl::Error(GL_INVALID_ENUM));
7660 return;
7661 }
Shannon Woods15934d52013-08-19 14:28:49 -04007662
Geoff Langbfdea662014-07-23 14:16:32 -04007663 if (numParams == 0)
7664 return; // it is known that pname is valid, but there are no parameters to return
7665
7666 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007667 {
Geoff Langbfdea662014-07-23 14:16:32 -04007668 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007669
Geoff Langbfdea662014-07-23 14:16:32 -04007670 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007671
Geoff Langbfdea662014-07-23 14:16:32 -04007672 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007673 {
Geoff Langbfdea662014-07-23 14:16:32 -04007674 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007675 }
Geoff Langbfdea662014-07-23 14:16:32 -04007676
7677 delete [] intParams;
7678 }
7679 else
7680 {
7681 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007682 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007683 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007684 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007685}
7686
Kenneth Russell67ea1902014-10-06 16:44:50 -07007687void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007688{
7689 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7690 target, pname, params);
7691
Geoff Langbfdea662014-07-23 14:16:32 -04007692 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007693 if (context)
7694 {
7695 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007696 {
Geoff Langb1196682014-07-23 13:47:29 -04007697 context->recordError(gl::Error(GL_INVALID_OPERATION));
7698 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007699 }
Geoff Langbfdea662014-07-23 14:16:32 -04007700
7701 if (!gl::ValidBufferTarget(context, target))
7702 {
Geoff Langb1196682014-07-23 13:47:29 -04007703 context->recordError(gl::Error(GL_INVALID_ENUM));
7704 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007705 }
7706
7707 if (!gl::ValidBufferParameter(context, pname))
7708 {
Geoff Langb1196682014-07-23 13:47:29 -04007709 context->recordError(gl::Error(GL_INVALID_ENUM));
7710 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007711 }
7712
7713 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7714
7715 if (!buffer)
7716 {
7717 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007718 context->recordError(gl::Error(GL_INVALID_OPERATION));
7719 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007720 }
7721
7722 switch (pname)
7723 {
7724 case GL_BUFFER_USAGE:
7725 *params = static_cast<GLint64>(buffer->getUsage());
7726 break;
7727 case GL_BUFFER_SIZE:
7728 *params = buffer->getSize();
7729 break;
7730 case GL_BUFFER_ACCESS_FLAGS:
7731 *params = static_cast<GLint64>(buffer->getAccessFlags());
7732 break;
7733 case GL_BUFFER_MAPPED:
7734 *params = static_cast<GLint64>(buffer->isMapped());
7735 break;
7736 case GL_BUFFER_MAP_OFFSET:
7737 *params = buffer->getMapOffset();
7738 break;
7739 case GL_BUFFER_MAP_LENGTH:
7740 *params = buffer->getMapLength();
7741 break;
7742 default: UNREACHABLE(); break;
7743 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007744 }
7745}
7746
Kenneth Russell67ea1902014-10-06 16:44:50 -07007747void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007748{
7749 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7750
Geoff Langbfdea662014-07-23 14:16:32 -04007751 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007752 if (context)
7753 {
7754 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007755 {
Geoff Langb1196682014-07-23 13:47:29 -04007756 context->recordError(gl::Error(GL_INVALID_OPERATION));
7757 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007758 }
Geoff Langbfdea662014-07-23 14:16:32 -04007759
7760 if (count < 0)
7761 {
Geoff Langb1196682014-07-23 13:47:29 -04007762 context->recordError(gl::Error(GL_INVALID_VALUE));
7763 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007764 }
7765
7766 for (int i = 0; i < count; i++)
7767 {
7768 samplers[i] = context->createSampler();
7769 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007770 }
7771}
7772
Kenneth Russell67ea1902014-10-06 16:44:50 -07007773void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007774{
7775 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7776
Geoff Langbfdea662014-07-23 14:16:32 -04007777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007778 if (context)
7779 {
7780 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007781 {
Geoff Langb1196682014-07-23 13:47:29 -04007782 context->recordError(gl::Error(GL_INVALID_OPERATION));
7783 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007784 }
Geoff Langbfdea662014-07-23 14:16:32 -04007785
7786 if (count < 0)
7787 {
Geoff Langb1196682014-07-23 13:47:29 -04007788 context->recordError(gl::Error(GL_INVALID_VALUE));
7789 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007790 }
7791
7792 for (int i = 0; i < count; i++)
7793 {
7794 context->deleteSampler(samplers[i]);
7795 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007796 }
7797}
7798
Kenneth Russell67ea1902014-10-06 16:44:50 -07007799GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007800{
7801 EVENT("(GLuint sampler = %u)", sampler);
7802
Geoff Langbfdea662014-07-23 14:16:32 -04007803 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007804 if (context)
7805 {
7806 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007807 {
Geoff Langb1196682014-07-23 13:47:29 -04007808 context->recordError(gl::Error(GL_INVALID_OPERATION));
7809 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007810 }
Geoff Langbfdea662014-07-23 14:16:32 -04007811
7812 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007813 }
7814
7815 return GL_FALSE;
7816}
7817
Kenneth Russell67ea1902014-10-06 16:44:50 -07007818void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007819{
7820 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7821
Geoff Langbfdea662014-07-23 14:16:32 -04007822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007823 if (context)
7824 {
7825 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007826 {
Geoff Langb1196682014-07-23 13:47:29 -04007827 context->recordError(gl::Error(GL_INVALID_OPERATION));
7828 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007829 }
Geoff Langbfdea662014-07-23 14:16:32 -04007830
7831 if (sampler != 0 && !context->isSampler(sampler))
7832 {
Geoff Langb1196682014-07-23 13:47:29 -04007833 context->recordError(gl::Error(GL_INVALID_OPERATION));
7834 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007835 }
7836
Geoff Lang3a61c322014-07-10 13:01:54 -04007837 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007838 {
Geoff Langb1196682014-07-23 13:47:29 -04007839 context->recordError(gl::Error(GL_INVALID_VALUE));
7840 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007841 }
7842
7843 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007844 }
7845}
7846
Kenneth Russell67ea1902014-10-06 16:44:50 -07007847void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007848{
7849 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7850
Geoff Langbfdea662014-07-23 14:16:32 -04007851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007852 if (context)
7853 {
7854 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007855 {
Geoff Langb1196682014-07-23 13:47:29 -04007856 context->recordError(gl::Error(GL_INVALID_OPERATION));
7857 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007858 }
Geoff Langbfdea662014-07-23 14:16:32 -04007859
Geoff Langb1196682014-07-23 13:47:29 -04007860 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007861 {
7862 return;
7863 }
7864
7865 if (!gl::ValidateTexParamParameters(context, pname, param))
7866 {
7867 return;
7868 }
7869
7870 if (!context->isSampler(sampler))
7871 {
Geoff Langb1196682014-07-23 13:47:29 -04007872 context->recordError(gl::Error(GL_INVALID_OPERATION));
7873 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007874 }
7875
7876 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007877 }
7878}
7879
Kenneth Russell67ea1902014-10-06 16:44:50 -07007880void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007881{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007882 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007883}
7884
Kenneth Russell67ea1902014-10-06 16:44:50 -07007885void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007886{
7887 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7888
Geoff Langbfdea662014-07-23 14:16:32 -04007889 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007890 if (context)
7891 {
7892 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007893 {
Geoff Langb1196682014-07-23 13:47:29 -04007894 context->recordError(gl::Error(GL_INVALID_OPERATION));
7895 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007896 }
Geoff Langbfdea662014-07-23 14:16:32 -04007897
Geoff Langb1196682014-07-23 13:47:29 -04007898 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007899 {
7900 return;
7901 }
7902
7903 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7904 {
7905 return;
7906 }
7907
7908 if (!context->isSampler(sampler))
7909 {
Geoff Langb1196682014-07-23 13:47:29 -04007910 context->recordError(gl::Error(GL_INVALID_OPERATION));
7911 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007912 }
7913
7914 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007915 }
7916}
7917
Kenneth Russell67ea1902014-10-06 16:44:50 -07007918void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007919{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007920 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007921}
7922
Kenneth Russell67ea1902014-10-06 16:44:50 -07007923void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007924{
7925 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7926
Geoff Langbfdea662014-07-23 14:16:32 -04007927 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007928 if (context)
7929 {
7930 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007931 {
Geoff Langb1196682014-07-23 13:47:29 -04007932 context->recordError(gl::Error(GL_INVALID_OPERATION));
7933 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007934 }
Geoff Langbfdea662014-07-23 14:16:32 -04007935
Geoff Langb1196682014-07-23 13:47:29 -04007936 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007937 {
7938 return;
7939 }
7940
7941 if (!context->isSampler(sampler))
7942 {
Geoff Langb1196682014-07-23 13:47:29 -04007943 context->recordError(gl::Error(GL_INVALID_OPERATION));
7944 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007945 }
7946
7947 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007948 }
7949}
7950
Kenneth Russell67ea1902014-10-06 16:44:50 -07007951void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007952{
7953 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
7954
Geoff Langbfdea662014-07-23 14:16:32 -04007955 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007956 if (context)
7957 {
7958 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007959 {
Geoff Langb1196682014-07-23 13:47:29 -04007960 context->recordError(gl::Error(GL_INVALID_OPERATION));
7961 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007962 }
Geoff Langbfdea662014-07-23 14:16:32 -04007963
Geoff Langb1196682014-07-23 13:47:29 -04007964 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007965 {
7966 return;
7967 }
7968
7969 if (!context->isSampler(sampler))
7970 {
Geoff Langb1196682014-07-23 13:47:29 -04007971 context->recordError(gl::Error(GL_INVALID_OPERATION));
7972 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007973 }
7974
7975 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007976 }
7977}
7978
Kenneth Russell67ea1902014-10-06 16:44:50 -07007979void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980{
7981 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
7982
Geoff Langbfdea662014-07-23 14:16:32 -04007983 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007984 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007985 {
Geoff Langbfdea662014-07-23 14:16:32 -04007986 if (context->getClientVersion() < 3)
7987 {
Geoff Langb1196682014-07-23 13:47:29 -04007988 context->recordError(gl::Error(GL_INVALID_OPERATION));
7989 return;
7990 }
7991
7992 if (index >= gl::MAX_VERTEX_ATTRIBS)
7993 {
7994 context->recordError(gl::Error(GL_INVALID_VALUE));
7995 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007996 }
7997
7998 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007999 }
8000}
8001
Kenneth Russell67ea1902014-10-06 16:44:50 -07008002void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008003{
8004 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8005
Geoff Langbfdea662014-07-23 14:16:32 -04008006 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008007 if (context)
8008 {
8009 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008010 {
Geoff Langb1196682014-07-23 13:47:29 -04008011 context->recordError(gl::Error(GL_INVALID_OPERATION));
8012 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008013 }
Geoff Langbfdea662014-07-23 14:16:32 -04008014
8015 switch (target)
8016 {
8017 case GL_TRANSFORM_FEEDBACK:
8018 {
8019 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8020 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8021 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8022 {
Geoff Langb1196682014-07-23 13:47:29 -04008023 context->recordError(gl::Error(GL_INVALID_OPERATION));
8024 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008025 }
8026
8027 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8028 if (context->getTransformFeedback(id) == NULL)
8029 {
Geoff Langb1196682014-07-23 13:47:29 -04008030 context->recordError(gl::Error(GL_INVALID_OPERATION));
8031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008032 }
8033
8034 context->bindTransformFeedback(id);
8035 }
8036 break;
8037
8038 default:
Geoff Langb1196682014-07-23 13:47:29 -04008039 context->recordError(gl::Error(GL_INVALID_ENUM));
8040 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008041 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008042 }
8043}
8044
Kenneth Russell67ea1902014-10-06 16:44:50 -07008045void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008046{
8047 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8048
Geoff Langbfdea662014-07-23 14:16:32 -04008049 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008050 if (context)
8051 {
8052 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008053 {
Geoff Langb1196682014-07-23 13:47:29 -04008054 context->recordError(gl::Error(GL_INVALID_OPERATION));
8055 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008056 }
Geoff Langbfdea662014-07-23 14:16:32 -04008057
8058 for (int i = 0; i < n; i++)
8059 {
8060 context->deleteTransformFeedback(ids[i]);
8061 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008062 }
8063}
8064
Kenneth Russell67ea1902014-10-06 16:44:50 -07008065void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008066{
8067 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8068
Geoff Langbfdea662014-07-23 14:16:32 -04008069 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008070 if (context)
8071 {
8072 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008073 {
Geoff Langb1196682014-07-23 13:47:29 -04008074 context->recordError(gl::Error(GL_INVALID_OPERATION));
8075 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008076 }
Geoff Langbfdea662014-07-23 14:16:32 -04008077
8078 for (int i = 0; i < n; i++)
8079 {
8080 ids[i] = context->createTransformFeedback();
8081 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008082 }
8083}
8084
Kenneth Russell67ea1902014-10-06 16:44:50 -07008085GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008086{
8087 EVENT("(GLuint id = %u)", id);
8088
Geoff Langbfdea662014-07-23 14:16:32 -04008089 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008090 if (context)
8091 {
8092 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008093 {
Geoff Langb1196682014-07-23 13:47:29 -04008094 context->recordError(gl::Error(GL_INVALID_OPERATION));
8095 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008096 }
Geoff Langbfdea662014-07-23 14:16:32 -04008097
8098 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008099 }
8100
8101 return GL_FALSE;
8102}
8103
Kenneth Russell67ea1902014-10-06 16:44:50 -07008104void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008105{
8106 EVENT("(void)");
8107
Geoff Langbfdea662014-07-23 14:16:32 -04008108 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008109 if (context)
8110 {
8111 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008112 {
Geoff Langb1196682014-07-23 13:47:29 -04008113 context->recordError(gl::Error(GL_INVALID_OPERATION));
8114 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008115 }
Geoff Langbfdea662014-07-23 14:16:32 -04008116
8117 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8118 ASSERT(transformFeedback != NULL);
8119
8120 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8121 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8122 {
Geoff Langb1196682014-07-23 13:47:29 -04008123 context->recordError(gl::Error(GL_INVALID_OPERATION));
8124 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008125 }
8126
8127 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008128 }
8129}
8130
Kenneth Russell67ea1902014-10-06 16:44:50 -07008131void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008132{
8133 EVENT("(void)");
8134
Geoff Langbfdea662014-07-23 14:16:32 -04008135 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008136 if (context)
8137 {
8138 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008139 {
Geoff Langb1196682014-07-23 13:47:29 -04008140 context->recordError(gl::Error(GL_INVALID_OPERATION));
8141 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008142 }
Geoff Langbfdea662014-07-23 14:16:32 -04008143
8144 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8145 ASSERT(transformFeedback != NULL);
8146
8147 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8148 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8149 {
Geoff Langb1196682014-07-23 13:47:29 -04008150 context->recordError(gl::Error(GL_INVALID_OPERATION));
8151 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008152 }
8153
8154 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008155 }
8156}
8157
Kenneth Russell67ea1902014-10-06 16:44:50 -07008158void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008159{
8160 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8161 program, bufSize, length, binaryFormat, binary);
8162
Geoff Langbfdea662014-07-23 14:16:32 -04008163 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008164 if (context)
8165 {
8166 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008167 {
Geoff Langb1196682014-07-23 13:47:29 -04008168 context->recordError(gl::Error(GL_INVALID_OPERATION));
8169 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008170 }
Geoff Langbfdea662014-07-23 14:16:32 -04008171
8172 // glGetProgramBinary
8173 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008174 }
8175}
8176
Kenneth Russell67ea1902014-10-06 16:44:50 -07008177void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008178{
8179 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8180 program, binaryFormat, binary, length);
8181
Geoff Langbfdea662014-07-23 14:16:32 -04008182 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008183 if (context)
8184 {
8185 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008186 {
Geoff Langb1196682014-07-23 13:47:29 -04008187 context->recordError(gl::Error(GL_INVALID_OPERATION));
8188 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008189 }
Geoff Langbfdea662014-07-23 14:16:32 -04008190
8191 // glProgramBinary
8192 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008193 }
8194}
8195
Kenneth Russell67ea1902014-10-06 16:44:50 -07008196void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008197{
8198 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8199 program, pname, value);
8200
Geoff Langbfdea662014-07-23 14:16:32 -04008201 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008202 if (context)
8203 {
8204 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008205 {
Geoff Langb1196682014-07-23 13:47:29 -04008206 context->recordError(gl::Error(GL_INVALID_OPERATION));
8207 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008208 }
Geoff Langbfdea662014-07-23 14:16:32 -04008209
8210 // glProgramParameteri
8211 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008212 }
8213}
8214
Kenneth Russell67ea1902014-10-06 16:44:50 -07008215void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008216{
8217 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8218 target, numAttachments, attachments);
8219
Geoff Langbfdea662014-07-23 14:16:32 -04008220 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008221 if (context)
8222 {
8223 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008224 {
Geoff Langb1196682014-07-23 13:47:29 -04008225 context->recordError(gl::Error(GL_INVALID_OPERATION));
8226 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008227 }
Geoff Langbfdea662014-07-23 14:16:32 -04008228
8229 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8230 {
8231 return;
8232 }
8233
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008234 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008235 ASSERT(framebuffer);
8236
8237 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008238 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008239 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8240 if (error.isError())
8241 {
8242 context->recordError(error);
8243 return;
8244 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008245 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008246 }
8247}
8248
Kenneth Russell67ea1902014-10-06 16:44:50 -07008249void 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 +00008250{
8251 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8252 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8253 target, numAttachments, attachments, x, y, width, height);
8254
Geoff Langbfdea662014-07-23 14:16:32 -04008255 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008256 if (context)
8257 {
8258 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008259 {
Geoff Langb1196682014-07-23 13:47:29 -04008260 context->recordError(gl::Error(GL_INVALID_OPERATION));
8261 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008262 }
Geoff Langbfdea662014-07-23 14:16:32 -04008263
8264 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8265 {
8266 return;
8267 }
8268
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008269 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008270 ASSERT(framebuffer);
8271
8272 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008273 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008274 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8275 if (error.isError())
8276 {
8277 context->recordError(error);
8278 return;
8279 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008281 }
8282}
8283
Kenneth Russell67ea1902014-10-06 16:44:50 -07008284void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008285{
8286 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8287 target, levels, internalformat, width, height);
8288
Geoff Langbfdea662014-07-23 14:16:32 -04008289 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008290 if (context)
8291 {
8292 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008293 {
Geoff Langb1196682014-07-23 13:47:29 -04008294 context->recordError(gl::Error(GL_INVALID_OPERATION));
8295 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008296 }
Geoff Langbfdea662014-07-23 14:16:32 -04008297
8298 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8299 {
8300 return;
8301 }
8302
8303 switch (target)
8304 {
8305 case GL_TEXTURE_2D:
8306 {
8307 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008308 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8309 if (error.isError())
8310 {
8311 context->recordError(error);
8312 return;
8313 }
Geoff Langbfdea662014-07-23 14:16:32 -04008314 }
8315 break;
8316
8317 case GL_TEXTURE_CUBE_MAP:
8318 {
8319 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008320 gl::Error error = textureCube->storage(levels, internalformat, width);
8321 if (error.isError())
8322 {
8323 context->recordError(error);
8324 return;
8325 }
Geoff Langbfdea662014-07-23 14:16:32 -04008326 }
8327 break;
8328
8329 default:
Geoff Langb1196682014-07-23 13:47:29 -04008330 context->recordError(gl::Error(GL_INVALID_ENUM));
8331 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008332 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008333 }
8334}
8335
Kenneth Russell67ea1902014-10-06 16:44:50 -07008336void 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 +00008337{
8338 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8339 "GLsizei height = %d, GLsizei depth = %d)",
8340 target, levels, internalformat, width, height, depth);
8341
Geoff Langbfdea662014-07-23 14:16:32 -04008342 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008343 if (context)
8344 {
8345 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008346 {
Geoff Langb1196682014-07-23 13:47:29 -04008347 context->recordError(gl::Error(GL_INVALID_OPERATION));
8348 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008349 }
Geoff Langbfdea662014-07-23 14:16:32 -04008350
8351 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8352 {
8353 return;
8354 }
8355
8356 switch (target)
8357 {
8358 case GL_TEXTURE_3D:
8359 {
8360 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008361 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8362 if (error.isError())
8363 {
8364 context->recordError(error);
8365 return;
8366 }
Geoff Langbfdea662014-07-23 14:16:32 -04008367 }
8368 break;
8369
8370 case GL_TEXTURE_2D_ARRAY:
8371 {
8372 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008373 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8374 if (error.isError())
8375 {
8376 context->recordError(error);
8377 return;
8378 }
Geoff Langbfdea662014-07-23 14:16:32 -04008379 }
8380 break;
8381
8382 default:
8383 UNREACHABLE();
8384 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008385 }
8386}
8387
Kenneth Russell67ea1902014-10-06 16:44:50 -07008388void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008389{
8390 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8391 "GLint* params = 0x%0.8p)",
8392 target, internalformat, pname, bufSize, params);
8393
Geoff Langbfdea662014-07-23 14:16:32 -04008394 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008395 if (context)
8396 {
8397 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008398 {
Geoff Langb1196682014-07-23 13:47:29 -04008399 context->recordError(gl::Error(GL_INVALID_OPERATION));
8400 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008401 }
Geoff Langbfdea662014-07-23 14:16:32 -04008402
8403 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8404 if (!formatCaps.renderable)
8405 {
Geoff Langb1196682014-07-23 13:47:29 -04008406 context->recordError(gl::Error(GL_INVALID_ENUM));
8407 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008408 }
8409
8410 if (target != GL_RENDERBUFFER)
8411 {
Geoff Langb1196682014-07-23 13:47:29 -04008412 context->recordError(gl::Error(GL_INVALID_ENUM));
8413 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008414 }
8415
8416 if (bufSize < 0)
8417 {
Geoff Langb1196682014-07-23 13:47:29 -04008418 context->recordError(gl::Error(GL_INVALID_VALUE));
8419 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008420 }
8421
8422 switch (pname)
8423 {
8424 case GL_NUM_SAMPLE_COUNTS:
8425 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008426 {
8427 *params = formatCaps.sampleCounts.size();
8428 }
Geoff Langbfdea662014-07-23 14:16:32 -04008429 break;
Geoff Langb1196682014-07-23 13:47:29 -04008430
Geoff Langbfdea662014-07-23 14:16:32 -04008431 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008432 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008433 break;
Geoff Langb1196682014-07-23 13:47:29 -04008434
Geoff Langbfdea662014-07-23 14:16:32 -04008435 default:
Geoff Langb1196682014-07-23 13:47:29 -04008436 context->recordError(gl::Error(GL_INVALID_ENUM));
8437 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008438 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008439 }
8440}
8441
8442// Extension functions
8443
Kenneth Russell67ea1902014-10-06 16:44:50 -07008444void 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 +00008445 GLbitfield mask, GLenum filter)
8446{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008447 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008448 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8449 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8450 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8451
Geoff Langbfdea662014-07-23 14:16:32 -04008452 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008453 if (context)
8454 {
8455 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8456 dstX0, dstY0, dstX1, dstY1, mask, filter,
8457 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008458 {
Geoff Langbfdea662014-07-23 14:16:32 -04008459 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008460 }
Geoff Langbfdea662014-07-23 14:16:32 -04008461
Geoff Lang64839152014-08-26 16:23:25 -04008462 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8463 mask, filter);
8464 if (error.isError())
8465 {
8466 context->recordError(error);
8467 return;
8468 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008469 }
8470}
8471
Kenneth Russell67ea1902014-10-06 16:44:50 -07008472void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008473 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008474{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008475 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008476 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008477 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008478 target, level, internalformat, width, height, depth, border, format, type, pixels);
8479
Geoff Langbfdea662014-07-23 14:16:32 -04008480 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008481}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008482
Kenneth Russell67ea1902014-10-06 16:44:50 -07008483void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008484 GLenum *binaryFormat, void *binary)
8485{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008486 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 +00008487 program, bufSize, length, binaryFormat, binary);
8488
Geoff Langbfdea662014-07-23 14:16:32 -04008489 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008490 if (context)
8491 {
8492 gl::Program *programObject = context->getProgram(program);
8493
8494 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008495 {
Geoff Langb1196682014-07-23 13:47:29 -04008496 context->recordError(gl::Error(GL_INVALID_OPERATION));
8497 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008498 }
Geoff Langbfdea662014-07-23 14:16:32 -04008499
8500 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8501
8502 if (!programBinary)
8503 {
Geoff Langb1196682014-07-23 13:47:29 -04008504 context->recordError(gl::Error(GL_INVALID_OPERATION));
8505 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008506 }
8507
Geoff Langb543aff2014-09-30 14:52:54 -04008508 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8509 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008510 {
Geoff Langb543aff2014-09-30 14:52:54 -04008511 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008512 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008513 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008514 }
8515}
8516
Kenneth Russell67ea1902014-10-06 16:44:50 -07008517void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008518 const void *binary, GLint length)
8519{
8520 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8521 program, binaryFormat, binary, length);
8522
Geoff Langbfdea662014-07-23 14:16:32 -04008523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008524 if (context)
8525 {
Geoff Lang900013c2014-07-07 11:32:19 -04008526 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8527 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008528 {
Geoff Langb1196682014-07-23 13:47:29 -04008529 context->recordError(gl::Error(GL_INVALID_ENUM));
8530 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008531 }
Geoff Langbfdea662014-07-23 14:16:32 -04008532
8533 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008534 if (!programObject)
8535 {
Geoff Langb1196682014-07-23 13:47:29 -04008536 context->recordError(gl::Error(GL_INVALID_OPERATION));
8537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008538 }
8539
Geoff Langb543aff2014-09-30 14:52:54 -04008540 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8541 if (error.isError())
8542 {
8543 context->recordError(error);
8544 return;
8545 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008546 }
8547}
8548
Kenneth Russell67ea1902014-10-06 16:44:50 -07008549void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008550{
8551 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8552
Geoff Langbfdea662014-07-23 14:16:32 -04008553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008554 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008555 {
Geoff Langbfdea662014-07-23 14:16:32 -04008556 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008557 {
Geoff Langb1196682014-07-23 13:47:29 -04008558 context->recordError(gl::Error(GL_INVALID_VALUE));
8559 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008560 }
8561
Jamie Madill48faf802014-11-06 15:27:22 -05008562 ASSERT(context->getState().getDrawFramebuffer());
8563
Geoff Langbfdea662014-07-23 14:16:32 -04008564 if (context->getState().getDrawFramebuffer()->id() == 0)
8565 {
8566 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008567 {
Geoff Langb1196682014-07-23 13:47:29 -04008568 context->recordError(gl::Error(GL_INVALID_OPERATION));
8569 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008570 }
8571
Geoff Langbfdea662014-07-23 14:16:32 -04008572 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008573 {
Geoff Langb1196682014-07-23 13:47:29 -04008574 context->recordError(gl::Error(GL_INVALID_OPERATION));
8575 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008576 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008577 }
Geoff Langbfdea662014-07-23 14:16:32 -04008578 else
8579 {
8580 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8581 {
8582 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8583 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8584 {
Geoff Langb1196682014-07-23 13:47:29 -04008585 context->recordError(gl::Error(GL_INVALID_OPERATION));
8586 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008587 }
8588 }
8589 }
8590
8591 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -05008592 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04008593
8594 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8595 {
8596 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8597 }
8598
8599 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8600 {
8601 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8602 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008603 }
8604}
8605
Kenneth Russell67ea1902014-10-06 16:44:50 -07008606void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008607{
8608 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8609
Geoff Langbfdea662014-07-23 14:16:32 -04008610 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008611 if (context)
8612 {
8613 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008614 {
Geoff Langb1196682014-07-23 13:47:29 -04008615 context->recordError(gl::Error(GL_INVALID_ENUM));
8616 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008617 }
Geoff Langbfdea662014-07-23 14:16:32 -04008618
8619 if (pname != GL_BUFFER_MAP_POINTER)
8620 {
Geoff Langb1196682014-07-23 13:47:29 -04008621 context->recordError(gl::Error(GL_INVALID_ENUM));
8622 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008623 }
8624
8625 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8626
8627 if (!buffer || !buffer->isMapped())
8628 {
8629 *params = NULL;
8630 }
8631 else
8632 {
8633 *params = buffer->getMapPointer();
8634 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008635 }
8636}
8637
Kenneth Russell67ea1902014-10-06 16:44:50 -07008638void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008639{
8640 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8641
Geoff Langbfdea662014-07-23 14:16:32 -04008642 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008643 if (context)
8644 {
8645 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008646 {
Geoff Langb1196682014-07-23 13:47:29 -04008647 context->recordError(gl::Error(GL_INVALID_ENUM));
8648 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008649 }
Geoff Langbfdea662014-07-23 14:16:32 -04008650
8651 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8652
8653 if (buffer == NULL)
8654 {
Geoff Langb1196682014-07-23 13:47:29 -04008655 context->recordError(gl::Error(GL_INVALID_OPERATION));
8656 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008657 }
8658
8659 if (access != GL_WRITE_ONLY_OES)
8660 {
Geoff Langb1196682014-07-23 13:47:29 -04008661 context->recordError(gl::Error(GL_INVALID_ENUM));
8662 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008663 }
8664
8665 if (buffer->isMapped())
8666 {
Geoff Langb1196682014-07-23 13:47:29 -04008667 context->recordError(gl::Error(GL_INVALID_OPERATION));
8668 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008669 }
8670
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008671 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8672 if (error.isError())
8673 {
8674 context->recordError(error);
8675 return NULL;
8676 }
8677
8678 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008679 }
8680
8681 return NULL;
8682}
8683
Kenneth Russell67ea1902014-10-06 16:44:50 -07008684GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008685{
8686 EVENT("(GLenum target = 0x%X)", target);
8687
Geoff Langbfdea662014-07-23 14:16:32 -04008688 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008689 if (context)
8690 {
8691 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008692 {
Geoff Langb1196682014-07-23 13:47:29 -04008693 context->recordError(gl::Error(GL_INVALID_ENUM));
8694 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008695 }
Geoff Langbfdea662014-07-23 14:16:32 -04008696
8697 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8698
8699 if (buffer == NULL || !buffer->isMapped())
8700 {
Geoff Langb1196682014-07-23 13:47:29 -04008701 context->recordError(gl::Error(GL_INVALID_OPERATION));
8702 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008703 }
8704
8705 // TODO: detect if we had corruption. if so, throw an error and return false.
8706
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008707 gl::Error error = buffer->unmap();
8708 if (error.isError())
8709 {
8710 context->recordError(error);
8711 return GL_FALSE;
8712 }
Geoff Langbfdea662014-07-23 14:16:32 -04008713
8714 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008715 }
8716
8717 return GL_FALSE;
8718}
8719
Kenneth Russell67ea1902014-10-06 16:44:50 -07008720void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008721{
8722 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8723 target, offset, length, access);
8724
Geoff Langbfdea662014-07-23 14:16:32 -04008725 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008726 if (context)
8727 {
8728 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008729 {
Geoff Langb1196682014-07-23 13:47:29 -04008730 context->recordError(gl::Error(GL_INVALID_ENUM));
8731 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008732 }
Geoff Langbfdea662014-07-23 14:16:32 -04008733
8734 if (offset < 0 || length < 0)
8735 {
Geoff Langb1196682014-07-23 13:47:29 -04008736 context->recordError(gl::Error(GL_INVALID_VALUE));
8737 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008738 }
8739
8740 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8741
8742 if (buffer == NULL)
8743 {
Geoff Langb1196682014-07-23 13:47:29 -04008744 context->recordError(gl::Error(GL_INVALID_OPERATION));
8745 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008746 }
8747
8748 // Check for buffer overflow
8749 size_t offsetSize = static_cast<size_t>(offset);
8750 size_t lengthSize = static_cast<size_t>(length);
8751
8752 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8753 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8754 {
Geoff Langb1196682014-07-23 13:47:29 -04008755 context->recordError(gl::Error(GL_INVALID_VALUE));
8756 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008757 }
8758
8759 // Check for invalid bits in the mask
8760 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8761 GL_MAP_WRITE_BIT |
8762 GL_MAP_INVALIDATE_RANGE_BIT |
8763 GL_MAP_INVALIDATE_BUFFER_BIT |
8764 GL_MAP_FLUSH_EXPLICIT_BIT |
8765 GL_MAP_UNSYNCHRONIZED_BIT;
8766
8767 if (access & ~(allAccessBits))
8768 {
Geoff Langb1196682014-07-23 13:47:29 -04008769 context->recordError(gl::Error(GL_INVALID_VALUE));
8770 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008771 }
8772
8773 if (length == 0 || buffer->isMapped())
8774 {
Geoff Langb1196682014-07-23 13:47:29 -04008775 context->recordError(gl::Error(GL_INVALID_OPERATION));
8776 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008777 }
8778
8779 // Check for invalid bit combinations
8780 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8781 {
Geoff Langb1196682014-07-23 13:47:29 -04008782 context->recordError(gl::Error(GL_INVALID_OPERATION));
8783 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008784 }
8785
8786 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8787 GL_MAP_INVALIDATE_BUFFER_BIT |
8788 GL_MAP_UNSYNCHRONIZED_BIT;
8789
8790 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8791 {
Geoff Langb1196682014-07-23 13:47:29 -04008792 context->recordError(gl::Error(GL_INVALID_OPERATION));
8793 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008794 }
8795
8796 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8797 {
Geoff Langb1196682014-07-23 13:47:29 -04008798 context->recordError(gl::Error(GL_INVALID_OPERATION));
8799 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008800 }
8801
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008802 gl::Error error = buffer->mapRange(offset, length, access);
8803 if (error.isError())
8804 {
8805 context->recordError(error);
8806 return NULL;
8807 }
8808
8809 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008810 }
8811
8812 return NULL;
8813}
8814
Kenneth Russell67ea1902014-10-06 16:44:50 -07008815void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008816{
8817 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8818
Geoff Langbfdea662014-07-23 14:16:32 -04008819 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008820 if (context)
8821 {
8822 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008823 {
Geoff Langb1196682014-07-23 13:47:29 -04008824 context->recordError(gl::Error(GL_INVALID_VALUE));
8825 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008826 }
Geoff Langbfdea662014-07-23 14:16:32 -04008827
8828 if (!gl::ValidBufferTarget(context, target))
8829 {
Geoff Langb1196682014-07-23 13:47:29 -04008830 context->recordError(gl::Error(GL_INVALID_ENUM));
8831 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008832 }
8833
8834 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8835
8836 if (buffer == NULL)
8837 {
Geoff Langb1196682014-07-23 13:47:29 -04008838 context->recordError(gl::Error(GL_INVALID_OPERATION));
8839 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008840 }
8841
8842 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8843 {
Geoff Langb1196682014-07-23 13:47:29 -04008844 context->recordError(gl::Error(GL_INVALID_OPERATION));
8845 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008846 }
8847
8848 // Check for buffer overflow
8849 size_t offsetSize = static_cast<size_t>(offset);
8850 size_t lengthSize = static_cast<size_t>(length);
8851
8852 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8853 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8854 {
Geoff Langb1196682014-07-23 13:47:29 -04008855 context->recordError(gl::Error(GL_INVALID_VALUE));
8856 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008857 }
8858
8859 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008860 }
8861}
8862
Kenneth Russell67ea1902014-10-06 16:44:50 -07008863__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008864{
8865 struct Extension
8866 {
8867 const char *name;
8868 __eglMustCastToProperFunctionPointerType address;
8869 };
8870
8871 static const Extension glExtensions[] =
8872 {
8873 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008874 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008875 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008876 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8877 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8878 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8879 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8880 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8881 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8882 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008883 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008884 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008885 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8886 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8887 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8888 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008889 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8890 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8891 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8892 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8893 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8894 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8895 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008896 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008897 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8898 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8899 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008900 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008901 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8902 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8903 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008904 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8905 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8906 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008907
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008908 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008909 {
8910 if (strcmp(procname, glExtensions[ext].name) == 0)
8911 {
8912 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8913 }
8914 }
8915
8916 return NULL;
8917}
8918
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008919// Non-public functions used by EGL
8920
Kenneth Russell67ea1902014-10-06 16:44:50 -07008921bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008922{
8923 EVENT("(egl::Surface* surface = 0x%0.8p)",
8924 surface);
8925
Geoff Langbfdea662014-07-23 14:16:32 -04008926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008927 if (context)
8928 {
8929 gl::Texture2D *textureObject = context->getTexture2D();
8930 ASSERT(textureObject != NULL);
8931
8932 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008933 {
Geoff Langbfdea662014-07-23 14:16:32 -04008934 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008935 }
Geoff Langbfdea662014-07-23 14:16:32 -04008936
8937 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008938 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008939
8940 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008941}
8942
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008943}