blob: a585127341032fa402f5cdff56e3fdf8884c0c51 [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
731 shaderObject->compile();
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
1598 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1599 {
1600 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1601 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1602 }
1603 else
1604 {
1605 switch (attachment)
1606 {
1607 case GL_DEPTH_ATTACHMENT:
1608 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1609 break;
1610 case GL_STENCIL_ATTACHMENT:
1611 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1612 break;
1613 case GL_DEPTH_STENCIL_ATTACHMENT:
1614 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1615 break;
1616 default:
1617 UNREACHABLE();
1618 break;
1619 }
1620 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001621 }
1622}
1623
Kenneth Russell67ea1902014-10-06 16:44:50 -07001624void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001626 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001627 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001628
Geoff Langbfdea662014-07-23 14:16:32 -04001629 gl::Context *context = gl::getNonLostContext();
1630 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001633 {
Geoff Langbfdea662014-07-23 14:16:32 -04001634 return;
1635 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001636
Geoff Langbfdea662014-07-23 14:16:32 -04001637 if (texture == 0)
1638 {
1639 textarget = GL_NONE;
1640 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05001643 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001644
Geoff Langbfdea662014-07-23 14:16:32 -04001645 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1646 {
1647 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1648 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1649 }
1650 else
1651 {
1652 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001653 {
Geoff Langbfdea662014-07-23 14:16:32 -04001654 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1655 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1656 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001657 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001658 }
1659 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660}
1661
Kenneth Russell67ea1902014-10-06 16:44:50 -07001662void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001664 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665
Geoff Langb1196682014-07-23 13:47:29 -04001666 gl::Context *context = gl::getNonLostContext();
1667 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001668 {
Geoff Langb1196682014-07-23 13:47:29 -04001669 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001670 {
Geoff Langb1196682014-07-23 13:47:29 -04001671 case GL_CW:
1672 case GL_CCW:
1673 context->getState().setFrontFace(mode);
1674 break;
1675 default:
1676 context->recordError(gl::Error(GL_INVALID_ENUM));
1677 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001678 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001679 }
1680}
1681
Kenneth Russell67ea1902014-10-06 16:44:50 -07001682void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001683{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001684 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685
Geoff Langbfdea662014-07-23 14:16:32 -04001686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001687 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001688 {
Geoff Langb1196682014-07-23 13:47:29 -04001689 if (n < 0)
1690 {
1691 context->recordError(gl::Error(GL_INVALID_VALUE));
1692 return;
1693 }
1694
Geoff Langbfdea662014-07-23 14:16:32 -04001695 for (int i = 0; i < n; i++)
1696 {
1697 buffers[i] = context->createBuffer();
1698 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001699 }
1700}
1701
Kenneth Russell67ea1902014-10-06 16:44:50 -07001702void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001703{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001704 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001705
Geoff Langbfdea662014-07-23 14:16:32 -04001706 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001707 if (context)
1708 {
1709 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 {
Geoff Langb1196682014-07-23 13:47:29 -04001711 context->recordError(gl::Error(GL_INVALID_ENUM));
1712 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001713 }
Geoff Langbfdea662014-07-23 14:16:32 -04001714
1715 gl::Texture *texture = context->getTargetTexture(target);
1716
1717 if (texture == NULL)
1718 {
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 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1724 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001725 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001726
1727 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1728 // unsized formats or that are color renderable and filterable. Since we do not track if
1729 // the texture was created with sized or unsized format (only sized formats are stored),
1730 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1731 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1732 // textures since they're the only texture format that can be created with unsized formats
1733 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1734 // was the last version to use add them.
1735 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1736 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1737 internalFormat == GL_ALPHA8_EXT;
1738
Geoff Lang5d601382014-07-22 15:14:06 -04001739 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1740 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001741 {
Geoff Langb1196682014-07-23 13:47:29 -04001742 context->recordError(gl::Error(GL_INVALID_OPERATION));
1743 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001744 }
1745
1746 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001747 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001748 {
Geoff Langb1196682014-07-23 13:47:29 -04001749 context->recordError(gl::Error(GL_INVALID_OPERATION));
1750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001751 }
1752
1753 // Non-power of 2 ES2 check
1754 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1755 {
1756 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001757 context->recordError(gl::Error(GL_INVALID_OPERATION));
1758 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001759 }
1760
1761 // Cube completeness check
1762 if (target == GL_TEXTURE_CUBE_MAP)
1763 {
1764 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1765 if (!textureCube->isCubeComplete())
1766 {
Geoff Langb1196682014-07-23 13:47:29 -04001767 context->recordError(gl::Error(GL_INVALID_OPERATION));
1768 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001769 }
1770 }
1771
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001772 gl::Error error = texture->generateMipmaps();
1773 if (error.isError())
1774 {
1775 context->recordError(error);
1776 return;
1777 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001778 }
1779}
1780
Kenneth Russell67ea1902014-10-06 16:44:50 -07001781void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001782{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001783 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001784
Geoff Langbfdea662014-07-23 14:16:32 -04001785 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001786 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001787 {
Geoff Langb1196682014-07-23 13:47:29 -04001788 if (n < 0)
1789 {
1790 context->recordError(gl::Error(GL_INVALID_VALUE));
1791 return;
1792 }
1793
Geoff Langbfdea662014-07-23 14:16:32 -04001794 for (int i = 0; i < n; i++)
1795 {
1796 fences[i] = context->createFenceNV();
1797 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001798 }
1799}
1800
Kenneth Russell67ea1902014-10-06 16:44:50 -07001801void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001802{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001803 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001804
Geoff Langbfdea662014-07-23 14:16:32 -04001805 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001806 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001807 {
Geoff Langb1196682014-07-23 13:47:29 -04001808 if (n < 0)
1809 {
1810 context->recordError(gl::Error(GL_INVALID_VALUE));
1811 return;
1812 }
1813
Geoff Langbfdea662014-07-23 14:16:32 -04001814 for (int i = 0; i < n; i++)
1815 {
1816 framebuffers[i] = context->createFramebuffer();
1817 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001818 }
1819}
1820
Kenneth Russell67ea1902014-10-06 16:44:50 -07001821void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001822{
1823 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1824
Geoff Langbfdea662014-07-23 14:16:32 -04001825 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001826 if (context)
1827 {
1828 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001829 {
Geoff Langb1196682014-07-23 13:47:29 -04001830 context->recordError(gl::Error(GL_INVALID_VALUE));
1831 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001832 }
Geoff Langbfdea662014-07-23 14:16:32 -04001833
1834 for (GLsizei i = 0; i < n; i++)
1835 {
1836 ids[i] = context->createQuery();
1837 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001838 }
1839}
1840
Kenneth Russell67ea1902014-10-06 16:44:50 -07001841void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001842{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001843 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844
Geoff Langbfdea662014-07-23 14:16:32 -04001845 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001846 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001847 {
Geoff Langb1196682014-07-23 13:47:29 -04001848 if (n < 0)
1849 {
1850 context->recordError(gl::Error(GL_INVALID_VALUE));
1851 return;
1852 }
1853
Geoff Langbfdea662014-07-23 14:16:32 -04001854 for (int i = 0; i < n; i++)
1855 {
1856 renderbuffers[i] = context->createRenderbuffer();
1857 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001858 }
1859}
1860
Kenneth Russell67ea1902014-10-06 16:44:50 -07001861void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001863 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001864
Geoff Langbfdea662014-07-23 14:16:32 -04001865 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001866 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001867 {
Geoff Langb1196682014-07-23 13:47:29 -04001868 if (n < 0)
1869 {
1870 context->recordError(gl::Error(GL_INVALID_VALUE));
1871 return;
1872 }
1873
Geoff Langbfdea662014-07-23 14:16:32 -04001874 for (int i = 0; i < n; i++)
1875 {
1876 textures[i] = context->createTexture();
1877 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001878 }
1879}
1880
Kenneth Russell67ea1902014-10-06 16:44:50 -07001881void 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 +00001882{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001883 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001884 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001885 program, index, bufsize, length, size, type, name);
1886
Geoff Langbfdea662014-07-23 14:16:32 -04001887 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001888 if (context)
1889 {
Geoff Langb1196682014-07-23 13:47:29 -04001890 if (bufsize < 0)
1891 {
1892 context->recordError(gl::Error(GL_INVALID_VALUE));
1893 return;
1894 }
1895
Geoff Langbfdea662014-07-23 14:16:32 -04001896 gl::Program *programObject = context->getProgram(program);
1897
1898 if (!programObject)
1899 {
1900 if (context->getShader(program))
1901 {
Geoff Langb1196682014-07-23 13:47:29 -04001902 context->recordError(gl::Error(GL_INVALID_OPERATION));
1903 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001904 }
1905 else
1906 {
Geoff Langb1196682014-07-23 13:47:29 -04001907 context->recordError(gl::Error(GL_INVALID_VALUE));
1908 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001909 }
1910 }
1911
1912 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001913 {
Geoff Langb1196682014-07-23 13:47:29 -04001914 context->recordError(gl::Error(GL_INVALID_VALUE));
1915 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001916 }
1917
Geoff Langbfdea662014-07-23 14:16:32 -04001918 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001919 }
1920}
1921
Kenneth Russell67ea1902014-10-06 16:44:50 -07001922void 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 +00001923{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001924 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001925 "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 +00001926 program, index, bufsize, length, size, type, name);
1927
Geoff Langbfdea662014-07-23 14:16:32 -04001928
1929 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001930 if (context)
1931 {
Geoff Langb1196682014-07-23 13:47:29 -04001932 if (bufsize < 0)
1933 {
1934 context->recordError(gl::Error(GL_INVALID_VALUE));
1935 return;
1936 }
1937
Geoff Langbfdea662014-07-23 14:16:32 -04001938 gl::Program *programObject = context->getProgram(program);
1939
1940 if (!programObject)
1941 {
1942 if (context->getShader(program))
1943 {
Geoff Langb1196682014-07-23 13:47:29 -04001944 context->recordError(gl::Error(GL_INVALID_OPERATION));
1945 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001946 }
1947 else
1948 {
Geoff Langb1196682014-07-23 13:47:29 -04001949 context->recordError(gl::Error(GL_INVALID_VALUE));
1950 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001951 }
1952 }
1953
1954 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001955 {
Geoff Langb1196682014-07-23 13:47:29 -04001956 context->recordError(gl::Error(GL_INVALID_VALUE));
1957 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958 }
1959
Geoff Langbfdea662014-07-23 14:16:32 -04001960 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001961 }
1962}
1963
Kenneth Russell67ea1902014-10-06 16:44:50 -07001964void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001966 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 +00001967 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001968
Geoff Langbfdea662014-07-23 14:16:32 -04001969 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001970 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001971 {
Geoff Langb1196682014-07-23 13:47:29 -04001972 if (maxcount < 0)
1973 {
1974 context->recordError(gl::Error(GL_INVALID_VALUE));
1975 return;
1976 }
1977
Geoff Langbfdea662014-07-23 14:16:32 -04001978 gl::Program *programObject = context->getProgram(program);
1979
1980 if (!programObject)
1981 {
1982 if (context->getShader(program))
1983 {
Geoff Langb1196682014-07-23 13:47:29 -04001984 context->recordError(gl::Error(GL_INVALID_OPERATION));
1985 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001986 }
1987 else
1988 {
Geoff Langb1196682014-07-23 13:47:29 -04001989 context->recordError(gl::Error(GL_INVALID_VALUE));
1990 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001991 }
1992 }
1993
1994 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001995 }
1996}
1997
Kenneth Russell67ea1902014-10-06 16:44:50 -07001998GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002000 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002001
Geoff Langbfdea662014-07-23 14:16:32 -04002002 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002004 {
Geoff Langbfdea662014-07-23 14:16:32 -04002005 gl::Program *programObject = context->getProgram(program);
2006
2007 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002008 {
Geoff Langbfdea662014-07-23 14:16:32 -04002009 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002010 {
Geoff Langb1196682014-07-23 13:47:29 -04002011 context->recordError(gl::Error(GL_INVALID_OPERATION));
2012 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002013 }
Geoff Langbfdea662014-07-23 14:16:32 -04002014 else
2015 {
Geoff Langb1196682014-07-23 13:47:29 -04002016 context->recordError(gl::Error(GL_INVALID_VALUE));
2017 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002018 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002019 }
Geoff Langbfdea662014-07-23 14:16:32 -04002020
2021 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2022 if (!programObject->isLinked() || !programBinary)
2023 {
Geoff Langb1196682014-07-23 13:47:29 -04002024 context->recordError(gl::Error(GL_INVALID_OPERATION));
2025 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002026 }
2027
2028 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029 }
2030
2031 return -1;
2032}
2033
Kenneth Russell67ea1902014-10-06 16:44:50 -07002034void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002035{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002036 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002037
Geoff Langbfdea662014-07-23 14:16:32 -04002038 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002039 if (context)
2040 {
2041 GLenum nativeType;
2042 unsigned int numParams = 0;
2043 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002044 {
Geoff Langbfdea662014-07-23 14:16:32 -04002045 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002046 }
Geoff Langbfdea662014-07-23 14:16:32 -04002047
2048 if (nativeType == GL_BOOL)
2049 {
2050 context->getBooleanv(pname, params);
2051 }
2052 else
2053 {
2054 CastStateValues(context, nativeType, pname, numParams, params);
2055 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002056 }
2057}
2058
Kenneth Russell67ea1902014-10-06 16:44:50 -07002059void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002060{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002061 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 +00002062
Geoff Langbfdea662014-07-23 14:16:32 -04002063 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002064 if (context)
2065 {
2066 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002067 {
Geoff Langb1196682014-07-23 13:47:29 -04002068 context->recordError(gl::Error(GL_INVALID_ENUM));
2069 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002070 }
Geoff Langbfdea662014-07-23 14:16:32 -04002071
2072 if (!gl::ValidBufferParameter(context, pname))
2073 {
Geoff Langb1196682014-07-23 13:47:29 -04002074 context->recordError(gl::Error(GL_INVALID_ENUM));
2075 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002076 }
2077
2078 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2079
2080 if (!buffer)
2081 {
2082 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002083 context->recordError(gl::Error(GL_INVALID_OPERATION));
2084 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002085 }
2086
2087 switch (pname)
2088 {
2089 case GL_BUFFER_USAGE:
2090 *params = static_cast<GLint>(buffer->getUsage());
2091 break;
2092 case GL_BUFFER_SIZE:
2093 *params = gl::clampCast<GLint>(buffer->getSize());
2094 break;
2095 case GL_BUFFER_ACCESS_FLAGS:
2096 *params = buffer->getAccessFlags();
2097 break;
2098 case GL_BUFFER_MAPPED:
2099 *params = static_cast<GLint>(buffer->isMapped());
2100 break;
2101 case GL_BUFFER_MAP_OFFSET:
2102 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2103 break;
2104 case GL_BUFFER_MAP_LENGTH:
2105 *params = gl::clampCast<GLint>(buffer->getMapLength());
2106 break;
2107 default: UNREACHABLE(); break;
2108 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002109 }
2110}
2111
Kenneth Russell67ea1902014-10-06 16:44:50 -07002112GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002114 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002115
2116 gl::Context *context = gl::getContext();
2117
2118 if (context)
2119 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002120 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002121 }
2122
2123 return GL_NO_ERROR;
2124}
2125
Kenneth Russell67ea1902014-10-06 16:44:50 -07002126void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002127{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002128 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002129
Geoff Langbfdea662014-07-23 14:16:32 -04002130 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002131 if (context)
2132 {
2133 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2134
2135 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002136 {
Geoff Langb1196682014-07-23 13:47:29 -04002137 context->recordError(gl::Error(GL_INVALID_OPERATION));
2138 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002139 }
Geoff Langbfdea662014-07-23 14:16:32 -04002140
2141 if (fenceObject->isFence() != GL_TRUE)
2142 {
Geoff Langb1196682014-07-23 13:47:29 -04002143 context->recordError(gl::Error(GL_INVALID_OPERATION));
2144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002145 }
2146
2147 switch (pname)
2148 {
2149 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002150 {
2151 // GL_NV_fence spec:
2152 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2153 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2154 GLboolean status = GL_TRUE;
2155 if (fenceObject->getStatus() != GL_TRUE)
2156 {
2157 gl::Error error = fenceObject->testFence(&status);
2158 if (error.isError())
2159 {
2160 context->recordError(error);
2161 return;
2162 }
2163 }
2164 *params = status;
2165 break;
2166 }
2167
Geoff Langbfdea662014-07-23 14:16:32 -04002168 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002169 {
2170 *params = fenceObject->getCondition();
2171 break;
2172 }
Geoff Langbfdea662014-07-23 14:16:32 -04002173
Geoff Langb1196682014-07-23 13:47:29 -04002174 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002175 {
2176 context->recordError(gl::Error(GL_INVALID_ENUM));
2177 return;
2178 }
Geoff Lang882033e2014-09-30 11:26:07 -04002179 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002180 }
2181}
2182
Kenneth Russell67ea1902014-10-06 16:44:50 -07002183void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002184{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002185 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002186
Geoff Langbfdea662014-07-23 14:16:32 -04002187 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002188 if (context)
2189 {
2190 GLenum nativeType;
2191 unsigned int numParams = 0;
2192 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002193 {
Geoff Langbfdea662014-07-23 14:16:32 -04002194 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002195 }
Geoff Langbfdea662014-07-23 14:16:32 -04002196
2197 if (nativeType == GL_FLOAT)
2198 {
2199 context->getFloatv(pname, params);
2200 }
2201 else
2202 {
2203 CastStateValues(context, nativeType, pname, numParams, params);
2204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002205 }
2206}
2207
Kenneth Russell67ea1902014-10-06 16:44:50 -07002208void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002210 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 +00002211 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002212
Geoff Langbfdea662014-07-23 14:16:32 -04002213 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002214 if (context)
2215 {
2216 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002217 {
Geoff Langb1196682014-07-23 13:47:29 -04002218 context->recordError(gl::Error(GL_INVALID_ENUM));
2219 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002220 }
2221
2222 int clientVersion = context->getClientVersion();
2223
2224 switch (pname)
2225 {
2226 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2227 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2228 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2229 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2233 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002234 {
Geoff Langb1196682014-07-23 13:47:29 -04002235 context->recordError(gl::Error(GL_INVALID_ENUM));
2236 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002237 }
Geoff Langbfdea662014-07-23 14:16:32 -04002238 break;
Geoff Langb1196682014-07-23 13:47:29 -04002239
Geoff Langbfdea662014-07-23 14:16:32 -04002240 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2241 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2242 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2243 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2244 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2245 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2246 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2247 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2248 if (clientVersion < 3)
2249 {
Geoff Langb1196682014-07-23 13:47:29 -04002250 context->recordError(gl::Error(GL_INVALID_ENUM));
2251 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002252 }
2253 break;
Geoff Langb1196682014-07-23 13:47:29 -04002254
Geoff Langbfdea662014-07-23 14:16:32 -04002255 default:
Geoff Langb1196682014-07-23 13:47:29 -04002256 context->recordError(gl::Error(GL_INVALID_ENUM));
2257 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002258 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002259
Geoff Langbfdea662014-07-23 14:16:32 -04002260 // Determine if the attachment is a valid enum
2261 switch (attachment)
2262 {
2263 case GL_BACK:
2264 case GL_FRONT:
2265 case GL_DEPTH:
2266 case GL_STENCIL:
2267 case GL_DEPTH_STENCIL_ATTACHMENT:
2268 if (clientVersion < 3)
2269 {
Geoff Langb1196682014-07-23 13:47:29 -04002270 context->recordError(gl::Error(GL_INVALID_ENUM));
2271 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002272 }
2273 break;
2274
2275 case GL_DEPTH_ATTACHMENT:
2276 case GL_STENCIL_ATTACHMENT:
2277 break;
2278
2279 default:
2280 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2281 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2282 {
Geoff Langb1196682014-07-23 13:47:29 -04002283 context->recordError(gl::Error(GL_INVALID_ENUM));
2284 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002285 }
2286 break;
2287 }
2288
2289 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2290 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
Jamie Madill48faf802014-11-06 15:27:22 -05002291 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04002292
2293 if (framebufferHandle == 0)
2294 {
2295 if (clientVersion < 3)
2296 {
Geoff Langb1196682014-07-23 13:47:29 -04002297 context->recordError(gl::Error(GL_INVALID_OPERATION));
2298 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002299 }
2300
2301 switch (attachment)
2302 {
2303 case GL_BACK:
2304 case GL_DEPTH:
2305 case GL_STENCIL:
2306 break;
Geoff Langb1196682014-07-23 13:47:29 -04002307
Geoff Langbfdea662014-07-23 14:16:32 -04002308 default:
Geoff Langb1196682014-07-23 13:47:29 -04002309 context->recordError(gl::Error(GL_INVALID_OPERATION));
2310 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002311 }
2312 }
2313 else
2314 {
2315 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2316 {
2317 // Valid attachment query
2318 }
2319 else
2320 {
2321 switch (attachment)
2322 {
2323 case GL_DEPTH_ATTACHMENT:
2324 case GL_STENCIL_ATTACHMENT:
2325 break;
Geoff Langb1196682014-07-23 13:47:29 -04002326
Geoff Langbfdea662014-07-23 14:16:32 -04002327 case GL_DEPTH_STENCIL_ATTACHMENT:
2328 if (framebuffer->hasValidDepthStencil())
2329 {
Geoff Langb1196682014-07-23 13:47:29 -04002330 context->recordError(gl::Error(GL_INVALID_OPERATION));
2331 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002332 }
2333 break;
Geoff Langb1196682014-07-23 13:47:29 -04002334
Geoff Langbfdea662014-07-23 14:16:32 -04002335 default:
Geoff Langb1196682014-07-23 13:47:29 -04002336 context->recordError(gl::Error(GL_INVALID_OPERATION));
2337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002338 }
2339 }
2340 }
2341
2342 GLenum attachmentType = GL_NONE;
2343 GLuint attachmentHandle = 0;
2344 GLuint attachmentLevel = 0;
2345 GLuint attachmentLayer = 0;
2346
2347 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2348
2349 if (attachmentObject)
2350 {
2351 attachmentType = attachmentObject->type();
2352 attachmentHandle = attachmentObject->id();
2353 attachmentLevel = attachmentObject->mipLevel();
2354 attachmentLayer = attachmentObject->layer();
2355 }
2356
2357 GLenum attachmentObjectType; // Type category
2358 if (framebufferHandle == 0)
2359 {
2360 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2361 }
2362 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2363 {
2364 attachmentObjectType = attachmentType;
2365 }
2366 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2367 {
2368 attachmentObjectType = GL_TEXTURE;
2369 }
2370 else
2371 {
2372 UNREACHABLE();
2373 return;
2374 }
2375
2376 if (attachmentObjectType == GL_NONE)
2377 {
2378 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2379 // is NONE, then querying any other pname will generate INVALID_ENUM.
2380
2381 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2382 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2383 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002384
Geoff Lang646559f2013-08-15 11:08:15 -04002385 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002386 {
Geoff Lang646559f2013-08-15 11:08:15 -04002387 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002388 *params = attachmentObjectType;
2389 break;
2390
Geoff Lang646559f2013-08-15 11:08:15 -04002391 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002392 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002393 {
Geoff Langb1196682014-07-23 13:47:29 -04002394 context->recordError(gl::Error(GL_INVALID_ENUM));
2395 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002396 }
Geoff Langbfdea662014-07-23 14:16:32 -04002397 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002398 break;
2399
2400 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002401 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002402 {
Geoff Langb1196682014-07-23 13:47:29 -04002403 context->recordError(gl::Error(GL_INVALID_ENUM));
2404 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002405 }
2406 else
2407 {
Geoff Langb1196682014-07-23 13:47:29 -04002408 context->recordError(gl::Error(GL_INVALID_OPERATION));
2409 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002410 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002411 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002412 }
Geoff Langbfdea662014-07-23 14:16:32 -04002413 else
2414 {
2415 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2416 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2417 ASSERT(attachmentObject != NULL);
2418
2419 switch (pname)
2420 {
2421 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2422 *params = attachmentObjectType;
2423 break;
2424
2425 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2426 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2427 {
Geoff Langb1196682014-07-23 13:47:29 -04002428 context->recordError(gl::Error(GL_INVALID_ENUM));
2429 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002430 }
2431 *params = attachmentHandle;
2432 break;
2433
2434 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2435 if (attachmentObjectType != GL_TEXTURE)
2436 {
Geoff Langb1196682014-07-23 13:47:29 -04002437 context->recordError(gl::Error(GL_INVALID_ENUM));
2438 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002439 }
2440 *params = attachmentLevel;
2441 break;
2442
2443 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2444 if (attachmentObjectType != GL_TEXTURE)
2445 {
Geoff Langb1196682014-07-23 13:47:29 -04002446 context->recordError(gl::Error(GL_INVALID_ENUM));
2447 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002448 }
2449 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2450 break;
2451
2452 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2453 *params = attachmentObject->getRedSize();
2454 break;
2455
2456 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2457 *params = attachmentObject->getGreenSize();
2458 break;
2459
2460 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2461 *params = attachmentObject->getBlueSize();
2462 break;
2463
2464 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2465 *params = attachmentObject->getAlphaSize();
2466 break;
2467
2468 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2469 *params = attachmentObject->getDepthSize();
2470 break;
2471
2472 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2473 *params = attachmentObject->getStencilSize();
2474 break;
2475
2476 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002477 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002478 {
Geoff Langb1196682014-07-23 13:47:29 -04002479 context->recordError(gl::Error(GL_INVALID_OPERATION));
2480 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002481 }
2482 *params = attachmentObject->getComponentType();
2483 break;
2484
2485 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2486 *params = attachmentObject->getColorEncoding();
2487 break;
2488
2489 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2490 if (attachmentObjectType != GL_TEXTURE)
2491 {
Geoff Langb1196682014-07-23 13:47:29 -04002492 context->recordError(gl::Error(GL_INVALID_ENUM));
2493 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002494 }
2495 *params = attachmentLayer;
2496 break;
2497
2498 default:
2499 UNREACHABLE();
2500 break;
2501 }
2502 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002503 }
2504}
2505
Kenneth Russell67ea1902014-10-06 16:44:50 -07002506GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002507{
2508 EVENT("()");
2509
Geoff Langbfdea662014-07-23 14:16:32 -04002510 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002511
Geoff Langbfdea662014-07-23 14:16:32 -04002512 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002513 {
Geoff Langbfdea662014-07-23 14:16:32 -04002514 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002515 }
Geoff Langbfdea662014-07-23 14:16:32 -04002516
2517 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002518}
2519
Kenneth Russell67ea1902014-10-06 16:44:50 -07002520void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002521{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002522 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002523
Geoff Langbfdea662014-07-23 14:16:32 -04002524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002525 if (context)
2526 {
2527 GLenum nativeType;
2528 unsigned int numParams = 0;
2529
2530 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531 {
Geoff Langbfdea662014-07-23 14:16:32 -04002532 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 }
Geoff Langbfdea662014-07-23 14:16:32 -04002534
2535 if (nativeType == GL_INT)
2536 {
2537 context->getIntegerv(pname, params);
2538 }
2539 else
2540 {
2541 CastStateValues(context, nativeType, pname, numParams, params);
2542 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543 }
2544}
2545
Kenneth Russell67ea1902014-10-06 16:44:50 -07002546void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002548 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549
Geoff Langbfdea662014-07-23 14:16:32 -04002550 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002551 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002552 {
Geoff Langbfdea662014-07-23 14:16:32 -04002553 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002554
Geoff Langbfdea662014-07-23 14:16:32 -04002555 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002556 {
Geoff Langb1196682014-07-23 13:47:29 -04002557 context->recordError(gl::Error(GL_INVALID_VALUE));
2558 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002559 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002560
Geoff Langbfdea662014-07-23 14:16:32 -04002561 if (context->getClientVersion() < 3)
2562 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002563 switch (pname)
2564 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002565 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002566 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002567 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002568 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002569 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002570 context->recordError(gl::Error(GL_INVALID_ENUM));
2571 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002572 }
2573 }
Geoff Langbfdea662014-07-23 14:16:32 -04002574
2575 switch (pname)
2576 {
2577 case GL_DELETE_STATUS:
2578 *params = programObject->isFlaggedForDeletion();
2579 return;
2580 case GL_LINK_STATUS:
2581 *params = programObject->isLinked();
2582 return;
2583 case GL_VALIDATE_STATUS:
2584 *params = programObject->isValidated();
2585 return;
2586 case GL_INFO_LOG_LENGTH:
2587 *params = programObject->getInfoLogLength();
2588 return;
2589 case GL_ATTACHED_SHADERS:
2590 *params = programObject->getAttachedShadersCount();
2591 return;
2592 case GL_ACTIVE_ATTRIBUTES:
2593 *params = programObject->getActiveAttributeCount();
2594 return;
2595 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2596 *params = programObject->getActiveAttributeMaxLength();
2597 return;
2598 case GL_ACTIVE_UNIFORMS:
2599 *params = programObject->getActiveUniformCount();
2600 return;
2601 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2602 *params = programObject->getActiveUniformMaxLength();
2603 return;
2604 case GL_PROGRAM_BINARY_LENGTH_OES:
2605 *params = programObject->getProgramBinaryLength();
2606 return;
2607 case GL_ACTIVE_UNIFORM_BLOCKS:
2608 *params = programObject->getActiveUniformBlockCount();
2609 return;
2610 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2611 *params = programObject->getActiveUniformBlockMaxLength();
2612 break;
2613 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2614 *params = programObject->getTransformFeedbackBufferMode();
2615 break;
2616 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2617 *params = programObject->getTransformFeedbackVaryingCount();
2618 break;
2619 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2620 *params = programObject->getTransformFeedbackVaryingMaxLength();
2621 break;
Geoff Langb1196682014-07-23 13:47:29 -04002622
Geoff Langbfdea662014-07-23 14:16:32 -04002623 default:
Geoff Langb1196682014-07-23 13:47:29 -04002624 context->recordError(gl::Error(GL_INVALID_ENUM));
2625 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002626 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627 }
2628}
2629
Kenneth Russell67ea1902014-10-06 16:44:50 -07002630void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002631{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002632 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 +00002633 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002634
Geoff Langbfdea662014-07-23 14:16:32 -04002635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002636 if (context)
2637 {
Geoff Langb1196682014-07-23 13:47:29 -04002638 if (bufsize < 0)
2639 {
2640 context->recordError(gl::Error(GL_INVALID_VALUE));
2641 return;
2642 }
2643
Geoff Langbfdea662014-07-23 14:16:32 -04002644 gl::Program *programObject = context->getProgram(program);
2645
2646 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002647 {
Geoff Langb1196682014-07-23 13:47:29 -04002648 context->recordError(gl::Error(GL_INVALID_VALUE));
2649 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002650 }
2651
Geoff Langbfdea662014-07-23 14:16:32 -04002652 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002653 }
2654}
2655
Kenneth Russell67ea1902014-10-06 16:44:50 -07002656void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002657{
2658 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2659
Geoff Langbfdea662014-07-23 14:16:32 -04002660 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002661 if (context)
2662 {
2663 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002664 {
Geoff Langb1196682014-07-23 13:47:29 -04002665 context->recordError(gl::Error(GL_INVALID_ENUM));
2666 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002667 }
Geoff Langbfdea662014-07-23 14:16:32 -04002668
2669 switch (pname)
2670 {
2671 case GL_CURRENT_QUERY_EXT:
2672 params[0] = context->getState().getActiveQueryId(target);
2673 break;
2674
2675 default:
Geoff Langb1196682014-07-23 13:47:29 -04002676 context->recordError(gl::Error(GL_INVALID_ENUM));
2677 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002678 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002679 }
2680}
2681
Kenneth Russell67ea1902014-10-06 16:44:50 -07002682void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002683{
2684 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2685
Geoff Langbfdea662014-07-23 14:16:32 -04002686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002687 if (context)
2688 {
2689 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2690
2691 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002692 {
Geoff Langb1196682014-07-23 13:47:29 -04002693 context->recordError(gl::Error(GL_INVALID_OPERATION));
2694 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002695 }
Geoff Langbfdea662014-07-23 14:16:32 -04002696
2697 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2698 {
Geoff Langb1196682014-07-23 13:47:29 -04002699 context->recordError(gl::Error(GL_INVALID_OPERATION));
2700 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002701 }
2702
2703 switch(pname)
2704 {
2705 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002706 {
2707 gl::Error error = queryObject->getResult(params);
2708 if (error.isError())
2709 {
2710 context->recordError(error);
2711 return;
2712 }
2713 }
Geoff Langbfdea662014-07-23 14:16:32 -04002714 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002715
Geoff Langbfdea662014-07-23 14:16:32 -04002716 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002717 {
2718 gl::Error error = queryObject->isResultAvailable(params);
2719 if (error.isError())
2720 {
2721 context->recordError(error);
2722 return;
2723 }
2724 }
Geoff Langbfdea662014-07-23 14:16:32 -04002725 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002726
Geoff Langbfdea662014-07-23 14:16:32 -04002727 default:
Geoff Langb1196682014-07-23 13:47:29 -04002728 context->recordError(gl::Error(GL_INVALID_ENUM));
2729 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002730 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002731 }
2732}
2733
Kenneth Russell67ea1902014-10-06 16:44:50 -07002734void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002735{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002736 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 +00002737
Geoff Langbfdea662014-07-23 14:16:32 -04002738 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002739 if (context)
2740 {
2741 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002742 {
Geoff Langb1196682014-07-23 13:47:29 -04002743 context->recordError(gl::Error(GL_INVALID_ENUM));
2744 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002745 }
Geoff Langbfdea662014-07-23 14:16:32 -04002746
2747 if (context->getState().getRenderbufferId() == 0)
2748 {
Geoff Langb1196682014-07-23 13:47:29 -04002749 context->recordError(gl::Error(GL_INVALID_OPERATION));
2750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002751 }
2752
2753 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2754
2755 switch (pname)
2756 {
2757 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2758 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2759 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2760 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2761 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2762 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2763 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2764 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2765 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002766
Geoff Langbfdea662014-07-23 14:16:32 -04002767 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2768 if (!context->getExtensions().framebufferMultisample)
2769 {
Geoff Langb1196682014-07-23 13:47:29 -04002770 context->recordError(gl::Error(GL_INVALID_ENUM));
2771 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002772 }
2773 *params = renderbuffer->getSamples();
2774 break;
Geoff Langb1196682014-07-23 13:47:29 -04002775
Geoff Langbfdea662014-07-23 14:16:32 -04002776 default:
Geoff Langb1196682014-07-23 13:47:29 -04002777 context->recordError(gl::Error(GL_INVALID_ENUM));
2778 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002779 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002780 }
2781}
2782
Kenneth Russell67ea1902014-10-06 16:44:50 -07002783void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002785 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002786
Geoff Langbfdea662014-07-23 14:16:32 -04002787 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002788 if (context)
2789 {
2790 gl::Shader *shaderObject = context->getShader(shader);
2791
2792 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002793 {
Geoff Langb1196682014-07-23 13:47:29 -04002794 context->recordError(gl::Error(GL_INVALID_VALUE));
2795 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002796 }
Geoff Langbfdea662014-07-23 14:16:32 -04002797
2798 switch (pname)
2799 {
2800 case GL_SHADER_TYPE:
2801 *params = shaderObject->getType();
2802 return;
2803 case GL_DELETE_STATUS:
2804 *params = shaderObject->isFlaggedForDeletion();
2805 return;
2806 case GL_COMPILE_STATUS:
2807 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2808 return;
2809 case GL_INFO_LOG_LENGTH:
2810 *params = shaderObject->getInfoLogLength();
2811 return;
2812 case GL_SHADER_SOURCE_LENGTH:
2813 *params = shaderObject->getSourceLength();
2814 return;
2815 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2816 *params = shaderObject->getTranslatedSourceLength();
2817 return;
Geoff Langb1196682014-07-23 13:47:29 -04002818
Geoff Langbfdea662014-07-23 14:16:32 -04002819 default:
Geoff Langb1196682014-07-23 13:47:29 -04002820 context->recordError(gl::Error(GL_INVALID_ENUM));
2821 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002822 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823 }
2824}
2825
Kenneth Russell67ea1902014-10-06 16:44:50 -07002826void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002827{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002828 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 +00002829 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002830
Geoff Langbfdea662014-07-23 14:16:32 -04002831 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002832 if (context)
2833 {
Geoff Langb1196682014-07-23 13:47:29 -04002834 if (bufsize < 0)
2835 {
2836 context->recordError(gl::Error(GL_INVALID_VALUE));
2837 return;
2838 }
2839
Geoff Langbfdea662014-07-23 14:16:32 -04002840 gl::Shader *shaderObject = context->getShader(shader);
2841
2842 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002843 {
Geoff Langb1196682014-07-23 13:47:29 -04002844 context->recordError(gl::Error(GL_INVALID_VALUE));
2845 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002846 }
2847
Geoff Langbfdea662014-07-23 14:16:32 -04002848 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002849 }
2850}
2851
Kenneth Russell67ea1902014-10-06 16:44:50 -07002852void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002853{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002854 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 +00002855 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002856
Geoff Langb1196682014-07-23 13:47:29 -04002857 gl::Context *context = gl::getNonLostContext();
2858 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002859 {
Geoff Langb1196682014-07-23 13:47:29 -04002860 switch (shadertype)
2861 {
2862 case GL_VERTEX_SHADER:
2863 case GL_FRAGMENT_SHADER:
2864 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002865
Geoff Langb1196682014-07-23 13:47:29 -04002866 default:
2867 context->recordError(gl::Error(GL_INVALID_ENUM));
2868 return;
2869 }
2870
2871 switch (precisiontype)
2872 {
2873 case GL_LOW_FLOAT:
2874 case GL_MEDIUM_FLOAT:
2875 case GL_HIGH_FLOAT:
2876 // Assume IEEE 754 precision
2877 range[0] = 127;
2878 range[1] = 127;
2879 *precision = 23;
2880 break;
2881
2882 case GL_LOW_INT:
2883 case GL_MEDIUM_INT:
2884 case GL_HIGH_INT:
2885 // Some (most) hardware only supports single-precision floating-point numbers,
2886 // which can accurately represent integers up to +/-16777216
2887 range[0] = 24;
2888 range[1] = 24;
2889 *precision = 0;
2890 break;
2891
2892 default:
2893 context->recordError(gl::Error(GL_INVALID_ENUM));
2894 return;
2895 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002896 }
2897}
2898
Kenneth Russell67ea1902014-10-06 16:44:50 -07002899void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002901 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 +00002902 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002903
Geoff Langbfdea662014-07-23 14:16:32 -04002904 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002905 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002906 {
Geoff Langb1196682014-07-23 13:47:29 -04002907 if (bufsize < 0)
2908 {
2909 context->recordError(gl::Error(GL_INVALID_VALUE));
2910 return;
2911 }
2912
Geoff Langbfdea662014-07-23 14:16:32 -04002913 gl::Shader *shaderObject = context->getShader(shader);
2914
2915 if (!shaderObject)
2916 {
Geoff Langb1196682014-07-23 13:47:29 -04002917 context->recordError(gl::Error(GL_INVALID_OPERATION));
2918 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002919 }
2920
2921 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002922 }
2923}
2924
Kenneth Russell67ea1902014-10-06 16:44:50 -07002925void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002926{
2927 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2928 shader, bufsize, length, source);
2929
Geoff Langbfdea662014-07-23 14:16:32 -04002930 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002931 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002932 {
Geoff Langb1196682014-07-23 13:47:29 -04002933 if (bufsize < 0)
2934 {
2935 context->recordError(gl::Error(GL_INVALID_VALUE));
2936 return;
2937 }
2938
Geoff Langbfdea662014-07-23 14:16:32 -04002939 gl::Shader *shaderObject = context->getShader(shader);
2940
2941 if (!shaderObject)
2942 {
Geoff Langb1196682014-07-23 13:47:29 -04002943 context->recordError(gl::Error(GL_INVALID_OPERATION));
2944 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002945 }
2946
Tibor den Ouden97049c62014-10-06 21:39:16 +02002947 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2948 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002949 }
2950}
2951
Kenneth Russell67ea1902014-10-06 16:44:50 -07002952const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002953{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002954 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002955
Geoff Langbfdea662014-07-23 14:16:32 -04002956 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002957
Geoff Langbfdea662014-07-23 14:16:32 -04002958 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002959 {
Geoff Langbfdea662014-07-23 14:16:32 -04002960 case GL_VENDOR:
2961 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002962
Geoff Langbfdea662014-07-23 14:16:32 -04002963 case GL_RENDERER:
2964 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002965
Geoff Langbfdea662014-07-23 14:16:32 -04002966 case GL_VERSION:
2967 if (context->getClientVersion() == 2)
2968 {
2969 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2970 }
2971 else
2972 {
2973 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2974 }
Geoff Langb1196682014-07-23 13:47:29 -04002975
Geoff Langbfdea662014-07-23 14:16:32 -04002976 case GL_SHADING_LANGUAGE_VERSION:
2977 if (context->getClientVersion() == 2)
2978 {
2979 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2980 }
2981 else
2982 {
2983 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2984 }
Geoff Langb1196682014-07-23 13:47:29 -04002985
Geoff Langbfdea662014-07-23 14:16:32 -04002986 case GL_EXTENSIONS:
2987 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002988
Geoff Langbfdea662014-07-23 14:16:32 -04002989 default:
Geoff Langb1196682014-07-23 13:47:29 -04002990 if (context)
2991 {
2992 context->recordError(gl::Error(GL_INVALID_ENUM));
2993 }
2994 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002996}
2997
Kenneth Russell67ea1902014-10-06 16:44:50 -07002998void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003000 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 +00003001
Geoff Langbfdea662014-07-23 14:16:32 -04003002 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003003 if (context)
3004 {
3005 gl::Texture *texture = context->getTargetTexture(target);
3006
3007 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003008 {
Geoff Langb1196682014-07-23 13:47:29 -04003009 context->recordError(gl::Error(GL_INVALID_ENUM));
3010 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003011 }
Geoff Langbfdea662014-07-23 14:16:32 -04003012
3013 switch (pname)
3014 {
3015 case GL_TEXTURE_MAG_FILTER:
3016 *params = (GLfloat)texture->getSamplerState().magFilter;
3017 break;
3018 case GL_TEXTURE_MIN_FILTER:
3019 *params = (GLfloat)texture->getSamplerState().minFilter;
3020 break;
3021 case GL_TEXTURE_WRAP_S:
3022 *params = (GLfloat)texture->getSamplerState().wrapS;
3023 break;
3024 case GL_TEXTURE_WRAP_T:
3025 *params = (GLfloat)texture->getSamplerState().wrapT;
3026 break;
3027 case GL_TEXTURE_WRAP_R:
3028 if (context->getClientVersion() < 3)
3029 {
Geoff Langb1196682014-07-23 13:47:29 -04003030 context->recordError(gl::Error(GL_INVALID_ENUM));
3031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003032 }
3033 *params = (GLfloat)texture->getSamplerState().wrapR;
3034 break;
3035 case GL_TEXTURE_IMMUTABLE_FORMAT:
3036 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3037 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3038 break;
3039 case GL_TEXTURE_IMMUTABLE_LEVELS:
3040 if (context->getClientVersion() < 3)
3041 {
Geoff Langb1196682014-07-23 13:47:29 -04003042 context->recordError(gl::Error(GL_INVALID_ENUM));
3043 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003044 }
3045 *params = (GLfloat)texture->immutableLevelCount();
3046 break;
3047 case GL_TEXTURE_USAGE_ANGLE:
3048 *params = (GLfloat)texture->getUsage();
3049 break;
3050 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3051 if (!context->getExtensions().textureFilterAnisotropic)
3052 {
Geoff Langb1196682014-07-23 13:47:29 -04003053 context->recordError(gl::Error(GL_INVALID_ENUM));
3054 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003055 }
3056 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3057 break;
3058 case GL_TEXTURE_SWIZZLE_R:
3059 if (context->getClientVersion() < 3)
3060 {
Geoff Langb1196682014-07-23 13:47:29 -04003061 context->recordError(gl::Error(GL_INVALID_ENUM));
3062 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003063 }
3064 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3065 break;
3066 case GL_TEXTURE_SWIZZLE_G:
3067 if (context->getClientVersion() < 3)
3068 {
Geoff Langb1196682014-07-23 13:47:29 -04003069 context->recordError(gl::Error(GL_INVALID_ENUM));
3070 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003071 }
3072 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3073 break;
3074 case GL_TEXTURE_SWIZZLE_B:
3075 if (context->getClientVersion() < 3)
3076 {
Geoff Langb1196682014-07-23 13:47:29 -04003077 context->recordError(gl::Error(GL_INVALID_ENUM));
3078 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003079 }
3080 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3081 break;
3082 case GL_TEXTURE_SWIZZLE_A:
3083 if (context->getClientVersion() < 3)
3084 {
Geoff Langb1196682014-07-23 13:47:29 -04003085 context->recordError(gl::Error(GL_INVALID_ENUM));
3086 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003087 }
3088 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3089 break;
3090 case GL_TEXTURE_BASE_LEVEL:
3091 if (context->getClientVersion() < 3)
3092 {
Geoff Langb1196682014-07-23 13:47:29 -04003093 context->recordError(gl::Error(GL_INVALID_ENUM));
3094 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003095 }
3096 *params = (GLfloat)texture->getSamplerState().baseLevel;
3097 break;
3098 case GL_TEXTURE_MAX_LEVEL:
3099 if (context->getClientVersion() < 3)
3100 {
Geoff Langb1196682014-07-23 13:47:29 -04003101 context->recordError(gl::Error(GL_INVALID_ENUM));
3102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003103 }
3104 *params = (GLfloat)texture->getSamplerState().maxLevel;
3105 break;
3106 case GL_TEXTURE_MIN_LOD:
3107 if (context->getClientVersion() < 3)
3108 {
Geoff Langb1196682014-07-23 13:47:29 -04003109 context->recordError(gl::Error(GL_INVALID_ENUM));
3110 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003111 }
3112 *params = texture->getSamplerState().minLod;
3113 break;
3114 case GL_TEXTURE_MAX_LOD:
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 }
3120 *params = texture->getSamplerState().maxLod;
3121 break;
Geoff Langb1196682014-07-23 13:47:29 -04003122
Geoff Langbfdea662014-07-23 14:16:32 -04003123 default:
Geoff Langb1196682014-07-23 13:47:29 -04003124 context->recordError(gl::Error(GL_INVALID_ENUM));
3125 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003126 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003127 }
3128}
3129
Kenneth Russell67ea1902014-10-06 16:44:50 -07003130void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003131{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003132 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 +00003133
Geoff Langbfdea662014-07-23 14:16:32 -04003134 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003135 if (context)
3136 {
3137 gl::Texture *texture = context->getTargetTexture(target);
3138
3139 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003140 {
Geoff Langb1196682014-07-23 13:47:29 -04003141 context->recordError(gl::Error(GL_INVALID_ENUM));
3142 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003143 }
Geoff Langbfdea662014-07-23 14:16:32 -04003144
3145 switch (pname)
3146 {
3147 case GL_TEXTURE_MAG_FILTER:
3148 *params = texture->getSamplerState().magFilter;
3149 break;
3150 case GL_TEXTURE_MIN_FILTER:
3151 *params = texture->getSamplerState().minFilter;
3152 break;
3153 case GL_TEXTURE_WRAP_S:
3154 *params = texture->getSamplerState().wrapS;
3155 break;
3156 case GL_TEXTURE_WRAP_T:
3157 *params = texture->getSamplerState().wrapT;
3158 break;
3159 case GL_TEXTURE_WRAP_R:
3160 if (context->getClientVersion() < 3)
3161 {
Geoff Langb1196682014-07-23 13:47:29 -04003162 context->recordError(gl::Error(GL_INVALID_ENUM));
3163 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003164 }
3165 *params = texture->getSamplerState().wrapR;
3166 break;
3167 case GL_TEXTURE_IMMUTABLE_FORMAT:
3168 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3169 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3170 break;
3171 case GL_TEXTURE_IMMUTABLE_LEVELS:
3172 if (context->getClientVersion() < 3)
3173 {
Geoff Langb1196682014-07-23 13:47:29 -04003174 context->recordError(gl::Error(GL_INVALID_ENUM));
3175 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003176 }
Jamie Madill6948e302014-10-20 17:04:33 -04003177 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003178 break;
3179 case GL_TEXTURE_USAGE_ANGLE:
3180 *params = texture->getUsage();
3181 break;
3182 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3183 if (!context->getExtensions().textureFilterAnisotropic)
3184 {
Geoff Langb1196682014-07-23 13:47:29 -04003185 context->recordError(gl::Error(GL_INVALID_ENUM));
3186 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003187 }
3188 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3189 break;
3190 case GL_TEXTURE_SWIZZLE_R:
3191 if (context->getClientVersion() < 3)
3192 {
Geoff Langb1196682014-07-23 13:47:29 -04003193 context->recordError(gl::Error(GL_INVALID_ENUM));
3194 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003195 }
3196 *params = texture->getSamplerState().swizzleRed;
3197 break;
3198 case GL_TEXTURE_SWIZZLE_G:
3199 if (context->getClientVersion() < 3)
3200 {
Geoff Langb1196682014-07-23 13:47:29 -04003201 context->recordError(gl::Error(GL_INVALID_ENUM));
3202 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003203 }
3204 *params = texture->getSamplerState().swizzleGreen;
3205 break;
3206 case GL_TEXTURE_SWIZZLE_B:
3207 if (context->getClientVersion() < 3)
3208 {
Geoff Langb1196682014-07-23 13:47:29 -04003209 context->recordError(gl::Error(GL_INVALID_ENUM));
3210 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003211 }
3212 *params = texture->getSamplerState().swizzleBlue;
3213 break;
3214 case GL_TEXTURE_SWIZZLE_A:
3215 if (context->getClientVersion() < 3)
3216 {
Geoff Langb1196682014-07-23 13:47:29 -04003217 context->recordError(gl::Error(GL_INVALID_ENUM));
3218 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003219 }
3220 *params = texture->getSamplerState().swizzleAlpha;
3221 break;
3222 case GL_TEXTURE_BASE_LEVEL:
3223 if (context->getClientVersion() < 3)
3224 {
Geoff Langb1196682014-07-23 13:47:29 -04003225 context->recordError(gl::Error(GL_INVALID_ENUM));
3226 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003227 }
3228 *params = texture->getSamplerState().baseLevel;
3229 break;
3230 case GL_TEXTURE_MAX_LEVEL:
3231 if (context->getClientVersion() < 3)
3232 {
Geoff Langb1196682014-07-23 13:47:29 -04003233 context->recordError(gl::Error(GL_INVALID_ENUM));
3234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003235 }
3236 *params = texture->getSamplerState().maxLevel;
3237 break;
3238 case GL_TEXTURE_MIN_LOD:
3239 if (context->getClientVersion() < 3)
3240 {
Geoff Langb1196682014-07-23 13:47:29 -04003241 context->recordError(gl::Error(GL_INVALID_ENUM));
3242 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003243 }
3244 *params = (GLint)texture->getSamplerState().minLod;
3245 break;
3246 case GL_TEXTURE_MAX_LOD:
3247 if (context->getClientVersion() < 3)
3248 {
Geoff Langb1196682014-07-23 13:47:29 -04003249 context->recordError(gl::Error(GL_INVALID_ENUM));
3250 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003251 }
3252 *params = (GLint)texture->getSamplerState().maxLod;
3253 break;
Geoff Langb1196682014-07-23 13:47:29 -04003254
Geoff Langbfdea662014-07-23 14:16:32 -04003255 default:
Geoff Langb1196682014-07-23 13:47:29 -04003256 context->recordError(gl::Error(GL_INVALID_ENUM));
3257 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003258 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003259 }
3260}
3261
Kenneth Russell67ea1902014-10-06 16:44:50 -07003262void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003263{
3264 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3265 program, location, bufSize, params);
3266
Geoff Langbfdea662014-07-23 14:16:32 -04003267 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003268 if (context)
3269 {
Jamie Madill0063c512014-08-25 15:47:53 -04003270 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003271 {
Jamie Madill0063c512014-08-25 15:47:53 -04003272 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003273 }
3274
Jamie Madilla502c742014-08-28 17:19:13 -04003275 gl::Program *programObject = context->getProgram(program);
3276 ASSERT(programObject);
3277 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003278 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003279
Jamie Madill99a1e982014-08-25 15:47:54 -04003280 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003281 }
3282}
3283
Kenneth Russell67ea1902014-10-06 16:44:50 -07003284void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003285{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003286 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003287
Geoff Langbfdea662014-07-23 14:16:32 -04003288 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003289 if (context)
3290 {
Jamie Madill0063c512014-08-25 15:47:53 -04003291 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003292 {
Jamie Madill0063c512014-08-25 15:47:53 -04003293 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003294 }
Geoff Langbfdea662014-07-23 14:16:32 -04003295
Jamie Madilla502c742014-08-28 17:19:13 -04003296 gl::Program *programObject = context->getProgram(program);
3297 ASSERT(programObject);
3298 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003299 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003300
Jamie Madill99a1e982014-08-25 15:47:54 -04003301 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003302 }
3303}
3304
Kenneth Russell67ea1902014-10-06 16:44:50 -07003305void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003306{
Geoff Langbfdea662014-07-23 14:16:32 -04003307 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003308 program, location, bufSize, params);
3309
Geoff Langbfdea662014-07-23 14:16:32 -04003310 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003311 if (context)
3312 {
Jamie Madill0063c512014-08-25 15:47:53 -04003313 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003314 {
Jamie Madill0063c512014-08-25 15:47:53 -04003315 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003316 }
3317
Jamie Madilla502c742014-08-28 17:19:13 -04003318 gl::Program *programObject = context->getProgram(program);
3319 ASSERT(programObject);
3320 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003321 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003322
Jamie Madill99a1e982014-08-25 15:47:54 -04003323 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003324 }
3325}
3326
Kenneth Russell67ea1902014-10-06 16:44:50 -07003327void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003328{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003329 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003330
Geoff Langbfdea662014-07-23 14:16:32 -04003331 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003332 if (context)
3333 {
Jamie Madill0063c512014-08-25 15:47:53 -04003334 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003335 {
Jamie Madill0063c512014-08-25 15:47:53 -04003336 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003337 }
Geoff Langbfdea662014-07-23 14:16:32 -04003338
Jamie Madilla502c742014-08-28 17:19:13 -04003339 gl::Program *programObject = context->getProgram(program);
3340 ASSERT(programObject);
3341 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003342 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003343
Jamie Madill99a1e982014-08-25 15:47:54 -04003344 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003345 }
3346}
3347
Kenneth Russell67ea1902014-10-06 16:44:50 -07003348GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003349{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003350 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351
Geoff Langbfdea662014-07-23 14:16:32 -04003352 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003353 if (context)
3354 {
Geoff Langb1196682014-07-23 13:47:29 -04003355 if (strstr(name, "gl_") == name)
3356 {
3357 return -1;
3358 }
3359
Geoff Langbfdea662014-07-23 14:16:32 -04003360 gl::Program *programObject = context->getProgram(program);
3361
3362 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003363 {
Geoff Langbfdea662014-07-23 14:16:32 -04003364 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003365 {
Geoff Langb1196682014-07-23 13:47:29 -04003366 context->recordError(gl::Error(GL_INVALID_OPERATION));
3367 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003368 }
Geoff Langbfdea662014-07-23 14:16:32 -04003369 else
3370 {
Geoff Langb1196682014-07-23 13:47:29 -04003371 context->recordError(gl::Error(GL_INVALID_VALUE));
3372 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003373 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003374 }
Geoff Langbfdea662014-07-23 14:16:32 -04003375
3376 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3377 if (!programObject->isLinked() || !programBinary)
3378 {
Geoff Langb1196682014-07-23 13:47:29 -04003379 context->recordError(gl::Error(GL_INVALID_OPERATION));
3380 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003381 }
3382
3383 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003384 }
3385
3386 return -1;
3387}
3388
Kenneth Russell67ea1902014-10-06 16:44:50 -07003389void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003390{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003391 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003392
Geoff Langbfdea662014-07-23 14:16:32 -04003393 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003394 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003395 {
Geoff Langbfdea662014-07-23 14:16:32 -04003396 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003397 {
Geoff Langb1196682014-07-23 13:47:29 -04003398 context->recordError(gl::Error(GL_INVALID_VALUE));
3399 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003400 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003401
Geoff Langbfdea662014-07-23 14:16:32 -04003402 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003403 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003404 {
3405 return;
3406 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003407
Geoff Langbfdea662014-07-23 14:16:32 -04003408 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3409 {
3410 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3411 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003412 {
Geoff Langbfdea662014-07-23 14:16:32 -04003413 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003414 }
3415 }
Geoff Langbfdea662014-07-23 14:16:32 -04003416 else
3417 {
3418 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3419 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003420 }
3421}
3422
Kenneth Russell67ea1902014-10-06 16:44:50 -07003423void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003424{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003425 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003426
Geoff Langbfdea662014-07-23 14:16:32 -04003427 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003428 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003429 {
Geoff Langbfdea662014-07-23 14:16:32 -04003430 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003431 {
Geoff Langb1196682014-07-23 13:47:29 -04003432 context->recordError(gl::Error(GL_INVALID_VALUE));
3433 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003434 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003435
Geoff Langbfdea662014-07-23 14:16:32 -04003436 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003437
Geoff Langb1196682014-07-23 13:47:29 -04003438 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003439 {
3440 return;
3441 }
Jamie Madillaff71502013-07-02 11:57:05 -04003442
Geoff Langbfdea662014-07-23 14:16:32 -04003443 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3444 {
3445 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3446 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003447 {
Geoff Langbfdea662014-07-23 14:16:32 -04003448 float currentValue = currentValueData.FloatValues[i];
3449 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003450 }
3451 }
Geoff Langbfdea662014-07-23 14:16:32 -04003452 else
3453 {
3454 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3455 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456 }
3457}
3458
Kenneth Russell67ea1902014-10-06 16:44:50 -07003459void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003460{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003461 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462
Geoff Langbfdea662014-07-23 14:16:32 -04003463 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003464 if (context)
3465 {
3466 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003467 {
Geoff Langb1196682014-07-23 13:47:29 -04003468 context->recordError(gl::Error(GL_INVALID_VALUE));
3469 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003470 }
Geoff Langbfdea662014-07-23 14:16:32 -04003471
3472 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3473 {
Geoff Langb1196682014-07-23 13:47:29 -04003474 context->recordError(gl::Error(GL_INVALID_ENUM));
3475 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003476 }
3477
3478 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003479 }
3480}
3481
Kenneth Russell67ea1902014-10-06 16:44:50 -07003482void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003483{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003484 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003485
Geoff Langbfdea662014-07-23 14:16:32 -04003486 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003487 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003488 {
Geoff Langb1196682014-07-23 13:47:29 -04003489 switch (mode)
3490 {
3491 case GL_FASTEST:
3492 case GL_NICEST:
3493 case GL_DONT_CARE:
3494 break;
3495
3496 default:
3497 context->recordError(gl::Error(GL_INVALID_ENUM));
3498 return;
3499 }
3500
3501 switch (target)
3502 {
3503 case GL_GENERATE_MIPMAP_HINT:
3504 context->getState().setGenerateMipmapHint(mode);
3505 break;
3506
3507 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3508 context->getState().setFragmentShaderDerivativeHint(mode);
3509 break;
3510
3511 default:
3512 context->recordError(gl::Error(GL_INVALID_ENUM));
3513 return;
3514 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003515 }
3516}
3517
Kenneth Russell67ea1902014-10-06 16:44:50 -07003518GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003519{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003520 EVENT("(GLuint buffer = %d)", buffer);
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 && buffer)
3524 {
3525 gl::Buffer *bufferObject = context->getBuffer(buffer);
3526
3527 if (bufferObject)
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 glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003538 EVENT("(GLenum cap = 0x%X)", cap);
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)
3542 {
3543 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003544 {
Geoff Langb1196682014-07-23 13:47:29 -04003545 context->recordError(gl::Error(GL_INVALID_ENUM));
3546 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003547 }
Geoff Langbfdea662014-07-23 14:16:32 -04003548
3549 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550 }
3551
3552 return false;
3553}
3554
Kenneth Russell67ea1902014-10-06 16:44:50 -07003555GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003556{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003557 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003558
Geoff Langbfdea662014-07-23 14:16:32 -04003559 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003560 if (context)
3561 {
3562 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3563
3564 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003565 {
Geoff Langbfdea662014-07-23 14:16:32 -04003566 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003567 }
Geoff Langbfdea662014-07-23 14:16:32 -04003568
3569 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003570 }
3571
3572 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003573}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003574
Kenneth Russell67ea1902014-10-06 16:44:50 -07003575GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003576{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003577 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003578
Geoff Langbfdea662014-07-23 14:16:32 -04003579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003580 if (context && framebuffer)
3581 {
3582 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3583
3584 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585 {
Geoff Langbfdea662014-07-23 14:16:32 -04003586 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003587 }
3588 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003589
3590 return GL_FALSE;
3591}
3592
Kenneth Russell67ea1902014-10-06 16:44:50 -07003593GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003595 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003596
Geoff Langbfdea662014-07-23 14:16:32 -04003597 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003598 if (context && program)
3599 {
3600 gl::Program *programObject = context->getProgram(program);
3601
3602 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003603 {
Geoff Langbfdea662014-07-23 14:16:32 -04003604 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003605 }
3606 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003607
3608 return GL_FALSE;
3609}
3610
Kenneth Russell67ea1902014-10-06 16:44:50 -07003611GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003612{
3613 EVENT("(GLuint id = %d)", id);
3614
Geoff Langbfdea662014-07-23 14:16:32 -04003615 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003616 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003617 {
Geoff Langbfdea662014-07-23 14:16:32 -04003618 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003619 }
3620
3621 return GL_FALSE;
3622}
3623
Kenneth Russell67ea1902014-10-06 16:44:50 -07003624GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003626 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003627
Geoff Langbfdea662014-07-23 14:16:32 -04003628 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003629 if (context && renderbuffer)
3630 {
3631 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3632
3633 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003634 {
Geoff Langbfdea662014-07-23 14:16:32 -04003635 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003636 }
3637 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003638
3639 return GL_FALSE;
3640}
3641
Kenneth Russell67ea1902014-10-06 16:44:50 -07003642GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003643{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003644 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645
Geoff Langbfdea662014-07-23 14:16:32 -04003646 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003647 if (context && shader)
3648 {
3649 gl::Shader *shaderObject = context->getShader(shader);
3650
3651 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003652 {
Geoff Langbfdea662014-07-23 14:16:32 -04003653 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003654 }
3655 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003656
3657 return GL_FALSE;
3658}
3659
Kenneth Russell67ea1902014-10-06 16:44:50 -07003660GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003662 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003663
Geoff Langbfdea662014-07-23 14:16:32 -04003664 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003665 if (context && texture)
3666 {
3667 gl::Texture *textureObject = context->getTexture(texture);
3668
3669 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670 {
Geoff Langbfdea662014-07-23 14:16:32 -04003671 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003672 }
3673 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003674
3675 return GL_FALSE;
3676}
3677
Kenneth Russell67ea1902014-10-06 16:44:50 -07003678void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003679{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003680 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003681
Geoff Langbfdea662014-07-23 14:16:32 -04003682 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003683 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684 {
Geoff Langb1196682014-07-23 13:47:29 -04003685 if (width <= 0.0f)
3686 {
3687 context->recordError(gl::Error(GL_INVALID_VALUE));
3688 return;
3689 }
3690
Geoff Langbfdea662014-07-23 14:16:32 -04003691 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003692 }
3693}
3694
Kenneth Russell67ea1902014-10-06 16:44:50 -07003695void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003696{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003697 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003698
Geoff Langbfdea662014-07-23 14:16:32 -04003699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003700 if (context)
3701 {
3702 gl::Program *programObject = context->getProgram(program);
3703
3704 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003705 {
Geoff Langbfdea662014-07-23 14:16:32 -04003706 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707 {
Geoff Langb1196682014-07-23 13:47:29 -04003708 context->recordError(gl::Error(GL_INVALID_OPERATION));
3709 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003710 }
Geoff Langbfdea662014-07-23 14:16:32 -04003711 else
3712 {
Geoff Langb1196682014-07-23 13:47:29 -04003713 context->recordError(gl::Error(GL_INVALID_VALUE));
3714 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003715 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003716 }
Geoff Langbfdea662014-07-23 14:16:32 -04003717
Geoff Langb543aff2014-09-30 14:52:54 -04003718 gl::Error error = context->linkProgram(program);
3719 if (error.isError())
3720 {
3721 context->recordError(error);
3722 return;
3723 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724 }
3725}
3726
Kenneth Russell67ea1902014-10-06 16:44:50 -07003727void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003728{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003729 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003730
Geoff Langbfdea662014-07-23 14:16:32 -04003731 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003732 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 {
Geoff Langbfdea662014-07-23 14:16:32 -04003734 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003735 {
Geoff Langbfdea662014-07-23 14:16:32 -04003736 case GL_UNPACK_ALIGNMENT:
3737 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003738 {
Geoff Langb1196682014-07-23 13:47:29 -04003739 context->recordError(gl::Error(GL_INVALID_VALUE));
3740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003741 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003742
Geoff Langbfdea662014-07-23 14:16:32 -04003743 context->getState().setUnpackAlignment(param);
3744 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003745
Geoff Langbfdea662014-07-23 14:16:32 -04003746 case GL_PACK_ALIGNMENT:
3747 if (param != 1 && param != 2 && param != 4 && param != 8)
3748 {
Geoff Langb1196682014-07-23 13:47:29 -04003749 context->recordError(gl::Error(GL_INVALID_VALUE));
3750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003751 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003752
Geoff Langbfdea662014-07-23 14:16:32 -04003753 context->getState().setPackAlignment(param);
3754 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003755
Geoff Langbfdea662014-07-23 14:16:32 -04003756 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3757 context->getState().setPackReverseRowOrder(param != 0);
3758 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003759
Geoff Langbfdea662014-07-23 14:16:32 -04003760 case GL_UNPACK_IMAGE_HEIGHT:
3761 case GL_UNPACK_SKIP_IMAGES:
3762 case GL_UNPACK_ROW_LENGTH:
3763 case GL_UNPACK_SKIP_ROWS:
3764 case GL_UNPACK_SKIP_PIXELS:
3765 case GL_PACK_ROW_LENGTH:
3766 case GL_PACK_SKIP_ROWS:
3767 case GL_PACK_SKIP_PIXELS:
3768 if (context->getClientVersion() < 3)
3769 {
Geoff Langb1196682014-07-23 13:47:29 -04003770 context->recordError(gl::Error(GL_INVALID_ENUM));
3771 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003772 }
Geoff Langbfdea662014-07-23 14:16:32 -04003773 UNIMPLEMENTED();
3774 break;
3775
3776 default:
Geoff Langb1196682014-07-23 13:47:29 -04003777 context->recordError(gl::Error(GL_INVALID_ENUM));
3778 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003779 }
3780 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003781}
3782
Kenneth Russell67ea1902014-10-06 16:44:50 -07003783void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003785 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003786
Geoff Langbfdea662014-07-23 14:16:32 -04003787 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003788 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003789 {
Geoff Langbfdea662014-07-23 14:16:32 -04003790 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003791 }
3792}
3793
Kenneth Russell67ea1902014-10-06 16:44:50 -07003794void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003795 GLenum format, GLenum type, GLsizei bufSize,
3796 GLvoid *data)
3797{
3798 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3799 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3800 x, y, width, height, format, type, bufSize, data);
3801
Geoff Langbfdea662014-07-23 14:16:32 -04003802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003803 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003804 {
Geoff Langb1196682014-07-23 13:47:29 -04003805 if (width < 0 || height < 0 || bufSize < 0)
3806 {
3807 context->recordError(gl::Error(GL_INVALID_VALUE));
3808 return;
3809 }
3810
Geoff Langbfdea662014-07-23 14:16:32 -04003811 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3812 format, type, &bufSize, data))
3813 {
3814 return;
3815 }
3816
Geoff Lang63d2fc72014-07-25 14:51:41 -04003817 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3818 if (error.isError())
3819 {
3820 context->recordError(error);
3821 return;
3822 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003823 }
3824}
3825
Kenneth Russell67ea1902014-10-06 16:44:50 -07003826void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003827 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003829 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003830 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003831 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003832
Geoff Langbfdea662014-07-23 14:16:32 -04003833 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003834 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003835 {
Geoff Langb1196682014-07-23 13:47:29 -04003836 if (width < 0 || height < 0)
3837 {
3838 context->recordError(gl::Error(GL_INVALID_VALUE));
3839 return;
3840 }
3841
Geoff Langbfdea662014-07-23 14:16:32 -04003842 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3843 format, type, NULL, pixels))
3844 {
3845 return;
3846 }
3847
Geoff Lang63d2fc72014-07-25 14:51:41 -04003848 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3849 if (error.isError())
3850 {
3851 context->recordError(error);
3852 return;
3853 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003854 }
3855}
3856
Kenneth Russell67ea1902014-10-06 16:44:50 -07003857void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003859 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003860
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003861 gl::Context *context = gl::getNonLostContext();
3862
3863 if (context)
3864 {
3865 context->releaseShaderCompiler();
3866 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867}
3868
Kenneth Russell67ea1902014-10-06 16:44:50 -07003869void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003870{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003871 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 +00003872 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003873
Geoff Langbfdea662014-07-23 14:16:32 -04003874 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003875 if (context)
3876 {
3877 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3878 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003879 {
Geoff Langbfdea662014-07-23 14:16:32 -04003880 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003881 }
Geoff Langbfdea662014-07-23 14:16:32 -04003882
Shannon Woodse2632d22014-10-17 13:08:51 -04003883 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
Geoff Langbafefdf2014-10-10 14:26:35 -04003884 gl::Error error = renderbuffer->setStorage(width, height, internalformat, samples);
3885 if (error.isError())
3886 {
3887 context->recordError(error);
3888 return;
3889 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003890 }
3891}
3892
Kenneth Russell67ea1902014-10-06 16:44:50 -07003893void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003894{
3895 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3896}
3897
Kenneth Russell67ea1902014-10-06 16:44:50 -07003898void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003899{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003900 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003901
Geoff Langbfdea662014-07-23 14:16:32 -04003902 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003903
Geoff Langbfdea662014-07-23 14:16:32 -04003904 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003905 {
Geoff Langbfdea662014-07-23 14:16:32 -04003906 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003907 }
3908}
3909
Kenneth Russell67ea1902014-10-06 16:44:50 -07003910void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003911{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003912 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003913
Geoff Langbfdea662014-07-23 14:16:32 -04003914 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003915 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003916 {
Geoff Langb1196682014-07-23 13:47:29 -04003917 if (condition != GL_ALL_COMPLETED_NV)
3918 {
3919 context->recordError(gl::Error(GL_INVALID_ENUM));
3920 return;
3921 }
3922
Geoff Langbfdea662014-07-23 14:16:32 -04003923 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3924
3925 if (fenceObject == NULL)
3926 {
Geoff Langb1196682014-07-23 13:47:29 -04003927 context->recordError(gl::Error(GL_INVALID_OPERATION));
3928 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003929 }
3930
Geoff Lang882033e2014-09-30 11:26:07 -04003931 gl::Error error = fenceObject->setFence(condition);
3932 if (error.isError())
3933 {
3934 context->recordError(error);
3935 return;
3936 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003937 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003938}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003939
Kenneth Russell67ea1902014-10-06 16:44:50 -07003940void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003941{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003942 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 +00003943
Geoff Langbfdea662014-07-23 14:16:32 -04003944 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003945 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003946 {
Geoff Langb1196682014-07-23 13:47:29 -04003947 if (width < 0 || height < 0)
3948 {
3949 context->recordError(gl::Error(GL_INVALID_VALUE));
3950 return;
3951 }
3952
Geoff Langbfdea662014-07-23 14:16:32 -04003953 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003954 }
3955}
3956
Kenneth Russell67ea1902014-10-06 16:44:50 -07003957void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003958{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003959 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003960 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003961 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003962
Geoff Lang900013c2014-07-07 11:32:19 -04003963 gl::Context* context = gl::getNonLostContext();
3964 if (context)
3965 {
3966 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3967 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3968 {
Geoff Langb1196682014-07-23 13:47:29 -04003969 context->recordError(gl::Error(GL_INVALID_ENUM));
3970 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003971 }
3972
3973 // No binary shader formats are supported.
3974 UNIMPLEMENTED();
3975 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003976}
3977
Kenneth Russell67ea1902014-10-06 16:44:50 -07003978void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003979{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003980 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 +00003981 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003982
Geoff Langbfdea662014-07-23 14:16:32 -04003983 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003984 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003985 {
Geoff Langb1196682014-07-23 13:47:29 -04003986 if (count < 0)
3987 {
3988 context->recordError(gl::Error(GL_INVALID_VALUE));
3989 return;
3990 }
3991
Geoff Langbfdea662014-07-23 14:16:32 -04003992 gl::Shader *shaderObject = context->getShader(shader);
3993
3994 if (!shaderObject)
3995 {
3996 if (context->getProgram(shader))
3997 {
Geoff Langb1196682014-07-23 13:47:29 -04003998 context->recordError(gl::Error(GL_INVALID_OPERATION));
3999 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004000 }
4001 else
4002 {
Geoff Langb1196682014-07-23 13:47:29 -04004003 context->recordError(gl::Error(GL_INVALID_VALUE));
4004 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004005 }
4006 }
4007
4008 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009 }
4010}
4011
Kenneth Russell67ea1902014-10-06 16:44:50 -07004012void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004013{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004014 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004015}
4016
Kenneth Russell67ea1902014-10-06 16:44:50 -07004017void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004018{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004019 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 +00004020
Geoff Langbfdea662014-07-23 14:16:32 -04004021 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004022 if (context)
4023 {
Geoff Langb1196682014-07-23 13:47:29 -04004024 switch (face)
4025 {
4026 case GL_FRONT:
4027 case GL_BACK:
4028 case GL_FRONT_AND_BACK:
4029 break;
4030
4031 default:
4032 context->recordError(gl::Error(GL_INVALID_ENUM));
4033 return;
4034 }
4035
4036 switch (func)
4037 {
4038 case GL_NEVER:
4039 case GL_ALWAYS:
4040 case GL_LESS:
4041 case GL_LEQUAL:
4042 case GL_EQUAL:
4043 case GL_GEQUAL:
4044 case GL_GREATER:
4045 case GL_NOTEQUAL:
4046 break;
4047
4048 default:
4049 context->recordError(gl::Error(GL_INVALID_ENUM));
4050 return;
4051 }
4052
Geoff Langbfdea662014-07-23 14:16:32 -04004053 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4054 {
4055 context->getState().setStencilParams(func, ref, mask);
4056 }
4057
4058 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4059 {
4060 context->getState().setStencilBackParams(func, ref, mask);
4061 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004062 }
4063}
4064
Kenneth Russell67ea1902014-10-06 16:44:50 -07004065void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004066{
4067 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4068}
4069
Kenneth Russell67ea1902014-10-06 16:44:50 -07004070void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004071{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004072 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004073
Geoff Langbfdea662014-07-23 14:16:32 -04004074 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004075 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004076 {
Geoff Langb1196682014-07-23 13:47:29 -04004077 switch (face)
4078 {
4079 case GL_FRONT:
4080 case GL_BACK:
4081 case GL_FRONT_AND_BACK:
4082 break;
4083
4084 default:
4085 context->recordError(gl::Error(GL_INVALID_ENUM));
4086 return;
4087 }
4088
Geoff Langbfdea662014-07-23 14:16:32 -04004089 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4090 {
4091 context->getState().setStencilWritemask(mask);
4092 }
4093
4094 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4095 {
4096 context->getState().setStencilBackWritemask(mask);
4097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004098 }
4099}
4100
Kenneth Russell67ea1902014-10-06 16:44:50 -07004101void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102{
4103 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4104}
4105
Kenneth Russell67ea1902014-10-06 16:44:50 -07004106void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004107{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004108 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 +00004109 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004110
Geoff Langbfdea662014-07-23 14:16:32 -04004111 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004112 if (context)
4113 {
Geoff Langb1196682014-07-23 13:47:29 -04004114 switch (face)
4115 {
4116 case GL_FRONT:
4117 case GL_BACK:
4118 case GL_FRONT_AND_BACK:
4119 break;
4120
4121 default:
4122 context->recordError(gl::Error(GL_INVALID_ENUM));
4123 return;
4124 }
4125
4126 switch (fail)
4127 {
4128 case GL_ZERO:
4129 case GL_KEEP:
4130 case GL_REPLACE:
4131 case GL_INCR:
4132 case GL_DECR:
4133 case GL_INVERT:
4134 case GL_INCR_WRAP:
4135 case GL_DECR_WRAP:
4136 break;
4137
4138 default:
4139 context->recordError(gl::Error(GL_INVALID_ENUM));
4140 return;
4141 }
4142
4143 switch (zfail)
4144 {
4145 case GL_ZERO:
4146 case GL_KEEP:
4147 case GL_REPLACE:
4148 case GL_INCR:
4149 case GL_DECR:
4150 case GL_INVERT:
4151 case GL_INCR_WRAP:
4152 case GL_DECR_WRAP:
4153 break;
4154
4155 default:
4156 context->recordError(gl::Error(GL_INVALID_ENUM));
4157 return;
4158 }
4159
4160 switch (zpass)
4161 {
4162 case GL_ZERO:
4163 case GL_KEEP:
4164 case GL_REPLACE:
4165 case GL_INCR:
4166 case GL_DECR:
4167 case GL_INVERT:
4168 case GL_INCR_WRAP:
4169 case GL_DECR_WRAP:
4170 break;
4171
4172 default:
4173 context->recordError(gl::Error(GL_INVALID_ENUM));
4174 return;
4175 }
4176
Geoff Langbfdea662014-07-23 14:16:32 -04004177 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4178 {
4179 context->getState().setStencilOperations(fail, zfail, zpass);
4180 }
4181
4182 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4183 {
4184 context->getState().setStencilBackOperations(fail, zfail, zpass);
4185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004186 }
4187}
4188
Kenneth Russell67ea1902014-10-06 16:44:50 -07004189GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004191 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004192
Geoff Langbfdea662014-07-23 14:16:32 -04004193 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004194 if (context)
4195 {
4196 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4197
4198 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004199 {
Geoff Langb1196682014-07-23 13:47:29 -04004200 context->recordError(gl::Error(GL_INVALID_OPERATION));
4201 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004202 }
Geoff Langbfdea662014-07-23 14:16:32 -04004203
4204 if (fenceObject->isFence() != GL_TRUE)
4205 {
Geoff Langb1196682014-07-23 13:47:29 -04004206 context->recordError(gl::Error(GL_INVALID_OPERATION));
4207 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004208 }
4209
Geoff Lang882033e2014-09-30 11:26:07 -04004210 GLboolean result;
4211 gl::Error error = fenceObject->testFence(&result);
4212 if (error.isError())
4213 {
4214 context->recordError(error);
4215 return GL_TRUE;
4216 }
4217
4218 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004219 }
Geoff Langbfdea662014-07-23 14:16:32 -04004220
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004221 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004222}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004223
Kenneth Russell67ea1902014-10-06 16:44:50 -07004224void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004225 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004226{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004227 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004228 "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 +00004229 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004230
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 (context->getClientVersion() < 3 &&
4235 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4236 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004237 {
Geoff Langbfdea662014-07-23 14:16:32 -04004238 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004239 }
Geoff Langbfdea662014-07-23 14:16:32 -04004240
4241 if (context->getClientVersion() >= 3 &&
4242 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4243 0, 0, 0, width, height, 1, border, format, type, pixels))
4244 {
4245 return;
4246 }
4247
4248 switch (target)
4249 {
4250 case GL_TEXTURE_2D:
4251 {
4252 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004253 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4254 if (error.isError())
4255 {
4256 context->recordError(error);
4257 return;
4258 }
Geoff Langbfdea662014-07-23 14:16:32 -04004259 }
4260 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004261
Geoff Langbfdea662014-07-23 14:16:32 -04004262 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004263 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004264 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004265 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004266 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004267 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4268 {
4269 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004270 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004271 if (error.isError())
4272 {
4273 context->recordError(error);
4274 return;
4275 }
Geoff Langbfdea662014-07-23 14:16:32 -04004276 }
4277 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004278
Geoff Langbfdea662014-07-23 14:16:32 -04004279 default: UNREACHABLE();
4280 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004281 }
4282}
4283
Kenneth Russell67ea1902014-10-06 16:44:50 -07004284void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004285{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004286 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4287
Geoff Langbfdea662014-07-23 14:16:32 -04004288 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004289 if (context)
4290 {
4291 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004292 {
Geoff Langbfdea662014-07-23 14:16:32 -04004293 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004294 }
Geoff Langbfdea662014-07-23 14:16:32 -04004295
4296 gl::Texture *texture = context->getTargetTexture(target);
4297
4298 if (!texture)
4299 {
Geoff Langb1196682014-07-23 13:47:29 -04004300 context->recordError(gl::Error(GL_INVALID_ENUM));
4301 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004302 }
4303
4304 switch (pname)
4305 {
4306 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4307 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4308 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4309 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4310 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4311 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4312 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4313 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4314 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4315 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4316 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4317 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4318 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4319 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4320 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4321 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4322 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4323 default: UNREACHABLE(); break;
4324 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004325 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004326}
4327
Kenneth Russell67ea1902014-10-06 16:44:50 -07004328void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004329{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004330 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004331}
4332
Kenneth Russell67ea1902014-10-06 16:44:50 -07004333void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004334{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004335 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004336
Geoff Langbfdea662014-07-23 14:16:32 -04004337 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004338 if (context)
4339 {
4340 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004341 {
Geoff Langbfdea662014-07-23 14:16:32 -04004342 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004343 }
Geoff Langbfdea662014-07-23 14:16:32 -04004344
4345 gl::Texture *texture = context->getTargetTexture(target);
4346
4347 if (!texture)
4348 {
Geoff Langb1196682014-07-23 13:47:29 -04004349 context->recordError(gl::Error(GL_INVALID_ENUM));
4350 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004351 }
4352
4353 switch (pname)
4354 {
4355 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4356 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4357 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4358 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4359 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4360 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4361 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4362 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4363 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4364 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4365 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4366 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4367 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4368 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4369 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4370 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4371 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4372 default: UNREACHABLE(); break;
4373 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004374 }
4375}
4376
Kenneth Russell67ea1902014-10-06 16:44:50 -07004377void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004378{
4379 glTexParameteri(target, pname, *params);
4380}
4381
Kenneth Russell67ea1902014-10-06 16:44:50 -07004382void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004383{
4384 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4385 target, levels, internalformat, width, height);
4386
Geoff Langbfdea662014-07-23 14:16:32 -04004387 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004388 if (context)
4389 {
4390 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004391 {
Geoff Langb1196682014-07-23 13:47:29 -04004392 context->recordError(gl::Error(GL_INVALID_OPERATION));
4393 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004394 }
Geoff Langbfdea662014-07-23 14:16:32 -04004395
4396 if (context->getClientVersion() < 3 &&
4397 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4398 {
4399 return;
4400 }
4401
4402 if (context->getClientVersion() >= 3 &&
4403 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4404 {
4405 return;
4406 }
4407
4408 switch (target)
4409 {
4410 case GL_TEXTURE_2D:
4411 {
4412 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004413 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4414 if (error.isError())
4415 {
4416 context->recordError(error);
4417 return;
4418 }
Geoff Langbfdea662014-07-23 14:16:32 -04004419 }
4420 break;
4421
4422 case GL_TEXTURE_CUBE_MAP:
4423 {
4424 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004425 gl::Error error = textureCube->storage(levels, internalformat, width);
4426 if (error.isError())
4427 {
4428 context->recordError(error);
4429 return;
4430 }
Geoff Langbfdea662014-07-23 14:16:32 -04004431 }
4432 break;
4433
4434 default:
Geoff Langb1196682014-07-23 13:47:29 -04004435 context->recordError(gl::Error(GL_INVALID_ENUM));
4436 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004437 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004438 }
4439}
4440
Kenneth Russell67ea1902014-10-06 16:44:50 -07004441void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004442 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004443{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004444 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004445 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004446 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004447 target, level, xoffset, yoffset, width, height, format, type, pixels);
4448
Geoff Langbfdea662014-07-23 14:16:32 -04004449 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004450 if (context)
4451 {
4452 if (context->getClientVersion() < 3 &&
4453 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4454 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004455 {
Geoff Langbfdea662014-07-23 14:16:32 -04004456 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004457 }
Geoff Langbfdea662014-07-23 14:16:32 -04004458
4459 if (context->getClientVersion() >= 3 &&
4460 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4461 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4462 {
4463 return;
4464 }
4465
4466 // Zero sized uploads are valid but no-ops
4467 if (width == 0 || height == 0)
4468 {
4469 return;
4470 }
4471
4472 switch (target)
4473 {
4474 case GL_TEXTURE_2D:
4475 {
4476 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004477 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4478 if (error.isError())
4479 {
4480 context->recordError(error);
4481 return;
4482 }
Geoff Langbfdea662014-07-23 14:16:32 -04004483 }
4484 break;
4485
4486 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4487 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4488 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4489 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4490 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4491 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4492 {
4493 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004494 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4495 if (error.isError())
4496 {
4497 context->recordError(error);
4498 return;
4499 }
Geoff Langbfdea662014-07-23 14:16:32 -04004500 }
4501 break;
4502
4503 default:
4504 UNREACHABLE();
4505 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004506 }
4507}
4508
Kenneth Russell67ea1902014-10-06 16:44:50 -07004509void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004510{
4511 glUniform1fv(location, 1, &x);
4512}
4513
Kenneth Russell67ea1902014-10-06 16:44:50 -07004514void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004515{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004516 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004517
Geoff Langbfdea662014-07-23 14:16:32 -04004518 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004519 if (context)
4520 {
4521 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004522 {
Geoff Langbfdea662014-07-23 14:16:32 -04004523 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004524 }
Geoff Langbfdea662014-07-23 14:16:32 -04004525
4526 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4527 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528 }
4529}
4530
Kenneth Russell67ea1902014-10-06 16:44:50 -07004531void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004532{
4533 glUniform1iv(location, 1, &x);
4534}
4535
Kenneth Russell67ea1902014-10-06 16:44:50 -07004536void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004538 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004539
Geoff Langbfdea662014-07-23 14:16:32 -04004540 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004541 if (context)
4542 {
4543 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004544 {
Geoff Langbfdea662014-07-23 14:16:32 -04004545 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004546 }
Geoff Langbfdea662014-07-23 14:16:32 -04004547
4548 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4549 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004550 }
4551}
4552
Kenneth Russell67ea1902014-10-06 16:44:50 -07004553void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004554{
4555 GLfloat xy[2] = {x, y};
4556
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004557 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004558}
4559
Kenneth Russell67ea1902014-10-06 16:44:50 -07004560void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004562 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004563
Geoff Langbfdea662014-07-23 14:16:32 -04004564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004565 if (context)
4566 {
4567 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004568 {
Geoff Langbfdea662014-07-23 14:16:32 -04004569 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570 }
Geoff Langbfdea662014-07-23 14:16:32 -04004571
4572 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4573 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004574 }
4575}
4576
Kenneth Russell67ea1902014-10-06 16:44:50 -07004577void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004578{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004579 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004580
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004581 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004582}
4583
Kenneth Russell67ea1902014-10-06 16:44:50 -07004584void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004585{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004586 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004587
Geoff Langbfdea662014-07-23 14:16:32 -04004588 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004589 if (context)
4590 {
4591 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004592 {
Geoff Langbfdea662014-07-23 14:16:32 -04004593 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004594 }
Geoff Langbfdea662014-07-23 14:16:32 -04004595
4596 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4597 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004598 }
4599}
4600
Kenneth Russell67ea1902014-10-06 16:44:50 -07004601void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004602{
4603 GLfloat xyz[3] = {x, y, z};
4604
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004605 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004606}
4607
Kenneth Russell67ea1902014-10-06 16:44:50 -07004608void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004610 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004611
Geoff Langbfdea662014-07-23 14:16:32 -04004612 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004613 if (context)
4614 {
4615 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004616 {
Geoff Langbfdea662014-07-23 14:16:32 -04004617 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004618 }
Geoff Langbfdea662014-07-23 14:16:32 -04004619
4620 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4621 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004622 }
4623}
4624
Kenneth Russell67ea1902014-10-06 16:44:50 -07004625void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004626{
4627 GLint xyz[3] = {x, y, z};
4628
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004629 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004630}
4631
Kenneth Russell67ea1902014-10-06 16:44:50 -07004632void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004633{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004634 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004635
Geoff Langbfdea662014-07-23 14:16:32 -04004636 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004637 if (context)
4638 {
4639 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004640 {
Geoff Langbfdea662014-07-23 14:16:32 -04004641 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004642 }
Geoff Langbfdea662014-07-23 14:16:32 -04004643
4644 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4645 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004646 }
4647}
4648
Kenneth Russell67ea1902014-10-06 16:44:50 -07004649void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004650{
4651 GLfloat xyzw[4] = {x, y, z, w};
4652
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004653 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004654}
4655
Kenneth Russell67ea1902014-10-06 16:44:50 -07004656void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004657{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004658 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659
Geoff Langbfdea662014-07-23 14:16:32 -04004660 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004661 if (context)
4662 {
4663 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004664 {
Geoff Langbfdea662014-07-23 14:16:32 -04004665 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666 }
Geoff Langbfdea662014-07-23 14:16:32 -04004667
4668 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4669 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004670 }
4671}
4672
Kenneth Russell67ea1902014-10-06 16:44:50 -07004673void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004674{
4675 GLint xyzw[4] = {x, y, z, w};
4676
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004677 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004678}
4679
Kenneth Russell67ea1902014-10-06 16:44:50 -07004680void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004681{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004682 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004683
Geoff Langbfdea662014-07-23 14:16:32 -04004684 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004685 if (context)
4686 {
4687 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004688 {
Geoff Langbfdea662014-07-23 14:16:32 -04004689 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004690 }
Geoff Langbfdea662014-07-23 14:16:32 -04004691
4692 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4693 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004694 }
4695}
4696
Kenneth Russell67ea1902014-10-06 16:44:50 -07004697void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004698{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004699 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004700 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701
Geoff Langbfdea662014-07-23 14:16:32 -04004702 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004703 if (context)
4704 {
4705 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004706 {
Geoff Langbfdea662014-07-23 14:16:32 -04004707 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708 }
Geoff Langbfdea662014-07-23 14:16:32 -04004709
4710 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4711 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004712 }
4713}
4714
Kenneth Russell67ea1902014-10-06 16:44:50 -07004715void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004716{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004717 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004718 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719
Geoff Langbfdea662014-07-23 14:16:32 -04004720 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004721 if (context)
4722 {
4723 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004724 {
Geoff Langbfdea662014-07-23 14:16:32 -04004725 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004726 }
Geoff Langbfdea662014-07-23 14:16:32 -04004727
4728 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4729 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004730 }
4731}
4732
Kenneth Russell67ea1902014-10-06 16:44:50 -07004733void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004734{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004735 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004736 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004737
Geoff Langbfdea662014-07-23 14:16:32 -04004738 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004739 if (context)
4740 {
4741 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004742 {
Geoff Langbfdea662014-07-23 14:16:32 -04004743 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004744 }
Geoff Langbfdea662014-07-23 14:16:32 -04004745
4746 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4747 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004748 }
4749}
4750
Kenneth Russell67ea1902014-10-06 16:44:50 -07004751void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004752{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004753 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754
Geoff Langbfdea662014-07-23 14:16:32 -04004755 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004756 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757 {
Geoff Langbfdea662014-07-23 14:16:32 -04004758 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004759
Geoff Langbfdea662014-07-23 14:16:32 -04004760 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004761 {
Geoff Langbfdea662014-07-23 14:16:32 -04004762 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004763 {
Geoff Langb1196682014-07-23 13:47:29 -04004764 context->recordError(gl::Error(GL_INVALID_OPERATION));
4765 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004766 }
Geoff Langbfdea662014-07-23 14:16:32 -04004767 else
4768 {
Geoff Langb1196682014-07-23 13:47:29 -04004769 context->recordError(gl::Error(GL_INVALID_VALUE));
4770 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004771 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772 }
Geoff Langbfdea662014-07-23 14:16:32 -04004773
4774 if (program != 0 && !programObject->isLinked())
4775 {
Geoff Langb1196682014-07-23 13:47:29 -04004776 context->recordError(gl::Error(GL_INVALID_OPERATION));
4777 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004778 }
4779
4780 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004781 }
4782}
4783
Kenneth Russell67ea1902014-10-06 16:44:50 -07004784void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004786 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004787
Geoff Langbfdea662014-07-23 14:16:32 -04004788 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004789 if (context)
4790 {
4791 gl::Program *programObject = context->getProgram(program);
4792
4793 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004794 {
Geoff Langbfdea662014-07-23 14:16:32 -04004795 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004796 {
Geoff Langb1196682014-07-23 13:47:29 -04004797 context->recordError(gl::Error(GL_INVALID_OPERATION));
4798 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004799 }
Geoff Langbfdea662014-07-23 14:16:32 -04004800 else
4801 {
Geoff Langb1196682014-07-23 13:47:29 -04004802 context->recordError(gl::Error(GL_INVALID_VALUE));
4803 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004804 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004805 }
Geoff Langbfdea662014-07-23 14:16:32 -04004806
Brandon Jones43a53e22014-08-28 16:23:22 -07004807 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004808 }
4809}
4810
Kenneth Russell67ea1902014-10-06 16:44:50 -07004811void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004812{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004813 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004814
Geoff Langbfdea662014-07-23 14:16:32 -04004815 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004816 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004817 {
Geoff Langb1196682014-07-23 13:47:29 -04004818 if (index >= gl::MAX_VERTEX_ATTRIBS)
4819 {
4820 context->recordError(gl::Error(GL_INVALID_VALUE));
4821 return;
4822 }
4823
Geoff Langbfdea662014-07-23 14:16:32 -04004824 GLfloat vals[4] = { x, 0, 0, 1 };
4825 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004826 }
4827}
4828
Kenneth Russell67ea1902014-10-06 16:44:50 -07004829void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004831 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004832
Geoff Langbfdea662014-07-23 14:16:32 -04004833 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004834 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004835 {
Geoff Langb1196682014-07-23 13:47:29 -04004836 if (index >= gl::MAX_VERTEX_ATTRIBS)
4837 {
4838 context->recordError(gl::Error(GL_INVALID_VALUE));
4839 return;
4840 }
4841
Geoff Langbfdea662014-07-23 14:16:32 -04004842 GLfloat vals[4] = { values[0], 0, 0, 1 };
4843 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004844 }
4845}
4846
Kenneth Russell67ea1902014-10-06 16:44:50 -07004847void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004848{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004849 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004850
Geoff Langbfdea662014-07-23 14:16:32 -04004851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004852 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004853 {
Geoff Langb1196682014-07-23 13:47:29 -04004854 if (index >= gl::MAX_VERTEX_ATTRIBS)
4855 {
4856 context->recordError(gl::Error(GL_INVALID_VALUE));
4857 return;
4858 }
4859
Geoff Langbfdea662014-07-23 14:16:32 -04004860 GLfloat vals[4] = { x, y, 0, 1 };
4861 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004862 }
4863}
4864
Kenneth Russell67ea1902014-10-06 16:44:50 -07004865void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004866{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004867 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004868
Geoff Langbfdea662014-07-23 14:16:32 -04004869 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004870 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004871 {
Geoff Langb1196682014-07-23 13:47:29 -04004872 if (index >= gl::MAX_VERTEX_ATTRIBS)
4873 {
4874 context->recordError(gl::Error(GL_INVALID_VALUE));
4875 return;
4876 }
4877
Geoff Langbfdea662014-07-23 14:16:32 -04004878 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4879 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004880 }
4881}
4882
Kenneth Russell67ea1902014-10-06 16:44:50 -07004883void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004885 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 +00004886
Geoff Langbfdea662014-07-23 14:16:32 -04004887 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004888 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004889 {
Geoff Langb1196682014-07-23 13:47:29 -04004890 if (index >= gl::MAX_VERTEX_ATTRIBS)
4891 {
4892 context->recordError(gl::Error(GL_INVALID_VALUE));
4893 return;
4894 }
4895
Geoff Langbfdea662014-07-23 14:16:32 -04004896 GLfloat vals[4] = { x, y, z, 1 };
4897 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004898 }
4899}
4900
Kenneth Russell67ea1902014-10-06 16:44:50 -07004901void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004902{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004903 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004904
Geoff Langbfdea662014-07-23 14:16:32 -04004905 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004906 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004907 {
Geoff Langb1196682014-07-23 13:47:29 -04004908 if (index >= gl::MAX_VERTEX_ATTRIBS)
4909 {
4910 context->recordError(gl::Error(GL_INVALID_VALUE));
4911 return;
4912 }
4913
Geoff Langbfdea662014-07-23 14:16:32 -04004914 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4915 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004916 }
4917}
4918
Kenneth Russell67ea1902014-10-06 16:44:50 -07004919void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004920{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004921 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 +00004922
Geoff Langbfdea662014-07-23 14:16:32 -04004923 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004924 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004925 {
Geoff Langb1196682014-07-23 13:47:29 -04004926 if (index >= gl::MAX_VERTEX_ATTRIBS)
4927 {
4928 context->recordError(gl::Error(GL_INVALID_VALUE));
4929 return;
4930 }
4931
Geoff Langbfdea662014-07-23 14:16:32 -04004932 GLfloat vals[4] = { x, y, z, w };
4933 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004934 }
4935}
4936
Kenneth Russell67ea1902014-10-06 16:44:50 -07004937void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004938{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004939 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004940
Geoff Langbfdea662014-07-23 14:16:32 -04004941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004942 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004943 {
Geoff Langb1196682014-07-23 13:47:29 -04004944 if (index >= gl::MAX_VERTEX_ATTRIBS)
4945 {
4946 context->recordError(gl::Error(GL_INVALID_VALUE));
4947 return;
4948 }
4949
Geoff Langbfdea662014-07-23 14:16:32 -04004950 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004951 }
4952}
4953
Kenneth Russell67ea1902014-10-06 16:44:50 -07004954void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004955{
4956 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4957
Geoff Langbfdea662014-07-23 14:16:32 -04004958 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004959 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004960 {
Geoff Langb1196682014-07-23 13:47:29 -04004961 if (index >= gl::MAX_VERTEX_ATTRIBS)
4962 {
4963 context->recordError(gl::Error(GL_INVALID_VALUE));
4964 return;
4965 }
4966
Geoff Langbfdea662014-07-23 14:16:32 -04004967 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004968 }
4969}
4970
Kenneth Russell67ea1902014-10-06 16:44:50 -07004971void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004972{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004973 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004974 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004975 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004976
Geoff Langbfdea662014-07-23 14:16:32 -04004977 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004978 if (context)
4979 {
Geoff Langb1196682014-07-23 13:47:29 -04004980 if (index >= gl::MAX_VERTEX_ATTRIBS)
4981 {
4982 context->recordError(gl::Error(GL_INVALID_VALUE));
4983 return;
4984 }
4985
4986 if (size < 1 || size > 4)
4987 {
4988 context->recordError(gl::Error(GL_INVALID_VALUE));
4989 return;
4990 }
4991
4992 switch (type)
4993 {
4994 case GL_BYTE:
4995 case GL_UNSIGNED_BYTE:
4996 case GL_SHORT:
4997 case GL_UNSIGNED_SHORT:
4998 case GL_FIXED:
4999 case GL_FLOAT:
5000 break;
5001
5002 case GL_HALF_FLOAT:
5003 case GL_INT:
5004 case GL_UNSIGNED_INT:
5005 case GL_INT_2_10_10_10_REV:
5006 case GL_UNSIGNED_INT_2_10_10_10_REV:
5007 if (context->getClientVersion() < 3)
5008 {
5009 context->recordError(gl::Error(GL_INVALID_ENUM));
5010 return;
5011 }
5012 break;
5013
5014 default:
5015 context->recordError(gl::Error(GL_INVALID_ENUM));
5016 return;
5017 }
5018
5019 if (stride < 0)
5020 {
5021 context->recordError(gl::Error(GL_INVALID_VALUE));
5022 return;
5023 }
5024
5025 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5026 {
5027 context->recordError(gl::Error(GL_INVALID_OPERATION));
5028 return;
5029 }
5030
Geoff Langbfdea662014-07-23 14:16:32 -04005031 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5032 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5033 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5034 // and the pointer argument is not NULL.
5035 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005036 {
Geoff Langb1196682014-07-23 13:47:29 -04005037 context->recordError(gl::Error(GL_INVALID_OPERATION));
5038 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005039 }
5040
Geoff Langbfdea662014-07-23 14:16:32 -04005041 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5042 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005043 }
5044}
5045
Kenneth Russell67ea1902014-10-06 16:44:50 -07005046void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005047{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005048 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 +00005049
Geoff Langbfdea662014-07-23 14:16:32 -04005050 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005051 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005052 {
Geoff Langb1196682014-07-23 13:47:29 -04005053 if (width < 0 || height < 0)
5054 {
5055 context->recordError(gl::Error(GL_INVALID_VALUE));
5056 return;
5057 }
5058
Geoff Langbfdea662014-07-23 14:16:32 -04005059 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005060 }
5061}
5062
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005063// OpenGL ES 3.0 functions
5064
Kenneth Russell67ea1902014-10-06 16:44:50 -07005065void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005066{
5067 EVENT("(GLenum mode = 0x%X)", mode);
5068
Geoff Langbfdea662014-07-23 14:16:32 -04005069 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005070 if (context)
5071 {
5072 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005073 {
Geoff Langb1196682014-07-23 13:47:29 -04005074 context->recordError(gl::Error(GL_INVALID_OPERATION));
5075 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005076 }
Geoff Langbfdea662014-07-23 14:16:32 -04005077
5078 // glReadBuffer
5079 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005080 }
5081}
5082
Kenneth Russell67ea1902014-10-06 16:44:50 -07005083void 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 +00005084{
5085 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5086 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5087
Geoff Langbfdea662014-07-23 14:16:32 -04005088 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005089 if (context)
5090 {
5091 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005092 {
Geoff Langb1196682014-07-23 13:47:29 -04005093 context->recordError(gl::Error(GL_INVALID_OPERATION));
5094 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005095 }
Geoff Langbfdea662014-07-23 14:16:32 -04005096
5097 // glDrawRangeElements
5098 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005099 }
5100}
5101
Kenneth Russell67ea1902014-10-06 16:44:50 -07005102void 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 +00005103{
5104 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5105 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5106 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5107 target, level, internalformat, width, height, depth, border, format, type, pixels);
5108
Geoff Langbfdea662014-07-23 14:16:32 -04005109 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005110 if (context)
5111 {
5112 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005113 {
Geoff Langb1196682014-07-23 13:47:29 -04005114 context->recordError(gl::Error(GL_INVALID_OPERATION));
5115 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005116 }
Geoff Langbfdea662014-07-23 14:16:32 -04005117
5118 // validateES3TexImageFormat sets the error code if there is an error
5119 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5120 0, 0, 0, width, height, depth, border, format, type, pixels))
5121 {
5122 return;
5123 }
5124
5125 switch(target)
5126 {
5127 case GL_TEXTURE_3D:
5128 {
5129 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005130 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5131 if (error.isError())
5132 {
5133 context->recordError(error);
5134 return;
5135 }
Geoff Langbfdea662014-07-23 14:16:32 -04005136 }
5137 break;
5138
5139 case GL_TEXTURE_2D_ARRAY:
5140 {
5141 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005142 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5143 if (error.isError())
5144 {
5145 context->recordError(error);
5146 return;
5147 }
Geoff Langbfdea662014-07-23 14:16:32 -04005148 }
5149 break;
5150
5151 default:
Geoff Langb1196682014-07-23 13:47:29 -04005152 context->recordError(gl::Error(GL_INVALID_ENUM));
5153 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005154 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005155 }
5156}
5157
Kenneth Russell67ea1902014-10-06 16:44:50 -07005158void 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 +00005159{
5160 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5161 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5162 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5163 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5164
Geoff Langbfdea662014-07-23 14:16:32 -04005165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005166 if (context)
5167 {
5168 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005169 {
Geoff Langb1196682014-07-23 13:47:29 -04005170 context->recordError(gl::Error(GL_INVALID_OPERATION));
5171 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005172 }
Geoff Langbfdea662014-07-23 14:16:32 -04005173
5174 // validateES3TexImageFormat sets the error code if there is an error
5175 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5176 xoffset, yoffset, zoffset, width, height, depth, 0,
5177 format, type, pixels))
5178 {
5179 return;
5180 }
5181
5182 // Zero sized uploads are valid but no-ops
5183 if (width == 0 || height == 0 || depth == 0)
5184 {
5185 return;
5186 }
5187
5188 switch(target)
5189 {
5190 case GL_TEXTURE_3D:
5191 {
5192 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005193 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5194 if (error.isError())
5195 {
5196 context->recordError(error);
5197 return;
5198 }
Geoff Langbfdea662014-07-23 14:16:32 -04005199 }
5200 break;
5201
5202 case GL_TEXTURE_2D_ARRAY:
5203 {
5204 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005205 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5206 if (error.isError())
5207 {
5208 context->recordError(error);
5209 return;
5210 }
Geoff Langbfdea662014-07-23 14:16:32 -04005211 }
5212 break;
5213
5214 default:
Geoff Langb1196682014-07-23 13:47:29 -04005215 context->recordError(gl::Error(GL_INVALID_ENUM));
5216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005217 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005218 }
5219}
5220
Kenneth Russell67ea1902014-10-06 16:44:50 -07005221void 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 +00005222{
5223 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5224 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5225 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5226
Geoff Langbfdea662014-07-23 14:16:32 -04005227 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005228 if (context)
5229 {
5230 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005231 {
Geoff Langb1196682014-07-23 13:47:29 -04005232 context->recordError(gl::Error(GL_INVALID_OPERATION));
5233 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005234 }
Geoff Langbfdea662014-07-23 14:16:32 -04005235
5236 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5237 x, y, width, height, 0))
5238 {
5239 return;
5240 }
5241
5242 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5243 gl::Texture *texture = NULL;
5244 switch (target)
5245 {
5246 case GL_TEXTURE_3D:
5247 texture = context->getTexture3D();
5248 break;
5249
5250 case GL_TEXTURE_2D_ARRAY:
5251 texture = context->getTexture2DArray();
5252 break;
5253
5254 default:
Geoff Langb1196682014-07-23 13:47:29 -04005255 context->recordError(gl::Error(GL_INVALID_ENUM));
5256 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005257 }
5258
Geoff Langef7b0162014-09-04 13:29:23 -04005259 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5260 if (error.isError())
5261 {
5262 context->recordError(error);
5263 return;
5264 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005265 }
5266}
5267
Kenneth Russell67ea1902014-10-06 16:44:50 -07005268void 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 +00005269{
Geoff Langeef52cc2013-10-16 15:07:39 -04005270 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 +00005271 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5272 "const GLvoid* data = 0x%0.8p)",
5273 target, level, internalformat, width, height, depth, border, imageSize, data);
5274
Geoff Langbfdea662014-07-23 14:16:32 -04005275 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005276 if (context)
5277 {
5278 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005279 {
Geoff Langb1196682014-07-23 13:47:29 -04005280 context->recordError(gl::Error(GL_INVALID_OPERATION));
5281 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005282 }
Geoff Langbfdea662014-07-23 14:16:32 -04005283
Geoff Lang5d601382014-07-22 15:14:06 -04005284 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5285 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005286 {
Geoff Langb1196682014-07-23 13:47:29 -04005287 context->recordError(gl::Error(GL_INVALID_VALUE));
5288 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005289 }
5290
5291 // validateES3TexImageFormat sets the error code if there is an error
5292 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5293 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5294 {
5295 return;
5296 }
5297
5298 switch(target)
5299 {
5300 case GL_TEXTURE_3D:
5301 {
5302 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005303 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005304 if (error.isError())
5305 {
5306 context->recordError(error);
5307 return;
5308 }
Geoff Langbfdea662014-07-23 14:16:32 -04005309 }
5310 break;
5311
5312 case GL_TEXTURE_2D_ARRAY:
5313 {
5314 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005315 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005316 if (error.isError())
5317 {
5318 context->recordError(error);
5319 return;
5320 }
Geoff Langbfdea662014-07-23 14:16:32 -04005321 }
5322 break;
5323
5324 default:
Geoff Langb1196682014-07-23 13:47:29 -04005325 context->recordError(gl::Error(GL_INVALID_ENUM));
5326 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005327 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005328 }
5329}
5330
Kenneth Russell67ea1902014-10-06 16:44:50 -07005331void 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 +00005332{
5333 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5334 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5335 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5336 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5337
Geoff Langbfdea662014-07-23 14:16:32 -04005338 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005339 if (context)
5340 {
5341 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005342 {
Geoff Langb1196682014-07-23 13:47:29 -04005343 context->recordError(gl::Error(GL_INVALID_OPERATION));
5344 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005345 }
Geoff Langbfdea662014-07-23 14:16:32 -04005346
Geoff Lang5d601382014-07-22 15:14:06 -04005347 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5348 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005349 {
Geoff Langb1196682014-07-23 13:47:29 -04005350 context->recordError(gl::Error(GL_INVALID_VALUE));
5351 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005352 }
5353
5354 if (!data)
5355 {
Geoff Langb1196682014-07-23 13:47:29 -04005356 context->recordError(gl::Error(GL_INVALID_VALUE));
5357 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005358 }
5359
5360 // validateES3TexImageFormat sets the error code if there is an error
5361 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5362 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5363 {
5364 return;
5365 }
5366
5367 // Zero sized uploads are valid but no-ops
5368 if (width == 0 || height == 0)
5369 {
5370 return;
5371 }
5372
5373 switch(target)
5374 {
5375 case GL_TEXTURE_3D:
5376 {
5377 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005378 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005379 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005380 if (error.isError())
5381 {
5382 context->recordError(error);
5383 return;
5384 }
Geoff Langbfdea662014-07-23 14:16:32 -04005385 }
5386 break;
5387
5388 case GL_TEXTURE_2D_ARRAY:
5389 {
5390 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005391 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005392 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005393 if (error.isError())
5394 {
5395 context->recordError(error);
5396 return;
5397 }
Geoff Langbfdea662014-07-23 14:16:32 -04005398 }
5399 break;
5400
Geoff Langb1196682014-07-23 13:47:29 -04005401 default:
5402 context->recordError(gl::Error(GL_INVALID_ENUM));
5403 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005404 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005405 }
5406}
5407
Kenneth Russell67ea1902014-10-06 16:44:50 -07005408void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005409{
5410 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5411
Geoff Langbfdea662014-07-23 14:16:32 -04005412 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005413 if (context)
5414 {
5415 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005416 {
Geoff Langb1196682014-07-23 13:47:29 -04005417 context->recordError(gl::Error(GL_INVALID_OPERATION));
5418 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005419 }
Geoff Langbfdea662014-07-23 14:16:32 -04005420
5421 if (n < 0)
5422 {
Geoff Langb1196682014-07-23 13:47:29 -04005423 context->recordError(gl::Error(GL_INVALID_VALUE));
5424 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005425 }
5426
5427 for (GLsizei i = 0; i < n; i++)
5428 {
5429 ids[i] = context->createQuery();
5430 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005431 }
5432}
5433
Kenneth Russell67ea1902014-10-06 16:44:50 -07005434void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005435{
5436 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5437
Geoff Langbfdea662014-07-23 14:16:32 -04005438 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005439 if (context)
5440 {
5441 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005442 {
Geoff Langb1196682014-07-23 13:47:29 -04005443 context->recordError(gl::Error(GL_INVALID_OPERATION));
5444 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005445 }
Geoff Langbfdea662014-07-23 14:16:32 -04005446
5447 if (n < 0)
5448 {
Geoff Langb1196682014-07-23 13:47:29 -04005449 context->recordError(gl::Error(GL_INVALID_VALUE));
5450 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005451 }
5452
5453 for (GLsizei i = 0; i < n; i++)
5454 {
5455 context->deleteQuery(ids[i]);
5456 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005457 }
5458}
5459
Kenneth Russell67ea1902014-10-06 16:44:50 -07005460GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005461{
5462 EVENT("(GLuint id = %u)", id);
5463
Geoff Langbfdea662014-07-23 14:16:32 -04005464 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005465 if (context)
5466 {
5467 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005468 {
Geoff Langb1196682014-07-23 13:47:29 -04005469 context->recordError(gl::Error(GL_INVALID_OPERATION));
5470 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005471 }
Geoff Langbfdea662014-07-23 14:16:32 -04005472
5473 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005474 }
5475
5476 return GL_FALSE;
5477}
5478
Kenneth Russell67ea1902014-10-06 16:44:50 -07005479void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005480{
5481 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5482
Geoff Langbfdea662014-07-23 14:16:32 -04005483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005484 if (context)
5485 {
5486 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005487 {
Geoff Langb1196682014-07-23 13:47:29 -04005488 context->recordError(gl::Error(GL_INVALID_OPERATION));
5489 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005490 }
Geoff Langbfdea662014-07-23 14:16:32 -04005491
5492 if (!ValidateBeginQuery(context, target, id))
5493 {
5494 return;
5495 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005496
5497 gl::Error error = context->beginQuery(target, id);
5498 if (error.isError())
5499 {
5500 context->recordError(error);
5501 return;
5502 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005503 }
5504}
5505
Kenneth Russell67ea1902014-10-06 16:44:50 -07005506void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005507{
5508 EVENT("(GLenum target = 0x%X)", target);
5509
Geoff Langbfdea662014-07-23 14:16:32 -04005510 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005511 if (context)
5512 {
5513 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005514 {
Geoff Langb1196682014-07-23 13:47:29 -04005515 context->recordError(gl::Error(GL_INVALID_OPERATION));
5516 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005517 }
Geoff Langbfdea662014-07-23 14:16:32 -04005518
5519 if (!ValidateEndQuery(context, target))
5520 {
5521 return;
5522 }
5523
Geoff Lang5aad9672014-09-08 11:10:42 -04005524 gl::Error error = context->endQuery(target);
5525 if (error.isError())
5526 {
5527 context->recordError(error);
5528 return;
5529 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005530 }
5531}
5532
Kenneth Russell67ea1902014-10-06 16:44:50 -07005533void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005534{
5535 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5536
Geoff Langbfdea662014-07-23 14:16:32 -04005537 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005538 if (context)
5539 {
5540 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005541 {
Geoff Langb1196682014-07-23 13:47:29 -04005542 context->recordError(gl::Error(GL_INVALID_OPERATION));
5543 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005544 }
Geoff Langbfdea662014-07-23 14:16:32 -04005545
5546 if (!ValidQueryType(context, target))
5547 {
Geoff Langb1196682014-07-23 13:47:29 -04005548 context->recordError(gl::Error(GL_INVALID_ENUM));
5549 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005550 }
5551
5552 switch (pname)
5553 {
5554 case GL_CURRENT_QUERY:
5555 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5556 break;
5557
5558 default:
Geoff Langb1196682014-07-23 13:47:29 -04005559 context->recordError(gl::Error(GL_INVALID_ENUM));
5560 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005561 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005562 }
5563}
5564
Kenneth Russell67ea1902014-10-06 16:44:50 -07005565void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005566{
5567 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5568
Geoff Langbfdea662014-07-23 14:16:32 -04005569 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005570 if (context)
5571 {
5572 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005573 {
Geoff Langb1196682014-07-23 13:47:29 -04005574 context->recordError(gl::Error(GL_INVALID_OPERATION));
5575 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005576 }
Geoff Langbfdea662014-07-23 14:16:32 -04005577
5578 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5579
5580 if (!queryObject)
5581 {
Geoff Langb1196682014-07-23 13:47:29 -04005582 context->recordError(gl::Error(GL_INVALID_OPERATION));
5583 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005584 }
5585
5586 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5587 {
Geoff Langb1196682014-07-23 13:47:29 -04005588 context->recordError(gl::Error(GL_INVALID_OPERATION));
5589 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005590 }
5591
5592 switch(pname)
5593 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005594 case GL_QUERY_RESULT_EXT:
5595 {
5596 gl::Error error = queryObject->getResult(params);
5597 if (error.isError())
5598 {
5599 context->recordError(error);
5600 return;
5601 }
5602 }
Geoff Langbfdea662014-07-23 14:16:32 -04005603 break;
Geoff Langb1196682014-07-23 13:47:29 -04005604
Geoff Lang5aad9672014-09-08 11:10:42 -04005605 case GL_QUERY_RESULT_AVAILABLE_EXT:
5606 {
5607 gl::Error error = queryObject->isResultAvailable(params);
5608 if (error.isError())
5609 {
5610 context->recordError(error);
5611 return;
5612 }
5613 }
Geoff Langbfdea662014-07-23 14:16:32 -04005614 break;
Geoff Langb1196682014-07-23 13:47:29 -04005615
Geoff Langbfdea662014-07-23 14:16:32 -04005616 default:
Geoff Langb1196682014-07-23 13:47:29 -04005617 context->recordError(gl::Error(GL_INVALID_ENUM));
5618 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005619 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005620 }
5621}
5622
Kenneth Russell67ea1902014-10-06 16:44:50 -07005623GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005624{
5625 EVENT("(GLenum target = 0x%X)", target);
5626
Geoff Langbfdea662014-07-23 14:16:32 -04005627 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005628 if (context)
5629 {
5630 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005631 {
Geoff Langb1196682014-07-23 13:47:29 -04005632 context->recordError(gl::Error(GL_INVALID_OPERATION));
5633 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005634 }
Geoff Langbfdea662014-07-23 14:16:32 -04005635
5636 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005637 }
5638
5639 return GL_FALSE;
5640}
5641
Kenneth Russell67ea1902014-10-06 16:44:50 -07005642void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005643{
5644 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5645
Geoff Langbfdea662014-07-23 14:16:32 -04005646 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005647 if (context)
5648 {
5649 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005650 {
Geoff Langb1196682014-07-23 13:47:29 -04005651 context->recordError(gl::Error(GL_INVALID_OPERATION));
5652 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005653 }
Geoff Langbfdea662014-07-23 14:16:32 -04005654
5655 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005656 }
5657}
5658
Kenneth Russell67ea1902014-10-06 16:44:50 -07005659void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005660{
Geoff Langbfdea662014-07-23 14:16:32 -04005661 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005662 if (context)
5663 {
5664 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005665 {
Geoff Langb1196682014-07-23 13:47:29 -04005666 context->recordError(gl::Error(GL_INVALID_OPERATION));
5667 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005668 }
Geoff Langbfdea662014-07-23 14:16:32 -04005669
5670 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005671 }
5672}
5673
Kenneth Russell67ea1902014-10-06 16:44:50 -07005674void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005675{
5676 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5677 location, count, transpose, value);
5678
Geoff Langbfdea662014-07-23 14:16:32 -04005679 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005680 if (context)
5681 {
5682 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005683 {
Geoff Langbfdea662014-07-23 14:16:32 -04005684 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005685 }
Geoff Langbfdea662014-07-23 14:16:32 -04005686
5687 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5688 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005689 }
5690}
5691
Kenneth Russell67ea1902014-10-06 16:44:50 -07005692void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005693{
5694 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5695 location, count, transpose, value);
5696
Geoff Langbfdea662014-07-23 14:16:32 -04005697 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005698 if (context)
5699 {
5700 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005701 {
Geoff Langbfdea662014-07-23 14:16:32 -04005702 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005703 }
Geoff Langbfdea662014-07-23 14:16:32 -04005704
5705 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5706 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005707 }
5708}
5709
Kenneth Russell67ea1902014-10-06 16:44:50 -07005710void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005711{
5712 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5713 location, count, transpose, value);
5714
Geoff Langbfdea662014-07-23 14:16:32 -04005715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005716 if (context)
5717 {
5718 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005719 {
Geoff Langbfdea662014-07-23 14:16:32 -04005720 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005721 }
Geoff Langbfdea662014-07-23 14:16:32 -04005722
5723 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5724 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005725 }
5726}
5727
Kenneth Russell67ea1902014-10-06 16:44:50 -07005728void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005729{
5730 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5731 location, count, transpose, value);
5732
Geoff Langbfdea662014-07-23 14:16:32 -04005733 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005734 if (context)
5735 {
5736 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005737 {
Geoff Langbfdea662014-07-23 14:16:32 -04005738 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005739 }
Geoff Langbfdea662014-07-23 14:16:32 -04005740
5741 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5742 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005743 }
5744}
5745
Kenneth Russell67ea1902014-10-06 16:44:50 -07005746void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005747{
5748 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5749 location, count, transpose, value);
5750
Geoff Langbfdea662014-07-23 14:16:32 -04005751 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005752 if (context)
5753 {
5754 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005755 {
Geoff Langbfdea662014-07-23 14:16:32 -04005756 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005757 }
Geoff Langbfdea662014-07-23 14:16:32 -04005758
5759 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5760 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005761 }
5762}
5763
Kenneth Russell67ea1902014-10-06 16:44:50 -07005764void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005765{
5766 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5767 location, count, transpose, value);
5768
Geoff Langbfdea662014-07-23 14:16:32 -04005769 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005770 if (context)
5771 {
5772 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005773 {
Geoff Langbfdea662014-07-23 14:16:32 -04005774 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005775 }
Geoff Langbfdea662014-07-23 14:16:32 -04005776
5777 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5778 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005779 }
5780}
5781
Kenneth Russell67ea1902014-10-06 16:44:50 -07005782void 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 +00005783{
5784 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5785 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5786 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5787
Geoff Langbfdea662014-07-23 14:16:32 -04005788 gl::Context *context = gl::getNonLostContext();
5789 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005790 {
Geoff Langbfdea662014-07-23 14:16:32 -04005791 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005792 {
Geoff Langb1196682014-07-23 13:47:29 -04005793 context->recordError(gl::Error(GL_INVALID_OPERATION));
5794 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005795 }
Geoff Langbfdea662014-07-23 14:16:32 -04005796
5797 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5798 dstX0, dstY0, dstX1, dstY1, mask, filter,
5799 false))
5800 {
5801 return;
5802 }
5803
Geoff Lang64839152014-08-26 16:23:25 -04005804 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5805 mask, filter);
5806 if (error.isError())
5807 {
5808 context->recordError(error);
5809 return;
5810 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005811 }
5812}
5813
Kenneth Russell67ea1902014-10-06 16:44:50 -07005814void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005815{
5816 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5817 target, samples, internalformat, width, height);
5818
Geoff Langbfdea662014-07-23 14:16:32 -04005819 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005820 if (context)
5821 {
5822 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005823 {
Geoff Langb1196682014-07-23 13:47:29 -04005824 context->recordError(gl::Error(GL_INVALID_OPERATION));
5825 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005826 }
Geoff Langbfdea662014-07-23 14:16:32 -04005827
5828 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5829 width, height, false))
5830 {
5831 return;
5832 }
5833
Shannon Woodse2632d22014-10-17 13:08:51 -04005834 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5835 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005836 }
5837}
5838
Kenneth Russell67ea1902014-10-06 16:44:50 -07005839void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005840{
5841 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5842 target, attachment, texture, level, layer);
5843
Geoff Langbfdea662014-07-23 14:16:32 -04005844 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005845 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005846 {
Geoff Langbfdea662014-07-23 14:16:32 -04005847 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5848 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005849 {
Geoff Langbfdea662014-07-23 14:16:32 -04005850 return;
5851 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005852
Geoff Langbfdea662014-07-23 14:16:32 -04005853 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5854 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005855
Geoff Langbfdea662014-07-23 14:16:32 -04005856 gl::Texture *textureObject = context->getTexture(texture);
5857 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005858
Geoff Langbfdea662014-07-23 14:16:32 -04005859 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5860 {
5861 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5862 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5863 }
5864 else
5865 {
5866 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005867 {
Geoff Langbfdea662014-07-23 14:16:32 -04005868 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5869 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5870 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005871 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005873 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005874}
5875
Kenneth Russell67ea1902014-10-06 16:44:50 -07005876GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005877{
5878 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5879 target, offset, length, access);
5880
Geoff Langbfdea662014-07-23 14:16:32 -04005881 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005882 if (context)
5883 {
5884 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005885 {
Geoff Langb1196682014-07-23 13:47:29 -04005886 context->recordError(gl::Error(GL_INVALID_OPERATION));
5887 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005888 }
Geoff Langbfdea662014-07-23 14:16:32 -04005889
5890 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005891 }
5892
5893 return NULL;
5894}
5895
Kenneth Russell67ea1902014-10-06 16:44:50 -07005896void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005897{
5898 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5899
Geoff Langbfdea662014-07-23 14:16:32 -04005900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005901 if (context)
5902 {
5903 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005904 {
Geoff Langb1196682014-07-23 13:47:29 -04005905 context->recordError(gl::Error(GL_INVALID_OPERATION));
5906 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005907 }
Geoff Langbfdea662014-07-23 14:16:32 -04005908
5909 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005910 }
5911}
5912
Kenneth Russell67ea1902014-10-06 16:44:50 -07005913void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005914{
5915 EVENT("(GLuint array = %u)", array);
5916
Geoff Langbfdea662014-07-23 14:16:32 -04005917 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005918 if (context)
5919 {
5920 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005921 {
Geoff Langb1196682014-07-23 13:47:29 -04005922 context->recordError(gl::Error(GL_INVALID_OPERATION));
5923 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005924 }
Geoff Langbfdea662014-07-23 14:16:32 -04005925
5926 gl::VertexArray *vao = context->getVertexArray(array);
5927
5928 if (!vao)
5929 {
5930 // The default VAO should always exist
5931 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005932 context->recordError(gl::Error(GL_INVALID_OPERATION));
5933 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005934 }
5935
5936 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005937 }
5938}
5939
Kenneth Russell67ea1902014-10-06 16:44:50 -07005940void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005941{
5942 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5943
Geoff Langbfdea662014-07-23 14:16:32 -04005944 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005945 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005946 {
Geoff Langbfdea662014-07-23 14:16:32 -04005947 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005948 {
Geoff Langb1196682014-07-23 13:47:29 -04005949 context->recordError(gl::Error(GL_INVALID_OPERATION));
5950 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005951 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005952
Geoff Langbfdea662014-07-23 14:16:32 -04005953 if (n < 0)
5954 {
Geoff Langb1196682014-07-23 13:47:29 -04005955 context->recordError(gl::Error(GL_INVALID_VALUE));
5956 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005957 }
Jamie Madilld1028542013-07-02 11:57:04 -04005958
Geoff Langbfdea662014-07-23 14:16:32 -04005959 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5960 {
5961 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005962 {
Geoff Langbfdea662014-07-23 14:16:32 -04005963 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005964 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005965 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005966 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005967}
5968
Kenneth Russell67ea1902014-10-06 16:44:50 -07005969void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005970{
5971 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5972
Geoff Langbfdea662014-07-23 14:16:32 -04005973 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005974 if (context)
5975 {
5976 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005977 {
Geoff Langb1196682014-07-23 13:47:29 -04005978 context->recordError(gl::Error(GL_INVALID_OPERATION));
5979 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005980 }
Geoff Langbfdea662014-07-23 14:16:32 -04005981
5982 if (n < 0)
5983 {
Geoff Langb1196682014-07-23 13:47:29 -04005984 context->recordError(gl::Error(GL_INVALID_VALUE));
5985 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005986 }
5987
5988 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5989 {
5990 arrays[arrayIndex] = context->createVertexArray();
5991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005992 }
5993}
5994
Kenneth Russell67ea1902014-10-06 16:44:50 -07005995GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005996{
5997 EVENT("(GLuint array = %u)", array);
5998
Geoff Langbfdea662014-07-23 14:16:32 -04005999 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006000 if (context)
6001 {
6002 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006003 {
Geoff Langb1196682014-07-23 13:47:29 -04006004 context->recordError(gl::Error(GL_INVALID_OPERATION));
6005 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006006 }
Geoff Langbfdea662014-07-23 14:16:32 -04006007
6008 if (array == 0)
6009 {
6010 return GL_FALSE;
6011 }
6012
6013 gl::VertexArray *vao = context->getVertexArray(array);
6014
6015 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006016 }
6017
6018 return GL_FALSE;
6019}
6020
Kenneth Russell67ea1902014-10-06 16:44:50 -07006021void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006022{
6023 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6024 target, index, data);
6025
Geoff Langbfdea662014-07-23 14:16:32 -04006026 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006027 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006028 {
Geoff Langbfdea662014-07-23 14:16:32 -04006029 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006030 {
Geoff Langb1196682014-07-23 13:47:29 -04006031 context->recordError(gl::Error(GL_INVALID_OPERATION));
6032 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006033 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006034
Geoff Lang3a61c322014-07-10 13:01:54 -04006035 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006036 switch (target)
6037 {
6038 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6039 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6040 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006041 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6042 {
Geoff Langb1196682014-07-23 13:47:29 -04006043 context->recordError(gl::Error(GL_INVALID_VALUE));
6044 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006045 }
Geoff Langbfdea662014-07-23 14:16:32 -04006046 break;
Geoff Langb1196682014-07-23 13:47:29 -04006047
Geoff Langbfdea662014-07-23 14:16:32 -04006048 case GL_UNIFORM_BUFFER_START:
6049 case GL_UNIFORM_BUFFER_SIZE:
6050 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006051 if (index >= caps.maxCombinedUniformBlocks)
6052 {
Geoff Langb1196682014-07-23 13:47:29 -04006053 context->recordError(gl::Error(GL_INVALID_VALUE));
6054 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006055 }
Geoff Langbfdea662014-07-23 14:16:32 -04006056 break;
Geoff Langb1196682014-07-23 13:47:29 -04006057
Geoff Langbfdea662014-07-23 14:16:32 -04006058 default:
Geoff Langb1196682014-07-23 13:47:29 -04006059 context->recordError(gl::Error(GL_INVALID_ENUM));
6060 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006061 }
6062
6063 if (!(context->getIndexedIntegerv(target, index, data)))
6064 {
6065 GLenum nativeType;
6066 unsigned int numParams = 0;
6067 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006068 {
6069 context->recordError(gl::Error(GL_INVALID_ENUM));
6070 return;
6071 }
Shannon Woods15934d52013-08-19 14:28:49 -04006072
Geoff Langbfdea662014-07-23 14:16:32 -04006073 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006074 {
Geoff Langbfdea662014-07-23 14:16:32 -04006075 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006076 }
Geoff Langbfdea662014-07-23 14:16:32 -04006077
6078 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006079 {
Geoff Langbfdea662014-07-23 14:16:32 -04006080 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6081 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6082 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006083
Geoff Langbfdea662014-07-23 14:16:32 -04006084 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006085
Geoff Langbfdea662014-07-23 14:16:32 -04006086 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006087 {
Geoff Langbfdea662014-07-23 14:16:32 -04006088 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6089 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006090 }
Geoff Langbfdea662014-07-23 14:16:32 -04006091
6092 delete [] int64Params;
6093 }
6094 else
6095 {
6096 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006097 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006098 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006099 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006100}
6101
Kenneth Russell67ea1902014-10-06 16:44:50 -07006102void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006103{
6104 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6105
Geoff Langbfdea662014-07-23 14:16:32 -04006106 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006107 if (context)
6108 {
6109 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006110 {
Geoff Langb1196682014-07-23 13:47:29 -04006111 context->recordError(gl::Error(GL_INVALID_OPERATION));
6112 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006113 }
Geoff Langbfdea662014-07-23 14:16:32 -04006114
6115 switch (primitiveMode)
6116 {
6117 case GL_TRIANGLES:
6118 case GL_LINES:
6119 case GL_POINTS:
6120 break;
Geoff Langb1196682014-07-23 13:47:29 -04006121
Geoff Langbfdea662014-07-23 14:16:32 -04006122 default:
Geoff Langb1196682014-07-23 13:47:29 -04006123 context->recordError(gl::Error(GL_INVALID_ENUM));
6124 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006125 }
6126
6127 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6128 ASSERT(transformFeedback != NULL);
6129
6130 if (transformFeedback->isStarted())
6131 {
Geoff Langb1196682014-07-23 13:47:29 -04006132 context->recordError(gl::Error(GL_INVALID_OPERATION));
6133 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006134 }
6135
6136 if (transformFeedback->isPaused())
6137 {
6138 transformFeedback->resume();
6139 }
6140 else
6141 {
6142 transformFeedback->start(primitiveMode);
6143 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006144 }
6145}
6146
Kenneth Russell67ea1902014-10-06 16:44:50 -07006147void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006148{
6149 EVENT("(void)");
6150
Geoff Langbfdea662014-07-23 14:16:32 -04006151 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006152 if (context)
6153 {
6154 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006155 {
Geoff Langb1196682014-07-23 13:47:29 -04006156 context->recordError(gl::Error(GL_INVALID_OPERATION));
6157 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006158 }
Geoff Langbfdea662014-07-23 14:16:32 -04006159
6160 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6161 ASSERT(transformFeedback != NULL);
6162
6163 if (!transformFeedback->isStarted())
6164 {
Geoff Langb1196682014-07-23 13:47:29 -04006165 context->recordError(gl::Error(GL_INVALID_OPERATION));
6166 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006167 }
6168
6169 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006170 }
6171}
6172
Kenneth Russell67ea1902014-10-06 16:44:50 -07006173void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006174{
6175 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6176 target, index, buffer, offset, size);
6177
Geoff Langbfdea662014-07-23 14:16:32 -04006178 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006179 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006180 {
Geoff Langbfdea662014-07-23 14:16:32 -04006181 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006182 {
Geoff Langb1196682014-07-23 13:47:29 -04006183 context->recordError(gl::Error(GL_INVALID_OPERATION));
6184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006185 }
6186
Geoff Lang3a61c322014-07-10 13:01:54 -04006187 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006188 switch (target)
6189 {
6190 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006191 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006192 {
Geoff Langb1196682014-07-23 13:47:29 -04006193 context->recordError(gl::Error(GL_INVALID_VALUE));
6194 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006195 }
Geoff Langbfdea662014-07-23 14:16:32 -04006196 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006197
Geoff Langbfdea662014-07-23 14:16:32 -04006198 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006199 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006200 {
Geoff Langb1196682014-07-23 13:47:29 -04006201 context->recordError(gl::Error(GL_INVALID_VALUE));
6202 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006203 }
Geoff Langbfdea662014-07-23 14:16:32 -04006204 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006205
Geoff Langbfdea662014-07-23 14:16:32 -04006206 default:
Geoff Langb1196682014-07-23 13:47:29 -04006207 context->recordError(gl::Error(GL_INVALID_ENUM));
6208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006209 }
6210
6211 if (buffer != 0 && size <= 0)
6212 {
Geoff Langb1196682014-07-23 13:47:29 -04006213 context->recordError(gl::Error(GL_INVALID_VALUE));
6214 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006215 }
6216
6217 switch (target)
6218 {
6219 case GL_TRANSFORM_FEEDBACK_BUFFER:
6220
6221 // size and offset must be a multiple of 4
6222 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006223 {
Geoff Langb1196682014-07-23 13:47:29 -04006224 context->recordError(gl::Error(GL_INVALID_VALUE));
6225 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006226 }
6227
Geoff Langbfdea662014-07-23 14:16:32 -04006228 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6229 context->bindGenericTransformFeedbackBuffer(buffer);
6230 break;
6231
6232 case GL_UNIFORM_BUFFER:
6233
6234 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006235 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006236 {
Geoff Langb1196682014-07-23 13:47:29 -04006237 context->recordError(gl::Error(GL_INVALID_VALUE));
6238 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006239 }
Geoff Langbfdea662014-07-23 14:16:32 -04006240
6241 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6242 context->bindGenericUniformBuffer(buffer);
6243 break;
6244
6245 default:
6246 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006247 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006248 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006249}
6250
Kenneth Russell67ea1902014-10-06 16:44:50 -07006251void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006252{
6253 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6254 target, index, buffer);
6255
Geoff Langbfdea662014-07-23 14:16:32 -04006256 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006257 if (context)
6258 {
6259 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006260 {
Geoff Langb1196682014-07-23 13:47:29 -04006261 context->recordError(gl::Error(GL_INVALID_OPERATION));
6262 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006263 }
Geoff Langbfdea662014-07-23 14:16:32 -04006264
Geoff Lang3a61c322014-07-10 13:01:54 -04006265 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006266 switch (target)
6267 {
6268 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006269 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006270 {
Geoff Langb1196682014-07-23 13:47:29 -04006271 context->recordError(gl::Error(GL_INVALID_VALUE));
6272 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006273 }
6274 break;
6275
6276 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006277 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006278 {
Geoff Langb1196682014-07-23 13:47:29 -04006279 context->recordError(gl::Error(GL_INVALID_VALUE));
6280 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006281 }
6282 break;
6283
6284 default:
Geoff Langb1196682014-07-23 13:47:29 -04006285 context->recordError(gl::Error(GL_INVALID_ENUM));
6286 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006287 }
6288
6289 switch (target)
6290 {
6291 case GL_TRANSFORM_FEEDBACK_BUFFER:
6292 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6293 context->bindGenericTransformFeedbackBuffer(buffer);
6294 break;
6295
6296 case GL_UNIFORM_BUFFER:
6297 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6298 context->bindGenericUniformBuffer(buffer);
6299 break;
6300
6301 default:
6302 UNREACHABLE();
6303 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006304 }
6305}
6306
Kenneth Russell67ea1902014-10-06 16:44:50 -07006307void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006308{
6309 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6310 program, count, varyings, bufferMode);
6311
Geoff Langbfdea662014-07-23 14:16:32 -04006312 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006313 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006314 {
Geoff Langbfdea662014-07-23 14:16:32 -04006315 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006316 {
Geoff Langb1196682014-07-23 13:47:29 -04006317 context->recordError(gl::Error(GL_INVALID_OPERATION));
6318 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006319 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006320
Geoff Langbfdea662014-07-23 14:16:32 -04006321 if (count < 0)
6322 {
Geoff Langb1196682014-07-23 13:47:29 -04006323 context->recordError(gl::Error(GL_INVALID_VALUE));
6324 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006325 }
6326
Geoff Lang05881a02014-07-10 14:05:30 -04006327 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006328 switch (bufferMode)
6329 {
6330 case GL_INTERLEAVED_ATTRIBS:
6331 break;
6332 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006333 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006334 {
Geoff Langb1196682014-07-23 13:47:29 -04006335 context->recordError(gl::Error(GL_INVALID_VALUE));
6336 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006337 }
Geoff Langbfdea662014-07-23 14:16:32 -04006338 break;
6339 default:
Geoff Langb1196682014-07-23 13:47:29 -04006340 context->recordError(gl::Error(GL_INVALID_ENUM));
6341 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006342 }
Geoff Langbfdea662014-07-23 14:16:32 -04006343
6344 if (!gl::ValidProgram(context, program))
6345 {
6346 return;
6347 }
6348
6349 gl::Program *programObject = context->getProgram(program);
6350 ASSERT(programObject);
6351
6352 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006353 }
6354}
6355
Kenneth Russell67ea1902014-10-06 16:44:50 -07006356void 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 +00006357{
6358 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6359 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6360 program, index, bufSize, length, size, type, name);
6361
Geoff Langbfdea662014-07-23 14:16:32 -04006362 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006363 if (context)
6364 {
6365 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006366 {
Geoff Langb1196682014-07-23 13:47:29 -04006367 context->recordError(gl::Error(GL_INVALID_OPERATION));
6368 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006369 }
Geoff Langbfdea662014-07-23 14:16:32 -04006370
6371 if (bufSize < 0)
6372 {
Geoff Langb1196682014-07-23 13:47:29 -04006373 context->recordError(gl::Error(GL_INVALID_VALUE));
6374 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006375 }
6376
6377 if (!gl::ValidProgram(context, program))
6378 {
6379 return;
6380 }
6381
6382 gl::Program *programObject = context->getProgram(program);
6383 ASSERT(programObject);
6384
6385 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6386 {
Geoff Langb1196682014-07-23 13:47:29 -04006387 context->recordError(gl::Error(GL_INVALID_VALUE));
6388 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006389 }
6390
6391 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006392 }
6393}
6394
Kenneth Russell67ea1902014-10-06 16:44:50 -07006395void 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 +00006396{
6397 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6398 index, size, type, stride, pointer);
6399
Geoff Langbfdea662014-07-23 14:16:32 -04006400 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006401 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006402 {
Geoff Langbfdea662014-07-23 14:16:32 -04006403 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006404 {
Geoff Langb1196682014-07-23 13:47:29 -04006405 context->recordError(gl::Error(GL_INVALID_OPERATION));
6406 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006407 }
6408
Geoff Langb1196682014-07-23 13:47:29 -04006409 if (index >= gl::MAX_VERTEX_ATTRIBS)
6410 {
6411 context->recordError(gl::Error(GL_INVALID_VALUE));
6412 return;
6413 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006414
Geoff Langb1196682014-07-23 13:47:29 -04006415 if (size < 1 || size > 4)
6416 {
6417 context->recordError(gl::Error(GL_INVALID_VALUE));
6418 return;
6419 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006420
Geoff Langb1196682014-07-23 13:47:29 -04006421 switch (type)
6422 {
6423 case GL_BYTE:
6424 case GL_UNSIGNED_BYTE:
6425 case GL_SHORT:
6426 case GL_UNSIGNED_SHORT:
6427 case GL_INT:
6428 case GL_UNSIGNED_INT:
6429 case GL_INT_2_10_10_10_REV:
6430 case GL_UNSIGNED_INT_2_10_10_10_REV:
6431 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006432
Geoff Langb1196682014-07-23 13:47:29 -04006433 default:
6434 context->recordError(gl::Error(GL_INVALID_ENUM));
6435 return;
6436 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006437
Geoff Langb1196682014-07-23 13:47:29 -04006438 if (stride < 0)
6439 {
6440 context->recordError(gl::Error(GL_INVALID_VALUE));
6441 return;
6442 }
Geoff Langbfdea662014-07-23 14:16:32 -04006443
Geoff Langb1196682014-07-23 13:47:29 -04006444 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6445 {
6446 context->recordError(gl::Error(GL_INVALID_OPERATION));
6447 return;
6448 }
6449
Geoff Langbfdea662014-07-23 14:16:32 -04006450 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6451 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6452 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6453 // and the pointer argument is not NULL.
6454 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006455 {
Geoff Langb1196682014-07-23 13:47:29 -04006456 context->recordError(gl::Error(GL_INVALID_OPERATION));
6457 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006458 }
6459
Geoff Langbfdea662014-07-23 14:16:32 -04006460 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6461 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006462 }
6463}
6464
Kenneth Russell67ea1902014-10-06 16:44:50 -07006465void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006466{
6467 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6468 index, pname, params);
6469
Geoff Langbfdea662014-07-23 14:16:32 -04006470 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006471 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006472 {
Geoff Langbfdea662014-07-23 14:16:32 -04006473 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006474 {
Geoff Langb1196682014-07-23 13:47:29 -04006475 context->recordError(gl::Error(GL_INVALID_OPERATION));
6476 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006477 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006478
Geoff Langbfdea662014-07-23 14:16:32 -04006479 if (index >= gl::MAX_VERTEX_ATTRIBS)
6480 {
Geoff Langb1196682014-07-23 13:47:29 -04006481 context->recordError(gl::Error(GL_INVALID_VALUE));
6482 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006483 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006484
Geoff Langbfdea662014-07-23 14:16:32 -04006485 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006486
Geoff Langb1196682014-07-23 13:47:29 -04006487 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006488 {
6489 return;
6490 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006491
Geoff Langbfdea662014-07-23 14:16:32 -04006492 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6493 {
6494 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6495 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006496 {
Geoff Langbfdea662014-07-23 14:16:32 -04006497 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006498 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006499 }
Geoff Langbfdea662014-07-23 14:16:32 -04006500 else
6501 {
6502 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6503 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006504 }
6505}
6506
Kenneth Russell67ea1902014-10-06 16:44:50 -07006507void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006508{
6509 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6510 index, pname, params);
6511
Geoff Langbfdea662014-07-23 14:16:32 -04006512 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006513 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006514 {
Geoff Langbfdea662014-07-23 14:16:32 -04006515 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006516 {
Geoff Langb1196682014-07-23 13:47:29 -04006517 context->recordError(gl::Error(GL_INVALID_OPERATION));
6518 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006519 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006520
Geoff Langbfdea662014-07-23 14:16:32 -04006521 if (index >= gl::MAX_VERTEX_ATTRIBS)
6522 {
Geoff Langb1196682014-07-23 13:47:29 -04006523 context->recordError(gl::Error(GL_INVALID_VALUE));
6524 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006525 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006526
Geoff Langbfdea662014-07-23 14:16:32 -04006527 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006528
Geoff Langb1196682014-07-23 13:47:29 -04006529 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006530 {
6531 return;
6532 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006533
Geoff Langbfdea662014-07-23 14:16:32 -04006534 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6535 {
6536 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6537 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006538 {
Geoff Langbfdea662014-07-23 14:16:32 -04006539 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006540 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006541 }
Geoff Langbfdea662014-07-23 14:16:32 -04006542 else
6543 {
6544 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6545 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006546 }
6547}
6548
Kenneth Russell67ea1902014-10-06 16:44:50 -07006549void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006550{
6551 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6552 index, x, y, z, w);
6553
Geoff Langbfdea662014-07-23 14:16:32 -04006554 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006555 if (context)
6556 {
6557 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006558 {
Geoff Langb1196682014-07-23 13:47:29 -04006559 context->recordError(gl::Error(GL_INVALID_OPERATION));
6560 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006561 }
Geoff Langbfdea662014-07-23 14:16:32 -04006562
6563 if (index >= gl::MAX_VERTEX_ATTRIBS)
6564 {
Geoff Langb1196682014-07-23 13:47:29 -04006565 context->recordError(gl::Error(GL_INVALID_VALUE));
6566 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006567 }
6568
6569 GLint vals[4] = { x, y, z, w };
6570 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006571 }
6572}
6573
Kenneth Russell67ea1902014-10-06 16:44:50 -07006574void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006575{
6576 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6577 index, x, y, z, w);
6578
Geoff Langbfdea662014-07-23 14:16:32 -04006579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006580 if (context)
6581 {
6582 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006583 {
Geoff Langb1196682014-07-23 13:47:29 -04006584 context->recordError(gl::Error(GL_INVALID_OPERATION));
6585 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006586 }
Geoff Langbfdea662014-07-23 14:16:32 -04006587
6588 if (index >= gl::MAX_VERTEX_ATTRIBS)
6589 {
Geoff Langb1196682014-07-23 13:47:29 -04006590 context->recordError(gl::Error(GL_INVALID_VALUE));
6591 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006592 }
6593
6594 GLuint vals[4] = { x, y, z, w };
6595 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006596 }
6597}
6598
Kenneth Russell67ea1902014-10-06 16:44:50 -07006599void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006600{
6601 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6602
Geoff Langbfdea662014-07-23 14:16:32 -04006603 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006604 if (context)
6605 {
6606 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006607 {
Geoff Langb1196682014-07-23 13:47:29 -04006608 context->recordError(gl::Error(GL_INVALID_OPERATION));
6609 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006610 }
Geoff Langbfdea662014-07-23 14:16:32 -04006611
6612 if (index >= gl::MAX_VERTEX_ATTRIBS)
6613 {
Geoff Langb1196682014-07-23 13:47:29 -04006614 context->recordError(gl::Error(GL_INVALID_VALUE));
6615 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006616 }
6617
6618 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006619 }
6620}
6621
Kenneth Russell67ea1902014-10-06 16:44:50 -07006622void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006623{
6624 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6625
Geoff Langbfdea662014-07-23 14:16:32 -04006626 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006627 if (context)
6628 {
6629 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006630 {
Geoff Langb1196682014-07-23 13:47:29 -04006631 context->recordError(gl::Error(GL_INVALID_OPERATION));
6632 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006633 }
Geoff Langbfdea662014-07-23 14:16:32 -04006634
6635 if (index >= gl::MAX_VERTEX_ATTRIBS)
6636 {
Geoff Langb1196682014-07-23 13:47:29 -04006637 context->recordError(gl::Error(GL_INVALID_VALUE));
6638 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006639 }
6640
6641 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006642 }
6643}
6644
Kenneth Russell67ea1902014-10-06 16:44:50 -07006645void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006646{
6647 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6648 program, location, params);
6649
Geoff Langbfdea662014-07-23 14:16:32 -04006650 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006651 if (context)
6652 {
Jamie Madill0063c512014-08-25 15:47:53 -04006653 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006654 {
Jamie Madill0063c512014-08-25 15:47:53 -04006655 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006656 }
Geoff Langbfdea662014-07-23 14:16:32 -04006657
Jamie Madilla502c742014-08-28 17:19:13 -04006658 gl::Program *programObject = context->getProgram(program);
6659 ASSERT(programObject);
6660 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006661 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006662
Jamie Madill99a1e982014-08-25 15:47:54 -04006663 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006664 }
6665}
6666
Kenneth Russell67ea1902014-10-06 16:44:50 -07006667GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006668{
6669 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6670 program, name);
6671
Geoff Langbfdea662014-07-23 14:16:32 -04006672 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006673 if (context)
6674 {
6675 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006676 {
Geoff Langb1196682014-07-23 13:47:29 -04006677 context->recordError(gl::Error(GL_INVALID_OPERATION));
6678 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006679 }
Geoff Langbfdea662014-07-23 14:16:32 -04006680
6681 if (program == 0)
6682 {
Geoff Langb1196682014-07-23 13:47:29 -04006683 context->recordError(gl::Error(GL_INVALID_VALUE));
6684 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006685 }
6686
6687 gl::Program *programObject = context->getProgram(program);
6688
6689 if (!programObject || !programObject->isLinked())
6690 {
Geoff Langb1196682014-07-23 13:47:29 -04006691 context->recordError(gl::Error(GL_INVALID_OPERATION));
6692 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006693 }
6694
6695 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6696 if (!programBinary)
6697 {
Geoff Langb1196682014-07-23 13:47:29 -04006698 context->recordError(gl::Error(GL_INVALID_OPERATION));
6699 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006700 }
6701
6702 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006703 }
6704
6705 return 0;
6706}
6707
Kenneth Russell67ea1902014-10-06 16:44:50 -07006708void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006709{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006710 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006711}
6712
Kenneth Russell67ea1902014-10-06 16:44:50 -07006713void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006714{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006715 const GLuint xy[] = { v0, v1 };
6716 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006717}
6718
Kenneth Russell67ea1902014-10-06 16:44:50 -07006719void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006720{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006721 const GLuint xyz[] = { v0, v1, v2 };
6722 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006723}
6724
Kenneth Russell67ea1902014-10-06 16:44:50 -07006725void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006726{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006727 const GLuint xyzw[] = { v0, v1, v2, v3 };
6728 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006729}
6730
Kenneth Russell67ea1902014-10-06 16:44:50 -07006731void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006732{
6733 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6734 location, count, value);
6735
Geoff Langbfdea662014-07-23 14:16:32 -04006736 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006737 if (context)
6738 {
6739 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006740 {
Geoff Langbfdea662014-07-23 14:16:32 -04006741 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006742 }
Geoff Langbfdea662014-07-23 14:16:32 -04006743
6744 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6745 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006746 }
6747}
6748
Kenneth Russell67ea1902014-10-06 16:44:50 -07006749void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006750{
6751 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6752 location, count, value);
6753
Geoff Langbfdea662014-07-23 14:16:32 -04006754 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006755 if (context)
6756 {
6757 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006758 {
Geoff Langbfdea662014-07-23 14:16:32 -04006759 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006760 }
Geoff Langbfdea662014-07-23 14:16:32 -04006761
6762 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6763 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006764 }
6765}
6766
Kenneth Russell67ea1902014-10-06 16:44:50 -07006767void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006768{
6769 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6770 location, count, value);
6771
Geoff Langbfdea662014-07-23 14:16:32 -04006772 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006773 if (context)
6774 {
6775 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006776 {
Geoff Langbfdea662014-07-23 14:16:32 -04006777 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006778 }
Geoff Langbfdea662014-07-23 14:16:32 -04006779
6780 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6781 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006782 }
6783}
6784
Kenneth Russell67ea1902014-10-06 16:44:50 -07006785void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006786{
6787 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6788 location, count, value);
6789
Geoff Langbfdea662014-07-23 14:16:32 -04006790 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006791 if (context)
6792 {
6793 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006794 {
Geoff Langbfdea662014-07-23 14:16:32 -04006795 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006796 }
Geoff Langbfdea662014-07-23 14:16:32 -04006797
6798 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6799 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006800 }
6801}
6802
Kenneth Russell67ea1902014-10-06 16:44:50 -07006803void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006804{
6805 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6806 buffer, drawbuffer, value);
6807
Geoff Langbfdea662014-07-23 14:16:32 -04006808 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006809 if (context)
6810 {
6811 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006812 {
Geoff Langbfdea662014-07-23 14:16:32 -04006813 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006814 }
Geoff Langbfdea662014-07-23 14:16:32 -04006815
6816 switch (buffer)
6817 {
6818 case GL_COLOR:
6819 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6820 {
Geoff Langb1196682014-07-23 13:47:29 -04006821 context->recordError(gl::Error(GL_INVALID_VALUE));
6822 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006823 }
6824 break;
Geoff Langb1196682014-07-23 13:47:29 -04006825
Geoff Langbfdea662014-07-23 14:16:32 -04006826 case GL_STENCIL:
6827 if (drawbuffer != 0)
6828 {
Geoff Langb1196682014-07-23 13:47:29 -04006829 context->recordError(gl::Error(GL_INVALID_VALUE));
6830 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006831 }
6832 break;
Geoff Langb1196682014-07-23 13:47:29 -04006833
Geoff Langbfdea662014-07-23 14:16:32 -04006834 default:
Geoff Langb1196682014-07-23 13:47:29 -04006835 context->recordError(gl::Error(GL_INVALID_ENUM));
6836 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006837 }
6838
Geoff Langcc79b8c2014-07-25 13:48:02 -04006839 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6840 if (error.isError())
6841 {
6842 context->recordError(error);
6843 return;
6844 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006845 }
6846}
6847
Kenneth Russell67ea1902014-10-06 16:44:50 -07006848void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006849{
6850 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6851 buffer, drawbuffer, value);
6852
Geoff Langbfdea662014-07-23 14:16:32 -04006853 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006854 if (context)
6855 {
6856 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006857 {
Geoff Langbfdea662014-07-23 14:16:32 -04006858 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006859 }
Geoff Langbfdea662014-07-23 14:16:32 -04006860
6861 switch (buffer)
6862 {
6863 case GL_COLOR:
6864 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6865 {
Geoff Langb1196682014-07-23 13:47:29 -04006866 context->recordError(gl::Error(GL_INVALID_VALUE));
6867 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006868 }
6869 break;
Geoff Langb1196682014-07-23 13:47:29 -04006870
Geoff Langbfdea662014-07-23 14:16:32 -04006871 default:
Geoff Langb1196682014-07-23 13:47:29 -04006872 context->recordError(gl::Error(GL_INVALID_ENUM));
6873 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006874 }
6875
Geoff Langcc79b8c2014-07-25 13:48:02 -04006876 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6877 if (error.isError())
6878 {
6879 context->recordError(error);
6880 return;
6881 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006882 }
6883}
6884
Kenneth Russell67ea1902014-10-06 16:44:50 -07006885void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006886{
6887 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6888 buffer, drawbuffer, value);
6889
Geoff Langbfdea662014-07-23 14:16:32 -04006890 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006891 if (context)
6892 {
6893 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006894 {
Geoff Langbfdea662014-07-23 14:16:32 -04006895 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006896 }
Geoff Langbfdea662014-07-23 14:16:32 -04006897
6898 switch (buffer)
6899 {
6900 case GL_COLOR:
6901 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6902 {
Geoff Langb1196682014-07-23 13:47:29 -04006903 context->recordError(gl::Error(GL_INVALID_VALUE));
6904 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006905 }
6906 break;
Geoff Langb1196682014-07-23 13:47:29 -04006907
Geoff Langbfdea662014-07-23 14:16:32 -04006908 case GL_DEPTH:
6909 if (drawbuffer != 0)
6910 {
Geoff Langb1196682014-07-23 13:47:29 -04006911 context->recordError(gl::Error(GL_INVALID_VALUE));
6912 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006913 }
6914 break;
Geoff Langb1196682014-07-23 13:47:29 -04006915
Geoff Langbfdea662014-07-23 14:16:32 -04006916 default:
Geoff Langb1196682014-07-23 13:47:29 -04006917 context->recordError(gl::Error(GL_INVALID_ENUM));
6918 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006919 }
6920
Geoff Langcc79b8c2014-07-25 13:48:02 -04006921 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6922 if (error.isError())
6923 {
6924 context->recordError(error);
6925 return;
6926 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006927 }
6928}
6929
Kenneth Russell67ea1902014-10-06 16:44:50 -07006930void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006931{
6932 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6933 buffer, drawbuffer, depth, stencil);
6934
Geoff Langbfdea662014-07-23 14:16:32 -04006935 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006936 if (context)
6937 {
6938 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006939 {
Geoff Langbfdea662014-07-23 14:16:32 -04006940 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006941 }
Geoff Langbfdea662014-07-23 14:16:32 -04006942
6943 switch (buffer)
6944 {
6945 case GL_DEPTH_STENCIL:
6946 if (drawbuffer != 0)
6947 {
Geoff Langb1196682014-07-23 13:47:29 -04006948 context->recordError(gl::Error(GL_INVALID_VALUE));
6949 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006950 }
6951 break;
Geoff Langb1196682014-07-23 13:47:29 -04006952
Geoff Langbfdea662014-07-23 14:16:32 -04006953 default:
Geoff Langb1196682014-07-23 13:47:29 -04006954 context->recordError(gl::Error(GL_INVALID_ENUM));
6955 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006956 }
6957
Geoff Langcc79b8c2014-07-25 13:48:02 -04006958 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6959 if (error.isError())
6960 {
6961 context->recordError(error);
6962 return;
6963 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006964 }
6965}
6966
Kenneth Russell67ea1902014-10-06 16:44:50 -07006967const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006968{
6969 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6970
Geoff Langbfdea662014-07-23 14:16:32 -04006971 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006972 if (context)
6973 {
6974 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006975 {
Geoff Langb1196682014-07-23 13:47:29 -04006976 context->recordError(gl::Error(GL_INVALID_OPERATION));
6977 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006978 }
Geoff Langbfdea662014-07-23 14:16:32 -04006979
6980 if (name != GL_EXTENSIONS)
6981 {
Geoff Langb1196682014-07-23 13:47:29 -04006982 context->recordError(gl::Error(GL_INVALID_ENUM));
6983 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006984 }
6985
6986 if (index >= context->getExtensionStringCount())
6987 {
Geoff Langb1196682014-07-23 13:47:29 -04006988 context->recordError(gl::Error(GL_INVALID_VALUE));
6989 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006990 }
6991
6992 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006993 }
6994
6995 return NULL;
6996}
6997
Kenneth Russell67ea1902014-10-06 16:44:50 -07006998void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006999{
7000 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
7001 readTarget, writeTarget, readOffset, writeOffset, size);
7002
Geoff Langbfdea662014-07-23 14:16:32 -04007003 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007004 if (context)
7005 {
7006 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007007 {
Geoff Langb1196682014-07-23 13:47:29 -04007008 context->recordError(gl::Error(GL_INVALID_OPERATION));
7009 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00007010 }
Geoff Langbfdea662014-07-23 14:16:32 -04007011
Jamie Madill24e83192014-10-20 11:00:53 -04007012 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04007013 {
Geoff Langb1196682014-07-23 13:47:29 -04007014 context->recordError(gl::Error(GL_INVALID_ENUM));
7015 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007016 }
7017
7018 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
7019 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
7020
7021 if (!readBuffer || !writeBuffer)
7022 {
Geoff Langb1196682014-07-23 13:47:29 -04007023 context->recordError(gl::Error(GL_INVALID_OPERATION));
7024 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007025 }
7026
Jamie Madillcfaaf722014-07-31 10:47:54 -04007027 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04007028 if (readBuffer->isMapped() || writeBuffer->isMapped())
7029 {
Geoff Langb1196682014-07-23 13:47:29 -04007030 context->recordError(gl::Error(GL_INVALID_OPERATION));
7031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007032 }
7033
7034 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7035 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7036 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7037 {
Geoff Langb1196682014-07-23 13:47:29 -04007038 context->recordError(gl::Error(GL_INVALID_VALUE));
7039 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007040 }
7041
Kenneth Russell67ea1902014-10-06 16:44:50 -07007042 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007043 {
Geoff Langb1196682014-07-23 13:47:29 -04007044 context->recordError(gl::Error(GL_INVALID_VALUE));
7045 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007046 }
7047
Geoff Langbfdea662014-07-23 14:16:32 -04007048 // if size is zero, the copy is a successful no-op
7049 if (size > 0)
7050 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007051 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7052 if (error.isError())
7053 {
7054 context->recordError(error);
7055 return;
7056 }
Geoff Langbfdea662014-07-23 14:16:32 -04007057 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007058 }
7059}
7060
Kenneth Russell67ea1902014-10-06 16:44:50 -07007061void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007062{
7063 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7064 program, uniformCount, uniformNames, uniformIndices);
7065
Geoff Langbfdea662014-07-23 14:16:32 -04007066 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007067 if (context)
7068 {
7069 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007070 {
Geoff Langb1196682014-07-23 13:47:29 -04007071 context->recordError(gl::Error(GL_INVALID_OPERATION));
7072 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007073 }
7074
7075 if (uniformCount < 0)
7076 {
Geoff Langb1196682014-07-23 13:47:29 -04007077 context->recordError(gl::Error(GL_INVALID_VALUE));
7078 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007079 }
7080
7081 gl::Program *programObject = context->getProgram(program);
7082
7083 if (!programObject)
7084 {
7085 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007086 {
Geoff Langb1196682014-07-23 13:47:29 -04007087 context->recordError(gl::Error(GL_INVALID_OPERATION));
7088 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007089 }
Geoff Langbfdea662014-07-23 14:16:32 -04007090 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007091 {
Geoff Langb1196682014-07-23 13:47:29 -04007092 context->recordError(gl::Error(GL_INVALID_VALUE));
7093 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007094 }
Geoff Langbfdea662014-07-23 14:16:32 -04007095 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007096
Geoff Langbfdea662014-07-23 14:16:32 -04007097 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7098 if (!programObject->isLinked() || !programBinary)
7099 {
7100 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007101 {
Geoff Langbfdea662014-07-23 14:16:32 -04007102 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007103 }
7104 }
Geoff Langbfdea662014-07-23 14:16:32 -04007105 else
7106 {
7107 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7108 {
7109 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7110 }
7111 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007112 }
7113}
7114
Kenneth Russell67ea1902014-10-06 16:44:50 -07007115void 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 +00007116{
7117 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7118 program, uniformCount, uniformIndices, pname, params);
7119
Geoff Langbfdea662014-07-23 14:16:32 -04007120 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007121 if (context)
7122 {
7123 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007124 {
Geoff Langb1196682014-07-23 13:47:29 -04007125 context->recordError(gl::Error(GL_INVALID_OPERATION));
7126 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007127 }
7128
7129 if (uniformCount < 0)
7130 {
Geoff Langb1196682014-07-23 13:47:29 -04007131 context->recordError(gl::Error(GL_INVALID_VALUE));
7132 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007133 }
7134
7135 gl::Program *programObject = context->getProgram(program);
7136
7137 if (!programObject)
7138 {
7139 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007140 {
Geoff Langb1196682014-07-23 13:47:29 -04007141 context->recordError(gl::Error(GL_INVALID_OPERATION));
7142 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007143 }
Geoff Langbfdea662014-07-23 14:16:32 -04007144 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007145 {
Geoff Langb1196682014-07-23 13:47:29 -04007146 context->recordError(gl::Error(GL_INVALID_VALUE));
7147 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007148 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007149 }
Geoff Langbfdea662014-07-23 14:16:32 -04007150
7151 switch (pname)
7152 {
7153 case GL_UNIFORM_TYPE:
7154 case GL_UNIFORM_SIZE:
7155 case GL_UNIFORM_NAME_LENGTH:
7156 case GL_UNIFORM_BLOCK_INDEX:
7157 case GL_UNIFORM_OFFSET:
7158 case GL_UNIFORM_ARRAY_STRIDE:
7159 case GL_UNIFORM_MATRIX_STRIDE:
7160 case GL_UNIFORM_IS_ROW_MAJOR:
7161 break;
Geoff Langb1196682014-07-23 13:47:29 -04007162
Geoff Langbfdea662014-07-23 14:16:32 -04007163 default:
Geoff Langb1196682014-07-23 13:47:29 -04007164 context->recordError(gl::Error(GL_INVALID_ENUM));
7165 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007166 }
7167
7168 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7169
7170 if (!programBinary && uniformCount > 0)
7171 {
Geoff Langb1196682014-07-23 13:47:29 -04007172 context->recordError(gl::Error(GL_INVALID_VALUE));
7173 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007174 }
7175
7176 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7177 {
7178 const GLuint index = uniformIndices[uniformId];
7179
7180 if (index >= (GLuint)programBinary->getActiveUniformCount())
7181 {
Geoff Langb1196682014-07-23 13:47:29 -04007182 context->recordError(gl::Error(GL_INVALID_VALUE));
7183 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007184 }
7185 }
7186
7187 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7188 {
7189 const GLuint index = uniformIndices[uniformId];
7190 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7191 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007192 }
7193}
7194
Kenneth Russell67ea1902014-10-06 16:44:50 -07007195GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007196{
7197 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7198
Geoff Langbfdea662014-07-23 14:16:32 -04007199 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007200 if (context)
7201 {
7202 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007203 {
Geoff Langb1196682014-07-23 13:47:29 -04007204 context->recordError(gl::Error(GL_INVALID_OPERATION));
7205 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007206 }
7207
7208 gl::Program *programObject = context->getProgram(program);
7209
7210 if (!programObject)
7211 {
7212 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007213 {
Geoff Langb1196682014-07-23 13:47:29 -04007214 context->recordError(gl::Error(GL_INVALID_OPERATION));
7215 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007216 }
Geoff Langbfdea662014-07-23 14:16:32 -04007217 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007218 {
Geoff Langb1196682014-07-23 13:47:29 -04007219 context->recordError(gl::Error(GL_INVALID_VALUE));
7220 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007221 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007222 }
Geoff Langbfdea662014-07-23 14:16:32 -04007223
7224 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7225 if (!programBinary)
7226 {
7227 return GL_INVALID_INDEX;
7228 }
7229
7230 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007231 }
7232
7233 return 0;
7234}
7235
Kenneth Russell67ea1902014-10-06 16:44:50 -07007236void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007237{
7238 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7239 program, uniformBlockIndex, pname, params);
7240
Geoff Langbfdea662014-07-23 14:16:32 -04007241 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007242 if (context)
7243 {
7244 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007245 {
Geoff Langb1196682014-07-23 13:47:29 -04007246 context->recordError(gl::Error(GL_INVALID_OPERATION));
7247 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007248 }
7249 gl::Program *programObject = context->getProgram(program);
7250
7251 if (!programObject)
7252 {
7253 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007254 {
Geoff Langb1196682014-07-23 13:47:29 -04007255 context->recordError(gl::Error(GL_INVALID_OPERATION));
7256 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007257 }
Geoff Langbfdea662014-07-23 14:16:32 -04007258 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007259 {
Geoff Langb1196682014-07-23 13:47:29 -04007260 context->recordError(gl::Error(GL_INVALID_VALUE));
7261 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007262 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007263 }
Geoff Langbfdea662014-07-23 14:16:32 -04007264
7265 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7266
7267 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7268 {
Geoff Langb1196682014-07-23 13:47:29 -04007269 context->recordError(gl::Error(GL_INVALID_VALUE));
7270 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007271 }
7272
7273 switch (pname)
7274 {
7275 case GL_UNIFORM_BLOCK_BINDING:
7276 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7277 break;
7278
7279 case GL_UNIFORM_BLOCK_DATA_SIZE:
7280 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7281 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7282 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7283 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7284 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7285 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7286 break;
7287
7288 default:
Geoff Langb1196682014-07-23 13:47:29 -04007289 context->recordError(gl::Error(GL_INVALID_ENUM));
7290 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007291 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007292 }
7293}
7294
Kenneth Russell67ea1902014-10-06 16:44:50 -07007295void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007296{
7297 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7298 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7299
Geoff Langbfdea662014-07-23 14:16:32 -04007300 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007301 if (context)
7302 {
7303 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007304 {
Geoff Langb1196682014-07-23 13:47:29 -04007305 context->recordError(gl::Error(GL_INVALID_OPERATION));
7306 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007307 }
7308
7309 gl::Program *programObject = context->getProgram(program);
7310
7311 if (!programObject)
7312 {
7313 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007314 {
Geoff Langb1196682014-07-23 13:47:29 -04007315 context->recordError(gl::Error(GL_INVALID_OPERATION));
7316 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007317 }
Geoff Langbfdea662014-07-23 14:16:32 -04007318 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007319 {
Geoff Langb1196682014-07-23 13:47:29 -04007320 context->recordError(gl::Error(GL_INVALID_VALUE));
7321 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007322 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007323 }
Geoff Langbfdea662014-07-23 14:16:32 -04007324
7325 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7326
7327 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7328 {
Geoff Langb1196682014-07-23 13:47:29 -04007329 context->recordError(gl::Error(GL_INVALID_VALUE));
7330 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007331 }
7332
7333 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007334 }
7335}
7336
Kenneth Russell67ea1902014-10-06 16:44:50 -07007337void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007338{
7339 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7340 program, uniformBlockIndex, uniformBlockBinding);
7341
Geoff Langbfdea662014-07-23 14:16:32 -04007342 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007343 if (context)
7344 {
7345 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007346 {
Geoff Langb1196682014-07-23 13:47:29 -04007347 context->recordError(gl::Error(GL_INVALID_OPERATION));
7348 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007349 }
7350
Geoff Lang3a61c322014-07-10 13:01:54 -04007351 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007352 {
Geoff Langb1196682014-07-23 13:47:29 -04007353 context->recordError(gl::Error(GL_INVALID_VALUE));
7354 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007355 }
7356
7357 gl::Program *programObject = context->getProgram(program);
7358
7359 if (!programObject)
7360 {
7361 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007362 {
Geoff Langb1196682014-07-23 13:47:29 -04007363 context->recordError(gl::Error(GL_INVALID_OPERATION));
7364 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007365 }
Geoff Langbfdea662014-07-23 14:16:32 -04007366 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007367 {
Geoff Langb1196682014-07-23 13:47:29 -04007368 context->recordError(gl::Error(GL_INVALID_VALUE));
7369 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007370 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007371 }
Geoff Langbfdea662014-07-23 14:16:32 -04007372
7373 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7374
7375 // if never linked, there won't be any uniform blocks
7376 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7377 {
Geoff Langb1196682014-07-23 13:47:29 -04007378 context->recordError(gl::Error(GL_INVALID_VALUE));
7379 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007380 }
7381
7382 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007383 }
7384}
7385
Kenneth Russell67ea1902014-10-06 16:44:50 -07007386void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007387{
7388 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7389 mode, first, count, instanceCount);
7390
Geoff Langbfdea662014-07-23 14:16:32 -04007391 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007392 if (context)
7393 {
7394 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007395 {
Geoff Langb1196682014-07-23 13:47:29 -04007396 context->recordError(gl::Error(GL_INVALID_OPERATION));
7397 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007398 }
Geoff Langbfdea662014-07-23 14:16:32 -04007399
7400 // glDrawArraysInstanced
7401 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007402 }
7403}
7404
Kenneth Russell67ea1902014-10-06 16:44:50 -07007405void 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 +00007406{
7407 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7408 mode, count, type, indices, instanceCount);
7409
Geoff Langbfdea662014-07-23 14:16:32 -04007410 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007411 if (context)
7412 {
7413 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007414 {
Geoff Langb1196682014-07-23 13:47:29 -04007415 context->recordError(gl::Error(GL_INVALID_OPERATION));
7416 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007417 }
Geoff Langbfdea662014-07-23 14:16:32 -04007418
7419 // glDrawElementsInstanced
7420 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007421 }
7422}
7423
Kenneth Russell67ea1902014-10-06 16:44:50 -07007424GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007425{
7426 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7427
Geoff Langbfdea662014-07-23 14:16:32 -04007428 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007429 if (context)
7430 {
7431 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007432 {
Geoff Langb1196682014-07-23 13:47:29 -04007433 context->recordError(gl::Error(GL_INVALID_OPERATION));
7434 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007435 }
Geoff Langbfdea662014-07-23 14:16:32 -04007436
7437 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7438 {
Geoff Langb1196682014-07-23 13:47:29 -04007439 context->recordError(gl::Error(GL_INVALID_ENUM));
7440 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007441 }
7442
7443 if (flags != 0)
7444 {
Geoff Langb1196682014-07-23 13:47:29 -04007445 context->recordError(gl::Error(GL_INVALID_VALUE));
7446 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007447 }
7448
Geoff Lang882033e2014-09-30 11:26:07 -04007449 GLsync fenceSync = context->createFenceSync();
7450
7451 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7452 gl::Error error = fenceSyncObject->set(condition);
7453 if (error.isError())
7454 {
7455 context->deleteFenceSync(fenceSync);
7456 context->recordError(error);
7457 return NULL;
7458 }
7459
7460 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007461 }
7462
7463 return NULL;
7464}
7465
Kenneth Russell67ea1902014-10-06 16:44:50 -07007466GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007467{
7468 EVENT("(GLsync sync = 0x%0.8p)", sync);
7469
Geoff Langbfdea662014-07-23 14:16:32 -04007470 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007471 if (context)
7472 {
7473 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007474 {
Geoff Langb1196682014-07-23 13:47:29 -04007475 context->recordError(gl::Error(GL_INVALID_OPERATION));
7476 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007477 }
Geoff Langbfdea662014-07-23 14:16:32 -04007478
7479 return (context->getFenceSync(sync) != NULL);
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 glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007486{
7487 EVENT("(GLsync sync = 0x%0.8p)", sync);
7488
Geoff Langbfdea662014-07-23 14:16:32 -04007489 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007490 if (context)
7491 {
7492 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007493 {
Geoff Langb1196682014-07-23 13:47:29 -04007494 context->recordError(gl::Error(GL_INVALID_OPERATION));
7495 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007496 }
Geoff Langbfdea662014-07-23 14:16:32 -04007497
7498 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7499 {
Geoff Langb1196682014-07-23 13:47:29 -04007500 context->recordError(gl::Error(GL_INVALID_VALUE));
7501 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007502 }
7503
7504 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007505 }
7506}
7507
Kenneth Russell67ea1902014-10-06 16:44:50 -07007508GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007509{
7510 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7511 sync, flags, timeout);
7512
Geoff Langbfdea662014-07-23 14:16:32 -04007513 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007514 if (context)
7515 {
7516 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007517 {
Geoff Langb1196682014-07-23 13:47:29 -04007518 context->recordError(gl::Error(GL_INVALID_OPERATION));
7519 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007520 }
Geoff Langbfdea662014-07-23 14:16:32 -04007521
7522 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7523 {
Geoff Langb1196682014-07-23 13:47:29 -04007524 context->recordError(gl::Error(GL_INVALID_VALUE));
7525 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007526 }
7527
7528 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7529
7530 if (!fenceSync)
7531 {
Geoff Langb1196682014-07-23 13:47:29 -04007532 context->recordError(gl::Error(GL_INVALID_VALUE));
7533 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007534 }
7535
Geoff Lang882033e2014-09-30 11:26:07 -04007536 GLenum result = GL_WAIT_FAILED;
7537 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7538 if (error.isError())
7539 {
7540 context->recordError(error);
7541 return GL_WAIT_FAILED;
7542 }
7543
7544 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007545 }
7546
7547 return GL_FALSE;
7548}
7549
Kenneth Russell67ea1902014-10-06 16:44:50 -07007550void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007551{
7552 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7553 sync, flags, timeout);
7554
Geoff Langbfdea662014-07-23 14:16:32 -04007555 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007556 if (context)
7557 {
7558 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007559 {
Geoff Langb1196682014-07-23 13:47:29 -04007560 context->recordError(gl::Error(GL_INVALID_OPERATION));
7561 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007562 }
Geoff Langbfdea662014-07-23 14:16:32 -04007563
7564 if (flags != 0)
7565 {
Geoff Langb1196682014-07-23 13:47:29 -04007566 context->recordError(gl::Error(GL_INVALID_VALUE));
7567 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007568 }
7569
7570 if (timeout != GL_TIMEOUT_IGNORED)
7571 {
Geoff Langb1196682014-07-23 13:47:29 -04007572 context->recordError(gl::Error(GL_INVALID_VALUE));
7573 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007574 }
7575
7576 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7577
7578 if (!fenceSync)
7579 {
Geoff Langb1196682014-07-23 13:47:29 -04007580 context->recordError(gl::Error(GL_INVALID_VALUE));
7581 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007582 }
7583
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007584 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007585 if (error.isError())
7586 {
7587 context->recordError(error);
7588 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007589 }
7590}
7591
Kenneth Russell67ea1902014-10-06 16:44:50 -07007592void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007593{
7594 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7595 pname, params);
7596
Geoff Langbfdea662014-07-23 14:16:32 -04007597 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007598 if (context)
7599 {
7600 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007601 {
Geoff Langb1196682014-07-23 13:47:29 -04007602 context->recordError(gl::Error(GL_INVALID_OPERATION));
7603 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007604 }
Geoff Langbfdea662014-07-23 14:16:32 -04007605
7606 GLenum nativeType;
7607 unsigned int numParams = 0;
7608 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7609 {
7610 return;
7611 }
7612
7613 if (nativeType == GL_INT_64_ANGLEX)
7614 {
7615 context->getInteger64v(pname, params);
7616 }
7617 else
7618 {
7619 CastStateValues(context, nativeType, pname, numParams, params);
7620 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007621 }
7622}
7623
Kenneth Russell67ea1902014-10-06 16:44:50 -07007624void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007625{
7626 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7627 sync, pname, bufSize, length, values);
7628
Geoff Langbfdea662014-07-23 14:16:32 -04007629 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007630 if (context)
7631 {
7632 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007633 {
Geoff Langb1196682014-07-23 13:47:29 -04007634 context->recordError(gl::Error(GL_INVALID_OPERATION));
7635 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007636 }
Geoff Langbfdea662014-07-23 14:16:32 -04007637
7638 if (bufSize < 0)
7639 {
Geoff Langb1196682014-07-23 13:47:29 -04007640 context->recordError(gl::Error(GL_INVALID_VALUE));
7641 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007642 }
7643
7644 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7645
7646 if (!fenceSync)
7647 {
Geoff Langb1196682014-07-23 13:47:29 -04007648 context->recordError(gl::Error(GL_INVALID_VALUE));
7649 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007650 }
7651
7652 switch (pname)
7653 {
7654 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007655 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7656 case GL_SYNC_FLAGS: values[0] = 0; break;
7657
Geoff Lang882033e2014-09-30 11:26:07 -04007658 case GL_SYNC_STATUS:
7659 {
7660 gl::Error error = fenceSync->getStatus(values);
7661 if (error.isError())
7662 {
7663 context->recordError(error);
7664 return;
7665 }
7666 break;
7667 }
7668
Geoff Langbfdea662014-07-23 14:16:32 -04007669 default:
Geoff Langb1196682014-07-23 13:47:29 -04007670 context->recordError(gl::Error(GL_INVALID_ENUM));
7671 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007672 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007673 }
7674}
7675
Kenneth Russell67ea1902014-10-06 16:44:50 -07007676void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007677{
7678 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7679 target, index, data);
7680
Geoff Langbfdea662014-07-23 14:16:32 -04007681 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007682 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007683 {
Geoff Langbfdea662014-07-23 14:16:32 -04007684 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007685 {
Geoff Langb1196682014-07-23 13:47:29 -04007686 context->recordError(gl::Error(GL_INVALID_OPERATION));
7687 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007688 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007689
Geoff Lang3a61c322014-07-10 13:01:54 -04007690 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007691 switch (target)
7692 {
7693 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7694 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7695 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007696 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7697 {
Geoff Langb1196682014-07-23 13:47:29 -04007698 context->recordError(gl::Error(GL_INVALID_VALUE));
7699 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007700 }
Geoff Langbfdea662014-07-23 14:16:32 -04007701 break;
Geoff Langb1196682014-07-23 13:47:29 -04007702
Geoff Langbfdea662014-07-23 14:16:32 -04007703 case GL_UNIFORM_BUFFER_START:
7704 case GL_UNIFORM_BUFFER_SIZE:
7705 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007706 if (index >= caps.maxUniformBufferBindings)
7707 {
Geoff Langb1196682014-07-23 13:47:29 -04007708 context->recordError(gl::Error(GL_INVALID_VALUE));
7709 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007710 }
Geoff Langbfdea662014-07-23 14:16:32 -04007711 break;
Geoff Langb1196682014-07-23 13:47:29 -04007712
Geoff Langbfdea662014-07-23 14:16:32 -04007713 default:
Geoff Langb1196682014-07-23 13:47:29 -04007714 context->recordError(gl::Error(GL_INVALID_ENUM));
7715 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007716 }
7717
7718 if (!(context->getIndexedInteger64v(target, index, data)))
7719 {
7720 GLenum nativeType;
7721 unsigned int numParams = 0;
7722 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007723 {
7724 context->recordError(gl::Error(GL_INVALID_ENUM));
7725 return;
7726 }
Shannon Woods15934d52013-08-19 14:28:49 -04007727
Geoff Langbfdea662014-07-23 14:16:32 -04007728 if (numParams == 0)
7729 return; // it is known that pname is valid, but there are no parameters to return
7730
7731 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007732 {
Geoff Langbfdea662014-07-23 14:16:32 -04007733 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007734
Geoff Langbfdea662014-07-23 14:16:32 -04007735 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007736
Geoff Langbfdea662014-07-23 14:16:32 -04007737 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007738 {
Geoff Langbfdea662014-07-23 14:16:32 -04007739 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007740 }
Geoff Langbfdea662014-07-23 14:16:32 -04007741
7742 delete [] intParams;
7743 }
7744 else
7745 {
7746 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007747 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007748 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007749 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007750}
7751
Kenneth Russell67ea1902014-10-06 16:44:50 -07007752void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007753{
7754 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7755 target, pname, params);
7756
Geoff Langbfdea662014-07-23 14:16:32 -04007757 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007758 if (context)
7759 {
7760 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007761 {
Geoff Langb1196682014-07-23 13:47:29 -04007762 context->recordError(gl::Error(GL_INVALID_OPERATION));
7763 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007764 }
Geoff Langbfdea662014-07-23 14:16:32 -04007765
7766 if (!gl::ValidBufferTarget(context, target))
7767 {
Geoff Langb1196682014-07-23 13:47:29 -04007768 context->recordError(gl::Error(GL_INVALID_ENUM));
7769 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007770 }
7771
7772 if (!gl::ValidBufferParameter(context, pname))
7773 {
Geoff Langb1196682014-07-23 13:47:29 -04007774 context->recordError(gl::Error(GL_INVALID_ENUM));
7775 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007776 }
7777
7778 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7779
7780 if (!buffer)
7781 {
7782 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007783 context->recordError(gl::Error(GL_INVALID_OPERATION));
7784 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007785 }
7786
7787 switch (pname)
7788 {
7789 case GL_BUFFER_USAGE:
7790 *params = static_cast<GLint64>(buffer->getUsage());
7791 break;
7792 case GL_BUFFER_SIZE:
7793 *params = buffer->getSize();
7794 break;
7795 case GL_BUFFER_ACCESS_FLAGS:
7796 *params = static_cast<GLint64>(buffer->getAccessFlags());
7797 break;
7798 case GL_BUFFER_MAPPED:
7799 *params = static_cast<GLint64>(buffer->isMapped());
7800 break;
7801 case GL_BUFFER_MAP_OFFSET:
7802 *params = buffer->getMapOffset();
7803 break;
7804 case GL_BUFFER_MAP_LENGTH:
7805 *params = buffer->getMapLength();
7806 break;
7807 default: UNREACHABLE(); break;
7808 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007809 }
7810}
7811
Kenneth Russell67ea1902014-10-06 16:44:50 -07007812void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007813{
7814 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7815
Geoff Langbfdea662014-07-23 14:16:32 -04007816 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007817 if (context)
7818 {
7819 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007820 {
Geoff Langb1196682014-07-23 13:47:29 -04007821 context->recordError(gl::Error(GL_INVALID_OPERATION));
7822 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007823 }
Geoff Langbfdea662014-07-23 14:16:32 -04007824
7825 if (count < 0)
7826 {
Geoff Langb1196682014-07-23 13:47:29 -04007827 context->recordError(gl::Error(GL_INVALID_VALUE));
7828 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007829 }
7830
7831 for (int i = 0; i < count; i++)
7832 {
7833 samplers[i] = context->createSampler();
7834 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007835 }
7836}
7837
Kenneth Russell67ea1902014-10-06 16:44:50 -07007838void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007839{
7840 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7841
Geoff Langbfdea662014-07-23 14:16:32 -04007842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007843 if (context)
7844 {
7845 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007846 {
Geoff Langb1196682014-07-23 13:47:29 -04007847 context->recordError(gl::Error(GL_INVALID_OPERATION));
7848 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007849 }
Geoff Langbfdea662014-07-23 14:16:32 -04007850
7851 if (count < 0)
7852 {
Geoff Langb1196682014-07-23 13:47:29 -04007853 context->recordError(gl::Error(GL_INVALID_VALUE));
7854 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007855 }
7856
7857 for (int i = 0; i < count; i++)
7858 {
7859 context->deleteSampler(samplers[i]);
7860 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007861 }
7862}
7863
Kenneth Russell67ea1902014-10-06 16:44:50 -07007864GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007865{
7866 EVENT("(GLuint sampler = %u)", sampler);
7867
Geoff Langbfdea662014-07-23 14:16:32 -04007868 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007869 if (context)
7870 {
7871 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007872 {
Geoff Langb1196682014-07-23 13:47:29 -04007873 context->recordError(gl::Error(GL_INVALID_OPERATION));
7874 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007875 }
Geoff Langbfdea662014-07-23 14:16:32 -04007876
7877 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007878 }
7879
7880 return GL_FALSE;
7881}
7882
Kenneth Russell67ea1902014-10-06 16:44:50 -07007883void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007884{
7885 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7886
Geoff Langbfdea662014-07-23 14:16:32 -04007887 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007888 if (context)
7889 {
7890 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007891 {
Geoff Langb1196682014-07-23 13:47:29 -04007892 context->recordError(gl::Error(GL_INVALID_OPERATION));
7893 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007894 }
Geoff Langbfdea662014-07-23 14:16:32 -04007895
7896 if (sampler != 0 && !context->isSampler(sampler))
7897 {
Geoff Langb1196682014-07-23 13:47:29 -04007898 context->recordError(gl::Error(GL_INVALID_OPERATION));
7899 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007900 }
7901
Geoff Lang3a61c322014-07-10 13:01:54 -04007902 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007903 {
Geoff Langb1196682014-07-23 13:47:29 -04007904 context->recordError(gl::Error(GL_INVALID_VALUE));
7905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007906 }
7907
7908 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007909 }
7910}
7911
Kenneth Russell67ea1902014-10-06 16:44:50 -07007912void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007913{
7914 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7915
Geoff Langbfdea662014-07-23 14:16:32 -04007916 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007917 if (context)
7918 {
7919 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007920 {
Geoff Langb1196682014-07-23 13:47:29 -04007921 context->recordError(gl::Error(GL_INVALID_OPERATION));
7922 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007923 }
Geoff Langbfdea662014-07-23 14:16:32 -04007924
Geoff Langb1196682014-07-23 13:47:29 -04007925 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007926 {
7927 return;
7928 }
7929
7930 if (!gl::ValidateTexParamParameters(context, pname, param))
7931 {
7932 return;
7933 }
7934
7935 if (!context->isSampler(sampler))
7936 {
Geoff Langb1196682014-07-23 13:47:29 -04007937 context->recordError(gl::Error(GL_INVALID_OPERATION));
7938 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007939 }
7940
7941 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007942 }
7943}
7944
Kenneth Russell67ea1902014-10-06 16:44:50 -07007945void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007946{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007947 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007948}
7949
Kenneth Russell67ea1902014-10-06 16:44:50 -07007950void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007951{
7952 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7953
Geoff Langbfdea662014-07-23 14:16:32 -04007954 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007955 if (context)
7956 {
7957 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007958 {
Geoff Langb1196682014-07-23 13:47:29 -04007959 context->recordError(gl::Error(GL_INVALID_OPERATION));
7960 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007961 }
Geoff Langbfdea662014-07-23 14:16:32 -04007962
Geoff Langb1196682014-07-23 13:47:29 -04007963 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007964 {
7965 return;
7966 }
7967
7968 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7969 {
7970 return;
7971 }
7972
7973 if (!context->isSampler(sampler))
7974 {
Geoff Langb1196682014-07-23 13:47:29 -04007975 context->recordError(gl::Error(GL_INVALID_OPERATION));
7976 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007977 }
7978
7979 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980 }
7981}
7982
Kenneth Russell67ea1902014-10-06 16:44:50 -07007983void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007984{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007985 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007986}
7987
Kenneth Russell67ea1902014-10-06 16:44:50 -07007988void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007989{
7990 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7991
Geoff Langbfdea662014-07-23 14:16:32 -04007992 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007993 if (context)
7994 {
7995 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007996 {
Geoff Langb1196682014-07-23 13:47:29 -04007997 context->recordError(gl::Error(GL_INVALID_OPERATION));
7998 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007999 }
Geoff Langbfdea662014-07-23 14:16:32 -04008000
Geoff Langb1196682014-07-23 13:47:29 -04008001 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008002 {
8003 return;
8004 }
8005
8006 if (!context->isSampler(sampler))
8007 {
Geoff Langb1196682014-07-23 13:47:29 -04008008 context->recordError(gl::Error(GL_INVALID_OPERATION));
8009 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008010 }
8011
8012 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008013 }
8014}
8015
Kenneth Russell67ea1902014-10-06 16:44:50 -07008016void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008017{
8018 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
8019
Geoff Langbfdea662014-07-23 14:16:32 -04008020 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008021 if (context)
8022 {
8023 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008024 {
Geoff Langb1196682014-07-23 13:47:29 -04008025 context->recordError(gl::Error(GL_INVALID_OPERATION));
8026 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008027 }
Geoff Langbfdea662014-07-23 14:16:32 -04008028
Geoff Langb1196682014-07-23 13:47:29 -04008029 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008030 {
8031 return;
8032 }
8033
8034 if (!context->isSampler(sampler))
8035 {
Geoff Langb1196682014-07-23 13:47:29 -04008036 context->recordError(gl::Error(GL_INVALID_OPERATION));
8037 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008038 }
8039
8040 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008041 }
8042}
8043
Kenneth Russell67ea1902014-10-06 16:44:50 -07008044void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008045{
8046 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8047
Geoff Langbfdea662014-07-23 14:16:32 -04008048 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008049 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008050 {
Geoff Langbfdea662014-07-23 14:16:32 -04008051 if (context->getClientVersion() < 3)
8052 {
Geoff Langb1196682014-07-23 13:47:29 -04008053 context->recordError(gl::Error(GL_INVALID_OPERATION));
8054 return;
8055 }
8056
8057 if (index >= gl::MAX_VERTEX_ATTRIBS)
8058 {
8059 context->recordError(gl::Error(GL_INVALID_VALUE));
8060 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008061 }
8062
8063 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008064 }
8065}
8066
Kenneth Russell67ea1902014-10-06 16:44:50 -07008067void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008068{
8069 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8070
Geoff Langbfdea662014-07-23 14:16:32 -04008071 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008072 if (context)
8073 {
8074 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008075 {
Geoff Langb1196682014-07-23 13:47:29 -04008076 context->recordError(gl::Error(GL_INVALID_OPERATION));
8077 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008078 }
Geoff Langbfdea662014-07-23 14:16:32 -04008079
8080 switch (target)
8081 {
8082 case GL_TRANSFORM_FEEDBACK:
8083 {
8084 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8085 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8086 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8087 {
Geoff Langb1196682014-07-23 13:47:29 -04008088 context->recordError(gl::Error(GL_INVALID_OPERATION));
8089 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008090 }
8091
8092 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8093 if (context->getTransformFeedback(id) == NULL)
8094 {
Geoff Langb1196682014-07-23 13:47:29 -04008095 context->recordError(gl::Error(GL_INVALID_OPERATION));
8096 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008097 }
8098
8099 context->bindTransformFeedback(id);
8100 }
8101 break;
8102
8103 default:
Geoff Langb1196682014-07-23 13:47:29 -04008104 context->recordError(gl::Error(GL_INVALID_ENUM));
8105 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008106 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008107 }
8108}
8109
Kenneth Russell67ea1902014-10-06 16:44:50 -07008110void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008111{
8112 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8113
Geoff Langbfdea662014-07-23 14:16:32 -04008114 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008115 if (context)
8116 {
8117 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008118 {
Geoff Langb1196682014-07-23 13:47:29 -04008119 context->recordError(gl::Error(GL_INVALID_OPERATION));
8120 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008121 }
Geoff Langbfdea662014-07-23 14:16:32 -04008122
8123 for (int i = 0; i < n; i++)
8124 {
8125 context->deleteTransformFeedback(ids[i]);
8126 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008127 }
8128}
8129
Kenneth Russell67ea1902014-10-06 16:44:50 -07008130void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008131{
8132 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8133
Geoff Langbfdea662014-07-23 14:16:32 -04008134 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008135 if (context)
8136 {
8137 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008138 {
Geoff Langb1196682014-07-23 13:47:29 -04008139 context->recordError(gl::Error(GL_INVALID_OPERATION));
8140 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008141 }
Geoff Langbfdea662014-07-23 14:16:32 -04008142
8143 for (int i = 0; i < n; i++)
8144 {
8145 ids[i] = context->createTransformFeedback();
8146 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008147 }
8148}
8149
Kenneth Russell67ea1902014-10-06 16:44:50 -07008150GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008151{
8152 EVENT("(GLuint id = %u)", id);
8153
Geoff Langbfdea662014-07-23 14:16:32 -04008154 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008155 if (context)
8156 {
8157 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008158 {
Geoff Langb1196682014-07-23 13:47:29 -04008159 context->recordError(gl::Error(GL_INVALID_OPERATION));
8160 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008161 }
Geoff Langbfdea662014-07-23 14:16:32 -04008162
8163 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008164 }
8165
8166 return GL_FALSE;
8167}
8168
Kenneth Russell67ea1902014-10-06 16:44:50 -07008169void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008170{
8171 EVENT("(void)");
8172
Geoff Langbfdea662014-07-23 14:16:32 -04008173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008174 if (context)
8175 {
8176 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008177 {
Geoff Langb1196682014-07-23 13:47:29 -04008178 context->recordError(gl::Error(GL_INVALID_OPERATION));
8179 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008180 }
Geoff Langbfdea662014-07-23 14:16:32 -04008181
8182 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8183 ASSERT(transformFeedback != NULL);
8184
8185 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8186 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8187 {
Geoff Langb1196682014-07-23 13:47:29 -04008188 context->recordError(gl::Error(GL_INVALID_OPERATION));
8189 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008190 }
8191
8192 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008193 }
8194}
8195
Kenneth Russell67ea1902014-10-06 16:44:50 -07008196void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008197{
8198 EVENT("(void)");
8199
Geoff Langbfdea662014-07-23 14:16:32 -04008200 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008201 if (context)
8202 {
8203 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008204 {
Geoff Langb1196682014-07-23 13:47:29 -04008205 context->recordError(gl::Error(GL_INVALID_OPERATION));
8206 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008207 }
Geoff Langbfdea662014-07-23 14:16:32 -04008208
8209 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8210 ASSERT(transformFeedback != NULL);
8211
8212 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8213 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8214 {
Geoff Langb1196682014-07-23 13:47:29 -04008215 context->recordError(gl::Error(GL_INVALID_OPERATION));
8216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008217 }
8218
8219 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008220 }
8221}
8222
Kenneth Russell67ea1902014-10-06 16:44:50 -07008223void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008224{
8225 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8226 program, bufSize, length, binaryFormat, binary);
8227
Geoff Langbfdea662014-07-23 14:16:32 -04008228 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008229 if (context)
8230 {
8231 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008232 {
Geoff Langb1196682014-07-23 13:47:29 -04008233 context->recordError(gl::Error(GL_INVALID_OPERATION));
8234 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008235 }
Geoff Langbfdea662014-07-23 14:16:32 -04008236
8237 // glGetProgramBinary
8238 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008239 }
8240}
8241
Kenneth Russell67ea1902014-10-06 16:44:50 -07008242void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008243{
8244 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8245 program, binaryFormat, binary, length);
8246
Geoff Langbfdea662014-07-23 14:16:32 -04008247 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008248 if (context)
8249 {
8250 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008251 {
Geoff Langb1196682014-07-23 13:47:29 -04008252 context->recordError(gl::Error(GL_INVALID_OPERATION));
8253 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008254 }
Geoff Langbfdea662014-07-23 14:16:32 -04008255
8256 // glProgramBinary
8257 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008258 }
8259}
8260
Kenneth Russell67ea1902014-10-06 16:44:50 -07008261void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008262{
8263 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8264 program, pname, value);
8265
Geoff Langbfdea662014-07-23 14:16:32 -04008266 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008267 if (context)
8268 {
8269 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008270 {
Geoff Langb1196682014-07-23 13:47:29 -04008271 context->recordError(gl::Error(GL_INVALID_OPERATION));
8272 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008273 }
Geoff Langbfdea662014-07-23 14:16:32 -04008274
8275 // glProgramParameteri
8276 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008277 }
8278}
8279
Kenneth Russell67ea1902014-10-06 16:44:50 -07008280void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008281{
8282 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8283 target, numAttachments, attachments);
8284
Geoff Langbfdea662014-07-23 14:16:32 -04008285 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008286 if (context)
8287 {
8288 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008289 {
Geoff Langb1196682014-07-23 13:47:29 -04008290 context->recordError(gl::Error(GL_INVALID_OPERATION));
8291 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008292 }
Geoff Langbfdea662014-07-23 14:16:32 -04008293
8294 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8295 {
8296 return;
8297 }
8298
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008299 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008300 ASSERT(framebuffer);
8301
8302 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008303 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008304 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8305 if (error.isError())
8306 {
8307 context->recordError(error);
8308 return;
8309 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008310 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008311 }
8312}
8313
Kenneth Russell67ea1902014-10-06 16:44:50 -07008314void 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 +00008315{
8316 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8317 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8318 target, numAttachments, attachments, x, y, width, height);
8319
Geoff Langbfdea662014-07-23 14:16:32 -04008320 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008321 if (context)
8322 {
8323 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008324 {
Geoff Langb1196682014-07-23 13:47:29 -04008325 context->recordError(gl::Error(GL_INVALID_OPERATION));
8326 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008327 }
Geoff Langbfdea662014-07-23 14:16:32 -04008328
8329 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8330 {
8331 return;
8332 }
8333
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008334 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008335 ASSERT(framebuffer);
8336
8337 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008338 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008339 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8340 if (error.isError())
8341 {
8342 context->recordError(error);
8343 return;
8344 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008345 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008346 }
8347}
8348
Kenneth Russell67ea1902014-10-06 16:44:50 -07008349void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008350{
8351 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8352 target, levels, internalformat, width, height);
8353
Geoff Langbfdea662014-07-23 14:16:32 -04008354 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008355 if (context)
8356 {
8357 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008358 {
Geoff Langb1196682014-07-23 13:47:29 -04008359 context->recordError(gl::Error(GL_INVALID_OPERATION));
8360 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008361 }
Geoff Langbfdea662014-07-23 14:16:32 -04008362
8363 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8364 {
8365 return;
8366 }
8367
8368 switch (target)
8369 {
8370 case GL_TEXTURE_2D:
8371 {
8372 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008373 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8374 if (error.isError())
8375 {
8376 context->recordError(error);
8377 return;
8378 }
Geoff Langbfdea662014-07-23 14:16:32 -04008379 }
8380 break;
8381
8382 case GL_TEXTURE_CUBE_MAP:
8383 {
8384 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008385 gl::Error error = textureCube->storage(levels, internalformat, width);
8386 if (error.isError())
8387 {
8388 context->recordError(error);
8389 return;
8390 }
Geoff Langbfdea662014-07-23 14:16:32 -04008391 }
8392 break;
8393
8394 default:
Geoff Langb1196682014-07-23 13:47:29 -04008395 context->recordError(gl::Error(GL_INVALID_ENUM));
8396 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008397 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008398 }
8399}
8400
Kenneth Russell67ea1902014-10-06 16:44:50 -07008401void 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 +00008402{
8403 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8404 "GLsizei height = %d, GLsizei depth = %d)",
8405 target, levels, internalformat, width, height, depth);
8406
Geoff Langbfdea662014-07-23 14:16:32 -04008407 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008408 if (context)
8409 {
8410 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008411 {
Geoff Langb1196682014-07-23 13:47:29 -04008412 context->recordError(gl::Error(GL_INVALID_OPERATION));
8413 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008414 }
Geoff Langbfdea662014-07-23 14:16:32 -04008415
8416 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8417 {
8418 return;
8419 }
8420
8421 switch (target)
8422 {
8423 case GL_TEXTURE_3D:
8424 {
8425 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008426 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8427 if (error.isError())
8428 {
8429 context->recordError(error);
8430 return;
8431 }
Geoff Langbfdea662014-07-23 14:16:32 -04008432 }
8433 break;
8434
8435 case GL_TEXTURE_2D_ARRAY:
8436 {
8437 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008438 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8439 if (error.isError())
8440 {
8441 context->recordError(error);
8442 return;
8443 }
Geoff Langbfdea662014-07-23 14:16:32 -04008444 }
8445 break;
8446
8447 default:
8448 UNREACHABLE();
8449 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008450 }
8451}
8452
Kenneth Russell67ea1902014-10-06 16:44:50 -07008453void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008454{
8455 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8456 "GLint* params = 0x%0.8p)",
8457 target, internalformat, pname, bufSize, params);
8458
Geoff Langbfdea662014-07-23 14:16:32 -04008459 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008460 if (context)
8461 {
8462 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008463 {
Geoff Langb1196682014-07-23 13:47:29 -04008464 context->recordError(gl::Error(GL_INVALID_OPERATION));
8465 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008466 }
Geoff Langbfdea662014-07-23 14:16:32 -04008467
8468 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8469 if (!formatCaps.renderable)
8470 {
Geoff Langb1196682014-07-23 13:47:29 -04008471 context->recordError(gl::Error(GL_INVALID_ENUM));
8472 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008473 }
8474
8475 if (target != GL_RENDERBUFFER)
8476 {
Geoff Langb1196682014-07-23 13:47:29 -04008477 context->recordError(gl::Error(GL_INVALID_ENUM));
8478 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008479 }
8480
8481 if (bufSize < 0)
8482 {
Geoff Langb1196682014-07-23 13:47:29 -04008483 context->recordError(gl::Error(GL_INVALID_VALUE));
8484 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008485 }
8486
8487 switch (pname)
8488 {
8489 case GL_NUM_SAMPLE_COUNTS:
8490 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008491 {
8492 *params = formatCaps.sampleCounts.size();
8493 }
Geoff Langbfdea662014-07-23 14:16:32 -04008494 break;
Geoff Langb1196682014-07-23 13:47:29 -04008495
Geoff Langbfdea662014-07-23 14:16:32 -04008496 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008497 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008498 break;
Geoff Langb1196682014-07-23 13:47:29 -04008499
Geoff Langbfdea662014-07-23 14:16:32 -04008500 default:
Geoff Langb1196682014-07-23 13:47:29 -04008501 context->recordError(gl::Error(GL_INVALID_ENUM));
8502 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008503 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008504 }
8505}
8506
8507// Extension functions
8508
Kenneth Russell67ea1902014-10-06 16:44:50 -07008509void 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 +00008510 GLbitfield mask, GLenum filter)
8511{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008512 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008513 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8514 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8515 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8516
Geoff Langbfdea662014-07-23 14:16:32 -04008517 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008518 if (context)
8519 {
8520 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8521 dstX0, dstY0, dstX1, dstY1, mask, filter,
8522 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008523 {
Geoff Langbfdea662014-07-23 14:16:32 -04008524 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008525 }
Geoff Langbfdea662014-07-23 14:16:32 -04008526
Geoff Lang64839152014-08-26 16:23:25 -04008527 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8528 mask, filter);
8529 if (error.isError())
8530 {
8531 context->recordError(error);
8532 return;
8533 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008534 }
8535}
8536
Kenneth Russell67ea1902014-10-06 16:44:50 -07008537void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008538 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008539{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008540 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008541 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008542 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008543 target, level, internalformat, width, height, depth, border, format, type, pixels);
8544
Geoff Langbfdea662014-07-23 14:16:32 -04008545 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008546}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008547
Kenneth Russell67ea1902014-10-06 16:44:50 -07008548void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008549 GLenum *binaryFormat, void *binary)
8550{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008551 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 +00008552 program, bufSize, length, binaryFormat, binary);
8553
Geoff Langbfdea662014-07-23 14:16:32 -04008554 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008555 if (context)
8556 {
8557 gl::Program *programObject = context->getProgram(program);
8558
8559 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008560 {
Geoff Langb1196682014-07-23 13:47:29 -04008561 context->recordError(gl::Error(GL_INVALID_OPERATION));
8562 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008563 }
Geoff Langbfdea662014-07-23 14:16:32 -04008564
8565 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8566
8567 if (!programBinary)
8568 {
Geoff Langb1196682014-07-23 13:47:29 -04008569 context->recordError(gl::Error(GL_INVALID_OPERATION));
8570 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008571 }
8572
Geoff Langb543aff2014-09-30 14:52:54 -04008573 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8574 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008575 {
Geoff Langb543aff2014-09-30 14:52:54 -04008576 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008577 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008578 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008579 }
8580}
8581
Kenneth Russell67ea1902014-10-06 16:44:50 -07008582void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008583 const void *binary, GLint length)
8584{
8585 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8586 program, binaryFormat, binary, length);
8587
Geoff Langbfdea662014-07-23 14:16:32 -04008588 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008589 if (context)
8590 {
Geoff Lang900013c2014-07-07 11:32:19 -04008591 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8592 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008593 {
Geoff Langb1196682014-07-23 13:47:29 -04008594 context->recordError(gl::Error(GL_INVALID_ENUM));
8595 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008596 }
Geoff Langbfdea662014-07-23 14:16:32 -04008597
8598 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008599 if (!programObject)
8600 {
Geoff Langb1196682014-07-23 13:47:29 -04008601 context->recordError(gl::Error(GL_INVALID_OPERATION));
8602 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008603 }
8604
Geoff Langb543aff2014-09-30 14:52:54 -04008605 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8606 if (error.isError())
8607 {
8608 context->recordError(error);
8609 return;
8610 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008611 }
8612}
8613
Kenneth Russell67ea1902014-10-06 16:44:50 -07008614void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008615{
8616 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8617
Geoff Langbfdea662014-07-23 14:16:32 -04008618 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008619 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008620 {
Geoff Langbfdea662014-07-23 14:16:32 -04008621 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008622 {
Geoff Langb1196682014-07-23 13:47:29 -04008623 context->recordError(gl::Error(GL_INVALID_VALUE));
8624 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008625 }
8626
Jamie Madill48faf802014-11-06 15:27:22 -05008627 ASSERT(context->getState().getDrawFramebuffer());
8628
Geoff Langbfdea662014-07-23 14:16:32 -04008629 if (context->getState().getDrawFramebuffer()->id() == 0)
8630 {
8631 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008632 {
Geoff Langb1196682014-07-23 13:47:29 -04008633 context->recordError(gl::Error(GL_INVALID_OPERATION));
8634 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008635 }
8636
Geoff Langbfdea662014-07-23 14:16:32 -04008637 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008638 {
Geoff Langb1196682014-07-23 13:47:29 -04008639 context->recordError(gl::Error(GL_INVALID_OPERATION));
8640 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008641 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008642 }
Geoff Langbfdea662014-07-23 14:16:32 -04008643 else
8644 {
8645 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8646 {
8647 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8648 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8649 {
Geoff Langb1196682014-07-23 13:47:29 -04008650 context->recordError(gl::Error(GL_INVALID_OPERATION));
8651 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008652 }
8653 }
8654 }
8655
8656 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -05008657 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04008658
8659 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8660 {
8661 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8662 }
8663
8664 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8665 {
8666 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8667 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008668 }
8669}
8670
Kenneth Russell67ea1902014-10-06 16:44:50 -07008671void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008672{
8673 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8674
Geoff Langbfdea662014-07-23 14:16:32 -04008675 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008676 if (context)
8677 {
8678 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008679 {
Geoff Langb1196682014-07-23 13:47:29 -04008680 context->recordError(gl::Error(GL_INVALID_ENUM));
8681 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008682 }
Geoff Langbfdea662014-07-23 14:16:32 -04008683
8684 if (pname != GL_BUFFER_MAP_POINTER)
8685 {
Geoff Langb1196682014-07-23 13:47:29 -04008686 context->recordError(gl::Error(GL_INVALID_ENUM));
8687 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008688 }
8689
8690 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8691
8692 if (!buffer || !buffer->isMapped())
8693 {
8694 *params = NULL;
8695 }
8696 else
8697 {
8698 *params = buffer->getMapPointer();
8699 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008700 }
8701}
8702
Kenneth Russell67ea1902014-10-06 16:44:50 -07008703void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008704{
8705 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8706
Geoff Langbfdea662014-07-23 14:16:32 -04008707 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008708 if (context)
8709 {
8710 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008711 {
Geoff Langb1196682014-07-23 13:47:29 -04008712 context->recordError(gl::Error(GL_INVALID_ENUM));
8713 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008714 }
Geoff Langbfdea662014-07-23 14:16:32 -04008715
8716 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8717
8718 if (buffer == NULL)
8719 {
Geoff Langb1196682014-07-23 13:47:29 -04008720 context->recordError(gl::Error(GL_INVALID_OPERATION));
8721 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008722 }
8723
8724 if (access != GL_WRITE_ONLY_OES)
8725 {
Geoff Langb1196682014-07-23 13:47:29 -04008726 context->recordError(gl::Error(GL_INVALID_ENUM));
8727 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008728 }
8729
8730 if (buffer->isMapped())
8731 {
Geoff Langb1196682014-07-23 13:47:29 -04008732 context->recordError(gl::Error(GL_INVALID_OPERATION));
8733 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008734 }
8735
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008736 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8737 if (error.isError())
8738 {
8739 context->recordError(error);
8740 return NULL;
8741 }
8742
8743 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008744 }
8745
8746 return NULL;
8747}
8748
Kenneth Russell67ea1902014-10-06 16:44:50 -07008749GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008750{
8751 EVENT("(GLenum target = 0x%X)", target);
8752
Geoff Langbfdea662014-07-23 14:16:32 -04008753 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008754 if (context)
8755 {
8756 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008757 {
Geoff Langb1196682014-07-23 13:47:29 -04008758 context->recordError(gl::Error(GL_INVALID_ENUM));
8759 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008760 }
Geoff Langbfdea662014-07-23 14:16:32 -04008761
8762 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8763
8764 if (buffer == NULL || !buffer->isMapped())
8765 {
Geoff Langb1196682014-07-23 13:47:29 -04008766 context->recordError(gl::Error(GL_INVALID_OPERATION));
8767 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008768 }
8769
8770 // TODO: detect if we had corruption. if so, throw an error and return false.
8771
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008772 gl::Error error = buffer->unmap();
8773 if (error.isError())
8774 {
8775 context->recordError(error);
8776 return GL_FALSE;
8777 }
Geoff Langbfdea662014-07-23 14:16:32 -04008778
8779 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008780 }
8781
8782 return GL_FALSE;
8783}
8784
Kenneth Russell67ea1902014-10-06 16:44:50 -07008785void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008786{
8787 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8788 target, offset, length, access);
8789
Geoff Langbfdea662014-07-23 14:16:32 -04008790 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008791 if (context)
8792 {
8793 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008794 {
Geoff Langb1196682014-07-23 13:47:29 -04008795 context->recordError(gl::Error(GL_INVALID_ENUM));
8796 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008797 }
Geoff Langbfdea662014-07-23 14:16:32 -04008798
8799 if (offset < 0 || length < 0)
8800 {
Geoff Langb1196682014-07-23 13:47:29 -04008801 context->recordError(gl::Error(GL_INVALID_VALUE));
8802 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008803 }
8804
8805 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8806
8807 if (buffer == NULL)
8808 {
Geoff Langb1196682014-07-23 13:47:29 -04008809 context->recordError(gl::Error(GL_INVALID_OPERATION));
8810 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008811 }
8812
8813 // Check for buffer overflow
8814 size_t offsetSize = static_cast<size_t>(offset);
8815 size_t lengthSize = static_cast<size_t>(length);
8816
8817 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8818 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8819 {
Geoff Langb1196682014-07-23 13:47:29 -04008820 context->recordError(gl::Error(GL_INVALID_VALUE));
8821 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008822 }
8823
8824 // Check for invalid bits in the mask
8825 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8826 GL_MAP_WRITE_BIT |
8827 GL_MAP_INVALIDATE_RANGE_BIT |
8828 GL_MAP_INVALIDATE_BUFFER_BIT |
8829 GL_MAP_FLUSH_EXPLICIT_BIT |
8830 GL_MAP_UNSYNCHRONIZED_BIT;
8831
8832 if (access & ~(allAccessBits))
8833 {
Geoff Langb1196682014-07-23 13:47:29 -04008834 context->recordError(gl::Error(GL_INVALID_VALUE));
8835 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008836 }
8837
8838 if (length == 0 || buffer->isMapped())
8839 {
Geoff Langb1196682014-07-23 13:47:29 -04008840 context->recordError(gl::Error(GL_INVALID_OPERATION));
8841 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008842 }
8843
8844 // Check for invalid bit combinations
8845 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8846 {
Geoff Langb1196682014-07-23 13:47:29 -04008847 context->recordError(gl::Error(GL_INVALID_OPERATION));
8848 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008849 }
8850
8851 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8852 GL_MAP_INVALIDATE_BUFFER_BIT |
8853 GL_MAP_UNSYNCHRONIZED_BIT;
8854
8855 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8856 {
Geoff Langb1196682014-07-23 13:47:29 -04008857 context->recordError(gl::Error(GL_INVALID_OPERATION));
8858 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008859 }
8860
8861 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8862 {
Geoff Langb1196682014-07-23 13:47:29 -04008863 context->recordError(gl::Error(GL_INVALID_OPERATION));
8864 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008865 }
8866
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008867 gl::Error error = buffer->mapRange(offset, length, access);
8868 if (error.isError())
8869 {
8870 context->recordError(error);
8871 return NULL;
8872 }
8873
8874 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008875 }
8876
8877 return NULL;
8878}
8879
Kenneth Russell67ea1902014-10-06 16:44:50 -07008880void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008881{
8882 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8883
Geoff Langbfdea662014-07-23 14:16:32 -04008884 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008885 if (context)
8886 {
8887 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008888 {
Geoff Langb1196682014-07-23 13:47:29 -04008889 context->recordError(gl::Error(GL_INVALID_VALUE));
8890 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008891 }
Geoff Langbfdea662014-07-23 14:16:32 -04008892
8893 if (!gl::ValidBufferTarget(context, target))
8894 {
Geoff Langb1196682014-07-23 13:47:29 -04008895 context->recordError(gl::Error(GL_INVALID_ENUM));
8896 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008897 }
8898
8899 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8900
8901 if (buffer == NULL)
8902 {
Geoff Langb1196682014-07-23 13:47:29 -04008903 context->recordError(gl::Error(GL_INVALID_OPERATION));
8904 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008905 }
8906
8907 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8908 {
Geoff Langb1196682014-07-23 13:47:29 -04008909 context->recordError(gl::Error(GL_INVALID_OPERATION));
8910 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008911 }
8912
8913 // Check for buffer overflow
8914 size_t offsetSize = static_cast<size_t>(offset);
8915 size_t lengthSize = static_cast<size_t>(length);
8916
8917 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8918 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8919 {
Geoff Langb1196682014-07-23 13:47:29 -04008920 context->recordError(gl::Error(GL_INVALID_VALUE));
8921 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008922 }
8923
8924 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008925 }
8926}
8927
Kenneth Russell67ea1902014-10-06 16:44:50 -07008928__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008929{
8930 struct Extension
8931 {
8932 const char *name;
8933 __eglMustCastToProperFunctionPointerType address;
8934 };
8935
8936 static const Extension glExtensions[] =
8937 {
8938 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008939 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008940 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008941 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8942 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8943 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8944 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8945 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8946 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8947 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008948 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008949 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008950 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8951 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8952 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8953 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008954 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8955 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8956 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8957 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8958 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8959 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8960 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008961 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008962 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8963 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8964 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008965 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008966 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8967 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8968 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008969 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8970 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8971 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008972
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008973 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008974 {
8975 if (strcmp(procname, glExtensions[ext].name) == 0)
8976 {
8977 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8978 }
8979 }
8980
8981 return NULL;
8982}
8983
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008984// Non-public functions used by EGL
8985
Kenneth Russell67ea1902014-10-06 16:44:50 -07008986bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008987{
8988 EVENT("(egl::Surface* surface = 0x%0.8p)",
8989 surface);
8990
Geoff Langbfdea662014-07-23 14:16:32 -04008991 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008992 if (context)
8993 {
8994 gl::Texture2D *textureObject = context->getTexture2D();
8995 ASSERT(textureObject != NULL);
8996
8997 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008998 {
Geoff Langbfdea662014-07-23 14:16:32 -04008999 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00009000 }
Geoff Langbfdea662014-07-23 14:16:32 -04009001
9002 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00009003 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00009004
9005 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00009006}
9007
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009008}