blob: 4a31f2ceee9b397f44b2656e9d088139b802a993 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
624 return framebuffer->completeness();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000625 }
626
627 return 0;
628}
629
Kenneth Russell67ea1902014-10-06 16:44:50 -0700630void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000631{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000632 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000633
Geoff Langbfdea662014-07-23 14:16:32 -0400634 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400635 if (context)
636 {
637 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
638
639 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000640 {
Geoff Langb1196682014-07-23 13:47:29 -0400641 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000643 }
Geoff Langbfdea662014-07-23 14:16:32 -0400644
645 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
646 {
Geoff Langb1196682014-07-23 13:47:29 -0400647 context->recordError(gl::Error(GL_INVALID_VALUE));
648 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400649 }
650
Geoff Langcc79b8c2014-07-25 13:48:02 -0400651 gl::Error error = context->clear(mask);
652 if (error.isError())
653 {
654 context->recordError(error);
655 return;
656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000657 }
658}
659
Kenneth Russell67ea1902014-10-06 16:44:50 -0700660void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000662 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000663 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000664
Geoff Langbfdea662014-07-23 14:16:32 -0400665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400666 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000667 {
Geoff Langbfdea662014-07-23 14:16:32 -0400668 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 }
670}
671
Kenneth Russell67ea1902014-10-06 16:44:50 -0700672void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000674 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675
Geoff Langbfdea662014-07-23 14:16:32 -0400676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400677 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000678 {
Geoff Langbfdea662014-07-23 14:16:32 -0400679 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 }
681}
682
Kenneth Russell67ea1902014-10-06 16:44:50 -0700683void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000685 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686
Geoff Langbfdea662014-07-23 14:16:32 -0400687 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400688 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000689 {
Geoff Langbfdea662014-07-23 14:16:32 -0400690 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 }
692}
693
Kenneth Russell67ea1902014-10-06 16:44:50 -0700694void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000695{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000696 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000697 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000698
Geoff Langbfdea662014-07-23 14:16:32 -0400699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400700 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000701 {
Geoff Langbfdea662014-07-23 14:16:32 -0400702 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 }
704}
705
Kenneth Russell67ea1902014-10-06 16:44:50 -0700706void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000708 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709
Geoff Langbfdea662014-07-23 14:16:32 -0400710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400711 if (context)
712 {
713 gl::Shader *shaderObject = context->getShader(shader);
714
715 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000716 {
Geoff Langbfdea662014-07-23 14:16:32 -0400717 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langb1196682014-07-23 13:47:29 -0400719 context->recordError(gl::Error(GL_INVALID_OPERATION));
720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000721 }
Geoff Langbfdea662014-07-23 14:16:32 -0400722 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000723 {
Geoff Langb1196682014-07-23 13:47:29 -0400724 context->recordError(gl::Error(GL_INVALID_VALUE));
725 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000726 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000727 }
Geoff Langbfdea662014-07-23 14:16:32 -0400728
729 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000730 }
Geoff Langbfdea662014-07-23 14:16:32 -0400731}
732
Kenneth Russell67ea1902014-10-06 16:44:50 -0700733void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400734 GLint border, GLsizei imageSize, const GLvoid* data)
735{
736 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
737 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
738 target, level, internalformat, width, height, border, imageSize, data);
739
740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400741 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000742 {
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context->getClientVersion() < 3 &&
744 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
745 0, 0, width, height, border, GL_NONE, GL_NONE, data))
746 {
747 return;
748 }
749
750 if (context->getClientVersion() >= 3 &&
751 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
752 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
753 {
754 return;
755 }
756
Geoff Lang5d601382014-07-22 15:14:06 -0400757 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
758 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400759 {
Geoff Langb1196682014-07-23 13:47:29 -0400760 context->recordError(gl::Error(GL_INVALID_VALUE));
761 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400762 }
763
764 switch (target)
765 {
766 case GL_TEXTURE_2D:
767 {
768 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400769 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400770 if (error.isError())
771 {
772 context->recordError(error);
773 return;
774 }
Geoff Langbfdea662014-07-23 14:16:32 -0400775 }
776 break;
777
778 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
779 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
784 {
785 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400786 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400787 if (error.isError())
788 {
789 context->recordError(error);
790 return;
791 }
Geoff Langbfdea662014-07-23 14:16:32 -0400792 }
793 break;
794
795 default:
Geoff Langb1196682014-07-23 13:47:29 -0400796 context->recordError(gl::Error(GL_INVALID_ENUM));
797 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400798 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000799 }
800}
801
Kenneth Russell67ea1902014-10-06 16:44:50 -0700802void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000803 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000805 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000806 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000807 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000808 target, level, xoffset, yoffset, width, height, format, imageSize, data);
809
Geoff Langbfdea662014-07-23 14:16:32 -0400810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400811 if (context)
812 {
813 if (context->getClientVersion() < 3 &&
814 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
815 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000816 {
Geoff Langbfdea662014-07-23 14:16:32 -0400817 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 }
Geoff Langbfdea662014-07-23 14:16:32 -0400819
820 if (context->getClientVersion() >= 3 &&
821 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
822 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
823 {
824 return;
825 }
826
Geoff Lang5d601382014-07-22 15:14:06 -0400827 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
828 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400829 {
Geoff Langb1196682014-07-23 13:47:29 -0400830 context->recordError(gl::Error(GL_INVALID_VALUE));
831 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400832 }
833
834 switch (target)
835 {
836 case GL_TEXTURE_2D:
837 {
838 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400839 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400840 if (error.isError())
841 {
842 context->recordError(error);
843 return;
844 }
Geoff Langbfdea662014-07-23 14:16:32 -0400845 }
846 break;
847
848 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
849 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
854 {
855 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400856 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400857 if (error.isError())
858 {
859 context->recordError(error);
860 return;
861 }
Geoff Langbfdea662014-07-23 14:16:32 -0400862 }
863 break;
864
865 default:
Geoff Langb1196682014-07-23 13:47:29 -0400866 context->recordError(gl::Error(GL_INVALID_ENUM));
867 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400868 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000869 }
870}
871
Kenneth Russell67ea1902014-10-06 16:44:50 -0700872void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000874 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000875 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000876 target, level, internalformat, x, y, width, height, border);
877
Geoff Langbfdea662014-07-23 14:16:32 -0400878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400879 if (context)
880 {
881 if (context->getClientVersion() < 3 &&
882 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
883 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000884 {
Geoff Langbfdea662014-07-23 14:16:32 -0400885 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 }
Geoff Langbfdea662014-07-23 14:16:32 -0400887
888 if (context->getClientVersion() >= 3 &&
889 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
890 0, 0, 0, x, y, width, height, border))
891 {
892 return;
893 }
894
895 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
896
897 switch (target)
898 {
899 case GL_TEXTURE_2D:
900 {
901 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400902 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
903 if (error.isError())
904 {
905 context->recordError(error);
906 return;
907 }
Geoff Langbfdea662014-07-23 14:16:32 -0400908 }
909 break;
910
911 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
912 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
917 {
918 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400919 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
920 if (error.isError())
921 {
922 context->recordError(error);
923 return;
924 }
Geoff Langbfdea662014-07-23 14:16:32 -0400925 }
926 break;
927
Geoff Langb1196682014-07-23 13:47:29 -0400928 default:
929 context->recordError(gl::Error(GL_INVALID_ENUM));
930 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400931 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000932 }
933}
934
Kenneth Russell67ea1902014-10-06 16:44:50 -0700935void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000937 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000938 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000939 target, level, xoffset, yoffset, x, y, width, height);
940
Geoff Langbfdea662014-07-23 14:16:32 -0400941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400942 if (context)
943 {
944 if (context->getClientVersion() < 3 &&
945 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
946 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000947 {
Geoff Langbfdea662014-07-23 14:16:32 -0400948 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000950
Geoff Langbfdea662014-07-23 14:16:32 -0400951 if (context->getClientVersion() >= 3 &&
952 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
953 xoffset, yoffset, 0, x, y, width, height, 0))
954 {
955 return;
956 }
957
958 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
959
960 switch (target)
961 {
962 case GL_TEXTURE_2D:
963 {
964 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400965 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
966 if (error.isError())
967 {
968 context->recordError(error);
969 return;
970 }
Geoff Langbfdea662014-07-23 14:16:32 -0400971 }
972 break;
973
974 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
975 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
980 {
981 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400982 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
983 if (error.isError())
984 {
985 context->recordError(error);
986 return;
987 }
Geoff Langbfdea662014-07-23 14:16:32 -0400988 }
989 break;
990
991 default:
Geoff Langb1196682014-07-23 13:47:29 -0400992 context->recordError(gl::Error(GL_INVALID_ENUM));
993 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400994 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000995 }
996}
997
Kenneth Russell67ea1902014-10-06 16:44:50 -0700998GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001000 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001
Geoff Langbfdea662014-07-23 14:16:32 -04001002 gl::Context *context = gl::getNonLostContext();
1003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001004 {
Geoff Langbfdea662014-07-23 14:16:32 -04001005 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 }
1007
1008 return 0;
1009}
1010
Kenneth Russell67ea1902014-10-06 16:44:50 -07001011GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001013 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014
Geoff Langbfdea662014-07-23 14:16:32 -04001015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001016 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001017 {
Geoff Langbfdea662014-07-23 14:16:32 -04001018 switch (type)
1019 {
1020 case GL_FRAGMENT_SHADER:
1021 case GL_VERTEX_SHADER:
1022 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001023
Geoff Langbfdea662014-07-23 14:16:32 -04001024 default:
Geoff Langb1196682014-07-23 13:47:29 -04001025 context->recordError(gl::Error(GL_INVALID_ENUM));
1026 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001028 }
1029
1030 return 0;
1031}
1032
Kenneth Russell67ea1902014-10-06 16:44:50 -07001033void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001034{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001035 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036
Geoff Langb1196682014-07-23 13:47:29 -04001037 gl::Context *context = gl::getNonLostContext();
1038 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001039 {
Geoff Langb1196682014-07-23 13:47:29 -04001040 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 case GL_FRONT:
1043 case GL_BACK:
1044 case GL_FRONT_AND_BACK:
1045 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001046
Geoff Langb1196682014-07-23 13:47:29 -04001047 default:
1048 context->recordError(gl::Error(GL_INVALID_ENUM));
1049 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001050 }
Geoff Langb1196682014-07-23 13:47:29 -04001051
1052 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001053 }
1054}
1055
Kenneth Russell67ea1902014-10-06 16:44:50 -07001056void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001058 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059
Geoff Langbfdea662014-07-23 14:16:32 -04001060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001061 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001062 {
Geoff Langb1196682014-07-23 13:47:29 -04001063 if (n < 0)
1064 {
1065 context->recordError(gl::Error(GL_INVALID_VALUE));
1066 return;
1067 }
1068
Geoff Langbfdea662014-07-23 14:16:32 -04001069 for (int i = 0; i < n; i++)
1070 {
1071 context->deleteBuffer(buffers[i]);
1072 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001073 }
1074}
1075
Kenneth Russell67ea1902014-10-06 16:44:50 -07001076void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001077{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001078 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079
Geoff Langbfdea662014-07-23 14:16:32 -04001080 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001081 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001082 {
Geoff Langb1196682014-07-23 13:47:29 -04001083 if (n < 0)
1084 {
1085 context->recordError(gl::Error(GL_INVALID_VALUE));
1086 return;
1087 }
1088
Geoff Langbfdea662014-07-23 14:16:32 -04001089 for (int i = 0; i < n; i++)
1090 {
1091 context->deleteFenceNV(fences[i]);
1092 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001093 }
1094}
1095
Kenneth Russell67ea1902014-10-06 16:44:50 -07001096void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001097{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001098 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099
Geoff Langbfdea662014-07-23 14:16:32 -04001100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001101 if (context)
1102 {
Geoff Langb1196682014-07-23 13:47:29 -04001103 if (n < 0)
1104 {
1105 context->recordError(gl::Error(GL_INVALID_VALUE));
1106 return;
1107 }
1108
Geoff Langbfdea662014-07-23 14:16:32 -04001109 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001110 {
Geoff Langbfdea662014-07-23 14:16:32 -04001111 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 }
1115 }
1116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001117}
1118
Kenneth Russell67ea1902014-10-06 16:44:50 -07001119void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001120{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001121 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122
Geoff Langbfdea662014-07-23 14:16:32 -04001123 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001124 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001125 {
Geoff Langb1196682014-07-23 13:47:29 -04001126 if (program == 0)
1127 {
1128 return;
1129 }
1130
Geoff Langbfdea662014-07-23 14:16:32 -04001131 if (!context->getProgram(program))
1132 {
1133 if(context->getShader(program))
1134 {
Geoff Langb1196682014-07-23 13:47:29 -04001135 context->recordError(gl::Error(GL_INVALID_OPERATION));
1136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001137 }
1138 else
1139 {
Geoff Langb1196682014-07-23 13:47:29 -04001140 context->recordError(gl::Error(GL_INVALID_VALUE));
1141 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001142 }
1143 }
1144
1145 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146 }
1147}
1148
Kenneth Russell67ea1902014-10-06 16:44:50 -07001149void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001150{
1151 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1152
Geoff Langbfdea662014-07-23 14:16:32 -04001153 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001154 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001155 {
Geoff Langb1196682014-07-23 13:47:29 -04001156 if (n < 0)
1157 {
1158 context->recordError(gl::Error(GL_INVALID_VALUE));
1159 return;
1160 }
1161
Geoff Langbfdea662014-07-23 14:16:32 -04001162 for (int i = 0; i < n; i++)
1163 {
1164 context->deleteQuery(ids[i]);
1165 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001166 }
1167}
1168
Kenneth Russell67ea1902014-10-06 16:44:50 -07001169void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001170{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001171 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172
Geoff Langbfdea662014-07-23 14:16:32 -04001173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001174 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001175 {
Geoff Langb1196682014-07-23 13:47:29 -04001176 if (n < 0)
1177 {
1178 context->recordError(gl::Error(GL_INVALID_VALUE));
1179 return;
1180 }
1181
Geoff Langbfdea662014-07-23 14:16:32 -04001182 for (int i = 0; i < n; i++)
1183 {
1184 context->deleteRenderbuffer(renderbuffers[i]);
1185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001186 }
1187}
1188
Kenneth Russell67ea1902014-10-06 16:44:50 -07001189void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001191 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192
Geoff Langbfdea662014-07-23 14:16:32 -04001193 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001194 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001195 {
Geoff Langb1196682014-07-23 13:47:29 -04001196 if (shader == 0)
1197 {
1198 return;
1199 }
1200
Geoff Langbfdea662014-07-23 14:16:32 -04001201 if (!context->getShader(shader))
1202 {
1203 if(context->getProgram(shader))
1204 {
Geoff Langb1196682014-07-23 13:47:29 -04001205 context->recordError(gl::Error(GL_INVALID_OPERATION));
1206 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001207 }
1208 else
1209 {
Geoff Langb1196682014-07-23 13:47:29 -04001210 context->recordError(gl::Error(GL_INVALID_VALUE));
1211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001212 }
1213 }
1214
1215 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001216 }
1217}
1218
Kenneth Russell67ea1902014-10-06 16:44:50 -07001219void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001220{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001221 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222
Geoff Langbfdea662014-07-23 14:16:32 -04001223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001224 if (context)
1225 {
Geoff Langb1196682014-07-23 13:47:29 -04001226 if (n < 0)
1227 {
1228 context->recordError(gl::Error(GL_INVALID_VALUE));
1229 return;
1230 }
1231
Geoff Langbfdea662014-07-23 14:16:32 -04001232 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001233 {
Geoff Langbfdea662014-07-23 14:16:32 -04001234 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 }
1238 }
1239 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001240}
1241
Kenneth Russell67ea1902014-10-06 16:44:50 -07001242void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001243{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001244 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245
Geoff Langbfdea662014-07-23 14:16:32 -04001246 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001247 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001248 {
Geoff Langb1196682014-07-23 13:47:29 -04001249 switch (func)
1250 {
1251 case GL_NEVER:
1252 case GL_ALWAYS:
1253 case GL_LESS:
1254 case GL_LEQUAL:
1255 case GL_EQUAL:
1256 case GL_GREATER:
1257 case GL_GEQUAL:
1258 case GL_NOTEQUAL:
1259 context->getState().setDepthFunc(func);
1260 break;
1261
1262 default:
1263 context->recordError(gl::Error(GL_INVALID_ENUM));
1264 return;
1265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001266 }
1267}
1268
Kenneth Russell67ea1902014-10-06 16:44:50 -07001269void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001270{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001271 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272
Geoff Langbfdea662014-07-23 14:16:32 -04001273 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001274 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001275 {
Geoff Langbfdea662014-07-23 14:16:32 -04001276 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 }
1278}
1279
Kenneth Russell67ea1902014-10-06 16:44:50 -07001280void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001282 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283
Geoff Langbfdea662014-07-23 14:16:32 -04001284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001285 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001286 {
Geoff Langbfdea662014-07-23 14:16:32 -04001287 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 }
1289}
1290
Kenneth Russell67ea1902014-10-06 16:44:50 -07001291void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001293 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294
Geoff Langbfdea662014-07-23 14:16:32 -04001295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001297 {
Geoff Langbfdea662014-07-23 14:16:32 -04001298 gl::Program *programObject = context->getProgram(program);
1299 gl::Shader *shaderObject = context->getShader(shader);
1300
1301 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001302 {
Geoff Langbfdea662014-07-23 14:16:32 -04001303 gl::Shader *shaderByProgramHandle;
1304 shaderByProgramHandle = context->getShader(program);
1305 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001306 {
Geoff Langb1196682014-07-23 13:47:29 -04001307 context->recordError(gl::Error(GL_INVALID_VALUE));
1308 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001309 }
Geoff Langbfdea662014-07-23 14:16:32 -04001310 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001311 {
Geoff Langb1196682014-07-23 13:47:29 -04001312 context->recordError(gl::Error(GL_INVALID_OPERATION));
1313 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001314 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001315 }
Geoff Langbfdea662014-07-23 14:16:32 -04001316
1317 if (!shaderObject)
1318 {
1319 gl::Program *programByShaderHandle = context->getProgram(shader);
1320 if (!programByShaderHandle)
1321 {
Geoff Langb1196682014-07-23 13:47:29 -04001322 context->recordError(gl::Error(GL_INVALID_VALUE));
1323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001324 }
1325 else
1326 {
Geoff Langb1196682014-07-23 13:47:29 -04001327 context->recordError(gl::Error(GL_INVALID_OPERATION));
1328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001329 }
1330 }
1331
1332 if (!programObject->detachShader(shaderObject))
1333 {
Geoff Langb1196682014-07-23 13:47:29 -04001334 context->recordError(gl::Error(GL_INVALID_OPERATION));
1335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001336 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001337 }
1338}
1339
Kenneth Russell67ea1902014-10-06 16:44:50 -07001340void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001342 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343
Geoff Langbfdea662014-07-23 14:16:32 -04001344 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001345 if (context)
1346 {
1347 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001348 {
Geoff Langb1196682014-07-23 13:47:29 -04001349 context->recordError(gl::Error(GL_INVALID_ENUM));
1350 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001351 }
Geoff Langbfdea662014-07-23 14:16:32 -04001352
1353 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001354 }
1355}
1356
Kenneth Russell67ea1902014-10-06 16:44:50 -07001357void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001359 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360
Geoff Langbfdea662014-07-23 14:16:32 -04001361 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001362 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001363 {
Geoff Langb1196682014-07-23 13:47:29 -04001364 if (index >= gl::MAX_VERTEX_ATTRIBS)
1365 {
1366 context->recordError(gl::Error(GL_INVALID_VALUE));
1367 return;
1368 }
1369
Geoff Langbfdea662014-07-23 14:16:32 -04001370 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001371 }
1372}
1373
Kenneth Russell67ea1902014-10-06 16:44:50 -07001374void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001375{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001376 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377
Geoff Langbfdea662014-07-23 14:16:32 -04001378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001379 if (context)
1380 {
Jamie Madill2b976812014-08-25 15:47:49 -04001381 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001382 {
Geoff Langbfdea662014-07-23 14:16:32 -04001383 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 }
Geoff Langbfdea662014-07-23 14:16:32 -04001385
Geoff Langc77e8c32014-09-08 16:28:24 -04001386 gl::Error error = context->drawArrays(mode, first, count, 0);
1387 if (error.isError())
1388 {
1389 context->recordError(error);
1390 return;
1391 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001392 }
1393}
1394
Kenneth Russell67ea1902014-10-06 16:44:50 -07001395void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001396{
1397 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1398
Geoff Langbfdea662014-07-23 14:16:32 -04001399 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001400 if (context)
1401 {
Geoff Lang87a93302014-09-16 13:29:43 -04001402 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001403 {
Geoff Langbfdea662014-07-23 14:16:32 -04001404 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 }
Geoff Langbfdea662014-07-23 14:16:32 -04001406
Geoff Langc77e8c32014-09-08 16:28:24 -04001407 gl::Error error = context->drawArrays(mode, first, count, primcount);
1408 if (error.isError())
1409 {
1410 context->recordError(error);
1411 return;
1412 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001413 }
1414}
1415
Kenneth Russell67ea1902014-10-06 16:44:50 -07001416void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001417{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001418 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001419 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001420
Geoff Langbfdea662014-07-23 14:16:32 -04001421 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001422 if (context)
1423 {
Jamie Madill2b976812014-08-25 15:47:49 -04001424 rx::RangeUI indexRange;
1425 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001426 {
Geoff Langbfdea662014-07-23 14:16:32 -04001427 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 }
Geoff Langbfdea662014-07-23 14:16:32 -04001429
Geoff Langc77e8c32014-09-08 16:28:24 -04001430 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1431 if (error.isError())
1432 {
1433 context->recordError(error);
1434 return;
1435 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001436 }
1437}
1438
Kenneth Russell67ea1902014-10-06 16:44:50 -07001439void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001440{
1441 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1442 mode, count, type, indices, primcount);
1443
Geoff Langbfdea662014-07-23 14:16:32 -04001444 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001445 if (context)
1446 {
Jamie Madill2b976812014-08-25 15:47:49 -04001447 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001448 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001449 {
Geoff Langbfdea662014-07-23 14:16:32 -04001450 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 }
Geoff Langbfdea662014-07-23 14:16:32 -04001452
Geoff Langc77e8c32014-09-08 16:28:24 -04001453 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1454 if (error.isError())
1455 {
1456 context->recordError(error);
1457 return;
1458 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001459 }
1460}
1461
Kenneth Russell67ea1902014-10-06 16:44:50 -07001462void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001463{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001464 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465
Geoff Langbfdea662014-07-23 14:16:32 -04001466 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001467 if (context)
1468 {
1469 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001470 {
Geoff Langb1196682014-07-23 13:47:29 -04001471 context->recordError(gl::Error(GL_INVALID_ENUM));
1472 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001473 }
Geoff Langbfdea662014-07-23 14:16:32 -04001474
1475 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001476 }
1477}
1478
Kenneth Russell67ea1902014-10-06 16:44:50 -07001479void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001481 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
Geoff Langbfdea662014-07-23 14:16:32 -04001483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001484 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001485 {
Geoff Langb1196682014-07-23 13:47:29 -04001486 if (index >= gl::MAX_VERTEX_ATTRIBS)
1487 {
1488 context->recordError(gl::Error(GL_INVALID_VALUE));
1489 return;
1490 }
1491
Geoff Langbfdea662014-07-23 14:16:32 -04001492 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001493 }
1494}
1495
Kenneth Russell67ea1902014-10-06 16:44:50 -07001496void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001497{
1498 EVENT("GLenum target = 0x%X)", target);
1499
Geoff Langbfdea662014-07-23 14:16:32 -04001500 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001501 if (context)
1502 {
1503 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001504 {
Geoff Langbfdea662014-07-23 14:16:32 -04001505 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 }
Geoff Langbfdea662014-07-23 14:16:32 -04001507
Geoff Lang5aad9672014-09-08 11:10:42 -04001508 gl::Error error = context->endQuery(target);
1509 if (error.isError())
1510 {
1511 context->recordError(error);
1512 return;
1513 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001514 }
1515}
1516
Kenneth Russell67ea1902014-10-06 16:44:50 -07001517void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001518{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001519 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520
Geoff Langbfdea662014-07-23 14:16:32 -04001521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001522 if (context)
1523 {
1524 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1525
1526 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001527 {
Geoff Langb1196682014-07-23 13:47:29 -04001528 context->recordError(gl::Error(GL_INVALID_OPERATION));
1529 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001530 }
Geoff Langbfdea662014-07-23 14:16:32 -04001531
1532 if (fenceObject->isFence() != GL_TRUE)
1533 {
Geoff Langb1196682014-07-23 13:47:29 -04001534 context->recordError(gl::Error(GL_INVALID_OPERATION));
1535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001536 }
1537
1538 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001539 }
1540}
1541
Kenneth Russell67ea1902014-10-06 16:44:50 -07001542void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001543{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001544 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545
Geoff Langbfdea662014-07-23 14:16:32 -04001546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001547 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001548 {
Geoff Lang26298562014-10-01 10:49:03 -04001549 gl::Error error = context->sync(true);
1550 if (error.isError())
1551 {
1552 context->recordError(error);
1553 return;
1554 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555 }
1556}
1557
Kenneth Russell67ea1902014-10-06 16:44:50 -07001558void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001559{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001560 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561
Geoff Langbfdea662014-07-23 14:16:32 -04001562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001563 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001564 {
Geoff Lang26298562014-10-01 10:49:03 -04001565 gl::Error error = context->sync(false);
1566 if (error.isError())
1567 {
1568 context->recordError(error);
1569 return;
1570 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 }
1572}
1573
Kenneth Russell67ea1902014-10-06 16:44:50 -07001574void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001575{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001576 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001577 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001578
Geoff Langbfdea662014-07-23 14:16:32 -04001579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001580 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
Geoff Langb1196682014-07-23 13:47:29 -04001582 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1583 {
1584 context->recordError(gl::Error(GL_INVALID_ENUM));
1585 return;
1586 }
1587
Geoff Langbfdea662014-07-23 14:16:32 -04001588 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1589 {
1590 return;
1591 }
1592
1593 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1594 ASSERT(framebuffer);
1595
1596 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1597 {
1598 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1599 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1600 }
1601 else
1602 {
1603 switch (attachment)
1604 {
1605 case GL_DEPTH_ATTACHMENT:
1606 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1607 break;
1608 case GL_STENCIL_ATTACHMENT:
1609 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1610 break;
1611 case GL_DEPTH_STENCIL_ATTACHMENT:
1612 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1613 break;
1614 default:
1615 UNREACHABLE();
1616 break;
1617 }
1618 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 }
1620}
1621
Kenneth Russell67ea1902014-10-06 16:44:50 -07001622void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001624 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001625 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001626
Geoff Langbfdea662014-07-23 14:16:32 -04001627 gl::Context *context = gl::getNonLostContext();
1628 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001629 {
Geoff Langbfdea662014-07-23 14:16:32 -04001630 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 return;
1633 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001634
Geoff Langbfdea662014-07-23 14:16:32 -04001635 if (texture == 0)
1636 {
1637 textarget = GL_NONE;
1638 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001639
Geoff Langbfdea662014-07-23 14:16:32 -04001640 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1643 {
1644 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1645 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1646 }
1647 else
1648 {
1649 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001650 {
Geoff Langbfdea662014-07-23 14:16:32 -04001651 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1652 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1653 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001654 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
1656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langb1196682014-07-23 13:47:29 -04001663 gl::Context *context = gl::getNonLostContext();
1664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001667 {
Geoff Langb1196682014-07-23 13:47:29 -04001668 case GL_CW:
1669 case GL_CCW:
1670 context->getState().setFrontFace(mode);
1671 break;
1672 default:
1673 context->recordError(gl::Error(GL_INVALID_ENUM));
1674 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685 {
Geoff Langb1196682014-07-23 13:47:29 -04001686 if (n < 0)
1687 {
1688 context->recordError(gl::Error(GL_INVALID_VALUE));
1689 return;
1690 }
1691
Geoff Langbfdea662014-07-23 14:16:32 -04001692 for (int i = 0; i < n; i++)
1693 {
1694 buffers[i] = context->createBuffer();
1695 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001696 }
1697}
1698
Kenneth Russell67ea1902014-10-06 16:44:50 -07001699void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001701 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001702
Geoff Langbfdea662014-07-23 14:16:32 -04001703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001704 if (context)
1705 {
1706 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001707 {
Geoff Langb1196682014-07-23 13:47:29 -04001708 context->recordError(gl::Error(GL_INVALID_ENUM));
1709 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 }
Geoff Langbfdea662014-07-23 14:16:32 -04001711
1712 gl::Texture *texture = context->getTargetTexture(target);
1713
1714 if (texture == NULL)
1715 {
Geoff Langb1196682014-07-23 13:47:29 -04001716 context->recordError(gl::Error(GL_INVALID_OPERATION));
1717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001718 }
1719
1720 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1721 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001722 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001723
1724 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1725 // unsized formats or that are color renderable and filterable. Since we do not track if
1726 // the texture was created with sized or unsized format (only sized formats are stored),
1727 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1728 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1729 // textures since they're the only texture format that can be created with unsized formats
1730 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1731 // was the last version to use add them.
1732 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1733 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1734 internalFormat == GL_ALPHA8_EXT;
1735
Geoff Lang5d601382014-07-22 15:14:06 -04001736 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1737 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001738 {
Geoff Langb1196682014-07-23 13:47:29 -04001739 context->recordError(gl::Error(GL_INVALID_OPERATION));
1740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001741 }
1742
1743 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001744 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001745 {
Geoff Langb1196682014-07-23 13:47:29 -04001746 context->recordError(gl::Error(GL_INVALID_OPERATION));
1747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001748 }
1749
1750 // Non-power of 2 ES2 check
1751 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1752 {
1753 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001754 context->recordError(gl::Error(GL_INVALID_OPERATION));
1755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001756 }
1757
1758 // Cube completeness check
1759 if (target == GL_TEXTURE_CUBE_MAP)
1760 {
1761 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1762 if (!textureCube->isCubeComplete())
1763 {
Geoff Langb1196682014-07-23 13:47:29 -04001764 context->recordError(gl::Error(GL_INVALID_OPERATION));
1765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001766 }
1767 }
1768
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001769 gl::Error error = texture->generateMipmaps();
1770 if (error.isError())
1771 {
1772 context->recordError(error);
1773 return;
1774 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001775 }
1776}
1777
Kenneth Russell67ea1902014-10-06 16:44:50 -07001778void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001779{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001780 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001781
Geoff Langbfdea662014-07-23 14:16:32 -04001782 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001783 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001784 {
Geoff Langb1196682014-07-23 13:47:29 -04001785 if (n < 0)
1786 {
1787 context->recordError(gl::Error(GL_INVALID_VALUE));
1788 return;
1789 }
1790
Geoff Langbfdea662014-07-23 14:16:32 -04001791 for (int i = 0; i < n; i++)
1792 {
1793 fences[i] = context->createFenceNV();
1794 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001795 }
1796}
1797
Kenneth Russell67ea1902014-10-06 16:44:50 -07001798void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001800 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001801
Geoff Langbfdea662014-07-23 14:16:32 -04001802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001803 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001804 {
Geoff Langb1196682014-07-23 13:47:29 -04001805 if (n < 0)
1806 {
1807 context->recordError(gl::Error(GL_INVALID_VALUE));
1808 return;
1809 }
1810
Geoff Langbfdea662014-07-23 14:16:32 -04001811 for (int i = 0; i < n; i++)
1812 {
1813 framebuffers[i] = context->createFramebuffer();
1814 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001815 }
1816}
1817
Kenneth Russell67ea1902014-10-06 16:44:50 -07001818void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001819{
1820 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1821
Geoff Langbfdea662014-07-23 14:16:32 -04001822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001823 if (context)
1824 {
1825 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001826 {
Geoff Langb1196682014-07-23 13:47:29 -04001827 context->recordError(gl::Error(GL_INVALID_VALUE));
1828 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001829 }
Geoff Langbfdea662014-07-23 14:16:32 -04001830
1831 for (GLsizei i = 0; i < n; i++)
1832 {
1833 ids[i] = context->createQuery();
1834 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001835 }
1836}
1837
Kenneth Russell67ea1902014-10-06 16:44:50 -07001838void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001840 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001841
Geoff Langbfdea662014-07-23 14:16:32 -04001842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001843 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844 {
Geoff Langb1196682014-07-23 13:47:29 -04001845 if (n < 0)
1846 {
1847 context->recordError(gl::Error(GL_INVALID_VALUE));
1848 return;
1849 }
1850
Geoff Langbfdea662014-07-23 14:16:32 -04001851 for (int i = 0; i < n; i++)
1852 {
1853 renderbuffers[i] = context->createRenderbuffer();
1854 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001855 }
1856}
1857
Kenneth Russell67ea1902014-10-06 16:44:50 -07001858void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001860 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001861
Geoff Langbfdea662014-07-23 14:16:32 -04001862 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001863 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001864 {
Geoff Langb1196682014-07-23 13:47:29 -04001865 if (n < 0)
1866 {
1867 context->recordError(gl::Error(GL_INVALID_VALUE));
1868 return;
1869 }
1870
Geoff Langbfdea662014-07-23 14:16:32 -04001871 for (int i = 0; i < n; i++)
1872 {
1873 textures[i] = context->createTexture();
1874 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001875 }
1876}
1877
Kenneth Russell67ea1902014-10-06 16:44:50 -07001878void 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 +00001879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001880 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001881 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001882 program, index, bufsize, length, size, type, name);
1883
Geoff Langbfdea662014-07-23 14:16:32 -04001884 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001885 if (context)
1886 {
Geoff Langb1196682014-07-23 13:47:29 -04001887 if (bufsize < 0)
1888 {
1889 context->recordError(gl::Error(GL_INVALID_VALUE));
1890 return;
1891 }
1892
Geoff Langbfdea662014-07-23 14:16:32 -04001893 gl::Program *programObject = context->getProgram(program);
1894
1895 if (!programObject)
1896 {
1897 if (context->getShader(program))
1898 {
Geoff Langb1196682014-07-23 13:47:29 -04001899 context->recordError(gl::Error(GL_INVALID_OPERATION));
1900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001901 }
1902 else
1903 {
Geoff Langb1196682014-07-23 13:47:29 -04001904 context->recordError(gl::Error(GL_INVALID_VALUE));
1905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001906 }
1907 }
1908
1909 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001910 {
Geoff Langb1196682014-07-23 13:47:29 -04001911 context->recordError(gl::Error(GL_INVALID_VALUE));
1912 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001913 }
1914
Geoff Langbfdea662014-07-23 14:16:32 -04001915 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001916 }
1917}
1918
Kenneth Russell67ea1902014-10-06 16:44:50 -07001919void 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 +00001920{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001921 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001922 "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 +00001923 program, index, bufsize, length, size, type, name);
1924
Geoff Langbfdea662014-07-23 14:16:32 -04001925
1926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001927 if (context)
1928 {
Geoff Langb1196682014-07-23 13:47:29 -04001929 if (bufsize < 0)
1930 {
1931 context->recordError(gl::Error(GL_INVALID_VALUE));
1932 return;
1933 }
1934
Geoff Langbfdea662014-07-23 14:16:32 -04001935 gl::Program *programObject = context->getProgram(program);
1936
1937 if (!programObject)
1938 {
1939 if (context->getShader(program))
1940 {
Geoff Langb1196682014-07-23 13:47:29 -04001941 context->recordError(gl::Error(GL_INVALID_OPERATION));
1942 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001943 }
1944 else
1945 {
Geoff Langb1196682014-07-23 13:47:29 -04001946 context->recordError(gl::Error(GL_INVALID_VALUE));
1947 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001948 }
1949 }
1950
1951 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001952 {
Geoff Langb1196682014-07-23 13:47:29 -04001953 context->recordError(gl::Error(GL_INVALID_VALUE));
1954 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001955 }
1956
Geoff Langbfdea662014-07-23 14:16:32 -04001957 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958 }
1959}
1960
Kenneth Russell67ea1902014-10-06 16:44:50 -07001961void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001962{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001963 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 +00001964 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965
Geoff Langbfdea662014-07-23 14:16:32 -04001966 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001967 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001968 {
Geoff Langb1196682014-07-23 13:47:29 -04001969 if (maxcount < 0)
1970 {
1971 context->recordError(gl::Error(GL_INVALID_VALUE));
1972 return;
1973 }
1974
Geoff Langbfdea662014-07-23 14:16:32 -04001975 gl::Program *programObject = context->getProgram(program);
1976
1977 if (!programObject)
1978 {
1979 if (context->getShader(program))
1980 {
Geoff Langb1196682014-07-23 13:47:29 -04001981 context->recordError(gl::Error(GL_INVALID_OPERATION));
1982 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001983 }
1984 else
1985 {
Geoff Langb1196682014-07-23 13:47:29 -04001986 context->recordError(gl::Error(GL_INVALID_VALUE));
1987 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001988 }
1989 }
1990
1991 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001992 }
1993}
1994
Kenneth Russell67ea1902014-10-06 16:44:50 -07001995GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001997 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001998
Geoff Langbfdea662014-07-23 14:16:32 -04001999 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002000 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002001 {
Geoff Langbfdea662014-07-23 14:16:32 -04002002 gl::Program *programObject = context->getProgram(program);
2003
2004 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002005 {
Geoff Langbfdea662014-07-23 14:16:32 -04002006 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002007 {
Geoff Langb1196682014-07-23 13:47:29 -04002008 context->recordError(gl::Error(GL_INVALID_OPERATION));
2009 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002010 }
Geoff Langbfdea662014-07-23 14:16:32 -04002011 else
2012 {
Geoff Langb1196682014-07-23 13:47:29 -04002013 context->recordError(gl::Error(GL_INVALID_VALUE));
2014 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002015 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002016 }
Geoff Langbfdea662014-07-23 14:16:32 -04002017
2018 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2019 if (!programObject->isLinked() || !programBinary)
2020 {
Geoff Langb1196682014-07-23 13:47:29 -04002021 context->recordError(gl::Error(GL_INVALID_OPERATION));
2022 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002023 }
2024
2025 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002026 }
2027
2028 return -1;
2029}
2030
Kenneth Russell67ea1902014-10-06 16:44:50 -07002031void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002032{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002033 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002034
Geoff Langbfdea662014-07-23 14:16:32 -04002035 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002036 if (context)
2037 {
2038 GLenum nativeType;
2039 unsigned int numParams = 0;
2040 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002041 {
Geoff Langbfdea662014-07-23 14:16:32 -04002042 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002043 }
Geoff Langbfdea662014-07-23 14:16:32 -04002044
2045 if (nativeType == GL_BOOL)
2046 {
2047 context->getBooleanv(pname, params);
2048 }
2049 else
2050 {
2051 CastStateValues(context, nativeType, pname, numParams, params);
2052 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002053 }
2054}
2055
Kenneth Russell67ea1902014-10-06 16:44:50 -07002056void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002058 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 +00002059
Geoff Langbfdea662014-07-23 14:16:32 -04002060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002061 if (context)
2062 {
2063 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002064 {
Geoff Langb1196682014-07-23 13:47:29 -04002065 context->recordError(gl::Error(GL_INVALID_ENUM));
2066 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002067 }
Geoff Langbfdea662014-07-23 14:16:32 -04002068
2069 if (!gl::ValidBufferParameter(context, pname))
2070 {
Geoff Langb1196682014-07-23 13:47:29 -04002071 context->recordError(gl::Error(GL_INVALID_ENUM));
2072 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002073 }
2074
2075 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2076
2077 if (!buffer)
2078 {
2079 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002080 context->recordError(gl::Error(GL_INVALID_OPERATION));
2081 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002082 }
2083
2084 switch (pname)
2085 {
2086 case GL_BUFFER_USAGE:
2087 *params = static_cast<GLint>(buffer->getUsage());
2088 break;
2089 case GL_BUFFER_SIZE:
2090 *params = gl::clampCast<GLint>(buffer->getSize());
2091 break;
2092 case GL_BUFFER_ACCESS_FLAGS:
2093 *params = buffer->getAccessFlags();
2094 break;
2095 case GL_BUFFER_MAPPED:
2096 *params = static_cast<GLint>(buffer->isMapped());
2097 break;
2098 case GL_BUFFER_MAP_OFFSET:
2099 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2100 break;
2101 case GL_BUFFER_MAP_LENGTH:
2102 *params = gl::clampCast<GLint>(buffer->getMapLength());
2103 break;
2104 default: UNREACHABLE(); break;
2105 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002106 }
2107}
2108
Kenneth Russell67ea1902014-10-06 16:44:50 -07002109GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002110{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002111 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002112
2113 gl::Context *context = gl::getContext();
2114
2115 if (context)
2116 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002117 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002118 }
2119
2120 return GL_NO_ERROR;
2121}
2122
Kenneth Russell67ea1902014-10-06 16:44:50 -07002123void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002124{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002125 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002126
Geoff Langbfdea662014-07-23 14:16:32 -04002127 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002128 if (context)
2129 {
2130 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2131
2132 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002133 {
Geoff Langb1196682014-07-23 13:47:29 -04002134 context->recordError(gl::Error(GL_INVALID_OPERATION));
2135 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002136 }
Geoff Langbfdea662014-07-23 14:16:32 -04002137
2138 if (fenceObject->isFence() != GL_TRUE)
2139 {
Geoff Langb1196682014-07-23 13:47:29 -04002140 context->recordError(gl::Error(GL_INVALID_OPERATION));
2141 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002142 }
2143
2144 switch (pname)
2145 {
2146 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002147 {
2148 // GL_NV_fence spec:
2149 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2150 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2151 GLboolean status = GL_TRUE;
2152 if (fenceObject->getStatus() != GL_TRUE)
2153 {
2154 gl::Error error = fenceObject->testFence(&status);
2155 if (error.isError())
2156 {
2157 context->recordError(error);
2158 return;
2159 }
2160 }
2161 *params = status;
2162 break;
2163 }
2164
Geoff Langbfdea662014-07-23 14:16:32 -04002165 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002166 {
2167 *params = fenceObject->getCondition();
2168 break;
2169 }
Geoff Langbfdea662014-07-23 14:16:32 -04002170
Geoff Langb1196682014-07-23 13:47:29 -04002171 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002172 {
2173 context->recordError(gl::Error(GL_INVALID_ENUM));
2174 return;
2175 }
Geoff Lang882033e2014-09-30 11:26:07 -04002176 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002177 }
2178}
2179
Kenneth Russell67ea1902014-10-06 16:44:50 -07002180void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002181{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002182 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002183
Geoff Langbfdea662014-07-23 14:16:32 -04002184 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002185 if (context)
2186 {
2187 GLenum nativeType;
2188 unsigned int numParams = 0;
2189 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002190 {
Geoff Langbfdea662014-07-23 14:16:32 -04002191 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002192 }
Geoff Langbfdea662014-07-23 14:16:32 -04002193
2194 if (nativeType == GL_FLOAT)
2195 {
2196 context->getFloatv(pname, params);
2197 }
2198 else
2199 {
2200 CastStateValues(context, nativeType, pname, numParams, params);
2201 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002202 }
2203}
2204
Kenneth Russell67ea1902014-10-06 16:44:50 -07002205void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002206{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002207 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 +00002208 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209
Geoff Langbfdea662014-07-23 14:16:32 -04002210 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002211 if (context)
2212 {
2213 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002214 {
Geoff Langb1196682014-07-23 13:47:29 -04002215 context->recordError(gl::Error(GL_INVALID_ENUM));
2216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002217 }
2218
2219 int clientVersion = context->getClientVersion();
2220
2221 switch (pname)
2222 {
2223 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2224 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2225 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2226 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2227 break;
Geoff Langb1196682014-07-23 13:47:29 -04002228
Geoff Langbfdea662014-07-23 14:16:32 -04002229 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2230 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002231 {
Geoff Langb1196682014-07-23 13:47:29 -04002232 context->recordError(gl::Error(GL_INVALID_ENUM));
2233 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002234 }
Geoff Langbfdea662014-07-23 14:16:32 -04002235 break;
Geoff Langb1196682014-07-23 13:47:29 -04002236
Geoff Langbfdea662014-07-23 14:16:32 -04002237 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2238 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2239 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2240 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2241 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2242 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2243 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2244 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2245 if (clientVersion < 3)
2246 {
Geoff Langb1196682014-07-23 13:47:29 -04002247 context->recordError(gl::Error(GL_INVALID_ENUM));
2248 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002249 }
2250 break;
Geoff Langb1196682014-07-23 13:47:29 -04002251
Geoff Langbfdea662014-07-23 14:16:32 -04002252 default:
Geoff Langb1196682014-07-23 13:47:29 -04002253 context->recordError(gl::Error(GL_INVALID_ENUM));
2254 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002255 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002256
Geoff Langbfdea662014-07-23 14:16:32 -04002257 // Determine if the attachment is a valid enum
2258 switch (attachment)
2259 {
2260 case GL_BACK:
2261 case GL_FRONT:
2262 case GL_DEPTH:
2263 case GL_STENCIL:
2264 case GL_DEPTH_STENCIL_ATTACHMENT:
2265 if (clientVersion < 3)
2266 {
Geoff Langb1196682014-07-23 13:47:29 -04002267 context->recordError(gl::Error(GL_INVALID_ENUM));
2268 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002269 }
2270 break;
2271
2272 case GL_DEPTH_ATTACHMENT:
2273 case GL_STENCIL_ATTACHMENT:
2274 break;
2275
2276 default:
2277 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2278 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2279 {
Geoff Langb1196682014-07-23 13:47:29 -04002280 context->recordError(gl::Error(GL_INVALID_ENUM));
2281 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002282 }
2283 break;
2284 }
2285
2286 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2287 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2288
2289 if (framebufferHandle == 0)
2290 {
2291 if (clientVersion < 3)
2292 {
Geoff Langb1196682014-07-23 13:47:29 -04002293 context->recordError(gl::Error(GL_INVALID_OPERATION));
2294 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002295 }
2296
2297 switch (attachment)
2298 {
2299 case GL_BACK:
2300 case GL_DEPTH:
2301 case GL_STENCIL:
2302 break;
Geoff Langb1196682014-07-23 13:47:29 -04002303
Geoff Langbfdea662014-07-23 14:16:32 -04002304 default:
Geoff Langb1196682014-07-23 13:47:29 -04002305 context->recordError(gl::Error(GL_INVALID_OPERATION));
2306 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002307 }
2308 }
2309 else
2310 {
2311 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2312 {
2313 // Valid attachment query
2314 }
2315 else
2316 {
2317 switch (attachment)
2318 {
2319 case GL_DEPTH_ATTACHMENT:
2320 case GL_STENCIL_ATTACHMENT:
2321 break;
Geoff Langb1196682014-07-23 13:47:29 -04002322
Geoff Langbfdea662014-07-23 14:16:32 -04002323 case GL_DEPTH_STENCIL_ATTACHMENT:
2324 if (framebuffer->hasValidDepthStencil())
2325 {
Geoff Langb1196682014-07-23 13:47:29 -04002326 context->recordError(gl::Error(GL_INVALID_OPERATION));
2327 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002328 }
2329 break;
Geoff Langb1196682014-07-23 13:47:29 -04002330
Geoff Langbfdea662014-07-23 14:16:32 -04002331 default:
Geoff Langb1196682014-07-23 13:47:29 -04002332 context->recordError(gl::Error(GL_INVALID_OPERATION));
2333 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002334 }
2335 }
2336 }
2337
2338 GLenum attachmentType = GL_NONE;
2339 GLuint attachmentHandle = 0;
2340 GLuint attachmentLevel = 0;
2341 GLuint attachmentLayer = 0;
2342
2343 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2344
2345 if (attachmentObject)
2346 {
2347 attachmentType = attachmentObject->type();
2348 attachmentHandle = attachmentObject->id();
2349 attachmentLevel = attachmentObject->mipLevel();
2350 attachmentLayer = attachmentObject->layer();
2351 }
2352
2353 GLenum attachmentObjectType; // Type category
2354 if (framebufferHandle == 0)
2355 {
2356 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2357 }
2358 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2359 {
2360 attachmentObjectType = attachmentType;
2361 }
2362 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2363 {
2364 attachmentObjectType = GL_TEXTURE;
2365 }
2366 else
2367 {
2368 UNREACHABLE();
2369 return;
2370 }
2371
2372 if (attachmentObjectType == GL_NONE)
2373 {
2374 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2375 // is NONE, then querying any other pname will generate INVALID_ENUM.
2376
2377 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2378 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2379 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002380
Geoff Lang646559f2013-08-15 11:08:15 -04002381 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002382 {
Geoff Lang646559f2013-08-15 11:08:15 -04002383 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002384 *params = attachmentObjectType;
2385 break;
2386
Geoff Lang646559f2013-08-15 11:08:15 -04002387 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002388 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002389 {
Geoff Langb1196682014-07-23 13:47:29 -04002390 context->recordError(gl::Error(GL_INVALID_ENUM));
2391 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002392 }
Geoff Langbfdea662014-07-23 14:16:32 -04002393 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002394 break;
2395
2396 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002397 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002398 {
Geoff Langb1196682014-07-23 13:47:29 -04002399 context->recordError(gl::Error(GL_INVALID_ENUM));
2400 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002401 }
2402 else
2403 {
Geoff Langb1196682014-07-23 13:47:29 -04002404 context->recordError(gl::Error(GL_INVALID_OPERATION));
2405 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002406 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002407 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002408 }
Geoff Langbfdea662014-07-23 14:16:32 -04002409 else
2410 {
2411 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2412 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2413 ASSERT(attachmentObject != NULL);
2414
2415 switch (pname)
2416 {
2417 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2418 *params = attachmentObjectType;
2419 break;
2420
2421 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2422 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2423 {
Geoff Langb1196682014-07-23 13:47:29 -04002424 context->recordError(gl::Error(GL_INVALID_ENUM));
2425 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002426 }
2427 *params = attachmentHandle;
2428 break;
2429
2430 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2431 if (attachmentObjectType != GL_TEXTURE)
2432 {
Geoff Langb1196682014-07-23 13:47:29 -04002433 context->recordError(gl::Error(GL_INVALID_ENUM));
2434 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002435 }
2436 *params = attachmentLevel;
2437 break;
2438
2439 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2440 if (attachmentObjectType != GL_TEXTURE)
2441 {
Geoff Langb1196682014-07-23 13:47:29 -04002442 context->recordError(gl::Error(GL_INVALID_ENUM));
2443 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002444 }
2445 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2446 break;
2447
2448 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2449 *params = attachmentObject->getRedSize();
2450 break;
2451
2452 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2453 *params = attachmentObject->getGreenSize();
2454 break;
2455
2456 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2457 *params = attachmentObject->getBlueSize();
2458 break;
2459
2460 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2461 *params = attachmentObject->getAlphaSize();
2462 break;
2463
2464 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2465 *params = attachmentObject->getDepthSize();
2466 break;
2467
2468 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2469 *params = attachmentObject->getStencilSize();
2470 break;
2471
2472 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002473 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002474 {
Geoff Langb1196682014-07-23 13:47:29 -04002475 context->recordError(gl::Error(GL_INVALID_OPERATION));
2476 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002477 }
2478 *params = attachmentObject->getComponentType();
2479 break;
2480
2481 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2482 *params = attachmentObject->getColorEncoding();
2483 break;
2484
2485 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2486 if (attachmentObjectType != GL_TEXTURE)
2487 {
Geoff Langb1196682014-07-23 13:47:29 -04002488 context->recordError(gl::Error(GL_INVALID_ENUM));
2489 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002490 }
2491 *params = attachmentLayer;
2492 break;
2493
2494 default:
2495 UNREACHABLE();
2496 break;
2497 }
2498 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002499 }
2500}
2501
Kenneth Russell67ea1902014-10-06 16:44:50 -07002502GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002503{
2504 EVENT("()");
2505
Geoff Langbfdea662014-07-23 14:16:32 -04002506 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002507
Geoff Langbfdea662014-07-23 14:16:32 -04002508 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002509 {
Geoff Langbfdea662014-07-23 14:16:32 -04002510 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002511 }
Geoff Langbfdea662014-07-23 14:16:32 -04002512
2513 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002514}
2515
Kenneth Russell67ea1902014-10-06 16:44:50 -07002516void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002517{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002518 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002519
Geoff Langbfdea662014-07-23 14:16:32 -04002520 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002521 if (context)
2522 {
2523 GLenum nativeType;
2524 unsigned int numParams = 0;
2525
2526 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002527 {
Geoff Langbfdea662014-07-23 14:16:32 -04002528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529 }
Geoff Langbfdea662014-07-23 14:16:32 -04002530
2531 if (nativeType == GL_INT)
2532 {
2533 context->getIntegerv(pname, params);
2534 }
2535 else
2536 {
2537 CastStateValues(context, nativeType, pname, numParams, params);
2538 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002539 }
2540}
2541
Kenneth Russell67ea1902014-10-06 16:44:50 -07002542void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002544 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002545
Geoff Langbfdea662014-07-23 14:16:32 -04002546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002547 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002548 {
Geoff Langbfdea662014-07-23 14:16:32 -04002549 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002550
Geoff Langbfdea662014-07-23 14:16:32 -04002551 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002552 {
Geoff Langb1196682014-07-23 13:47:29 -04002553 context->recordError(gl::Error(GL_INVALID_VALUE));
2554 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002555 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002556
Geoff Langbfdea662014-07-23 14:16:32 -04002557 if (context->getClientVersion() < 3)
2558 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002559 switch (pname)
2560 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002561 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002562 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002563 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002564 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002565 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002566 context->recordError(gl::Error(GL_INVALID_ENUM));
2567 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002568 }
2569 }
Geoff Langbfdea662014-07-23 14:16:32 -04002570
2571 switch (pname)
2572 {
2573 case GL_DELETE_STATUS:
2574 *params = programObject->isFlaggedForDeletion();
2575 return;
2576 case GL_LINK_STATUS:
2577 *params = programObject->isLinked();
2578 return;
2579 case GL_VALIDATE_STATUS:
2580 *params = programObject->isValidated();
2581 return;
2582 case GL_INFO_LOG_LENGTH:
2583 *params = programObject->getInfoLogLength();
2584 return;
2585 case GL_ATTACHED_SHADERS:
2586 *params = programObject->getAttachedShadersCount();
2587 return;
2588 case GL_ACTIVE_ATTRIBUTES:
2589 *params = programObject->getActiveAttributeCount();
2590 return;
2591 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2592 *params = programObject->getActiveAttributeMaxLength();
2593 return;
2594 case GL_ACTIVE_UNIFORMS:
2595 *params = programObject->getActiveUniformCount();
2596 return;
2597 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2598 *params = programObject->getActiveUniformMaxLength();
2599 return;
2600 case GL_PROGRAM_BINARY_LENGTH_OES:
2601 *params = programObject->getProgramBinaryLength();
2602 return;
2603 case GL_ACTIVE_UNIFORM_BLOCKS:
2604 *params = programObject->getActiveUniformBlockCount();
2605 return;
2606 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2607 *params = programObject->getActiveUniformBlockMaxLength();
2608 break;
2609 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2610 *params = programObject->getTransformFeedbackBufferMode();
2611 break;
2612 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2613 *params = programObject->getTransformFeedbackVaryingCount();
2614 break;
2615 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2616 *params = programObject->getTransformFeedbackVaryingMaxLength();
2617 break;
Geoff Langb1196682014-07-23 13:47:29 -04002618
Geoff Langbfdea662014-07-23 14:16:32 -04002619 default:
Geoff Langb1196682014-07-23 13:47:29 -04002620 context->recordError(gl::Error(GL_INVALID_ENUM));
2621 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002622 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002623 }
2624}
2625
Kenneth Russell67ea1902014-10-06 16:44:50 -07002626void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002628 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 +00002629 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002630
Geoff Langbfdea662014-07-23 14:16:32 -04002631 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002632 if (context)
2633 {
Geoff Langb1196682014-07-23 13:47:29 -04002634 if (bufsize < 0)
2635 {
2636 context->recordError(gl::Error(GL_INVALID_VALUE));
2637 return;
2638 }
2639
Geoff Langbfdea662014-07-23 14:16:32 -04002640 gl::Program *programObject = context->getProgram(program);
2641
2642 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002643 {
Geoff Langb1196682014-07-23 13:47:29 -04002644 context->recordError(gl::Error(GL_INVALID_VALUE));
2645 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002646 }
2647
Geoff Langbfdea662014-07-23 14:16:32 -04002648 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002649 }
2650}
2651
Kenneth Russell67ea1902014-10-06 16:44:50 -07002652void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002653{
2654 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2655
Geoff Langbfdea662014-07-23 14:16:32 -04002656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002657 if (context)
2658 {
2659 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002660 {
Geoff Langb1196682014-07-23 13:47:29 -04002661 context->recordError(gl::Error(GL_INVALID_ENUM));
2662 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002663 }
Geoff Langbfdea662014-07-23 14:16:32 -04002664
2665 switch (pname)
2666 {
2667 case GL_CURRENT_QUERY_EXT:
2668 params[0] = context->getState().getActiveQueryId(target);
2669 break;
2670
2671 default:
Geoff Langb1196682014-07-23 13:47:29 -04002672 context->recordError(gl::Error(GL_INVALID_ENUM));
2673 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002674 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002675 }
2676}
2677
Kenneth Russell67ea1902014-10-06 16:44:50 -07002678void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002679{
2680 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2681
Geoff Langbfdea662014-07-23 14:16:32 -04002682 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002683 if (context)
2684 {
2685 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2686
2687 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002688 {
Geoff Langb1196682014-07-23 13:47:29 -04002689 context->recordError(gl::Error(GL_INVALID_OPERATION));
2690 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002691 }
Geoff Langbfdea662014-07-23 14:16:32 -04002692
2693 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2694 {
Geoff Langb1196682014-07-23 13:47:29 -04002695 context->recordError(gl::Error(GL_INVALID_OPERATION));
2696 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002697 }
2698
2699 switch(pname)
2700 {
2701 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002702 {
2703 gl::Error error = queryObject->getResult(params);
2704 if (error.isError())
2705 {
2706 context->recordError(error);
2707 return;
2708 }
2709 }
Geoff Langbfdea662014-07-23 14:16:32 -04002710 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002711
Geoff Langbfdea662014-07-23 14:16:32 -04002712 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002713 {
2714 gl::Error error = queryObject->isResultAvailable(params);
2715 if (error.isError())
2716 {
2717 context->recordError(error);
2718 return;
2719 }
2720 }
Geoff Langbfdea662014-07-23 14:16:32 -04002721 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002722
Geoff Langbfdea662014-07-23 14:16:32 -04002723 default:
Geoff Langb1196682014-07-23 13:47:29 -04002724 context->recordError(gl::Error(GL_INVALID_ENUM));
2725 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002726 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002727 }
2728}
2729
Kenneth Russell67ea1902014-10-06 16:44:50 -07002730void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002731{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002732 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 +00002733
Geoff Langbfdea662014-07-23 14:16:32 -04002734 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002735 if (context)
2736 {
2737 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002738 {
Geoff Langb1196682014-07-23 13:47:29 -04002739 context->recordError(gl::Error(GL_INVALID_ENUM));
2740 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002741 }
Geoff Langbfdea662014-07-23 14:16:32 -04002742
2743 if (context->getState().getRenderbufferId() == 0)
2744 {
Geoff Langb1196682014-07-23 13:47:29 -04002745 context->recordError(gl::Error(GL_INVALID_OPERATION));
2746 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002747 }
2748
2749 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2750
2751 switch (pname)
2752 {
2753 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2754 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2755 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2756 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2757 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2758 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2759 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2760 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2761 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002762
Geoff Langbfdea662014-07-23 14:16:32 -04002763 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2764 if (!context->getExtensions().framebufferMultisample)
2765 {
Geoff Langb1196682014-07-23 13:47:29 -04002766 context->recordError(gl::Error(GL_INVALID_ENUM));
2767 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002768 }
2769 *params = renderbuffer->getSamples();
2770 break;
Geoff Langb1196682014-07-23 13:47:29 -04002771
Geoff Langbfdea662014-07-23 14:16:32 -04002772 default:
Geoff Langb1196682014-07-23 13:47:29 -04002773 context->recordError(gl::Error(GL_INVALID_ENUM));
2774 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002775 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002776 }
2777}
2778
Kenneth Russell67ea1902014-10-06 16:44:50 -07002779void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002780{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002781 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002782
Geoff Langbfdea662014-07-23 14:16:32 -04002783 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002784 if (context)
2785 {
2786 gl::Shader *shaderObject = context->getShader(shader);
2787
2788 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002789 {
Geoff Langb1196682014-07-23 13:47:29 -04002790 context->recordError(gl::Error(GL_INVALID_VALUE));
2791 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002792 }
Geoff Langbfdea662014-07-23 14:16:32 -04002793
2794 switch (pname)
2795 {
2796 case GL_SHADER_TYPE:
2797 *params = shaderObject->getType();
2798 return;
2799 case GL_DELETE_STATUS:
2800 *params = shaderObject->isFlaggedForDeletion();
2801 return;
2802 case GL_COMPILE_STATUS:
2803 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2804 return;
2805 case GL_INFO_LOG_LENGTH:
2806 *params = shaderObject->getInfoLogLength();
2807 return;
2808 case GL_SHADER_SOURCE_LENGTH:
2809 *params = shaderObject->getSourceLength();
2810 return;
2811 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2812 *params = shaderObject->getTranslatedSourceLength();
2813 return;
Geoff Langb1196682014-07-23 13:47:29 -04002814
Geoff Langbfdea662014-07-23 14:16:32 -04002815 default:
Geoff Langb1196682014-07-23 13:47:29 -04002816 context->recordError(gl::Error(GL_INVALID_ENUM));
2817 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002818 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002819 }
2820}
2821
Kenneth Russell67ea1902014-10-06 16:44:50 -07002822void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002824 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 +00002825 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002826
Geoff Langbfdea662014-07-23 14:16:32 -04002827 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002828 if (context)
2829 {
Geoff Langb1196682014-07-23 13:47:29 -04002830 if (bufsize < 0)
2831 {
2832 context->recordError(gl::Error(GL_INVALID_VALUE));
2833 return;
2834 }
2835
Geoff Langbfdea662014-07-23 14:16:32 -04002836 gl::Shader *shaderObject = context->getShader(shader);
2837
2838 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002839 {
Geoff Langb1196682014-07-23 13:47:29 -04002840 context->recordError(gl::Error(GL_INVALID_VALUE));
2841 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002842 }
2843
Geoff Langbfdea662014-07-23 14:16:32 -04002844 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002845 }
2846}
2847
Kenneth Russell67ea1902014-10-06 16:44:50 -07002848void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002849{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002850 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 +00002851 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002852
Geoff Langb1196682014-07-23 13:47:29 -04002853 gl::Context *context = gl::getNonLostContext();
2854 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002855 {
Geoff Langb1196682014-07-23 13:47:29 -04002856 switch (shadertype)
2857 {
2858 case GL_VERTEX_SHADER:
2859 case GL_FRAGMENT_SHADER:
2860 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002861
Geoff Langb1196682014-07-23 13:47:29 -04002862 default:
2863 context->recordError(gl::Error(GL_INVALID_ENUM));
2864 return;
2865 }
2866
2867 switch (precisiontype)
2868 {
2869 case GL_LOW_FLOAT:
2870 case GL_MEDIUM_FLOAT:
2871 case GL_HIGH_FLOAT:
2872 // Assume IEEE 754 precision
2873 range[0] = 127;
2874 range[1] = 127;
2875 *precision = 23;
2876 break;
2877
2878 case GL_LOW_INT:
2879 case GL_MEDIUM_INT:
2880 case GL_HIGH_INT:
2881 // Some (most) hardware only supports single-precision floating-point numbers,
2882 // which can accurately represent integers up to +/-16777216
2883 range[0] = 24;
2884 range[1] = 24;
2885 *precision = 0;
2886 break;
2887
2888 default:
2889 context->recordError(gl::Error(GL_INVALID_ENUM));
2890 return;
2891 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002892 }
2893}
2894
Kenneth Russell67ea1902014-10-06 16:44:50 -07002895void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002896{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002897 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 +00002898 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002899
Geoff Langbfdea662014-07-23 14:16:32 -04002900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002901 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002902 {
Geoff Langb1196682014-07-23 13:47:29 -04002903 if (bufsize < 0)
2904 {
2905 context->recordError(gl::Error(GL_INVALID_VALUE));
2906 return;
2907 }
2908
Geoff Langbfdea662014-07-23 14:16:32 -04002909 gl::Shader *shaderObject = context->getShader(shader);
2910
2911 if (!shaderObject)
2912 {
Geoff Langb1196682014-07-23 13:47:29 -04002913 context->recordError(gl::Error(GL_INVALID_OPERATION));
2914 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002915 }
2916
2917 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002918 }
2919}
2920
Kenneth Russell67ea1902014-10-06 16:44:50 -07002921void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002922{
2923 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2924 shader, bufsize, length, source);
2925
Geoff Langbfdea662014-07-23 14:16:32 -04002926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002927 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002928 {
Geoff Langb1196682014-07-23 13:47:29 -04002929 if (bufsize < 0)
2930 {
2931 context->recordError(gl::Error(GL_INVALID_VALUE));
2932 return;
2933 }
2934
Geoff Langbfdea662014-07-23 14:16:32 -04002935 gl::Shader *shaderObject = context->getShader(shader);
2936
2937 if (!shaderObject)
2938 {
Geoff Langb1196682014-07-23 13:47:29 -04002939 context->recordError(gl::Error(GL_INVALID_OPERATION));
2940 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002941 }
2942
Tibor den Ouden97049c62014-10-06 21:39:16 +02002943 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2944 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002945 }
2946}
2947
Kenneth Russell67ea1902014-10-06 16:44:50 -07002948const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002949{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002950 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002951
Geoff Langbfdea662014-07-23 14:16:32 -04002952 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002953
Geoff Langbfdea662014-07-23 14:16:32 -04002954 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002955 {
Geoff Langbfdea662014-07-23 14:16:32 -04002956 case GL_VENDOR:
2957 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002958
Geoff Langbfdea662014-07-23 14:16:32 -04002959 case GL_RENDERER:
2960 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002961
Geoff Langbfdea662014-07-23 14:16:32 -04002962 case GL_VERSION:
2963 if (context->getClientVersion() == 2)
2964 {
2965 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2966 }
2967 else
2968 {
2969 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2970 }
Geoff Langb1196682014-07-23 13:47:29 -04002971
Geoff Langbfdea662014-07-23 14:16:32 -04002972 case GL_SHADING_LANGUAGE_VERSION:
2973 if (context->getClientVersion() == 2)
2974 {
2975 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2976 }
2977 else
2978 {
2979 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2980 }
Geoff Langb1196682014-07-23 13:47:29 -04002981
Geoff Langbfdea662014-07-23 14:16:32 -04002982 case GL_EXTENSIONS:
2983 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002984
Geoff Langbfdea662014-07-23 14:16:32 -04002985 default:
Geoff Langb1196682014-07-23 13:47:29 -04002986 if (context)
2987 {
2988 context->recordError(gl::Error(GL_INVALID_ENUM));
2989 }
2990 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002991 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002992}
2993
Kenneth Russell67ea1902014-10-06 16:44:50 -07002994void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002995{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002996 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 +00002997
Geoff Langbfdea662014-07-23 14:16:32 -04002998 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002999 if (context)
3000 {
3001 gl::Texture *texture = context->getTargetTexture(target);
3002
3003 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003004 {
Geoff Langb1196682014-07-23 13:47:29 -04003005 context->recordError(gl::Error(GL_INVALID_ENUM));
3006 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003007 }
Geoff Langbfdea662014-07-23 14:16:32 -04003008
3009 switch (pname)
3010 {
3011 case GL_TEXTURE_MAG_FILTER:
3012 *params = (GLfloat)texture->getSamplerState().magFilter;
3013 break;
3014 case GL_TEXTURE_MIN_FILTER:
3015 *params = (GLfloat)texture->getSamplerState().minFilter;
3016 break;
3017 case GL_TEXTURE_WRAP_S:
3018 *params = (GLfloat)texture->getSamplerState().wrapS;
3019 break;
3020 case GL_TEXTURE_WRAP_T:
3021 *params = (GLfloat)texture->getSamplerState().wrapT;
3022 break;
3023 case GL_TEXTURE_WRAP_R:
3024 if (context->getClientVersion() < 3)
3025 {
Geoff Langb1196682014-07-23 13:47:29 -04003026 context->recordError(gl::Error(GL_INVALID_ENUM));
3027 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003028 }
3029 *params = (GLfloat)texture->getSamplerState().wrapR;
3030 break;
3031 case GL_TEXTURE_IMMUTABLE_FORMAT:
3032 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3033 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3034 break;
3035 case GL_TEXTURE_IMMUTABLE_LEVELS:
3036 if (context->getClientVersion() < 3)
3037 {
Geoff Langb1196682014-07-23 13:47:29 -04003038 context->recordError(gl::Error(GL_INVALID_ENUM));
3039 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003040 }
3041 *params = (GLfloat)texture->immutableLevelCount();
3042 break;
3043 case GL_TEXTURE_USAGE_ANGLE:
3044 *params = (GLfloat)texture->getUsage();
3045 break;
3046 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3047 if (!context->getExtensions().textureFilterAnisotropic)
3048 {
Geoff Langb1196682014-07-23 13:47:29 -04003049 context->recordError(gl::Error(GL_INVALID_ENUM));
3050 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003051 }
3052 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3053 break;
3054 case GL_TEXTURE_SWIZZLE_R:
3055 if (context->getClientVersion() < 3)
3056 {
Geoff Langb1196682014-07-23 13:47:29 -04003057 context->recordError(gl::Error(GL_INVALID_ENUM));
3058 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003059 }
3060 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3061 break;
3062 case GL_TEXTURE_SWIZZLE_G:
3063 if (context->getClientVersion() < 3)
3064 {
Geoff Langb1196682014-07-23 13:47:29 -04003065 context->recordError(gl::Error(GL_INVALID_ENUM));
3066 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003067 }
3068 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3069 break;
3070 case GL_TEXTURE_SWIZZLE_B:
3071 if (context->getClientVersion() < 3)
3072 {
Geoff Langb1196682014-07-23 13:47:29 -04003073 context->recordError(gl::Error(GL_INVALID_ENUM));
3074 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003075 }
3076 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3077 break;
3078 case GL_TEXTURE_SWIZZLE_A:
3079 if (context->getClientVersion() < 3)
3080 {
Geoff Langb1196682014-07-23 13:47:29 -04003081 context->recordError(gl::Error(GL_INVALID_ENUM));
3082 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003083 }
3084 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3085 break;
3086 case GL_TEXTURE_BASE_LEVEL:
3087 if (context->getClientVersion() < 3)
3088 {
Geoff Langb1196682014-07-23 13:47:29 -04003089 context->recordError(gl::Error(GL_INVALID_ENUM));
3090 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003091 }
3092 *params = (GLfloat)texture->getSamplerState().baseLevel;
3093 break;
3094 case GL_TEXTURE_MAX_LEVEL:
3095 if (context->getClientVersion() < 3)
3096 {
Geoff Langb1196682014-07-23 13:47:29 -04003097 context->recordError(gl::Error(GL_INVALID_ENUM));
3098 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003099 }
3100 *params = (GLfloat)texture->getSamplerState().maxLevel;
3101 break;
3102 case GL_TEXTURE_MIN_LOD:
3103 if (context->getClientVersion() < 3)
3104 {
Geoff Langb1196682014-07-23 13:47:29 -04003105 context->recordError(gl::Error(GL_INVALID_ENUM));
3106 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003107 }
3108 *params = texture->getSamplerState().minLod;
3109 break;
3110 case GL_TEXTURE_MAX_LOD:
3111 if (context->getClientVersion() < 3)
3112 {
Geoff Langb1196682014-07-23 13:47:29 -04003113 context->recordError(gl::Error(GL_INVALID_ENUM));
3114 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003115 }
3116 *params = texture->getSamplerState().maxLod;
3117 break;
Geoff Langb1196682014-07-23 13:47:29 -04003118
Geoff Langbfdea662014-07-23 14:16:32 -04003119 default:
Geoff Langb1196682014-07-23 13:47:29 -04003120 context->recordError(gl::Error(GL_INVALID_ENUM));
3121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003122 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003123 }
3124}
3125
Kenneth Russell67ea1902014-10-06 16:44:50 -07003126void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003127{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003128 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 +00003129
Geoff Langbfdea662014-07-23 14:16:32 -04003130 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003131 if (context)
3132 {
3133 gl::Texture *texture = context->getTargetTexture(target);
3134
3135 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003136 {
Geoff Langb1196682014-07-23 13:47:29 -04003137 context->recordError(gl::Error(GL_INVALID_ENUM));
3138 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003139 }
Geoff Langbfdea662014-07-23 14:16:32 -04003140
3141 switch (pname)
3142 {
3143 case GL_TEXTURE_MAG_FILTER:
3144 *params = texture->getSamplerState().magFilter;
3145 break;
3146 case GL_TEXTURE_MIN_FILTER:
3147 *params = texture->getSamplerState().minFilter;
3148 break;
3149 case GL_TEXTURE_WRAP_S:
3150 *params = texture->getSamplerState().wrapS;
3151 break;
3152 case GL_TEXTURE_WRAP_T:
3153 *params = texture->getSamplerState().wrapT;
3154 break;
3155 case GL_TEXTURE_WRAP_R:
3156 if (context->getClientVersion() < 3)
3157 {
Geoff Langb1196682014-07-23 13:47:29 -04003158 context->recordError(gl::Error(GL_INVALID_ENUM));
3159 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003160 }
3161 *params = texture->getSamplerState().wrapR;
3162 break;
3163 case GL_TEXTURE_IMMUTABLE_FORMAT:
3164 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3165 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3166 break;
3167 case GL_TEXTURE_IMMUTABLE_LEVELS:
3168 if (context->getClientVersion() < 3)
3169 {
Geoff Langb1196682014-07-23 13:47:29 -04003170 context->recordError(gl::Error(GL_INVALID_ENUM));
3171 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003172 }
Jamie Madill6948e302014-10-20 17:04:33 -04003173 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003174 break;
3175 case GL_TEXTURE_USAGE_ANGLE:
3176 *params = texture->getUsage();
3177 break;
3178 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3179 if (!context->getExtensions().textureFilterAnisotropic)
3180 {
Geoff Langb1196682014-07-23 13:47:29 -04003181 context->recordError(gl::Error(GL_INVALID_ENUM));
3182 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003183 }
3184 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3185 break;
3186 case GL_TEXTURE_SWIZZLE_R:
3187 if (context->getClientVersion() < 3)
3188 {
Geoff Langb1196682014-07-23 13:47:29 -04003189 context->recordError(gl::Error(GL_INVALID_ENUM));
3190 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003191 }
3192 *params = texture->getSamplerState().swizzleRed;
3193 break;
3194 case GL_TEXTURE_SWIZZLE_G:
3195 if (context->getClientVersion() < 3)
3196 {
Geoff Langb1196682014-07-23 13:47:29 -04003197 context->recordError(gl::Error(GL_INVALID_ENUM));
3198 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003199 }
3200 *params = texture->getSamplerState().swizzleGreen;
3201 break;
3202 case GL_TEXTURE_SWIZZLE_B:
3203 if (context->getClientVersion() < 3)
3204 {
Geoff Langb1196682014-07-23 13:47:29 -04003205 context->recordError(gl::Error(GL_INVALID_ENUM));
3206 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003207 }
3208 *params = texture->getSamplerState().swizzleBlue;
3209 break;
3210 case GL_TEXTURE_SWIZZLE_A:
3211 if (context->getClientVersion() < 3)
3212 {
Geoff Langb1196682014-07-23 13:47:29 -04003213 context->recordError(gl::Error(GL_INVALID_ENUM));
3214 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003215 }
3216 *params = texture->getSamplerState().swizzleAlpha;
3217 break;
3218 case GL_TEXTURE_BASE_LEVEL:
3219 if (context->getClientVersion() < 3)
3220 {
Geoff Langb1196682014-07-23 13:47:29 -04003221 context->recordError(gl::Error(GL_INVALID_ENUM));
3222 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003223 }
3224 *params = texture->getSamplerState().baseLevel;
3225 break;
3226 case GL_TEXTURE_MAX_LEVEL:
3227 if (context->getClientVersion() < 3)
3228 {
Geoff Langb1196682014-07-23 13:47:29 -04003229 context->recordError(gl::Error(GL_INVALID_ENUM));
3230 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003231 }
3232 *params = texture->getSamplerState().maxLevel;
3233 break;
3234 case GL_TEXTURE_MIN_LOD:
3235 if (context->getClientVersion() < 3)
3236 {
Geoff Langb1196682014-07-23 13:47:29 -04003237 context->recordError(gl::Error(GL_INVALID_ENUM));
3238 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003239 }
3240 *params = (GLint)texture->getSamplerState().minLod;
3241 break;
3242 case GL_TEXTURE_MAX_LOD:
3243 if (context->getClientVersion() < 3)
3244 {
Geoff Langb1196682014-07-23 13:47:29 -04003245 context->recordError(gl::Error(GL_INVALID_ENUM));
3246 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003247 }
3248 *params = (GLint)texture->getSamplerState().maxLod;
3249 break;
Geoff Langb1196682014-07-23 13:47:29 -04003250
Geoff Langbfdea662014-07-23 14:16:32 -04003251 default:
Geoff Langb1196682014-07-23 13:47:29 -04003252 context->recordError(gl::Error(GL_INVALID_ENUM));
3253 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003254 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003255 }
3256}
3257
Kenneth Russell67ea1902014-10-06 16:44:50 -07003258void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003259{
3260 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3261 program, location, bufSize, params);
3262
Geoff Langbfdea662014-07-23 14:16:32 -04003263 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003264 if (context)
3265 {
Jamie Madill0063c512014-08-25 15:47:53 -04003266 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003267 {
Jamie Madill0063c512014-08-25 15:47:53 -04003268 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003269 }
3270
Jamie Madilla502c742014-08-28 17:19:13 -04003271 gl::Program *programObject = context->getProgram(program);
3272 ASSERT(programObject);
3273 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003274 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003275
Jamie Madill99a1e982014-08-25 15:47:54 -04003276 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003277 }
3278}
3279
Kenneth Russell67ea1902014-10-06 16:44:50 -07003280void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003282 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003283
Geoff Langbfdea662014-07-23 14:16:32 -04003284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003285 if (context)
3286 {
Jamie Madill0063c512014-08-25 15:47:53 -04003287 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003288 {
Jamie Madill0063c512014-08-25 15:47:53 -04003289 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003290 }
Geoff Langbfdea662014-07-23 14:16:32 -04003291
Jamie Madilla502c742014-08-28 17:19:13 -04003292 gl::Program *programObject = context->getProgram(program);
3293 ASSERT(programObject);
3294 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003295 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003296
Jamie Madill99a1e982014-08-25 15:47:54 -04003297 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003298 }
3299}
3300
Kenneth Russell67ea1902014-10-06 16:44:50 -07003301void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003302{
Geoff Langbfdea662014-07-23 14:16:32 -04003303 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003304 program, location, bufSize, params);
3305
Geoff Langbfdea662014-07-23 14:16:32 -04003306 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003307 if (context)
3308 {
Jamie Madill0063c512014-08-25 15:47:53 -04003309 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003310 {
Jamie Madill0063c512014-08-25 15:47:53 -04003311 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003312 }
3313
Jamie Madilla502c742014-08-28 17:19:13 -04003314 gl::Program *programObject = context->getProgram(program);
3315 ASSERT(programObject);
3316 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003317 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003318
Jamie Madill99a1e982014-08-25 15:47:54 -04003319 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003320 }
3321}
3322
Kenneth Russell67ea1902014-10-06 16:44:50 -07003323void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003324{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003325 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003326
Geoff Langbfdea662014-07-23 14:16:32 -04003327 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003328 if (context)
3329 {
Jamie Madill0063c512014-08-25 15:47:53 -04003330 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003331 {
Jamie Madill0063c512014-08-25 15:47:53 -04003332 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003333 }
Geoff Langbfdea662014-07-23 14:16:32 -04003334
Jamie Madilla502c742014-08-28 17:19:13 -04003335 gl::Program *programObject = context->getProgram(program);
3336 ASSERT(programObject);
3337 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003338 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003339
Jamie Madill99a1e982014-08-25 15:47:54 -04003340 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003341 }
3342}
3343
Kenneth Russell67ea1902014-10-06 16:44:50 -07003344GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003345{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003346 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003347
Geoff Langbfdea662014-07-23 14:16:32 -04003348 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003349 if (context)
3350 {
Geoff Langb1196682014-07-23 13:47:29 -04003351 if (strstr(name, "gl_") == name)
3352 {
3353 return -1;
3354 }
3355
Geoff Langbfdea662014-07-23 14:16:32 -04003356 gl::Program *programObject = context->getProgram(program);
3357
3358 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003359 {
Geoff Langbfdea662014-07-23 14:16:32 -04003360 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003361 {
Geoff Langb1196682014-07-23 13:47:29 -04003362 context->recordError(gl::Error(GL_INVALID_OPERATION));
3363 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003364 }
Geoff Langbfdea662014-07-23 14:16:32 -04003365 else
3366 {
Geoff Langb1196682014-07-23 13:47:29 -04003367 context->recordError(gl::Error(GL_INVALID_VALUE));
3368 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003369 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003370 }
Geoff Langbfdea662014-07-23 14:16:32 -04003371
3372 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3373 if (!programObject->isLinked() || !programBinary)
3374 {
Geoff Langb1196682014-07-23 13:47:29 -04003375 context->recordError(gl::Error(GL_INVALID_OPERATION));
3376 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003377 }
3378
3379 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003380 }
3381
3382 return -1;
3383}
3384
Kenneth Russell67ea1902014-10-06 16:44:50 -07003385void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003386{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003387 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003388
Geoff Langbfdea662014-07-23 14:16:32 -04003389 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003390 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003391 {
Geoff Langbfdea662014-07-23 14:16:32 -04003392 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003393 {
Geoff Langb1196682014-07-23 13:47:29 -04003394 context->recordError(gl::Error(GL_INVALID_VALUE));
3395 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003396 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003397
Geoff Langbfdea662014-07-23 14:16:32 -04003398 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003399 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003400 {
3401 return;
3402 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003403
Geoff Langbfdea662014-07-23 14:16:32 -04003404 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3405 {
3406 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3407 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003408 {
Geoff Langbfdea662014-07-23 14:16:32 -04003409 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003410 }
3411 }
Geoff Langbfdea662014-07-23 14:16:32 -04003412 else
3413 {
3414 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3415 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003416 }
3417}
3418
Kenneth Russell67ea1902014-10-06 16:44:50 -07003419void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003420{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003421 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003422
Geoff Langbfdea662014-07-23 14:16:32 -04003423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003424 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003425 {
Geoff Langbfdea662014-07-23 14:16:32 -04003426 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003427 {
Geoff Langb1196682014-07-23 13:47:29 -04003428 context->recordError(gl::Error(GL_INVALID_VALUE));
3429 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003430 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003431
Geoff Langbfdea662014-07-23 14:16:32 -04003432 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003433
Geoff Langb1196682014-07-23 13:47:29 -04003434 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003435 {
3436 return;
3437 }
Jamie Madillaff71502013-07-02 11:57:05 -04003438
Geoff Langbfdea662014-07-23 14:16:32 -04003439 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3440 {
3441 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3442 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003443 {
Geoff Langbfdea662014-07-23 14:16:32 -04003444 float currentValue = currentValueData.FloatValues[i];
3445 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003446 }
3447 }
Geoff Langbfdea662014-07-23 14:16:32 -04003448 else
3449 {
3450 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3451 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003452 }
3453}
3454
Kenneth Russell67ea1902014-10-06 16:44:50 -07003455void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003457 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003458
Geoff Langbfdea662014-07-23 14:16:32 -04003459 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003460 if (context)
3461 {
3462 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003463 {
Geoff Langb1196682014-07-23 13:47:29 -04003464 context->recordError(gl::Error(GL_INVALID_VALUE));
3465 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003466 }
Geoff Langbfdea662014-07-23 14:16:32 -04003467
3468 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3469 {
Geoff Langb1196682014-07-23 13:47:29 -04003470 context->recordError(gl::Error(GL_INVALID_ENUM));
3471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003472 }
3473
3474 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003475 }
3476}
3477
Kenneth Russell67ea1902014-10-06 16:44:50 -07003478void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003479{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003480 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003481
Geoff Langbfdea662014-07-23 14:16:32 -04003482 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003483 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003484 {
Geoff Langb1196682014-07-23 13:47:29 -04003485 switch (mode)
3486 {
3487 case GL_FASTEST:
3488 case GL_NICEST:
3489 case GL_DONT_CARE:
3490 break;
3491
3492 default:
3493 context->recordError(gl::Error(GL_INVALID_ENUM));
3494 return;
3495 }
3496
3497 switch (target)
3498 {
3499 case GL_GENERATE_MIPMAP_HINT:
3500 context->getState().setGenerateMipmapHint(mode);
3501 break;
3502
3503 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3504 context->getState().setFragmentShaderDerivativeHint(mode);
3505 break;
3506
3507 default:
3508 context->recordError(gl::Error(GL_INVALID_ENUM));
3509 return;
3510 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003511 }
3512}
3513
Kenneth Russell67ea1902014-10-06 16:44:50 -07003514GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003515{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003516 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003517
Geoff Langbfdea662014-07-23 14:16:32 -04003518 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003519 if (context && buffer)
3520 {
3521 gl::Buffer *bufferObject = context->getBuffer(buffer);
3522
3523 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003524 {
Geoff Langbfdea662014-07-23 14:16:32 -04003525 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003526 }
3527 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003528
3529 return GL_FALSE;
3530}
3531
Kenneth Russell67ea1902014-10-06 16:44:50 -07003532GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003533{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003534 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003535
Geoff Langbfdea662014-07-23 14:16:32 -04003536 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003537 if (context)
3538 {
3539 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003540 {
Geoff Langb1196682014-07-23 13:47:29 -04003541 context->recordError(gl::Error(GL_INVALID_ENUM));
3542 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003543 }
Geoff Langbfdea662014-07-23 14:16:32 -04003544
3545 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003546 }
3547
3548 return false;
3549}
3550
Kenneth Russell67ea1902014-10-06 16:44:50 -07003551GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003552{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003553 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003554
Geoff Langbfdea662014-07-23 14:16:32 -04003555 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003556 if (context)
3557 {
3558 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3559
3560 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003561 {
Geoff Langbfdea662014-07-23 14:16:32 -04003562 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003563 }
Geoff Langbfdea662014-07-23 14:16:32 -04003564
3565 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003566 }
3567
3568 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003569}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003570
Kenneth Russell67ea1902014-10-06 16:44:50 -07003571GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003572{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003573 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003574
Geoff Langbfdea662014-07-23 14:16:32 -04003575 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003576 if (context && framebuffer)
3577 {
3578 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3579
3580 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003581 {
Geoff Langbfdea662014-07-23 14:16:32 -04003582 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003583 }
3584 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585
3586 return GL_FALSE;
3587}
3588
Kenneth Russell67ea1902014-10-06 16:44:50 -07003589GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003590{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003591 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003592
Geoff Langbfdea662014-07-23 14:16:32 -04003593 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003594 if (context && program)
3595 {
3596 gl::Program *programObject = context->getProgram(program);
3597
3598 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003599 {
Geoff Langbfdea662014-07-23 14:16:32 -04003600 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003601 }
3602 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003603
3604 return GL_FALSE;
3605}
3606
Kenneth Russell67ea1902014-10-06 16:44:50 -07003607GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003608{
3609 EVENT("(GLuint id = %d)", id);
3610
Geoff Langbfdea662014-07-23 14:16:32 -04003611 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003612 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003613 {
Geoff Langbfdea662014-07-23 14:16:32 -04003614 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003615 }
3616
3617 return GL_FALSE;
3618}
3619
Kenneth Russell67ea1902014-10-06 16:44:50 -07003620GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003621{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003622 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003623
Geoff Langbfdea662014-07-23 14:16:32 -04003624 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003625 if (context && renderbuffer)
3626 {
3627 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3628
3629 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003630 {
Geoff Langbfdea662014-07-23 14:16:32 -04003631 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003632 }
3633 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003634
3635 return GL_FALSE;
3636}
3637
Kenneth Russell67ea1902014-10-06 16:44:50 -07003638GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003639{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003640 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003641
Geoff Langbfdea662014-07-23 14:16:32 -04003642 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003643 if (context && shader)
3644 {
3645 gl::Shader *shaderObject = context->getShader(shader);
3646
3647 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003648 {
Geoff Langbfdea662014-07-23 14:16:32 -04003649 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003650 }
3651 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003652
3653 return GL_FALSE;
3654}
3655
Kenneth Russell67ea1902014-10-06 16:44:50 -07003656GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003657{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003658 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003659
Geoff Langbfdea662014-07-23 14:16:32 -04003660 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003661 if (context && texture)
3662 {
3663 gl::Texture *textureObject = context->getTexture(texture);
3664
3665 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003666 {
Geoff Langbfdea662014-07-23 14:16:32 -04003667 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003668 }
3669 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670
3671 return GL_FALSE;
3672}
3673
Kenneth Russell67ea1902014-10-06 16:44:50 -07003674void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003676 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003677
Geoff Langbfdea662014-07-23 14:16:32 -04003678 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003679 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003680 {
Geoff Langb1196682014-07-23 13:47:29 -04003681 if (width <= 0.0f)
3682 {
3683 context->recordError(gl::Error(GL_INVALID_VALUE));
3684 return;
3685 }
3686
Geoff Langbfdea662014-07-23 14:16:32 -04003687 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003688 }
3689}
3690
Kenneth Russell67ea1902014-10-06 16:44:50 -07003691void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003692{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003693 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003694
Geoff Langbfdea662014-07-23 14:16:32 -04003695 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003696 if (context)
3697 {
3698 gl::Program *programObject = context->getProgram(program);
3699
3700 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003701 {
Geoff Langbfdea662014-07-23 14:16:32 -04003702 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003703 {
Geoff Langb1196682014-07-23 13:47:29 -04003704 context->recordError(gl::Error(GL_INVALID_OPERATION));
3705 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003706 }
Geoff Langbfdea662014-07-23 14:16:32 -04003707 else
3708 {
Geoff Langb1196682014-07-23 13:47:29 -04003709 context->recordError(gl::Error(GL_INVALID_VALUE));
3710 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003711 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003712 }
Geoff Langbfdea662014-07-23 14:16:32 -04003713
Geoff Langb543aff2014-09-30 14:52:54 -04003714 gl::Error error = context->linkProgram(program);
3715 if (error.isError())
3716 {
3717 context->recordError(error);
3718 return;
3719 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003720 }
3721}
3722
Kenneth Russell67ea1902014-10-06 16:44:50 -07003723void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003725 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003726
Geoff Langbfdea662014-07-23 14:16:32 -04003727 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003728 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003729 {
Geoff Langbfdea662014-07-23 14:16:32 -04003730 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003731 {
Geoff Langbfdea662014-07-23 14:16:32 -04003732 case GL_UNPACK_ALIGNMENT:
3733 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003734 {
Geoff Langb1196682014-07-23 13:47:29 -04003735 context->recordError(gl::Error(GL_INVALID_VALUE));
3736 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003737 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003738
Geoff Langbfdea662014-07-23 14:16:32 -04003739 context->getState().setUnpackAlignment(param);
3740 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003741
Geoff Langbfdea662014-07-23 14:16:32 -04003742 case GL_PACK_ALIGNMENT:
3743 if (param != 1 && param != 2 && param != 4 && param != 8)
3744 {
Geoff Langb1196682014-07-23 13:47:29 -04003745 context->recordError(gl::Error(GL_INVALID_VALUE));
3746 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003747 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003748
Geoff Langbfdea662014-07-23 14:16:32 -04003749 context->getState().setPackAlignment(param);
3750 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003751
Geoff Langbfdea662014-07-23 14:16:32 -04003752 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3753 context->getState().setPackReverseRowOrder(param != 0);
3754 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003755
Geoff Langbfdea662014-07-23 14:16:32 -04003756 case GL_UNPACK_IMAGE_HEIGHT:
3757 case GL_UNPACK_SKIP_IMAGES:
3758 case GL_UNPACK_ROW_LENGTH:
3759 case GL_UNPACK_SKIP_ROWS:
3760 case GL_UNPACK_SKIP_PIXELS:
3761 case GL_PACK_ROW_LENGTH:
3762 case GL_PACK_SKIP_ROWS:
3763 case GL_PACK_SKIP_PIXELS:
3764 if (context->getClientVersion() < 3)
3765 {
Geoff Langb1196682014-07-23 13:47:29 -04003766 context->recordError(gl::Error(GL_INVALID_ENUM));
3767 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003768 }
Geoff Langbfdea662014-07-23 14:16:32 -04003769 UNIMPLEMENTED();
3770 break;
3771
3772 default:
Geoff Langb1196682014-07-23 13:47:29 -04003773 context->recordError(gl::Error(GL_INVALID_ENUM));
3774 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003775 }
3776 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003777}
3778
Kenneth Russell67ea1902014-10-06 16:44:50 -07003779void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003780{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003781 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003782
Geoff Langbfdea662014-07-23 14:16:32 -04003783 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003784 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003785 {
Geoff Langbfdea662014-07-23 14:16:32 -04003786 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003787 }
3788}
3789
Kenneth Russell67ea1902014-10-06 16:44:50 -07003790void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003791 GLenum format, GLenum type, GLsizei bufSize,
3792 GLvoid *data)
3793{
3794 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3795 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3796 x, y, width, height, format, type, bufSize, data);
3797
Geoff Langbfdea662014-07-23 14:16:32 -04003798 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003799 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003800 {
Geoff Langb1196682014-07-23 13:47:29 -04003801 if (width < 0 || height < 0 || bufSize < 0)
3802 {
3803 context->recordError(gl::Error(GL_INVALID_VALUE));
3804 return;
3805 }
3806
Geoff Langbfdea662014-07-23 14:16:32 -04003807 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3808 format, type, &bufSize, data))
3809 {
3810 return;
3811 }
3812
Geoff Lang63d2fc72014-07-25 14:51:41 -04003813 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3814 if (error.isError())
3815 {
3816 context->recordError(error);
3817 return;
3818 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003819 }
3820}
3821
Kenneth Russell67ea1902014-10-06 16:44:50 -07003822void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003823 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003824{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003825 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003826 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003827 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828
Geoff Langbfdea662014-07-23 14:16:32 -04003829 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003830 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003831 {
Geoff Langb1196682014-07-23 13:47:29 -04003832 if (width < 0 || height < 0)
3833 {
3834 context->recordError(gl::Error(GL_INVALID_VALUE));
3835 return;
3836 }
3837
Geoff Langbfdea662014-07-23 14:16:32 -04003838 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3839 format, type, NULL, pixels))
3840 {
3841 return;
3842 }
3843
Geoff Lang63d2fc72014-07-25 14:51:41 -04003844 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3845 if (error.isError())
3846 {
3847 context->recordError(error);
3848 return;
3849 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850 }
3851}
3852
Kenneth Russell67ea1902014-10-06 16:44:50 -07003853void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003854{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003855 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003856
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003857 gl::Context *context = gl::getNonLostContext();
3858
3859 if (context)
3860 {
3861 context->releaseShaderCompiler();
3862 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003863}
3864
Kenneth Russell67ea1902014-10-06 16:44:50 -07003865void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003866{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003867 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 +00003868 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003869
Geoff Langbfdea662014-07-23 14:16:32 -04003870 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003871 if (context)
3872 {
3873 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3874 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003875 {
Geoff Langbfdea662014-07-23 14:16:32 -04003876 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003877 }
Geoff Langbfdea662014-07-23 14:16:32 -04003878
Shannon Woodse2632d22014-10-17 13:08:51 -04003879 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
3880 renderbuffer->setStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003881 }
3882}
3883
Kenneth Russell67ea1902014-10-06 16:44:50 -07003884void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003885{
3886 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3887}
3888
Kenneth Russell67ea1902014-10-06 16:44:50 -07003889void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003890{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003891 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003892
Geoff Langbfdea662014-07-23 14:16:32 -04003893 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003894
Geoff Langbfdea662014-07-23 14:16:32 -04003895 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003896 {
Geoff Langbfdea662014-07-23 14:16:32 -04003897 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003898 }
3899}
3900
Kenneth Russell67ea1902014-10-06 16:44:50 -07003901void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003902{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003903 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003904
Geoff Langbfdea662014-07-23 14:16:32 -04003905 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003906 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003907 {
Geoff Langb1196682014-07-23 13:47:29 -04003908 if (condition != GL_ALL_COMPLETED_NV)
3909 {
3910 context->recordError(gl::Error(GL_INVALID_ENUM));
3911 return;
3912 }
3913
Geoff Langbfdea662014-07-23 14:16:32 -04003914 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3915
3916 if (fenceObject == NULL)
3917 {
Geoff Langb1196682014-07-23 13:47:29 -04003918 context->recordError(gl::Error(GL_INVALID_OPERATION));
3919 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003920 }
3921
Geoff Lang882033e2014-09-30 11:26:07 -04003922 gl::Error error = fenceObject->setFence(condition);
3923 if (error.isError())
3924 {
3925 context->recordError(error);
3926 return;
3927 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003928 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003929}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003930
Kenneth Russell67ea1902014-10-06 16:44:50 -07003931void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003932{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003933 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 +00003934
Geoff Langbfdea662014-07-23 14:16:32 -04003935 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003936 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003937 {
Geoff Langb1196682014-07-23 13:47:29 -04003938 if (width < 0 || height < 0)
3939 {
3940 context->recordError(gl::Error(GL_INVALID_VALUE));
3941 return;
3942 }
3943
Geoff Langbfdea662014-07-23 14:16:32 -04003944 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003945 }
3946}
3947
Kenneth Russell67ea1902014-10-06 16:44:50 -07003948void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003949{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003950 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003951 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003952 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953
Geoff Lang900013c2014-07-07 11:32:19 -04003954 gl::Context* context = gl::getNonLostContext();
3955 if (context)
3956 {
3957 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3958 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3959 {
Geoff Langb1196682014-07-23 13:47:29 -04003960 context->recordError(gl::Error(GL_INVALID_ENUM));
3961 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003962 }
3963
3964 // No binary shader formats are supported.
3965 UNIMPLEMENTED();
3966 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003967}
3968
Kenneth Russell67ea1902014-10-06 16:44:50 -07003969void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003970{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003971 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 +00003972 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003973
Geoff Langbfdea662014-07-23 14:16:32 -04003974 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003975 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003976 {
Geoff Langb1196682014-07-23 13:47:29 -04003977 if (count < 0)
3978 {
3979 context->recordError(gl::Error(GL_INVALID_VALUE));
3980 return;
3981 }
3982
Geoff Langbfdea662014-07-23 14:16:32 -04003983 gl::Shader *shaderObject = context->getShader(shader);
3984
3985 if (!shaderObject)
3986 {
3987 if (context->getProgram(shader))
3988 {
Geoff Langb1196682014-07-23 13:47:29 -04003989 context->recordError(gl::Error(GL_INVALID_OPERATION));
3990 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003991 }
3992 else
3993 {
Geoff Langb1196682014-07-23 13:47:29 -04003994 context->recordError(gl::Error(GL_INVALID_VALUE));
3995 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003996 }
3997 }
3998
3999 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004000 }
4001}
4002
Kenneth Russell67ea1902014-10-06 16:44:50 -07004003void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004004{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004005 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004006}
4007
Kenneth Russell67ea1902014-10-06 16:44:50 -07004008void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004009{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004010 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 +00004011
Geoff Langbfdea662014-07-23 14:16:32 -04004012 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004013 if (context)
4014 {
Geoff Langb1196682014-07-23 13:47:29 -04004015 switch (face)
4016 {
4017 case GL_FRONT:
4018 case GL_BACK:
4019 case GL_FRONT_AND_BACK:
4020 break;
4021
4022 default:
4023 context->recordError(gl::Error(GL_INVALID_ENUM));
4024 return;
4025 }
4026
4027 switch (func)
4028 {
4029 case GL_NEVER:
4030 case GL_ALWAYS:
4031 case GL_LESS:
4032 case GL_LEQUAL:
4033 case GL_EQUAL:
4034 case GL_GEQUAL:
4035 case GL_GREATER:
4036 case GL_NOTEQUAL:
4037 break;
4038
4039 default:
4040 context->recordError(gl::Error(GL_INVALID_ENUM));
4041 return;
4042 }
4043
Geoff Langbfdea662014-07-23 14:16:32 -04004044 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4045 {
4046 context->getState().setStencilParams(func, ref, mask);
4047 }
4048
4049 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4050 {
4051 context->getState().setStencilBackParams(func, ref, mask);
4052 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004053 }
4054}
4055
Kenneth Russell67ea1902014-10-06 16:44:50 -07004056void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004057{
4058 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4059}
4060
Kenneth Russell67ea1902014-10-06 16:44:50 -07004061void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004062{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004063 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004064
Geoff Langbfdea662014-07-23 14:16:32 -04004065 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004066 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004067 {
Geoff Langb1196682014-07-23 13:47:29 -04004068 switch (face)
4069 {
4070 case GL_FRONT:
4071 case GL_BACK:
4072 case GL_FRONT_AND_BACK:
4073 break;
4074
4075 default:
4076 context->recordError(gl::Error(GL_INVALID_ENUM));
4077 return;
4078 }
4079
Geoff Langbfdea662014-07-23 14:16:32 -04004080 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4081 {
4082 context->getState().setStencilWritemask(mask);
4083 }
4084
4085 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4086 {
4087 context->getState().setStencilBackWritemask(mask);
4088 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004089 }
4090}
4091
Kenneth Russell67ea1902014-10-06 16:44:50 -07004092void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004093{
4094 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4095}
4096
Kenneth Russell67ea1902014-10-06 16:44:50 -07004097void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004098{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004099 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 +00004100 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004101
Geoff Langbfdea662014-07-23 14:16:32 -04004102 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004103 if (context)
4104 {
Geoff Langb1196682014-07-23 13:47:29 -04004105 switch (face)
4106 {
4107 case GL_FRONT:
4108 case GL_BACK:
4109 case GL_FRONT_AND_BACK:
4110 break;
4111
4112 default:
4113 context->recordError(gl::Error(GL_INVALID_ENUM));
4114 return;
4115 }
4116
4117 switch (fail)
4118 {
4119 case GL_ZERO:
4120 case GL_KEEP:
4121 case GL_REPLACE:
4122 case GL_INCR:
4123 case GL_DECR:
4124 case GL_INVERT:
4125 case GL_INCR_WRAP:
4126 case GL_DECR_WRAP:
4127 break;
4128
4129 default:
4130 context->recordError(gl::Error(GL_INVALID_ENUM));
4131 return;
4132 }
4133
4134 switch (zfail)
4135 {
4136 case GL_ZERO:
4137 case GL_KEEP:
4138 case GL_REPLACE:
4139 case GL_INCR:
4140 case GL_DECR:
4141 case GL_INVERT:
4142 case GL_INCR_WRAP:
4143 case GL_DECR_WRAP:
4144 break;
4145
4146 default:
4147 context->recordError(gl::Error(GL_INVALID_ENUM));
4148 return;
4149 }
4150
4151 switch (zpass)
4152 {
4153 case GL_ZERO:
4154 case GL_KEEP:
4155 case GL_REPLACE:
4156 case GL_INCR:
4157 case GL_DECR:
4158 case GL_INVERT:
4159 case GL_INCR_WRAP:
4160 case GL_DECR_WRAP:
4161 break;
4162
4163 default:
4164 context->recordError(gl::Error(GL_INVALID_ENUM));
4165 return;
4166 }
4167
Geoff Langbfdea662014-07-23 14:16:32 -04004168 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4169 {
4170 context->getState().setStencilOperations(fail, zfail, zpass);
4171 }
4172
4173 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4174 {
4175 context->getState().setStencilBackOperations(fail, zfail, zpass);
4176 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004177 }
4178}
4179
Kenneth Russell67ea1902014-10-06 16:44:50 -07004180GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004181{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004182 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004183
Geoff Langbfdea662014-07-23 14:16:32 -04004184 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004185 if (context)
4186 {
4187 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4188
4189 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004190 {
Geoff Langb1196682014-07-23 13:47:29 -04004191 context->recordError(gl::Error(GL_INVALID_OPERATION));
4192 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004193 }
Geoff Langbfdea662014-07-23 14:16:32 -04004194
4195 if (fenceObject->isFence() != GL_TRUE)
4196 {
Geoff Langb1196682014-07-23 13:47:29 -04004197 context->recordError(gl::Error(GL_INVALID_OPERATION));
4198 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004199 }
4200
Geoff Lang882033e2014-09-30 11:26:07 -04004201 GLboolean result;
4202 gl::Error error = fenceObject->testFence(&result);
4203 if (error.isError())
4204 {
4205 context->recordError(error);
4206 return GL_TRUE;
4207 }
4208
4209 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004210 }
Geoff Langbfdea662014-07-23 14:16:32 -04004211
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004212 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004213}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004214
Kenneth Russell67ea1902014-10-06 16:44:50 -07004215void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004216 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004217{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004218 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004219 "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 +00004220 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004221
Geoff Langbfdea662014-07-23 14:16:32 -04004222 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004223 if (context)
4224 {
4225 if (context->getClientVersion() < 3 &&
4226 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4227 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004228 {
Geoff Langbfdea662014-07-23 14:16:32 -04004229 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004230 }
Geoff Langbfdea662014-07-23 14:16:32 -04004231
4232 if (context->getClientVersion() >= 3 &&
4233 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4234 0, 0, 0, width, height, 1, border, format, type, pixels))
4235 {
4236 return;
4237 }
4238
4239 switch (target)
4240 {
4241 case GL_TEXTURE_2D:
4242 {
4243 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004244 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4245 if (error.isError())
4246 {
4247 context->recordError(error);
4248 return;
4249 }
Geoff Langbfdea662014-07-23 14:16:32 -04004250 }
4251 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004252
Geoff Langbfdea662014-07-23 14:16:32 -04004253 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004254 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004255 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004256 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004257 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004258 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4259 {
4260 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004261 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004262 if (error.isError())
4263 {
4264 context->recordError(error);
4265 return;
4266 }
Geoff Langbfdea662014-07-23 14:16:32 -04004267 }
4268 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004269
Geoff Langbfdea662014-07-23 14:16:32 -04004270 default: UNREACHABLE();
4271 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004272 }
4273}
4274
Kenneth Russell67ea1902014-10-06 16:44:50 -07004275void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004276{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004277 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4278
Geoff Langbfdea662014-07-23 14:16:32 -04004279 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004280 if (context)
4281 {
4282 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004283 {
Geoff Langbfdea662014-07-23 14:16:32 -04004284 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004285 }
Geoff Langbfdea662014-07-23 14:16:32 -04004286
4287 gl::Texture *texture = context->getTargetTexture(target);
4288
4289 if (!texture)
4290 {
Geoff Langb1196682014-07-23 13:47:29 -04004291 context->recordError(gl::Error(GL_INVALID_ENUM));
4292 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004293 }
4294
4295 switch (pname)
4296 {
4297 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4298 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4299 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4300 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4301 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4302 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4303 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4304 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4305 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4306 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4307 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4308 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4309 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4310 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4311 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4312 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4313 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4314 default: UNREACHABLE(); break;
4315 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004317}
4318
Kenneth Russell67ea1902014-10-06 16:44:50 -07004319void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004320{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004321 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004322}
4323
Kenneth Russell67ea1902014-10-06 16:44:50 -07004324void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004325{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004326 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004327
Geoff Langbfdea662014-07-23 14:16:32 -04004328 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004329 if (context)
4330 {
4331 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004332 {
Geoff Langbfdea662014-07-23 14:16:32 -04004333 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004334 }
Geoff Langbfdea662014-07-23 14:16:32 -04004335
4336 gl::Texture *texture = context->getTargetTexture(target);
4337
4338 if (!texture)
4339 {
Geoff Langb1196682014-07-23 13:47:29 -04004340 context->recordError(gl::Error(GL_INVALID_ENUM));
4341 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004342 }
4343
4344 switch (pname)
4345 {
4346 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4347 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4348 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4349 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4350 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4351 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4352 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4353 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4354 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4355 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4356 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4357 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4358 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4359 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4360 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4361 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4362 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4363 default: UNREACHABLE(); break;
4364 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004365 }
4366}
4367
Kenneth Russell67ea1902014-10-06 16:44:50 -07004368void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004369{
4370 glTexParameteri(target, pname, *params);
4371}
4372
Kenneth Russell67ea1902014-10-06 16:44:50 -07004373void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004374{
4375 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4376 target, levels, internalformat, width, height);
4377
Geoff Langbfdea662014-07-23 14:16:32 -04004378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004379 if (context)
4380 {
4381 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004382 {
Geoff Langb1196682014-07-23 13:47:29 -04004383 context->recordError(gl::Error(GL_INVALID_OPERATION));
4384 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004385 }
Geoff Langbfdea662014-07-23 14:16:32 -04004386
4387 if (context->getClientVersion() < 3 &&
4388 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4389 {
4390 return;
4391 }
4392
4393 if (context->getClientVersion() >= 3 &&
4394 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4395 {
4396 return;
4397 }
4398
4399 switch (target)
4400 {
4401 case GL_TEXTURE_2D:
4402 {
4403 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004404 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4405 if (error.isError())
4406 {
4407 context->recordError(error);
4408 return;
4409 }
Geoff Langbfdea662014-07-23 14:16:32 -04004410 }
4411 break;
4412
4413 case GL_TEXTURE_CUBE_MAP:
4414 {
4415 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004416 gl::Error error = textureCube->storage(levels, internalformat, width);
4417 if (error.isError())
4418 {
4419 context->recordError(error);
4420 return;
4421 }
Geoff Langbfdea662014-07-23 14:16:32 -04004422 }
4423 break;
4424
4425 default:
Geoff Langb1196682014-07-23 13:47:29 -04004426 context->recordError(gl::Error(GL_INVALID_ENUM));
4427 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004428 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004429 }
4430}
4431
Kenneth Russell67ea1902014-10-06 16:44:50 -07004432void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004433 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004434{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004435 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004436 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004437 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004438 target, level, xoffset, yoffset, width, height, format, type, pixels);
4439
Geoff Langbfdea662014-07-23 14:16:32 -04004440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004441 if (context)
4442 {
4443 if (context->getClientVersion() < 3 &&
4444 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4445 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004446 {
Geoff Langbfdea662014-07-23 14:16:32 -04004447 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004448 }
Geoff Langbfdea662014-07-23 14:16:32 -04004449
4450 if (context->getClientVersion() >= 3 &&
4451 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4452 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4453 {
4454 return;
4455 }
4456
4457 // Zero sized uploads are valid but no-ops
4458 if (width == 0 || height == 0)
4459 {
4460 return;
4461 }
4462
4463 switch (target)
4464 {
4465 case GL_TEXTURE_2D:
4466 {
4467 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004468 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4469 if (error.isError())
4470 {
4471 context->recordError(error);
4472 return;
4473 }
Geoff Langbfdea662014-07-23 14:16:32 -04004474 }
4475 break;
4476
4477 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4478 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4479 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4480 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4481 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4482 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4483 {
4484 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004485 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4486 if (error.isError())
4487 {
4488 context->recordError(error);
4489 return;
4490 }
Geoff Langbfdea662014-07-23 14:16:32 -04004491 }
4492 break;
4493
4494 default:
4495 UNREACHABLE();
4496 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004497 }
4498}
4499
Kenneth Russell67ea1902014-10-06 16:44:50 -07004500void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501{
4502 glUniform1fv(location, 1, &x);
4503}
4504
Kenneth Russell67ea1902014-10-06 16:44:50 -07004505void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004506{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004507 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004508
Geoff Langbfdea662014-07-23 14:16:32 -04004509 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004510 if (context)
4511 {
4512 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004513 {
Geoff Langbfdea662014-07-23 14:16:32 -04004514 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004515 }
Geoff Langbfdea662014-07-23 14:16:32 -04004516
4517 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4518 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004519 }
4520}
4521
Kenneth Russell67ea1902014-10-06 16:44:50 -07004522void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523{
4524 glUniform1iv(location, 1, &x);
4525}
4526
Kenneth Russell67ea1902014-10-06 16:44:50 -07004527void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004529 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004530
Geoff Langbfdea662014-07-23 14:16:32 -04004531 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004532 if (context)
4533 {
4534 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004535 {
Geoff Langbfdea662014-07-23 14:16:32 -04004536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004537 }
Geoff Langbfdea662014-07-23 14:16:32 -04004538
4539 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4540 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004541 }
4542}
4543
Kenneth Russell67ea1902014-10-06 16:44:50 -07004544void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545{
4546 GLfloat xy[2] = {x, y};
4547
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004548 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004549}
4550
Kenneth Russell67ea1902014-10-06 16:44:50 -07004551void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004552{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004553 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004554
Geoff Langbfdea662014-07-23 14:16:32 -04004555 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004556 if (context)
4557 {
4558 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559 {
Geoff Langbfdea662014-07-23 14:16:32 -04004560 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004561 }
Geoff Langbfdea662014-07-23 14:16:32 -04004562
4563 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4564 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004565 }
4566}
4567
Kenneth Russell67ea1902014-10-06 16:44:50 -07004568void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004569{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004570 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004571
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004572 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004573}
4574
Kenneth Russell67ea1902014-10-06 16:44:50 -07004575void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004576{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004577 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004578
Geoff Langbfdea662014-07-23 14:16:32 -04004579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004580 if (context)
4581 {
4582 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004583 {
Geoff Langbfdea662014-07-23 14:16:32 -04004584 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004585 }
Geoff Langbfdea662014-07-23 14:16:32 -04004586
4587 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4588 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004589 }
4590}
4591
Kenneth Russell67ea1902014-10-06 16:44:50 -07004592void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593{
4594 GLfloat xyz[3] = {x, y, z};
4595
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004596 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004597}
4598
Kenneth Russell67ea1902014-10-06 16:44:50 -07004599void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004600{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004601 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004602
Geoff Langbfdea662014-07-23 14:16:32 -04004603 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004604 if (context)
4605 {
4606 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004607 {
Geoff Langbfdea662014-07-23 14:16:32 -04004608 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609 }
Geoff Langbfdea662014-07-23 14:16:32 -04004610
4611 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4612 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004613 }
4614}
4615
Kenneth Russell67ea1902014-10-06 16:44:50 -07004616void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004617{
4618 GLint xyz[3] = {x, y, z};
4619
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004620 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004621}
4622
Kenneth Russell67ea1902014-10-06 16:44:50 -07004623void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004624{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004625 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004626
Geoff Langbfdea662014-07-23 14:16:32 -04004627 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004628 if (context)
4629 {
4630 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004631 {
Geoff Langbfdea662014-07-23 14:16:32 -04004632 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004633 }
Geoff Langbfdea662014-07-23 14:16:32 -04004634
4635 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4636 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004637 }
4638}
4639
Kenneth Russell67ea1902014-10-06 16:44:50 -07004640void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641{
4642 GLfloat xyzw[4] = {x, y, z, w};
4643
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004644 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004645}
4646
Kenneth Russell67ea1902014-10-06 16:44:50 -07004647void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004648{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004649 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004650
Geoff Langbfdea662014-07-23 14:16:32 -04004651 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004652 if (context)
4653 {
4654 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655 {
Geoff Langbfdea662014-07-23 14:16:32 -04004656 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004657 }
Geoff Langbfdea662014-07-23 14:16:32 -04004658
4659 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4660 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004661 }
4662}
4663
Kenneth Russell67ea1902014-10-06 16:44:50 -07004664void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004665{
4666 GLint xyzw[4] = {x, y, z, w};
4667
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004668 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004669}
4670
Kenneth Russell67ea1902014-10-06 16:44:50 -07004671void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004672{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004673 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004674
Geoff Langbfdea662014-07-23 14:16:32 -04004675 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004676 if (context)
4677 {
4678 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004679 {
Geoff Langbfdea662014-07-23 14:16:32 -04004680 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004681 }
Geoff Langbfdea662014-07-23 14:16:32 -04004682
4683 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4684 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004685 }
4686}
4687
Kenneth Russell67ea1902014-10-06 16:44:50 -07004688void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004689{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004690 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004691 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004692
Geoff Langbfdea662014-07-23 14:16:32 -04004693 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004694 if (context)
4695 {
4696 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004697 {
Geoff Langbfdea662014-07-23 14:16:32 -04004698 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004699 }
Geoff Langbfdea662014-07-23 14:16:32 -04004700
4701 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4702 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703 }
4704}
4705
Kenneth Russell67ea1902014-10-06 16:44:50 -07004706void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004707{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004708 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004709 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004710
Geoff Langbfdea662014-07-23 14:16:32 -04004711 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004712 if (context)
4713 {
4714 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004715 {
Geoff Langbfdea662014-07-23 14:16:32 -04004716 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004717 }
Geoff Langbfdea662014-07-23 14:16:32 -04004718
4719 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4720 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721 }
4722}
4723
Kenneth Russell67ea1902014-10-06 16:44:50 -07004724void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004725{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004726 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004727 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004728
Geoff Langbfdea662014-07-23 14:16:32 -04004729 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004730 if (context)
4731 {
4732 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004733 {
Geoff Langbfdea662014-07-23 14:16:32 -04004734 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004735 }
Geoff Langbfdea662014-07-23 14:16:32 -04004736
4737 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4738 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004739 }
4740}
4741
Kenneth Russell67ea1902014-10-06 16:44:50 -07004742void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004743{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004744 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004745
Geoff Langbfdea662014-07-23 14:16:32 -04004746 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004747 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004748 {
Geoff Langbfdea662014-07-23 14:16:32 -04004749 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004750
Geoff Langbfdea662014-07-23 14:16:32 -04004751 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004752 {
Geoff Langbfdea662014-07-23 14:16:32 -04004753 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754 {
Geoff Langb1196682014-07-23 13:47:29 -04004755 context->recordError(gl::Error(GL_INVALID_OPERATION));
4756 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004757 }
Geoff Langbfdea662014-07-23 14:16:32 -04004758 else
4759 {
Geoff Langb1196682014-07-23 13:47:29 -04004760 context->recordError(gl::Error(GL_INVALID_VALUE));
4761 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004762 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004763 }
Geoff Langbfdea662014-07-23 14:16:32 -04004764
4765 if (program != 0 && !programObject->isLinked())
4766 {
Geoff Langb1196682014-07-23 13:47:29 -04004767 context->recordError(gl::Error(GL_INVALID_OPERATION));
4768 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004769 }
4770
4771 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004772 }
4773}
4774
Kenneth Russell67ea1902014-10-06 16:44:50 -07004775void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004776{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004777 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004778
Geoff Langbfdea662014-07-23 14:16:32 -04004779 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004780 if (context)
4781 {
4782 gl::Program *programObject = context->getProgram(program);
4783
4784 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004785 {
Geoff Langbfdea662014-07-23 14:16:32 -04004786 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004787 {
Geoff Langb1196682014-07-23 13:47:29 -04004788 context->recordError(gl::Error(GL_INVALID_OPERATION));
4789 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004790 }
Geoff Langbfdea662014-07-23 14:16:32 -04004791 else
4792 {
Geoff Langb1196682014-07-23 13:47:29 -04004793 context->recordError(gl::Error(GL_INVALID_VALUE));
4794 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004795 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004796 }
Geoff Langbfdea662014-07-23 14:16:32 -04004797
Brandon Jones43a53e22014-08-28 16:23:22 -07004798 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004799 }
4800}
4801
Kenneth Russell67ea1902014-10-06 16:44:50 -07004802void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004804 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004805
Geoff Langbfdea662014-07-23 14:16:32 -04004806 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004807 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004808 {
Geoff Langb1196682014-07-23 13:47:29 -04004809 if (index >= gl::MAX_VERTEX_ATTRIBS)
4810 {
4811 context->recordError(gl::Error(GL_INVALID_VALUE));
4812 return;
4813 }
4814
Geoff Langbfdea662014-07-23 14:16:32 -04004815 GLfloat vals[4] = { x, 0, 0, 1 };
4816 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004817 }
4818}
4819
Kenneth Russell67ea1902014-10-06 16:44:50 -07004820void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004822 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004823
Geoff Langbfdea662014-07-23 14:16:32 -04004824 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004825 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004826 {
Geoff Langb1196682014-07-23 13:47:29 -04004827 if (index >= gl::MAX_VERTEX_ATTRIBS)
4828 {
4829 context->recordError(gl::Error(GL_INVALID_VALUE));
4830 return;
4831 }
4832
Geoff Langbfdea662014-07-23 14:16:32 -04004833 GLfloat vals[4] = { values[0], 0, 0, 1 };
4834 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004835 }
4836}
4837
Kenneth Russell67ea1902014-10-06 16:44:50 -07004838void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004839{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004840 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004841
Geoff Langbfdea662014-07-23 14:16:32 -04004842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004843 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004844 {
Geoff Langb1196682014-07-23 13:47:29 -04004845 if (index >= gl::MAX_VERTEX_ATTRIBS)
4846 {
4847 context->recordError(gl::Error(GL_INVALID_VALUE));
4848 return;
4849 }
4850
Geoff Langbfdea662014-07-23 14:16:32 -04004851 GLfloat vals[4] = { x, y, 0, 1 };
4852 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004853 }
4854}
4855
Kenneth Russell67ea1902014-10-06 16:44:50 -07004856void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004858 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004859
Geoff Langbfdea662014-07-23 14:16:32 -04004860 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004861 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004862 {
Geoff Langb1196682014-07-23 13:47:29 -04004863 if (index >= gl::MAX_VERTEX_ATTRIBS)
4864 {
4865 context->recordError(gl::Error(GL_INVALID_VALUE));
4866 return;
4867 }
4868
Geoff Langbfdea662014-07-23 14:16:32 -04004869 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4870 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004871 }
4872}
4873
Kenneth Russell67ea1902014-10-06 16:44:50 -07004874void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004876 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 +00004877
Geoff Langbfdea662014-07-23 14:16:32 -04004878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004879 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004880 {
Geoff Langb1196682014-07-23 13:47:29 -04004881 if (index >= gl::MAX_VERTEX_ATTRIBS)
4882 {
4883 context->recordError(gl::Error(GL_INVALID_VALUE));
4884 return;
4885 }
4886
Geoff Langbfdea662014-07-23 14:16:32 -04004887 GLfloat vals[4] = { x, y, z, 1 };
4888 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004889 }
4890}
4891
Kenneth Russell67ea1902014-10-06 16:44:50 -07004892void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004894 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004895
Geoff Langbfdea662014-07-23 14:16:32 -04004896 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004897 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004898 {
Geoff Langb1196682014-07-23 13:47:29 -04004899 if (index >= gl::MAX_VERTEX_ATTRIBS)
4900 {
4901 context->recordError(gl::Error(GL_INVALID_VALUE));
4902 return;
4903 }
4904
Geoff Langbfdea662014-07-23 14:16:32 -04004905 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4906 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004907 }
4908}
4909
Kenneth Russell67ea1902014-10-06 16:44:50 -07004910void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004911{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004912 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 +00004913
Geoff Langbfdea662014-07-23 14:16:32 -04004914 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004915 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004916 {
Geoff Langb1196682014-07-23 13:47:29 -04004917 if (index >= gl::MAX_VERTEX_ATTRIBS)
4918 {
4919 context->recordError(gl::Error(GL_INVALID_VALUE));
4920 return;
4921 }
4922
Geoff Langbfdea662014-07-23 14:16:32 -04004923 GLfloat vals[4] = { x, y, z, w };
4924 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004925 }
4926}
4927
Kenneth Russell67ea1902014-10-06 16:44:50 -07004928void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004929{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004930 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004931
Geoff Langbfdea662014-07-23 14:16:32 -04004932 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004933 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004934 {
Geoff Langb1196682014-07-23 13:47:29 -04004935 if (index >= gl::MAX_VERTEX_ATTRIBS)
4936 {
4937 context->recordError(gl::Error(GL_INVALID_VALUE));
4938 return;
4939 }
4940
Geoff Langbfdea662014-07-23 14:16:32 -04004941 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004942 }
4943}
4944
Kenneth Russell67ea1902014-10-06 16:44:50 -07004945void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004946{
4947 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4948
Geoff Langbfdea662014-07-23 14:16:32 -04004949 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004950 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004951 {
Geoff Langb1196682014-07-23 13:47:29 -04004952 if (index >= gl::MAX_VERTEX_ATTRIBS)
4953 {
4954 context->recordError(gl::Error(GL_INVALID_VALUE));
4955 return;
4956 }
4957
Geoff Langbfdea662014-07-23 14:16:32 -04004958 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004959 }
4960}
4961
Kenneth Russell67ea1902014-10-06 16:44:50 -07004962void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004963{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004964 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004965 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004966 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004967
Geoff Langbfdea662014-07-23 14:16:32 -04004968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004969 if (context)
4970 {
Geoff Langb1196682014-07-23 13:47:29 -04004971 if (index >= gl::MAX_VERTEX_ATTRIBS)
4972 {
4973 context->recordError(gl::Error(GL_INVALID_VALUE));
4974 return;
4975 }
4976
4977 if (size < 1 || size > 4)
4978 {
4979 context->recordError(gl::Error(GL_INVALID_VALUE));
4980 return;
4981 }
4982
4983 switch (type)
4984 {
4985 case GL_BYTE:
4986 case GL_UNSIGNED_BYTE:
4987 case GL_SHORT:
4988 case GL_UNSIGNED_SHORT:
4989 case GL_FIXED:
4990 case GL_FLOAT:
4991 break;
4992
4993 case GL_HALF_FLOAT:
4994 case GL_INT:
4995 case GL_UNSIGNED_INT:
4996 case GL_INT_2_10_10_10_REV:
4997 case GL_UNSIGNED_INT_2_10_10_10_REV:
4998 if (context->getClientVersion() < 3)
4999 {
5000 context->recordError(gl::Error(GL_INVALID_ENUM));
5001 return;
5002 }
5003 break;
5004
5005 default:
5006 context->recordError(gl::Error(GL_INVALID_ENUM));
5007 return;
5008 }
5009
5010 if (stride < 0)
5011 {
5012 context->recordError(gl::Error(GL_INVALID_VALUE));
5013 return;
5014 }
5015
5016 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5017 {
5018 context->recordError(gl::Error(GL_INVALID_OPERATION));
5019 return;
5020 }
5021
Geoff Langbfdea662014-07-23 14:16:32 -04005022 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5023 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5024 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5025 // and the pointer argument is not NULL.
5026 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005027 {
Geoff Langb1196682014-07-23 13:47:29 -04005028 context->recordError(gl::Error(GL_INVALID_OPERATION));
5029 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005030 }
5031
Geoff Langbfdea662014-07-23 14:16:32 -04005032 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5033 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005034 }
5035}
5036
Kenneth Russell67ea1902014-10-06 16:44:50 -07005037void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005038{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005039 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 +00005040
Geoff Langbfdea662014-07-23 14:16:32 -04005041 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005042 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005043 {
Geoff Langb1196682014-07-23 13:47:29 -04005044 if (width < 0 || height < 0)
5045 {
5046 context->recordError(gl::Error(GL_INVALID_VALUE));
5047 return;
5048 }
5049
Geoff Langbfdea662014-07-23 14:16:32 -04005050 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005051 }
5052}
5053
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005054// OpenGL ES 3.0 functions
5055
Kenneth Russell67ea1902014-10-06 16:44:50 -07005056void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005057{
5058 EVENT("(GLenum mode = 0x%X)", mode);
5059
Geoff Langbfdea662014-07-23 14:16:32 -04005060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005061 if (context)
5062 {
5063 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005064 {
Geoff Langb1196682014-07-23 13:47:29 -04005065 context->recordError(gl::Error(GL_INVALID_OPERATION));
5066 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005067 }
Geoff Langbfdea662014-07-23 14:16:32 -04005068
5069 // glReadBuffer
5070 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005071 }
5072}
5073
Kenneth Russell67ea1902014-10-06 16:44:50 -07005074void 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 +00005075{
5076 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5077 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5078
Geoff Langbfdea662014-07-23 14:16:32 -04005079 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005080 if (context)
5081 {
5082 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005083 {
Geoff Langb1196682014-07-23 13:47:29 -04005084 context->recordError(gl::Error(GL_INVALID_OPERATION));
5085 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005086 }
Geoff Langbfdea662014-07-23 14:16:32 -04005087
5088 // glDrawRangeElements
5089 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005090 }
5091}
5092
Kenneth Russell67ea1902014-10-06 16:44:50 -07005093void 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 +00005094{
5095 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5096 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5097 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5098 target, level, internalformat, width, height, depth, border, format, type, pixels);
5099
Geoff Langbfdea662014-07-23 14:16:32 -04005100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005101 if (context)
5102 {
5103 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005104 {
Geoff Langb1196682014-07-23 13:47:29 -04005105 context->recordError(gl::Error(GL_INVALID_OPERATION));
5106 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005107 }
Geoff Langbfdea662014-07-23 14:16:32 -04005108
5109 // validateES3TexImageFormat sets the error code if there is an error
5110 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5111 0, 0, 0, width, height, depth, border, format, type, pixels))
5112 {
5113 return;
5114 }
5115
5116 switch(target)
5117 {
5118 case GL_TEXTURE_3D:
5119 {
5120 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005121 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5122 if (error.isError())
5123 {
5124 context->recordError(error);
5125 return;
5126 }
Geoff Langbfdea662014-07-23 14:16:32 -04005127 }
5128 break;
5129
5130 case GL_TEXTURE_2D_ARRAY:
5131 {
5132 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005133 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5134 if (error.isError())
5135 {
5136 context->recordError(error);
5137 return;
5138 }
Geoff Langbfdea662014-07-23 14:16:32 -04005139 }
5140 break;
5141
5142 default:
Geoff Langb1196682014-07-23 13:47:29 -04005143 context->recordError(gl::Error(GL_INVALID_ENUM));
5144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005145 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005146 }
5147}
5148
Kenneth Russell67ea1902014-10-06 16:44:50 -07005149void 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 +00005150{
5151 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5152 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5153 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5154 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5155
Geoff Langbfdea662014-07-23 14:16:32 -04005156 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005157 if (context)
5158 {
5159 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005160 {
Geoff Langb1196682014-07-23 13:47:29 -04005161 context->recordError(gl::Error(GL_INVALID_OPERATION));
5162 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005163 }
Geoff Langbfdea662014-07-23 14:16:32 -04005164
5165 // validateES3TexImageFormat sets the error code if there is an error
5166 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5167 xoffset, yoffset, zoffset, width, height, depth, 0,
5168 format, type, pixels))
5169 {
5170 return;
5171 }
5172
5173 // Zero sized uploads are valid but no-ops
5174 if (width == 0 || height == 0 || depth == 0)
5175 {
5176 return;
5177 }
5178
5179 switch(target)
5180 {
5181 case GL_TEXTURE_3D:
5182 {
5183 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005184 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5185 if (error.isError())
5186 {
5187 context->recordError(error);
5188 return;
5189 }
Geoff Langbfdea662014-07-23 14:16:32 -04005190 }
5191 break;
5192
5193 case GL_TEXTURE_2D_ARRAY:
5194 {
5195 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005196 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5197 if (error.isError())
5198 {
5199 context->recordError(error);
5200 return;
5201 }
Geoff Langbfdea662014-07-23 14:16:32 -04005202 }
5203 break;
5204
5205 default:
Geoff Langb1196682014-07-23 13:47:29 -04005206 context->recordError(gl::Error(GL_INVALID_ENUM));
5207 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005208 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005209 }
5210}
5211
Kenneth Russell67ea1902014-10-06 16:44:50 -07005212void 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 +00005213{
5214 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5215 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5216 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5217
Geoff Langbfdea662014-07-23 14:16:32 -04005218 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005219 if (context)
5220 {
5221 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005222 {
Geoff Langb1196682014-07-23 13:47:29 -04005223 context->recordError(gl::Error(GL_INVALID_OPERATION));
5224 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005225 }
Geoff Langbfdea662014-07-23 14:16:32 -04005226
5227 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5228 x, y, width, height, 0))
5229 {
5230 return;
5231 }
5232
5233 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5234 gl::Texture *texture = NULL;
5235 switch (target)
5236 {
5237 case GL_TEXTURE_3D:
5238 texture = context->getTexture3D();
5239 break;
5240
5241 case GL_TEXTURE_2D_ARRAY:
5242 texture = context->getTexture2DArray();
5243 break;
5244
5245 default:
Geoff Langb1196682014-07-23 13:47:29 -04005246 context->recordError(gl::Error(GL_INVALID_ENUM));
5247 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005248 }
5249
Geoff Langef7b0162014-09-04 13:29:23 -04005250 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5251 if (error.isError())
5252 {
5253 context->recordError(error);
5254 return;
5255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005256 }
5257}
5258
Kenneth Russell67ea1902014-10-06 16:44:50 -07005259void 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 +00005260{
Geoff Langeef52cc2013-10-16 15:07:39 -04005261 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 +00005262 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5263 "const GLvoid* data = 0x%0.8p)",
5264 target, level, internalformat, width, height, depth, border, imageSize, data);
5265
Geoff Langbfdea662014-07-23 14:16:32 -04005266 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005267 if (context)
5268 {
5269 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005270 {
Geoff Langb1196682014-07-23 13:47:29 -04005271 context->recordError(gl::Error(GL_INVALID_OPERATION));
5272 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005273 }
Geoff Langbfdea662014-07-23 14:16:32 -04005274
Geoff Lang5d601382014-07-22 15:14:06 -04005275 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5276 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005277 {
Geoff Langb1196682014-07-23 13:47:29 -04005278 context->recordError(gl::Error(GL_INVALID_VALUE));
5279 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005280 }
5281
5282 // validateES3TexImageFormat sets the error code if there is an error
5283 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5284 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5285 {
5286 return;
5287 }
5288
5289 switch(target)
5290 {
5291 case GL_TEXTURE_3D:
5292 {
5293 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005294 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005295 if (error.isError())
5296 {
5297 context->recordError(error);
5298 return;
5299 }
Geoff Langbfdea662014-07-23 14:16:32 -04005300 }
5301 break;
5302
5303 case GL_TEXTURE_2D_ARRAY:
5304 {
5305 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005306 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005307 if (error.isError())
5308 {
5309 context->recordError(error);
5310 return;
5311 }
Geoff Langbfdea662014-07-23 14:16:32 -04005312 }
5313 break;
5314
5315 default:
Geoff Langb1196682014-07-23 13:47:29 -04005316 context->recordError(gl::Error(GL_INVALID_ENUM));
5317 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005318 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005319 }
5320}
5321
Kenneth Russell67ea1902014-10-06 16:44:50 -07005322void 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 +00005323{
5324 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5325 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5326 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5327 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5328
Geoff Langbfdea662014-07-23 14:16:32 -04005329 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005330 if (context)
5331 {
5332 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005333 {
Geoff Langb1196682014-07-23 13:47:29 -04005334 context->recordError(gl::Error(GL_INVALID_OPERATION));
5335 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005336 }
Geoff Langbfdea662014-07-23 14:16:32 -04005337
Geoff Lang5d601382014-07-22 15:14:06 -04005338 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5339 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005340 {
Geoff Langb1196682014-07-23 13:47:29 -04005341 context->recordError(gl::Error(GL_INVALID_VALUE));
5342 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005343 }
5344
5345 if (!data)
5346 {
Geoff Langb1196682014-07-23 13:47:29 -04005347 context->recordError(gl::Error(GL_INVALID_VALUE));
5348 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005349 }
5350
5351 // validateES3TexImageFormat sets the error code if there is an error
5352 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5353 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5354 {
5355 return;
5356 }
5357
5358 // Zero sized uploads are valid but no-ops
5359 if (width == 0 || height == 0)
5360 {
5361 return;
5362 }
5363
5364 switch(target)
5365 {
5366 case GL_TEXTURE_3D:
5367 {
5368 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005369 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005370 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005371 if (error.isError())
5372 {
5373 context->recordError(error);
5374 return;
5375 }
Geoff Langbfdea662014-07-23 14:16:32 -04005376 }
5377 break;
5378
5379 case GL_TEXTURE_2D_ARRAY:
5380 {
5381 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005382 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005383 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005384 if (error.isError())
5385 {
5386 context->recordError(error);
5387 return;
5388 }
Geoff Langbfdea662014-07-23 14:16:32 -04005389 }
5390 break;
5391
Geoff Langb1196682014-07-23 13:47:29 -04005392 default:
5393 context->recordError(gl::Error(GL_INVALID_ENUM));
5394 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005395 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005396 }
5397}
5398
Kenneth Russell67ea1902014-10-06 16:44:50 -07005399void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005400{
5401 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5402
Geoff Langbfdea662014-07-23 14:16:32 -04005403 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005404 if (context)
5405 {
5406 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005407 {
Geoff Langb1196682014-07-23 13:47:29 -04005408 context->recordError(gl::Error(GL_INVALID_OPERATION));
5409 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005410 }
Geoff Langbfdea662014-07-23 14:16:32 -04005411
5412 if (n < 0)
5413 {
Geoff Langb1196682014-07-23 13:47:29 -04005414 context->recordError(gl::Error(GL_INVALID_VALUE));
5415 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005416 }
5417
5418 for (GLsizei i = 0; i < n; i++)
5419 {
5420 ids[i] = context->createQuery();
5421 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005422 }
5423}
5424
Kenneth Russell67ea1902014-10-06 16:44:50 -07005425void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005426{
5427 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5428
Geoff Langbfdea662014-07-23 14:16:32 -04005429 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005430 if (context)
5431 {
5432 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005433 {
Geoff Langb1196682014-07-23 13:47:29 -04005434 context->recordError(gl::Error(GL_INVALID_OPERATION));
5435 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005436 }
Geoff Langbfdea662014-07-23 14:16:32 -04005437
5438 if (n < 0)
5439 {
Geoff Langb1196682014-07-23 13:47:29 -04005440 context->recordError(gl::Error(GL_INVALID_VALUE));
5441 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005442 }
5443
5444 for (GLsizei i = 0; i < n; i++)
5445 {
5446 context->deleteQuery(ids[i]);
5447 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005448 }
5449}
5450
Kenneth Russell67ea1902014-10-06 16:44:50 -07005451GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005452{
5453 EVENT("(GLuint id = %u)", id);
5454
Geoff Langbfdea662014-07-23 14:16:32 -04005455 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005456 if (context)
5457 {
5458 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005459 {
Geoff Langb1196682014-07-23 13:47:29 -04005460 context->recordError(gl::Error(GL_INVALID_OPERATION));
5461 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005462 }
Geoff Langbfdea662014-07-23 14:16:32 -04005463
5464 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005465 }
5466
5467 return GL_FALSE;
5468}
5469
Kenneth Russell67ea1902014-10-06 16:44:50 -07005470void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005471{
5472 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5473
Geoff Langbfdea662014-07-23 14:16:32 -04005474 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005475 if (context)
5476 {
5477 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005478 {
Geoff Langb1196682014-07-23 13:47:29 -04005479 context->recordError(gl::Error(GL_INVALID_OPERATION));
5480 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005481 }
Geoff Langbfdea662014-07-23 14:16:32 -04005482
5483 if (!ValidateBeginQuery(context, target, id))
5484 {
5485 return;
5486 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005487
5488 gl::Error error = context->beginQuery(target, id);
5489 if (error.isError())
5490 {
5491 context->recordError(error);
5492 return;
5493 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005494 }
5495}
5496
Kenneth Russell67ea1902014-10-06 16:44:50 -07005497void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005498{
5499 EVENT("(GLenum target = 0x%X)", target);
5500
Geoff Langbfdea662014-07-23 14:16:32 -04005501 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005502 if (context)
5503 {
5504 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005505 {
Geoff Langb1196682014-07-23 13:47:29 -04005506 context->recordError(gl::Error(GL_INVALID_OPERATION));
5507 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005508 }
Geoff Langbfdea662014-07-23 14:16:32 -04005509
5510 if (!ValidateEndQuery(context, target))
5511 {
5512 return;
5513 }
5514
Geoff Lang5aad9672014-09-08 11:10:42 -04005515 gl::Error error = context->endQuery(target);
5516 if (error.isError())
5517 {
5518 context->recordError(error);
5519 return;
5520 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005521 }
5522}
5523
Kenneth Russell67ea1902014-10-06 16:44:50 -07005524void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005525{
5526 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5527
Geoff Langbfdea662014-07-23 14:16:32 -04005528 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005529 if (context)
5530 {
5531 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005532 {
Geoff Langb1196682014-07-23 13:47:29 -04005533 context->recordError(gl::Error(GL_INVALID_OPERATION));
5534 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005535 }
Geoff Langbfdea662014-07-23 14:16:32 -04005536
5537 if (!ValidQueryType(context, target))
5538 {
Geoff Langb1196682014-07-23 13:47:29 -04005539 context->recordError(gl::Error(GL_INVALID_ENUM));
5540 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005541 }
5542
5543 switch (pname)
5544 {
5545 case GL_CURRENT_QUERY:
5546 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5547 break;
5548
5549 default:
Geoff Langb1196682014-07-23 13:47:29 -04005550 context->recordError(gl::Error(GL_INVALID_ENUM));
5551 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005552 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005553 }
5554}
5555
Kenneth Russell67ea1902014-10-06 16:44:50 -07005556void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005557{
5558 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5559
Geoff Langbfdea662014-07-23 14:16:32 -04005560 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005561 if (context)
5562 {
5563 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005564 {
Geoff Langb1196682014-07-23 13:47:29 -04005565 context->recordError(gl::Error(GL_INVALID_OPERATION));
5566 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005567 }
Geoff Langbfdea662014-07-23 14:16:32 -04005568
5569 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5570
5571 if (!queryObject)
5572 {
Geoff Langb1196682014-07-23 13:47:29 -04005573 context->recordError(gl::Error(GL_INVALID_OPERATION));
5574 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005575 }
5576
5577 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5578 {
Geoff Langb1196682014-07-23 13:47:29 -04005579 context->recordError(gl::Error(GL_INVALID_OPERATION));
5580 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005581 }
5582
5583 switch(pname)
5584 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005585 case GL_QUERY_RESULT_EXT:
5586 {
5587 gl::Error error = queryObject->getResult(params);
5588 if (error.isError())
5589 {
5590 context->recordError(error);
5591 return;
5592 }
5593 }
Geoff Langbfdea662014-07-23 14:16:32 -04005594 break;
Geoff Langb1196682014-07-23 13:47:29 -04005595
Geoff Lang5aad9672014-09-08 11:10:42 -04005596 case GL_QUERY_RESULT_AVAILABLE_EXT:
5597 {
5598 gl::Error error = queryObject->isResultAvailable(params);
5599 if (error.isError())
5600 {
5601 context->recordError(error);
5602 return;
5603 }
5604 }
Geoff Langbfdea662014-07-23 14:16:32 -04005605 break;
Geoff Langb1196682014-07-23 13:47:29 -04005606
Geoff Langbfdea662014-07-23 14:16:32 -04005607 default:
Geoff Langb1196682014-07-23 13:47:29 -04005608 context->recordError(gl::Error(GL_INVALID_ENUM));
5609 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005610 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005611 }
5612}
5613
Kenneth Russell67ea1902014-10-06 16:44:50 -07005614GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005615{
5616 EVENT("(GLenum target = 0x%X)", target);
5617
Geoff Langbfdea662014-07-23 14:16:32 -04005618 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005619 if (context)
5620 {
5621 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005622 {
Geoff Langb1196682014-07-23 13:47:29 -04005623 context->recordError(gl::Error(GL_INVALID_OPERATION));
5624 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005625 }
Geoff Langbfdea662014-07-23 14:16:32 -04005626
5627 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005628 }
5629
5630 return GL_FALSE;
5631}
5632
Kenneth Russell67ea1902014-10-06 16:44:50 -07005633void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005634{
5635 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5636
Geoff Langbfdea662014-07-23 14:16:32 -04005637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005638 if (context)
5639 {
5640 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005641 {
Geoff Langb1196682014-07-23 13:47:29 -04005642 context->recordError(gl::Error(GL_INVALID_OPERATION));
5643 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005644 }
Geoff Langbfdea662014-07-23 14:16:32 -04005645
5646 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005647 }
5648}
5649
Kenneth Russell67ea1902014-10-06 16:44:50 -07005650void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005651{
Geoff Langbfdea662014-07-23 14:16:32 -04005652 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005653 if (context)
5654 {
5655 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005656 {
Geoff Langb1196682014-07-23 13:47:29 -04005657 context->recordError(gl::Error(GL_INVALID_OPERATION));
5658 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005659 }
Geoff Langbfdea662014-07-23 14:16:32 -04005660
5661 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005662 }
5663}
5664
Kenneth Russell67ea1902014-10-06 16:44:50 -07005665void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005666{
5667 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5668 location, count, transpose, value);
5669
Geoff Langbfdea662014-07-23 14:16:32 -04005670 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005671 if (context)
5672 {
5673 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005674 {
Geoff Langbfdea662014-07-23 14:16:32 -04005675 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005676 }
Geoff Langbfdea662014-07-23 14:16:32 -04005677
5678 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5679 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005680 }
5681}
5682
Kenneth Russell67ea1902014-10-06 16:44:50 -07005683void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005684{
5685 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5686 location, count, transpose, value);
5687
Geoff Langbfdea662014-07-23 14:16:32 -04005688 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005689 if (context)
5690 {
5691 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005692 {
Geoff Langbfdea662014-07-23 14:16:32 -04005693 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005694 }
Geoff Langbfdea662014-07-23 14:16:32 -04005695
5696 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5697 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005698 }
5699}
5700
Kenneth Russell67ea1902014-10-06 16:44:50 -07005701void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005702{
5703 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5704 location, count, transpose, value);
5705
Geoff Langbfdea662014-07-23 14:16:32 -04005706 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005707 if (context)
5708 {
5709 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005710 {
Geoff Langbfdea662014-07-23 14:16:32 -04005711 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005712 }
Geoff Langbfdea662014-07-23 14:16:32 -04005713
5714 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5715 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005716 }
5717}
5718
Kenneth Russell67ea1902014-10-06 16:44:50 -07005719void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005720{
5721 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5722 location, count, transpose, value);
5723
Geoff Langbfdea662014-07-23 14:16:32 -04005724 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005725 if (context)
5726 {
5727 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005728 {
Geoff Langbfdea662014-07-23 14:16:32 -04005729 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005730 }
Geoff Langbfdea662014-07-23 14:16:32 -04005731
5732 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5733 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005734 }
5735}
5736
Kenneth Russell67ea1902014-10-06 16:44:50 -07005737void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005738{
5739 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5740 location, count, transpose, value);
5741
Geoff Langbfdea662014-07-23 14:16:32 -04005742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005743 if (context)
5744 {
5745 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005746 {
Geoff Langbfdea662014-07-23 14:16:32 -04005747 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005748 }
Geoff Langbfdea662014-07-23 14:16:32 -04005749
5750 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5751 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005752 }
5753}
5754
Kenneth Russell67ea1902014-10-06 16:44:50 -07005755void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005756{
5757 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5758 location, count, transpose, value);
5759
Geoff Langbfdea662014-07-23 14:16:32 -04005760 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005761 if (context)
5762 {
5763 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005764 {
Geoff Langbfdea662014-07-23 14:16:32 -04005765 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005766 }
Geoff Langbfdea662014-07-23 14:16:32 -04005767
5768 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5769 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005770 }
5771}
5772
Kenneth Russell67ea1902014-10-06 16:44:50 -07005773void 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 +00005774{
5775 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5776 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5777 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5778
Geoff Langbfdea662014-07-23 14:16:32 -04005779 gl::Context *context = gl::getNonLostContext();
5780 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005781 {
Geoff Langbfdea662014-07-23 14:16:32 -04005782 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005783 {
Geoff Langb1196682014-07-23 13:47:29 -04005784 context->recordError(gl::Error(GL_INVALID_OPERATION));
5785 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005786 }
Geoff Langbfdea662014-07-23 14:16:32 -04005787
5788 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5789 dstX0, dstY0, dstX1, dstY1, mask, filter,
5790 false))
5791 {
5792 return;
5793 }
5794
Geoff Lang64839152014-08-26 16:23:25 -04005795 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5796 mask, filter);
5797 if (error.isError())
5798 {
5799 context->recordError(error);
5800 return;
5801 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005802 }
5803}
5804
Kenneth Russell67ea1902014-10-06 16:44:50 -07005805void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005806{
5807 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5808 target, samples, internalformat, width, height);
5809
Geoff Langbfdea662014-07-23 14:16:32 -04005810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005811 if (context)
5812 {
5813 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005814 {
Geoff Langb1196682014-07-23 13:47:29 -04005815 context->recordError(gl::Error(GL_INVALID_OPERATION));
5816 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005817 }
Geoff Langbfdea662014-07-23 14:16:32 -04005818
5819 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5820 width, height, false))
5821 {
5822 return;
5823 }
5824
Shannon Woodse2632d22014-10-17 13:08:51 -04005825 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5826 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005827 }
5828}
5829
Kenneth Russell67ea1902014-10-06 16:44:50 -07005830void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005831{
5832 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5833 target, attachment, texture, level, layer);
5834
Geoff Langbfdea662014-07-23 14:16:32 -04005835 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005836 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005837 {
Geoff Langbfdea662014-07-23 14:16:32 -04005838 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5839 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005840 {
Geoff Langbfdea662014-07-23 14:16:32 -04005841 return;
5842 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005843
Geoff Langbfdea662014-07-23 14:16:32 -04005844 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5845 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005846
Geoff Langbfdea662014-07-23 14:16:32 -04005847 gl::Texture *textureObject = context->getTexture(texture);
5848 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005849
Geoff Langbfdea662014-07-23 14:16:32 -04005850 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5851 {
5852 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5853 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5854 }
5855 else
5856 {
5857 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005858 {
Geoff Langbfdea662014-07-23 14:16:32 -04005859 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5860 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5861 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005862 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005863 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005864 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005865}
5866
Kenneth Russell67ea1902014-10-06 16:44:50 -07005867GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005868{
5869 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5870 target, offset, length, access);
5871
Geoff Langbfdea662014-07-23 14:16:32 -04005872 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005873 if (context)
5874 {
5875 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005876 {
Geoff Langb1196682014-07-23 13:47:29 -04005877 context->recordError(gl::Error(GL_INVALID_OPERATION));
5878 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005879 }
Geoff Langbfdea662014-07-23 14:16:32 -04005880
5881 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005882 }
5883
5884 return NULL;
5885}
5886
Kenneth Russell67ea1902014-10-06 16:44:50 -07005887void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005888{
5889 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5890
Geoff Langbfdea662014-07-23 14:16:32 -04005891 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005892 if (context)
5893 {
5894 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005895 {
Geoff Langb1196682014-07-23 13:47:29 -04005896 context->recordError(gl::Error(GL_INVALID_OPERATION));
5897 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005898 }
Geoff Langbfdea662014-07-23 14:16:32 -04005899
5900 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005901 }
5902}
5903
Kenneth Russell67ea1902014-10-06 16:44:50 -07005904void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005905{
5906 EVENT("(GLuint array = %u)", array);
5907
Geoff Langbfdea662014-07-23 14:16:32 -04005908 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005909 if (context)
5910 {
5911 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005912 {
Geoff Langb1196682014-07-23 13:47:29 -04005913 context->recordError(gl::Error(GL_INVALID_OPERATION));
5914 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005915 }
Geoff Langbfdea662014-07-23 14:16:32 -04005916
5917 gl::VertexArray *vao = context->getVertexArray(array);
5918
5919 if (!vao)
5920 {
5921 // The default VAO should always exist
5922 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005923 context->recordError(gl::Error(GL_INVALID_OPERATION));
5924 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005925 }
5926
5927 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005928 }
5929}
5930
Kenneth Russell67ea1902014-10-06 16:44:50 -07005931void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005932{
5933 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5934
Geoff Langbfdea662014-07-23 14:16:32 -04005935 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005936 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005937 {
Geoff Langbfdea662014-07-23 14:16:32 -04005938 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005939 {
Geoff Langb1196682014-07-23 13:47:29 -04005940 context->recordError(gl::Error(GL_INVALID_OPERATION));
5941 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005942 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005943
Geoff Langbfdea662014-07-23 14:16:32 -04005944 if (n < 0)
5945 {
Geoff Langb1196682014-07-23 13:47:29 -04005946 context->recordError(gl::Error(GL_INVALID_VALUE));
5947 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005948 }
Jamie Madilld1028542013-07-02 11:57:04 -04005949
Geoff Langbfdea662014-07-23 14:16:32 -04005950 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5951 {
5952 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005953 {
Geoff Langbfdea662014-07-23 14:16:32 -04005954 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005955 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005956 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005957 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005958}
5959
Kenneth Russell67ea1902014-10-06 16:44:50 -07005960void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005961{
5962 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5963
Geoff Langbfdea662014-07-23 14:16:32 -04005964 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005965 if (context)
5966 {
5967 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005968 {
Geoff Langb1196682014-07-23 13:47:29 -04005969 context->recordError(gl::Error(GL_INVALID_OPERATION));
5970 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005971 }
Geoff Langbfdea662014-07-23 14:16:32 -04005972
5973 if (n < 0)
5974 {
Geoff Langb1196682014-07-23 13:47:29 -04005975 context->recordError(gl::Error(GL_INVALID_VALUE));
5976 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005977 }
5978
5979 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5980 {
5981 arrays[arrayIndex] = context->createVertexArray();
5982 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005983 }
5984}
5985
Kenneth Russell67ea1902014-10-06 16:44:50 -07005986GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005987{
5988 EVENT("(GLuint array = %u)", array);
5989
Geoff Langbfdea662014-07-23 14:16:32 -04005990 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005991 if (context)
5992 {
5993 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005994 {
Geoff Langb1196682014-07-23 13:47:29 -04005995 context->recordError(gl::Error(GL_INVALID_OPERATION));
5996 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005997 }
Geoff Langbfdea662014-07-23 14:16:32 -04005998
5999 if (array == 0)
6000 {
6001 return GL_FALSE;
6002 }
6003
6004 gl::VertexArray *vao = context->getVertexArray(array);
6005
6006 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006007 }
6008
6009 return GL_FALSE;
6010}
6011
Kenneth Russell67ea1902014-10-06 16:44:50 -07006012void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006013{
6014 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6015 target, index, data);
6016
Geoff Langbfdea662014-07-23 14:16:32 -04006017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006018 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006019 {
Geoff Langbfdea662014-07-23 14:16:32 -04006020 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006021 {
Geoff Langb1196682014-07-23 13:47:29 -04006022 context->recordError(gl::Error(GL_INVALID_OPERATION));
6023 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006024 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006025
Geoff Lang3a61c322014-07-10 13:01:54 -04006026 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006027 switch (target)
6028 {
6029 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6030 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6031 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006032 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6033 {
Geoff Langb1196682014-07-23 13:47:29 -04006034 context->recordError(gl::Error(GL_INVALID_VALUE));
6035 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006036 }
Geoff Langbfdea662014-07-23 14:16:32 -04006037 break;
Geoff Langb1196682014-07-23 13:47:29 -04006038
Geoff Langbfdea662014-07-23 14:16:32 -04006039 case GL_UNIFORM_BUFFER_START:
6040 case GL_UNIFORM_BUFFER_SIZE:
6041 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006042 if (index >= caps.maxCombinedUniformBlocks)
6043 {
Geoff Langb1196682014-07-23 13:47:29 -04006044 context->recordError(gl::Error(GL_INVALID_VALUE));
6045 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006046 }
Geoff Langbfdea662014-07-23 14:16:32 -04006047 break;
Geoff Langb1196682014-07-23 13:47:29 -04006048
Geoff Langbfdea662014-07-23 14:16:32 -04006049 default:
Geoff Langb1196682014-07-23 13:47:29 -04006050 context->recordError(gl::Error(GL_INVALID_ENUM));
6051 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006052 }
6053
6054 if (!(context->getIndexedIntegerv(target, index, data)))
6055 {
6056 GLenum nativeType;
6057 unsigned int numParams = 0;
6058 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006059 {
6060 context->recordError(gl::Error(GL_INVALID_ENUM));
6061 return;
6062 }
Shannon Woods15934d52013-08-19 14:28:49 -04006063
Geoff Langbfdea662014-07-23 14:16:32 -04006064 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006065 {
Geoff Langbfdea662014-07-23 14:16:32 -04006066 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006067 }
Geoff Langbfdea662014-07-23 14:16:32 -04006068
6069 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006070 {
Geoff Langbfdea662014-07-23 14:16:32 -04006071 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6072 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6073 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006074
Geoff Langbfdea662014-07-23 14:16:32 -04006075 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006076
Geoff Langbfdea662014-07-23 14:16:32 -04006077 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006078 {
Geoff Langbfdea662014-07-23 14:16:32 -04006079 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6080 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006081 }
Geoff Langbfdea662014-07-23 14:16:32 -04006082
6083 delete [] int64Params;
6084 }
6085 else
6086 {
6087 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006088 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006089 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006090 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006091}
6092
Kenneth Russell67ea1902014-10-06 16:44:50 -07006093void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006094{
6095 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6096
Geoff Langbfdea662014-07-23 14:16:32 -04006097 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006098 if (context)
6099 {
6100 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006101 {
Geoff Langb1196682014-07-23 13:47:29 -04006102 context->recordError(gl::Error(GL_INVALID_OPERATION));
6103 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006104 }
Geoff Langbfdea662014-07-23 14:16:32 -04006105
6106 switch (primitiveMode)
6107 {
6108 case GL_TRIANGLES:
6109 case GL_LINES:
6110 case GL_POINTS:
6111 break;
Geoff Langb1196682014-07-23 13:47:29 -04006112
Geoff Langbfdea662014-07-23 14:16:32 -04006113 default:
Geoff Langb1196682014-07-23 13:47:29 -04006114 context->recordError(gl::Error(GL_INVALID_ENUM));
6115 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006116 }
6117
6118 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6119 ASSERT(transformFeedback != NULL);
6120
6121 if (transformFeedback->isStarted())
6122 {
Geoff Langb1196682014-07-23 13:47:29 -04006123 context->recordError(gl::Error(GL_INVALID_OPERATION));
6124 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006125 }
6126
6127 if (transformFeedback->isPaused())
6128 {
6129 transformFeedback->resume();
6130 }
6131 else
6132 {
6133 transformFeedback->start(primitiveMode);
6134 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006135 }
6136}
6137
Kenneth Russell67ea1902014-10-06 16:44:50 -07006138void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006139{
6140 EVENT("(void)");
6141
Geoff Langbfdea662014-07-23 14:16:32 -04006142 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006143 if (context)
6144 {
6145 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006146 {
Geoff Langb1196682014-07-23 13:47:29 -04006147 context->recordError(gl::Error(GL_INVALID_OPERATION));
6148 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006149 }
Geoff Langbfdea662014-07-23 14:16:32 -04006150
6151 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6152 ASSERT(transformFeedback != NULL);
6153
6154 if (!transformFeedback->isStarted())
6155 {
Geoff Langb1196682014-07-23 13:47:29 -04006156 context->recordError(gl::Error(GL_INVALID_OPERATION));
6157 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006158 }
6159
6160 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006161 }
6162}
6163
Kenneth Russell67ea1902014-10-06 16:44:50 -07006164void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006165{
6166 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6167 target, index, buffer, offset, size);
6168
Geoff Langbfdea662014-07-23 14:16:32 -04006169 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006170 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006171 {
Geoff Langbfdea662014-07-23 14:16:32 -04006172 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006173 {
Geoff Langb1196682014-07-23 13:47:29 -04006174 context->recordError(gl::Error(GL_INVALID_OPERATION));
6175 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006176 }
6177
Geoff Lang3a61c322014-07-10 13:01:54 -04006178 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006179 switch (target)
6180 {
6181 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006182 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006183 {
Geoff Langb1196682014-07-23 13:47:29 -04006184 context->recordError(gl::Error(GL_INVALID_VALUE));
6185 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006186 }
Geoff Langbfdea662014-07-23 14:16:32 -04006187 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006188
Geoff Langbfdea662014-07-23 14:16:32 -04006189 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006190 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006191 {
Geoff Langb1196682014-07-23 13:47:29 -04006192 context->recordError(gl::Error(GL_INVALID_VALUE));
6193 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006194 }
Geoff Langbfdea662014-07-23 14:16:32 -04006195 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006196
Geoff Langbfdea662014-07-23 14:16:32 -04006197 default:
Geoff Langb1196682014-07-23 13:47:29 -04006198 context->recordError(gl::Error(GL_INVALID_ENUM));
6199 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006200 }
6201
6202 if (buffer != 0 && size <= 0)
6203 {
Geoff Langb1196682014-07-23 13:47:29 -04006204 context->recordError(gl::Error(GL_INVALID_VALUE));
6205 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006206 }
6207
6208 switch (target)
6209 {
6210 case GL_TRANSFORM_FEEDBACK_BUFFER:
6211
6212 // size and offset must be a multiple of 4
6213 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006214 {
Geoff Langb1196682014-07-23 13:47:29 -04006215 context->recordError(gl::Error(GL_INVALID_VALUE));
6216 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006217 }
6218
Geoff Langbfdea662014-07-23 14:16:32 -04006219 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6220 context->bindGenericTransformFeedbackBuffer(buffer);
6221 break;
6222
6223 case GL_UNIFORM_BUFFER:
6224
6225 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006226 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006227 {
Geoff Langb1196682014-07-23 13:47:29 -04006228 context->recordError(gl::Error(GL_INVALID_VALUE));
6229 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006230 }
Geoff Langbfdea662014-07-23 14:16:32 -04006231
6232 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6233 context->bindGenericUniformBuffer(buffer);
6234 break;
6235
6236 default:
6237 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006238 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006239 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006240}
6241
Kenneth Russell67ea1902014-10-06 16:44:50 -07006242void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006243{
6244 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6245 target, index, buffer);
6246
Geoff Langbfdea662014-07-23 14:16:32 -04006247 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006248 if (context)
6249 {
6250 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006251 {
Geoff Langb1196682014-07-23 13:47:29 -04006252 context->recordError(gl::Error(GL_INVALID_OPERATION));
6253 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006254 }
Geoff Langbfdea662014-07-23 14:16:32 -04006255
Geoff Lang3a61c322014-07-10 13:01:54 -04006256 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006257 switch (target)
6258 {
6259 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006260 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006261 {
Geoff Langb1196682014-07-23 13:47:29 -04006262 context->recordError(gl::Error(GL_INVALID_VALUE));
6263 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006264 }
6265 break;
6266
6267 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006268 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006269 {
Geoff Langb1196682014-07-23 13:47:29 -04006270 context->recordError(gl::Error(GL_INVALID_VALUE));
6271 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006272 }
6273 break;
6274
6275 default:
Geoff Langb1196682014-07-23 13:47:29 -04006276 context->recordError(gl::Error(GL_INVALID_ENUM));
6277 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006278 }
6279
6280 switch (target)
6281 {
6282 case GL_TRANSFORM_FEEDBACK_BUFFER:
6283 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6284 context->bindGenericTransformFeedbackBuffer(buffer);
6285 break;
6286
6287 case GL_UNIFORM_BUFFER:
6288 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6289 context->bindGenericUniformBuffer(buffer);
6290 break;
6291
6292 default:
6293 UNREACHABLE();
6294 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006295 }
6296}
6297
Kenneth Russell67ea1902014-10-06 16:44:50 -07006298void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006299{
6300 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6301 program, count, varyings, bufferMode);
6302
Geoff Langbfdea662014-07-23 14:16:32 -04006303 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006304 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006305 {
Geoff Langbfdea662014-07-23 14:16:32 -04006306 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006307 {
Geoff Langb1196682014-07-23 13:47:29 -04006308 context->recordError(gl::Error(GL_INVALID_OPERATION));
6309 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006310 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006311
Geoff Langbfdea662014-07-23 14:16:32 -04006312 if (count < 0)
6313 {
Geoff Langb1196682014-07-23 13:47:29 -04006314 context->recordError(gl::Error(GL_INVALID_VALUE));
6315 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006316 }
6317
Geoff Lang05881a02014-07-10 14:05:30 -04006318 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006319 switch (bufferMode)
6320 {
6321 case GL_INTERLEAVED_ATTRIBS:
6322 break;
6323 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006324 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006325 {
Geoff Langb1196682014-07-23 13:47:29 -04006326 context->recordError(gl::Error(GL_INVALID_VALUE));
6327 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006328 }
Geoff Langbfdea662014-07-23 14:16:32 -04006329 break;
6330 default:
Geoff Langb1196682014-07-23 13:47:29 -04006331 context->recordError(gl::Error(GL_INVALID_ENUM));
6332 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006333 }
Geoff Langbfdea662014-07-23 14:16:32 -04006334
6335 if (!gl::ValidProgram(context, program))
6336 {
6337 return;
6338 }
6339
6340 gl::Program *programObject = context->getProgram(program);
6341 ASSERT(programObject);
6342
6343 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006344 }
6345}
6346
Kenneth Russell67ea1902014-10-06 16:44:50 -07006347void 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 +00006348{
6349 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6350 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6351 program, index, bufSize, length, size, type, name);
6352
Geoff Langbfdea662014-07-23 14:16:32 -04006353 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006354 if (context)
6355 {
6356 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006357 {
Geoff Langb1196682014-07-23 13:47:29 -04006358 context->recordError(gl::Error(GL_INVALID_OPERATION));
6359 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006360 }
Geoff Langbfdea662014-07-23 14:16:32 -04006361
6362 if (bufSize < 0)
6363 {
Geoff Langb1196682014-07-23 13:47:29 -04006364 context->recordError(gl::Error(GL_INVALID_VALUE));
6365 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006366 }
6367
6368 if (!gl::ValidProgram(context, program))
6369 {
6370 return;
6371 }
6372
6373 gl::Program *programObject = context->getProgram(program);
6374 ASSERT(programObject);
6375
6376 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6377 {
Geoff Langb1196682014-07-23 13:47:29 -04006378 context->recordError(gl::Error(GL_INVALID_VALUE));
6379 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006380 }
6381
6382 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006383 }
6384}
6385
Kenneth Russell67ea1902014-10-06 16:44:50 -07006386void 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 +00006387{
6388 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6389 index, size, type, stride, pointer);
6390
Geoff Langbfdea662014-07-23 14:16:32 -04006391 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006392 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006393 {
Geoff Langbfdea662014-07-23 14:16:32 -04006394 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006395 {
Geoff Langb1196682014-07-23 13:47:29 -04006396 context->recordError(gl::Error(GL_INVALID_OPERATION));
6397 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006398 }
6399
Geoff Langb1196682014-07-23 13:47:29 -04006400 if (index >= gl::MAX_VERTEX_ATTRIBS)
6401 {
6402 context->recordError(gl::Error(GL_INVALID_VALUE));
6403 return;
6404 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006405
Geoff Langb1196682014-07-23 13:47:29 -04006406 if (size < 1 || size > 4)
6407 {
6408 context->recordError(gl::Error(GL_INVALID_VALUE));
6409 return;
6410 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006411
Geoff Langb1196682014-07-23 13:47:29 -04006412 switch (type)
6413 {
6414 case GL_BYTE:
6415 case GL_UNSIGNED_BYTE:
6416 case GL_SHORT:
6417 case GL_UNSIGNED_SHORT:
6418 case GL_INT:
6419 case GL_UNSIGNED_INT:
6420 case GL_INT_2_10_10_10_REV:
6421 case GL_UNSIGNED_INT_2_10_10_10_REV:
6422 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006423
Geoff Langb1196682014-07-23 13:47:29 -04006424 default:
6425 context->recordError(gl::Error(GL_INVALID_ENUM));
6426 return;
6427 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006428
Geoff Langb1196682014-07-23 13:47:29 -04006429 if (stride < 0)
6430 {
6431 context->recordError(gl::Error(GL_INVALID_VALUE));
6432 return;
6433 }
Geoff Langbfdea662014-07-23 14:16:32 -04006434
Geoff Langb1196682014-07-23 13:47:29 -04006435 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6436 {
6437 context->recordError(gl::Error(GL_INVALID_OPERATION));
6438 return;
6439 }
6440
Geoff Langbfdea662014-07-23 14:16:32 -04006441 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6442 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6443 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6444 // and the pointer argument is not NULL.
6445 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006446 {
Geoff Langb1196682014-07-23 13:47:29 -04006447 context->recordError(gl::Error(GL_INVALID_OPERATION));
6448 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006449 }
6450
Geoff Langbfdea662014-07-23 14:16:32 -04006451 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6452 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006453 }
6454}
6455
Kenneth Russell67ea1902014-10-06 16:44:50 -07006456void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006457{
6458 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6459 index, pname, params);
6460
Geoff Langbfdea662014-07-23 14:16:32 -04006461 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006462 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006463 {
Geoff Langbfdea662014-07-23 14:16:32 -04006464 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006465 {
Geoff Langb1196682014-07-23 13:47:29 -04006466 context->recordError(gl::Error(GL_INVALID_OPERATION));
6467 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006468 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006469
Geoff Langbfdea662014-07-23 14:16:32 -04006470 if (index >= gl::MAX_VERTEX_ATTRIBS)
6471 {
Geoff Langb1196682014-07-23 13:47:29 -04006472 context->recordError(gl::Error(GL_INVALID_VALUE));
6473 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006474 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006475
Geoff Langbfdea662014-07-23 14:16:32 -04006476 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006477
Geoff Langb1196682014-07-23 13:47:29 -04006478 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006479 {
6480 return;
6481 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006482
Geoff Langbfdea662014-07-23 14:16:32 -04006483 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6484 {
6485 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6486 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006487 {
Geoff Langbfdea662014-07-23 14:16:32 -04006488 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006489 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006490 }
Geoff Langbfdea662014-07-23 14:16:32 -04006491 else
6492 {
6493 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6494 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006495 }
6496}
6497
Kenneth Russell67ea1902014-10-06 16:44:50 -07006498void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006499{
6500 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6501 index, pname, params);
6502
Geoff Langbfdea662014-07-23 14:16:32 -04006503 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006504 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006505 {
Geoff Langbfdea662014-07-23 14:16:32 -04006506 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006507 {
Geoff Langb1196682014-07-23 13:47:29 -04006508 context->recordError(gl::Error(GL_INVALID_OPERATION));
6509 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006510 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006511
Geoff Langbfdea662014-07-23 14:16:32 -04006512 if (index >= gl::MAX_VERTEX_ATTRIBS)
6513 {
Geoff Langb1196682014-07-23 13:47:29 -04006514 context->recordError(gl::Error(GL_INVALID_VALUE));
6515 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006516 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006517
Geoff Langbfdea662014-07-23 14:16:32 -04006518 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006519
Geoff Langb1196682014-07-23 13:47:29 -04006520 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006521 {
6522 return;
6523 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006524
Geoff Langbfdea662014-07-23 14:16:32 -04006525 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6526 {
6527 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6528 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006529 {
Geoff Langbfdea662014-07-23 14:16:32 -04006530 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006531 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006532 }
Geoff Langbfdea662014-07-23 14:16:32 -04006533 else
6534 {
6535 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6536 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006537 }
6538}
6539
Kenneth Russell67ea1902014-10-06 16:44:50 -07006540void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541{
6542 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6543 index, x, y, z, w);
6544
Geoff Langbfdea662014-07-23 14:16:32 -04006545 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006546 if (context)
6547 {
6548 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006549 {
Geoff Langb1196682014-07-23 13:47:29 -04006550 context->recordError(gl::Error(GL_INVALID_OPERATION));
6551 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006552 }
Geoff Langbfdea662014-07-23 14:16:32 -04006553
6554 if (index >= gl::MAX_VERTEX_ATTRIBS)
6555 {
Geoff Langb1196682014-07-23 13:47:29 -04006556 context->recordError(gl::Error(GL_INVALID_VALUE));
6557 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006558 }
6559
6560 GLint vals[4] = { x, y, z, w };
6561 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006562 }
6563}
6564
Kenneth Russell67ea1902014-10-06 16:44:50 -07006565void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006566{
6567 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6568 index, x, y, z, w);
6569
Geoff Langbfdea662014-07-23 14:16:32 -04006570 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006571 if (context)
6572 {
6573 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006574 {
Geoff Langb1196682014-07-23 13:47:29 -04006575 context->recordError(gl::Error(GL_INVALID_OPERATION));
6576 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006577 }
Geoff Langbfdea662014-07-23 14:16:32 -04006578
6579 if (index >= gl::MAX_VERTEX_ATTRIBS)
6580 {
Geoff Langb1196682014-07-23 13:47:29 -04006581 context->recordError(gl::Error(GL_INVALID_VALUE));
6582 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006583 }
6584
6585 GLuint vals[4] = { x, y, z, w };
6586 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006587 }
6588}
6589
Kenneth Russell67ea1902014-10-06 16:44:50 -07006590void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006591{
6592 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6593
Geoff Langbfdea662014-07-23 14:16:32 -04006594 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006595 if (context)
6596 {
6597 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006598 {
Geoff Langb1196682014-07-23 13:47:29 -04006599 context->recordError(gl::Error(GL_INVALID_OPERATION));
6600 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006601 }
Geoff Langbfdea662014-07-23 14:16:32 -04006602
6603 if (index >= gl::MAX_VERTEX_ATTRIBS)
6604 {
Geoff Langb1196682014-07-23 13:47:29 -04006605 context->recordError(gl::Error(GL_INVALID_VALUE));
6606 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006607 }
6608
6609 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006610 }
6611}
6612
Kenneth Russell67ea1902014-10-06 16:44:50 -07006613void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006614{
6615 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6616
Geoff Langbfdea662014-07-23 14:16:32 -04006617 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006618 if (context)
6619 {
6620 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006621 {
Geoff Langb1196682014-07-23 13:47:29 -04006622 context->recordError(gl::Error(GL_INVALID_OPERATION));
6623 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006624 }
Geoff Langbfdea662014-07-23 14:16:32 -04006625
6626 if (index >= gl::MAX_VERTEX_ATTRIBS)
6627 {
Geoff Langb1196682014-07-23 13:47:29 -04006628 context->recordError(gl::Error(GL_INVALID_VALUE));
6629 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006630 }
6631
6632 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006633 }
6634}
6635
Kenneth Russell67ea1902014-10-06 16:44:50 -07006636void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637{
6638 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6639 program, location, params);
6640
Geoff Langbfdea662014-07-23 14:16:32 -04006641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006642 if (context)
6643 {
Jamie Madill0063c512014-08-25 15:47:53 -04006644 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006645 {
Jamie Madill0063c512014-08-25 15:47:53 -04006646 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006647 }
Geoff Langbfdea662014-07-23 14:16:32 -04006648
Jamie Madilla502c742014-08-28 17:19:13 -04006649 gl::Program *programObject = context->getProgram(program);
6650 ASSERT(programObject);
6651 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006652 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006653
Jamie Madill99a1e982014-08-25 15:47:54 -04006654 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006655 }
6656}
6657
Kenneth Russell67ea1902014-10-06 16:44:50 -07006658GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006659{
6660 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6661 program, name);
6662
Geoff Langbfdea662014-07-23 14:16:32 -04006663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006664 if (context)
6665 {
6666 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006667 {
Geoff Langb1196682014-07-23 13:47:29 -04006668 context->recordError(gl::Error(GL_INVALID_OPERATION));
6669 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006670 }
Geoff Langbfdea662014-07-23 14:16:32 -04006671
6672 if (program == 0)
6673 {
Geoff Langb1196682014-07-23 13:47:29 -04006674 context->recordError(gl::Error(GL_INVALID_VALUE));
6675 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006676 }
6677
6678 gl::Program *programObject = context->getProgram(program);
6679
6680 if (!programObject || !programObject->isLinked())
6681 {
Geoff Langb1196682014-07-23 13:47:29 -04006682 context->recordError(gl::Error(GL_INVALID_OPERATION));
6683 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006684 }
6685
6686 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6687 if (!programBinary)
6688 {
Geoff Langb1196682014-07-23 13:47:29 -04006689 context->recordError(gl::Error(GL_INVALID_OPERATION));
6690 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006691 }
6692
6693 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006694 }
6695
6696 return 0;
6697}
6698
Kenneth Russell67ea1902014-10-06 16:44:50 -07006699void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006700{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006701 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006702}
6703
Kenneth Russell67ea1902014-10-06 16:44:50 -07006704void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006705{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006706 const GLuint xy[] = { v0, v1 };
6707 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006708}
6709
Kenneth Russell67ea1902014-10-06 16:44:50 -07006710void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006711{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006712 const GLuint xyz[] = { v0, v1, v2 };
6713 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006714}
6715
Kenneth Russell67ea1902014-10-06 16:44:50 -07006716void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006717{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006718 const GLuint xyzw[] = { v0, v1, v2, v3 };
6719 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006720}
6721
Kenneth Russell67ea1902014-10-06 16:44:50 -07006722void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006723{
6724 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6725 location, count, value);
6726
Geoff Langbfdea662014-07-23 14:16:32 -04006727 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006728 if (context)
6729 {
6730 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006731 {
Geoff Langbfdea662014-07-23 14:16:32 -04006732 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006733 }
Geoff Langbfdea662014-07-23 14:16:32 -04006734
6735 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6736 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006737 }
6738}
6739
Kenneth Russell67ea1902014-10-06 16:44:50 -07006740void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006741{
6742 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6743 location, count, value);
6744
Geoff Langbfdea662014-07-23 14:16:32 -04006745 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006746 if (context)
6747 {
6748 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006749 {
Geoff Langbfdea662014-07-23 14:16:32 -04006750 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006751 }
Geoff Langbfdea662014-07-23 14:16:32 -04006752
6753 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6754 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006755 }
6756}
6757
Kenneth Russell67ea1902014-10-06 16:44:50 -07006758void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006759{
6760 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6761 location, count, value);
6762
Geoff Langbfdea662014-07-23 14:16:32 -04006763 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006764 if (context)
6765 {
6766 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006767 {
Geoff Langbfdea662014-07-23 14:16:32 -04006768 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006769 }
Geoff Langbfdea662014-07-23 14:16:32 -04006770
6771 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6772 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006773 }
6774}
6775
Kenneth Russell67ea1902014-10-06 16:44:50 -07006776void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006777{
6778 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6779 location, count, value);
6780
Geoff Langbfdea662014-07-23 14:16:32 -04006781 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006782 if (context)
6783 {
6784 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006785 {
Geoff Langbfdea662014-07-23 14:16:32 -04006786 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006787 }
Geoff Langbfdea662014-07-23 14:16:32 -04006788
6789 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6790 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006791 }
6792}
6793
Kenneth Russell67ea1902014-10-06 16:44:50 -07006794void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006795{
6796 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6797 buffer, drawbuffer, value);
6798
Geoff Langbfdea662014-07-23 14:16:32 -04006799 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006800 if (context)
6801 {
6802 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006803 {
Geoff Langbfdea662014-07-23 14:16:32 -04006804 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006805 }
Geoff Langbfdea662014-07-23 14:16:32 -04006806
6807 switch (buffer)
6808 {
6809 case GL_COLOR:
6810 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6811 {
Geoff Langb1196682014-07-23 13:47:29 -04006812 context->recordError(gl::Error(GL_INVALID_VALUE));
6813 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006814 }
6815 break;
Geoff Langb1196682014-07-23 13:47:29 -04006816
Geoff Langbfdea662014-07-23 14:16:32 -04006817 case GL_STENCIL:
6818 if (drawbuffer != 0)
6819 {
Geoff Langb1196682014-07-23 13:47:29 -04006820 context->recordError(gl::Error(GL_INVALID_VALUE));
6821 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006822 }
6823 break;
Geoff Langb1196682014-07-23 13:47:29 -04006824
Geoff Langbfdea662014-07-23 14:16:32 -04006825 default:
Geoff Langb1196682014-07-23 13:47:29 -04006826 context->recordError(gl::Error(GL_INVALID_ENUM));
6827 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006828 }
6829
Geoff Langcc79b8c2014-07-25 13:48:02 -04006830 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6831 if (error.isError())
6832 {
6833 context->recordError(error);
6834 return;
6835 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006836 }
6837}
6838
Kenneth Russell67ea1902014-10-06 16:44:50 -07006839void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006840{
6841 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6842 buffer, drawbuffer, value);
6843
Geoff Langbfdea662014-07-23 14:16:32 -04006844 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006845 if (context)
6846 {
6847 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006848 {
Geoff Langbfdea662014-07-23 14:16:32 -04006849 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006850 }
Geoff Langbfdea662014-07-23 14:16:32 -04006851
6852 switch (buffer)
6853 {
6854 case GL_COLOR:
6855 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6856 {
Geoff Langb1196682014-07-23 13:47:29 -04006857 context->recordError(gl::Error(GL_INVALID_VALUE));
6858 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006859 }
6860 break;
Geoff Langb1196682014-07-23 13:47:29 -04006861
Geoff Langbfdea662014-07-23 14:16:32 -04006862 default:
Geoff Langb1196682014-07-23 13:47:29 -04006863 context->recordError(gl::Error(GL_INVALID_ENUM));
6864 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006865 }
6866
Geoff Langcc79b8c2014-07-25 13:48:02 -04006867 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6868 if (error.isError())
6869 {
6870 context->recordError(error);
6871 return;
6872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006873 }
6874}
6875
Kenneth Russell67ea1902014-10-06 16:44:50 -07006876void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006877{
6878 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6879 buffer, drawbuffer, value);
6880
Geoff Langbfdea662014-07-23 14:16:32 -04006881 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006882 if (context)
6883 {
6884 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006885 {
Geoff Langbfdea662014-07-23 14:16:32 -04006886 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006887 }
Geoff Langbfdea662014-07-23 14:16:32 -04006888
6889 switch (buffer)
6890 {
6891 case GL_COLOR:
6892 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6893 {
Geoff Langb1196682014-07-23 13:47:29 -04006894 context->recordError(gl::Error(GL_INVALID_VALUE));
6895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006896 }
6897 break;
Geoff Langb1196682014-07-23 13:47:29 -04006898
Geoff Langbfdea662014-07-23 14:16:32 -04006899 case GL_DEPTH:
6900 if (drawbuffer != 0)
6901 {
Geoff Langb1196682014-07-23 13:47:29 -04006902 context->recordError(gl::Error(GL_INVALID_VALUE));
6903 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006904 }
6905 break;
Geoff Langb1196682014-07-23 13:47:29 -04006906
Geoff Langbfdea662014-07-23 14:16:32 -04006907 default:
Geoff Langb1196682014-07-23 13:47:29 -04006908 context->recordError(gl::Error(GL_INVALID_ENUM));
6909 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006910 }
6911
Geoff Langcc79b8c2014-07-25 13:48:02 -04006912 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6913 if (error.isError())
6914 {
6915 context->recordError(error);
6916 return;
6917 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006918 }
6919}
6920
Kenneth Russell67ea1902014-10-06 16:44:50 -07006921void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006922{
6923 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6924 buffer, drawbuffer, depth, stencil);
6925
Geoff Langbfdea662014-07-23 14:16:32 -04006926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006927 if (context)
6928 {
6929 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006930 {
Geoff Langbfdea662014-07-23 14:16:32 -04006931 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006932 }
Geoff Langbfdea662014-07-23 14:16:32 -04006933
6934 switch (buffer)
6935 {
6936 case GL_DEPTH_STENCIL:
6937 if (drawbuffer != 0)
6938 {
Geoff Langb1196682014-07-23 13:47:29 -04006939 context->recordError(gl::Error(GL_INVALID_VALUE));
6940 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006941 }
6942 break;
Geoff Langb1196682014-07-23 13:47:29 -04006943
Geoff Langbfdea662014-07-23 14:16:32 -04006944 default:
Geoff Langb1196682014-07-23 13:47:29 -04006945 context->recordError(gl::Error(GL_INVALID_ENUM));
6946 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006947 }
6948
Geoff Langcc79b8c2014-07-25 13:48:02 -04006949 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6950 if (error.isError())
6951 {
6952 context->recordError(error);
6953 return;
6954 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006955 }
6956}
6957
Kenneth Russell67ea1902014-10-06 16:44:50 -07006958const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006959{
6960 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6961
Geoff Langbfdea662014-07-23 14:16:32 -04006962 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006963 if (context)
6964 {
6965 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006966 {
Geoff Langb1196682014-07-23 13:47:29 -04006967 context->recordError(gl::Error(GL_INVALID_OPERATION));
6968 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006969 }
Geoff Langbfdea662014-07-23 14:16:32 -04006970
6971 if (name != GL_EXTENSIONS)
6972 {
Geoff Langb1196682014-07-23 13:47:29 -04006973 context->recordError(gl::Error(GL_INVALID_ENUM));
6974 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006975 }
6976
6977 if (index >= context->getExtensionStringCount())
6978 {
Geoff Langb1196682014-07-23 13:47:29 -04006979 context->recordError(gl::Error(GL_INVALID_VALUE));
6980 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006981 }
6982
6983 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006984 }
6985
6986 return NULL;
6987}
6988
Kenneth Russell67ea1902014-10-06 16:44:50 -07006989void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006990{
6991 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6992 readTarget, writeTarget, readOffset, writeOffset, size);
6993
Geoff Langbfdea662014-07-23 14:16:32 -04006994 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006995 if (context)
6996 {
6997 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006998 {
Geoff Langb1196682014-07-23 13:47:29 -04006999 context->recordError(gl::Error(GL_INVALID_OPERATION));
7000 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00007001 }
Geoff Langbfdea662014-07-23 14:16:32 -04007002
Jamie Madill24e83192014-10-20 11:00:53 -04007003 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04007004 {
Geoff Langb1196682014-07-23 13:47:29 -04007005 context->recordError(gl::Error(GL_INVALID_ENUM));
7006 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007007 }
7008
7009 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
7010 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
7011
7012 if (!readBuffer || !writeBuffer)
7013 {
Geoff Langb1196682014-07-23 13:47:29 -04007014 context->recordError(gl::Error(GL_INVALID_OPERATION));
7015 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007016 }
7017
Jamie Madillcfaaf722014-07-31 10:47:54 -04007018 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04007019 if (readBuffer->isMapped() || writeBuffer->isMapped())
7020 {
Geoff Langb1196682014-07-23 13:47:29 -04007021 context->recordError(gl::Error(GL_INVALID_OPERATION));
7022 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007023 }
7024
7025 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7026 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7027 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7028 {
Geoff Langb1196682014-07-23 13:47:29 -04007029 context->recordError(gl::Error(GL_INVALID_VALUE));
7030 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007031 }
7032
Kenneth Russell67ea1902014-10-06 16:44:50 -07007033 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007034 {
Geoff Langb1196682014-07-23 13:47:29 -04007035 context->recordError(gl::Error(GL_INVALID_VALUE));
7036 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007037 }
7038
Geoff Langbfdea662014-07-23 14:16:32 -04007039 // if size is zero, the copy is a successful no-op
7040 if (size > 0)
7041 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007042 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7043 if (error.isError())
7044 {
7045 context->recordError(error);
7046 return;
7047 }
Geoff Langbfdea662014-07-23 14:16:32 -04007048 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007049 }
7050}
7051
Kenneth Russell67ea1902014-10-06 16:44:50 -07007052void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007053{
7054 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7055 program, uniformCount, uniformNames, uniformIndices);
7056
Geoff Langbfdea662014-07-23 14:16:32 -04007057 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007058 if (context)
7059 {
7060 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007061 {
Geoff Langb1196682014-07-23 13:47:29 -04007062 context->recordError(gl::Error(GL_INVALID_OPERATION));
7063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007064 }
7065
7066 if (uniformCount < 0)
7067 {
Geoff Langb1196682014-07-23 13:47:29 -04007068 context->recordError(gl::Error(GL_INVALID_VALUE));
7069 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007070 }
7071
7072 gl::Program *programObject = context->getProgram(program);
7073
7074 if (!programObject)
7075 {
7076 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007077 {
Geoff Langb1196682014-07-23 13:47:29 -04007078 context->recordError(gl::Error(GL_INVALID_OPERATION));
7079 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007080 }
Geoff Langbfdea662014-07-23 14:16:32 -04007081 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007082 {
Geoff Langb1196682014-07-23 13:47:29 -04007083 context->recordError(gl::Error(GL_INVALID_VALUE));
7084 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007085 }
Geoff Langbfdea662014-07-23 14:16:32 -04007086 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007087
Geoff Langbfdea662014-07-23 14:16:32 -04007088 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7089 if (!programObject->isLinked() || !programBinary)
7090 {
7091 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007092 {
Geoff Langbfdea662014-07-23 14:16:32 -04007093 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007094 }
7095 }
Geoff Langbfdea662014-07-23 14:16:32 -04007096 else
7097 {
7098 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7099 {
7100 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7101 }
7102 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007103 }
7104}
7105
Kenneth Russell67ea1902014-10-06 16:44:50 -07007106void 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 +00007107{
7108 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7109 program, uniformCount, uniformIndices, pname, params);
7110
Geoff Langbfdea662014-07-23 14:16:32 -04007111 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007112 if (context)
7113 {
7114 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007115 {
Geoff Langb1196682014-07-23 13:47:29 -04007116 context->recordError(gl::Error(GL_INVALID_OPERATION));
7117 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007118 }
7119
7120 if (uniformCount < 0)
7121 {
Geoff Langb1196682014-07-23 13:47:29 -04007122 context->recordError(gl::Error(GL_INVALID_VALUE));
7123 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007124 }
7125
7126 gl::Program *programObject = context->getProgram(program);
7127
7128 if (!programObject)
7129 {
7130 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007131 {
Geoff Langb1196682014-07-23 13:47:29 -04007132 context->recordError(gl::Error(GL_INVALID_OPERATION));
7133 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007134 }
Geoff Langbfdea662014-07-23 14:16:32 -04007135 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007136 {
Geoff Langb1196682014-07-23 13:47:29 -04007137 context->recordError(gl::Error(GL_INVALID_VALUE));
7138 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007139 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007140 }
Geoff Langbfdea662014-07-23 14:16:32 -04007141
7142 switch (pname)
7143 {
7144 case GL_UNIFORM_TYPE:
7145 case GL_UNIFORM_SIZE:
7146 case GL_UNIFORM_NAME_LENGTH:
7147 case GL_UNIFORM_BLOCK_INDEX:
7148 case GL_UNIFORM_OFFSET:
7149 case GL_UNIFORM_ARRAY_STRIDE:
7150 case GL_UNIFORM_MATRIX_STRIDE:
7151 case GL_UNIFORM_IS_ROW_MAJOR:
7152 break;
Geoff Langb1196682014-07-23 13:47:29 -04007153
Geoff Langbfdea662014-07-23 14:16:32 -04007154 default:
Geoff Langb1196682014-07-23 13:47:29 -04007155 context->recordError(gl::Error(GL_INVALID_ENUM));
7156 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007157 }
7158
7159 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7160
7161 if (!programBinary && uniformCount > 0)
7162 {
Geoff Langb1196682014-07-23 13:47:29 -04007163 context->recordError(gl::Error(GL_INVALID_VALUE));
7164 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007165 }
7166
7167 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7168 {
7169 const GLuint index = uniformIndices[uniformId];
7170
7171 if (index >= (GLuint)programBinary->getActiveUniformCount())
7172 {
Geoff Langb1196682014-07-23 13:47:29 -04007173 context->recordError(gl::Error(GL_INVALID_VALUE));
7174 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007175 }
7176 }
7177
7178 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7179 {
7180 const GLuint index = uniformIndices[uniformId];
7181 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7182 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007183 }
7184}
7185
Kenneth Russell67ea1902014-10-06 16:44:50 -07007186GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007187{
7188 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7189
Geoff Langbfdea662014-07-23 14:16:32 -04007190 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007191 if (context)
7192 {
7193 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007194 {
Geoff Langb1196682014-07-23 13:47:29 -04007195 context->recordError(gl::Error(GL_INVALID_OPERATION));
7196 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007197 }
7198
7199 gl::Program *programObject = context->getProgram(program);
7200
7201 if (!programObject)
7202 {
7203 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007204 {
Geoff Langb1196682014-07-23 13:47:29 -04007205 context->recordError(gl::Error(GL_INVALID_OPERATION));
7206 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007207 }
Geoff Langbfdea662014-07-23 14:16:32 -04007208 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007209 {
Geoff Langb1196682014-07-23 13:47:29 -04007210 context->recordError(gl::Error(GL_INVALID_VALUE));
7211 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007212 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007213 }
Geoff Langbfdea662014-07-23 14:16:32 -04007214
7215 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7216 if (!programBinary)
7217 {
7218 return GL_INVALID_INDEX;
7219 }
7220
7221 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007222 }
7223
7224 return 0;
7225}
7226
Kenneth Russell67ea1902014-10-06 16:44:50 -07007227void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007228{
7229 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7230 program, uniformBlockIndex, pname, params);
7231
Geoff Langbfdea662014-07-23 14:16:32 -04007232 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007233 if (context)
7234 {
7235 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007236 {
Geoff Langb1196682014-07-23 13:47:29 -04007237 context->recordError(gl::Error(GL_INVALID_OPERATION));
7238 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007239 }
7240 gl::Program *programObject = context->getProgram(program);
7241
7242 if (!programObject)
7243 {
7244 if (context->getShader(program))
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;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007248 }
Geoff Langbfdea662014-07-23 14:16:32 -04007249 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007250 {
Geoff Langb1196682014-07-23 13:47:29 -04007251 context->recordError(gl::Error(GL_INVALID_VALUE));
7252 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007253 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007254 }
Geoff Langbfdea662014-07-23 14:16:32 -04007255
7256 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7257
7258 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7259 {
Geoff Langb1196682014-07-23 13:47:29 -04007260 context->recordError(gl::Error(GL_INVALID_VALUE));
7261 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007262 }
7263
7264 switch (pname)
7265 {
7266 case GL_UNIFORM_BLOCK_BINDING:
7267 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7268 break;
7269
7270 case GL_UNIFORM_BLOCK_DATA_SIZE:
7271 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7272 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7273 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7274 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7275 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7276 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7277 break;
7278
7279 default:
Geoff Langb1196682014-07-23 13:47:29 -04007280 context->recordError(gl::Error(GL_INVALID_ENUM));
7281 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007282 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007283 }
7284}
7285
Kenneth Russell67ea1902014-10-06 16:44:50 -07007286void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007287{
7288 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7289 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7290
Geoff Langbfdea662014-07-23 14:16:32 -04007291 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007292 if (context)
7293 {
7294 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007295 {
Geoff Langb1196682014-07-23 13:47:29 -04007296 context->recordError(gl::Error(GL_INVALID_OPERATION));
7297 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007298 }
7299
7300 gl::Program *programObject = context->getProgram(program);
7301
7302 if (!programObject)
7303 {
7304 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007305 {
Geoff Langb1196682014-07-23 13:47:29 -04007306 context->recordError(gl::Error(GL_INVALID_OPERATION));
7307 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007308 }
Geoff Langbfdea662014-07-23 14:16:32 -04007309 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007310 {
Geoff Langb1196682014-07-23 13:47:29 -04007311 context->recordError(gl::Error(GL_INVALID_VALUE));
7312 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007313 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007314 }
Geoff Langbfdea662014-07-23 14:16:32 -04007315
7316 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7317
7318 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7319 {
Geoff Langb1196682014-07-23 13:47:29 -04007320 context->recordError(gl::Error(GL_INVALID_VALUE));
7321 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007322 }
7323
7324 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007325 }
7326}
7327
Kenneth Russell67ea1902014-10-06 16:44:50 -07007328void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007329{
7330 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7331 program, uniformBlockIndex, uniformBlockBinding);
7332
Geoff Langbfdea662014-07-23 14:16:32 -04007333 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007334 if (context)
7335 {
7336 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007337 {
Geoff Langb1196682014-07-23 13:47:29 -04007338 context->recordError(gl::Error(GL_INVALID_OPERATION));
7339 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007340 }
7341
Geoff Lang3a61c322014-07-10 13:01:54 -04007342 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007343 {
Geoff Langb1196682014-07-23 13:47:29 -04007344 context->recordError(gl::Error(GL_INVALID_VALUE));
7345 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007346 }
7347
7348 gl::Program *programObject = context->getProgram(program);
7349
7350 if (!programObject)
7351 {
7352 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007353 {
Geoff Langb1196682014-07-23 13:47:29 -04007354 context->recordError(gl::Error(GL_INVALID_OPERATION));
7355 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007356 }
Geoff Langbfdea662014-07-23 14:16:32 -04007357 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007358 {
Geoff Langb1196682014-07-23 13:47:29 -04007359 context->recordError(gl::Error(GL_INVALID_VALUE));
7360 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007361 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007362 }
Geoff Langbfdea662014-07-23 14:16:32 -04007363
7364 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7365
7366 // if never linked, there won't be any uniform blocks
7367 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7368 {
Geoff Langb1196682014-07-23 13:47:29 -04007369 context->recordError(gl::Error(GL_INVALID_VALUE));
7370 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007371 }
7372
7373 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007374 }
7375}
7376
Kenneth Russell67ea1902014-10-06 16:44:50 -07007377void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007378{
7379 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7380 mode, first, count, instanceCount);
7381
Geoff Langbfdea662014-07-23 14:16:32 -04007382 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007383 if (context)
7384 {
7385 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007386 {
Geoff Langb1196682014-07-23 13:47:29 -04007387 context->recordError(gl::Error(GL_INVALID_OPERATION));
7388 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007389 }
Geoff Langbfdea662014-07-23 14:16:32 -04007390
7391 // glDrawArraysInstanced
7392 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007393 }
7394}
7395
Kenneth Russell67ea1902014-10-06 16:44:50 -07007396void 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 +00007397{
7398 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7399 mode, count, type, indices, instanceCount);
7400
Geoff Langbfdea662014-07-23 14:16:32 -04007401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007402 if (context)
7403 {
7404 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007405 {
Geoff Langb1196682014-07-23 13:47:29 -04007406 context->recordError(gl::Error(GL_INVALID_OPERATION));
7407 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007408 }
Geoff Langbfdea662014-07-23 14:16:32 -04007409
7410 // glDrawElementsInstanced
7411 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007412 }
7413}
7414
Kenneth Russell67ea1902014-10-06 16:44:50 -07007415GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007416{
7417 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7418
Geoff Langbfdea662014-07-23 14:16:32 -04007419 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007420 if (context)
7421 {
7422 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007423 {
Geoff Langb1196682014-07-23 13:47:29 -04007424 context->recordError(gl::Error(GL_INVALID_OPERATION));
7425 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007426 }
Geoff Langbfdea662014-07-23 14:16:32 -04007427
7428 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7429 {
Geoff Langb1196682014-07-23 13:47:29 -04007430 context->recordError(gl::Error(GL_INVALID_ENUM));
7431 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007432 }
7433
7434 if (flags != 0)
7435 {
Geoff Langb1196682014-07-23 13:47:29 -04007436 context->recordError(gl::Error(GL_INVALID_VALUE));
7437 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007438 }
7439
Geoff Lang882033e2014-09-30 11:26:07 -04007440 GLsync fenceSync = context->createFenceSync();
7441
7442 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7443 gl::Error error = fenceSyncObject->set(condition);
7444 if (error.isError())
7445 {
7446 context->deleteFenceSync(fenceSync);
7447 context->recordError(error);
7448 return NULL;
7449 }
7450
7451 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007452 }
7453
7454 return NULL;
7455}
7456
Kenneth Russell67ea1902014-10-06 16:44:50 -07007457GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007458{
7459 EVENT("(GLsync sync = 0x%0.8p)", sync);
7460
Geoff Langbfdea662014-07-23 14:16:32 -04007461 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007462 if (context)
7463 {
7464 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007465 {
Geoff Langb1196682014-07-23 13:47:29 -04007466 context->recordError(gl::Error(GL_INVALID_OPERATION));
7467 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007468 }
Geoff Langbfdea662014-07-23 14:16:32 -04007469
7470 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007471 }
7472
7473 return GL_FALSE;
7474}
7475
Kenneth Russell67ea1902014-10-06 16:44:50 -07007476void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007477{
7478 EVENT("(GLsync sync = 0x%0.8p)", sync);
7479
Geoff Langbfdea662014-07-23 14:16:32 -04007480 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007481 if (context)
7482 {
7483 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007484 {
Geoff Langb1196682014-07-23 13:47:29 -04007485 context->recordError(gl::Error(GL_INVALID_OPERATION));
7486 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007487 }
Geoff Langbfdea662014-07-23 14:16:32 -04007488
7489 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7490 {
Geoff Langb1196682014-07-23 13:47:29 -04007491 context->recordError(gl::Error(GL_INVALID_VALUE));
7492 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007493 }
7494
7495 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007496 }
7497}
7498
Kenneth Russell67ea1902014-10-06 16:44:50 -07007499GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007500{
7501 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7502 sync, flags, timeout);
7503
Geoff Langbfdea662014-07-23 14:16:32 -04007504 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007505 if (context)
7506 {
7507 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007508 {
Geoff Langb1196682014-07-23 13:47:29 -04007509 context->recordError(gl::Error(GL_INVALID_OPERATION));
7510 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007511 }
Geoff Langbfdea662014-07-23 14:16:32 -04007512
7513 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7514 {
Geoff Langb1196682014-07-23 13:47:29 -04007515 context->recordError(gl::Error(GL_INVALID_VALUE));
7516 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007517 }
7518
7519 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7520
7521 if (!fenceSync)
7522 {
Geoff Langb1196682014-07-23 13:47:29 -04007523 context->recordError(gl::Error(GL_INVALID_VALUE));
7524 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007525 }
7526
Geoff Lang882033e2014-09-30 11:26:07 -04007527 GLenum result = GL_WAIT_FAILED;
7528 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7529 if (error.isError())
7530 {
7531 context->recordError(error);
7532 return GL_WAIT_FAILED;
7533 }
7534
7535 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007536 }
7537
7538 return GL_FALSE;
7539}
7540
Kenneth Russell67ea1902014-10-06 16:44:50 -07007541void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007542{
7543 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7544 sync, flags, timeout);
7545
Geoff Langbfdea662014-07-23 14:16:32 -04007546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007547 if (context)
7548 {
7549 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007550 {
Geoff Langb1196682014-07-23 13:47:29 -04007551 context->recordError(gl::Error(GL_INVALID_OPERATION));
7552 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007553 }
Geoff Langbfdea662014-07-23 14:16:32 -04007554
7555 if (flags != 0)
7556 {
Geoff Langb1196682014-07-23 13:47:29 -04007557 context->recordError(gl::Error(GL_INVALID_VALUE));
7558 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007559 }
7560
7561 if (timeout != GL_TIMEOUT_IGNORED)
7562 {
Geoff Langb1196682014-07-23 13:47:29 -04007563 context->recordError(gl::Error(GL_INVALID_VALUE));
7564 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007565 }
7566
7567 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7568
7569 if (!fenceSync)
7570 {
Geoff Langb1196682014-07-23 13:47:29 -04007571 context->recordError(gl::Error(GL_INVALID_VALUE));
7572 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007573 }
7574
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007575 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007576 if (error.isError())
7577 {
7578 context->recordError(error);
7579 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007580 }
7581}
7582
Kenneth Russell67ea1902014-10-06 16:44:50 -07007583void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007584{
7585 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7586 pname, params);
7587
Geoff Langbfdea662014-07-23 14:16:32 -04007588 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007589 if (context)
7590 {
7591 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007592 {
Geoff Langb1196682014-07-23 13:47:29 -04007593 context->recordError(gl::Error(GL_INVALID_OPERATION));
7594 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007595 }
Geoff Langbfdea662014-07-23 14:16:32 -04007596
7597 GLenum nativeType;
7598 unsigned int numParams = 0;
7599 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7600 {
7601 return;
7602 }
7603
7604 if (nativeType == GL_INT_64_ANGLEX)
7605 {
7606 context->getInteger64v(pname, params);
7607 }
7608 else
7609 {
7610 CastStateValues(context, nativeType, pname, numParams, params);
7611 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007612 }
7613}
7614
Kenneth Russell67ea1902014-10-06 16:44:50 -07007615void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007616{
7617 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7618 sync, pname, bufSize, length, values);
7619
Geoff Langbfdea662014-07-23 14:16:32 -04007620 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007621 if (context)
7622 {
7623 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007624 {
Geoff Langb1196682014-07-23 13:47:29 -04007625 context->recordError(gl::Error(GL_INVALID_OPERATION));
7626 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007627 }
Geoff Langbfdea662014-07-23 14:16:32 -04007628
7629 if (bufSize < 0)
7630 {
Geoff Langb1196682014-07-23 13:47:29 -04007631 context->recordError(gl::Error(GL_INVALID_VALUE));
7632 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007633 }
7634
7635 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7636
7637 if (!fenceSync)
7638 {
Geoff Langb1196682014-07-23 13:47:29 -04007639 context->recordError(gl::Error(GL_INVALID_VALUE));
7640 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007641 }
7642
7643 switch (pname)
7644 {
7645 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007646 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7647 case GL_SYNC_FLAGS: values[0] = 0; break;
7648
Geoff Lang882033e2014-09-30 11:26:07 -04007649 case GL_SYNC_STATUS:
7650 {
7651 gl::Error error = fenceSync->getStatus(values);
7652 if (error.isError())
7653 {
7654 context->recordError(error);
7655 return;
7656 }
7657 break;
7658 }
7659
Geoff Langbfdea662014-07-23 14:16:32 -04007660 default:
Geoff Langb1196682014-07-23 13:47:29 -04007661 context->recordError(gl::Error(GL_INVALID_ENUM));
7662 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007663 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007664 }
7665}
7666
Kenneth Russell67ea1902014-10-06 16:44:50 -07007667void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007668{
7669 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7670 target, index, data);
7671
Geoff Langbfdea662014-07-23 14:16:32 -04007672 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007673 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007674 {
Geoff Langbfdea662014-07-23 14:16:32 -04007675 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007676 {
Geoff Langb1196682014-07-23 13:47:29 -04007677 context->recordError(gl::Error(GL_INVALID_OPERATION));
7678 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007679 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007680
Geoff Lang3a61c322014-07-10 13:01:54 -04007681 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007682 switch (target)
7683 {
7684 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7685 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7686 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007687 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7688 {
Geoff Langb1196682014-07-23 13:47:29 -04007689 context->recordError(gl::Error(GL_INVALID_VALUE));
7690 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007691 }
Geoff Langbfdea662014-07-23 14:16:32 -04007692 break;
Geoff Langb1196682014-07-23 13:47:29 -04007693
Geoff Langbfdea662014-07-23 14:16:32 -04007694 case GL_UNIFORM_BUFFER_START:
7695 case GL_UNIFORM_BUFFER_SIZE:
7696 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007697 if (index >= caps.maxUniformBufferBindings)
7698 {
Geoff Langb1196682014-07-23 13:47:29 -04007699 context->recordError(gl::Error(GL_INVALID_VALUE));
7700 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007701 }
Geoff Langbfdea662014-07-23 14:16:32 -04007702 break;
Geoff Langb1196682014-07-23 13:47:29 -04007703
Geoff Langbfdea662014-07-23 14:16:32 -04007704 default:
Geoff Langb1196682014-07-23 13:47:29 -04007705 context->recordError(gl::Error(GL_INVALID_ENUM));
7706 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007707 }
7708
7709 if (!(context->getIndexedInteger64v(target, index, data)))
7710 {
7711 GLenum nativeType;
7712 unsigned int numParams = 0;
7713 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007714 {
7715 context->recordError(gl::Error(GL_INVALID_ENUM));
7716 return;
7717 }
Shannon Woods15934d52013-08-19 14:28:49 -04007718
Geoff Langbfdea662014-07-23 14:16:32 -04007719 if (numParams == 0)
7720 return; // it is known that pname is valid, but there are no parameters to return
7721
7722 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007723 {
Geoff Langbfdea662014-07-23 14:16:32 -04007724 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007725
Geoff Langbfdea662014-07-23 14:16:32 -04007726 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007727
Geoff Langbfdea662014-07-23 14:16:32 -04007728 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007729 {
Geoff Langbfdea662014-07-23 14:16:32 -04007730 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007731 }
Geoff Langbfdea662014-07-23 14:16:32 -04007732
7733 delete [] intParams;
7734 }
7735 else
7736 {
7737 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007738 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007739 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007740 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007741}
7742
Kenneth Russell67ea1902014-10-06 16:44:50 -07007743void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007744{
7745 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7746 target, pname, params);
7747
Geoff Langbfdea662014-07-23 14:16:32 -04007748 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007749 if (context)
7750 {
7751 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007752 {
Geoff Langb1196682014-07-23 13:47:29 -04007753 context->recordError(gl::Error(GL_INVALID_OPERATION));
7754 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007755 }
Geoff Langbfdea662014-07-23 14:16:32 -04007756
7757 if (!gl::ValidBufferTarget(context, target))
7758 {
Geoff Langb1196682014-07-23 13:47:29 -04007759 context->recordError(gl::Error(GL_INVALID_ENUM));
7760 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007761 }
7762
7763 if (!gl::ValidBufferParameter(context, pname))
7764 {
Geoff Langb1196682014-07-23 13:47:29 -04007765 context->recordError(gl::Error(GL_INVALID_ENUM));
7766 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007767 }
7768
7769 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7770
7771 if (!buffer)
7772 {
7773 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007774 context->recordError(gl::Error(GL_INVALID_OPERATION));
7775 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007776 }
7777
7778 switch (pname)
7779 {
7780 case GL_BUFFER_USAGE:
7781 *params = static_cast<GLint64>(buffer->getUsage());
7782 break;
7783 case GL_BUFFER_SIZE:
7784 *params = buffer->getSize();
7785 break;
7786 case GL_BUFFER_ACCESS_FLAGS:
7787 *params = static_cast<GLint64>(buffer->getAccessFlags());
7788 break;
7789 case GL_BUFFER_MAPPED:
7790 *params = static_cast<GLint64>(buffer->isMapped());
7791 break;
7792 case GL_BUFFER_MAP_OFFSET:
7793 *params = buffer->getMapOffset();
7794 break;
7795 case GL_BUFFER_MAP_LENGTH:
7796 *params = buffer->getMapLength();
7797 break;
7798 default: UNREACHABLE(); break;
7799 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007800 }
7801}
7802
Kenneth Russell67ea1902014-10-06 16:44:50 -07007803void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804{
7805 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7806
Geoff Langbfdea662014-07-23 14:16:32 -04007807 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007808 if (context)
7809 {
7810 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007811 {
Geoff Langb1196682014-07-23 13:47:29 -04007812 context->recordError(gl::Error(GL_INVALID_OPERATION));
7813 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007814 }
Geoff Langbfdea662014-07-23 14:16:32 -04007815
7816 if (count < 0)
7817 {
Geoff Langb1196682014-07-23 13:47:29 -04007818 context->recordError(gl::Error(GL_INVALID_VALUE));
7819 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007820 }
7821
7822 for (int i = 0; i < count; i++)
7823 {
7824 samplers[i] = context->createSampler();
7825 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007826 }
7827}
7828
Kenneth Russell67ea1902014-10-06 16:44:50 -07007829void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830{
7831 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7832
Geoff Langbfdea662014-07-23 14:16:32 -04007833 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007834 if (context)
7835 {
7836 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007837 {
Geoff Langb1196682014-07-23 13:47:29 -04007838 context->recordError(gl::Error(GL_INVALID_OPERATION));
7839 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007840 }
Geoff Langbfdea662014-07-23 14:16:32 -04007841
7842 if (count < 0)
7843 {
Geoff Langb1196682014-07-23 13:47:29 -04007844 context->recordError(gl::Error(GL_INVALID_VALUE));
7845 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007846 }
7847
7848 for (int i = 0; i < count; i++)
7849 {
7850 context->deleteSampler(samplers[i]);
7851 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007852 }
7853}
7854
Kenneth Russell67ea1902014-10-06 16:44:50 -07007855GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007856{
7857 EVENT("(GLuint sampler = %u)", sampler);
7858
Geoff Langbfdea662014-07-23 14:16:32 -04007859 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007860 if (context)
7861 {
7862 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007863 {
Geoff Langb1196682014-07-23 13:47:29 -04007864 context->recordError(gl::Error(GL_INVALID_OPERATION));
7865 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007866 }
Geoff Langbfdea662014-07-23 14:16:32 -04007867
7868 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007869 }
7870
7871 return GL_FALSE;
7872}
7873
Kenneth Russell67ea1902014-10-06 16:44:50 -07007874void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007875{
7876 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7877
Geoff Langbfdea662014-07-23 14:16:32 -04007878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007879 if (context)
7880 {
7881 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007882 {
Geoff Langb1196682014-07-23 13:47:29 -04007883 context->recordError(gl::Error(GL_INVALID_OPERATION));
7884 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007885 }
Geoff Langbfdea662014-07-23 14:16:32 -04007886
7887 if (sampler != 0 && !context->isSampler(sampler))
7888 {
Geoff Langb1196682014-07-23 13:47:29 -04007889 context->recordError(gl::Error(GL_INVALID_OPERATION));
7890 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007891 }
7892
Geoff Lang3a61c322014-07-10 13:01:54 -04007893 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007894 {
Geoff Langb1196682014-07-23 13:47:29 -04007895 context->recordError(gl::Error(GL_INVALID_VALUE));
7896 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007897 }
7898
7899 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007900 }
7901}
7902
Kenneth Russell67ea1902014-10-06 16:44:50 -07007903void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007904{
7905 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7906
Geoff Langbfdea662014-07-23 14:16:32 -04007907 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007908 if (context)
7909 {
7910 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007911 {
Geoff Langb1196682014-07-23 13:47:29 -04007912 context->recordError(gl::Error(GL_INVALID_OPERATION));
7913 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007914 }
Geoff Langbfdea662014-07-23 14:16:32 -04007915
Geoff Langb1196682014-07-23 13:47:29 -04007916 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007917 {
7918 return;
7919 }
7920
7921 if (!gl::ValidateTexParamParameters(context, pname, param))
7922 {
7923 return;
7924 }
7925
7926 if (!context->isSampler(sampler))
7927 {
Geoff Langb1196682014-07-23 13:47:29 -04007928 context->recordError(gl::Error(GL_INVALID_OPERATION));
7929 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007930 }
7931
7932 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007933 }
7934}
7935
Kenneth Russell67ea1902014-10-06 16:44:50 -07007936void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007937{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007938 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007939}
7940
Kenneth Russell67ea1902014-10-06 16:44:50 -07007941void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007942{
7943 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7944
Geoff Langbfdea662014-07-23 14:16:32 -04007945 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007946 if (context)
7947 {
7948 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007949 {
Geoff Langb1196682014-07-23 13:47:29 -04007950 context->recordError(gl::Error(GL_INVALID_OPERATION));
7951 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007952 }
Geoff Langbfdea662014-07-23 14:16:32 -04007953
Geoff Langb1196682014-07-23 13:47:29 -04007954 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007955 {
7956 return;
7957 }
7958
7959 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7960 {
7961 return;
7962 }
7963
7964 if (!context->isSampler(sampler))
7965 {
Geoff Langb1196682014-07-23 13:47:29 -04007966 context->recordError(gl::Error(GL_INVALID_OPERATION));
7967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007968 }
7969
7970 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007971 }
7972}
7973
Kenneth Russell67ea1902014-10-06 16:44:50 -07007974void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007975{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007976 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007977}
7978
Kenneth Russell67ea1902014-10-06 16:44:50 -07007979void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980{
7981 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7982
Geoff Langbfdea662014-07-23 14:16:32 -04007983 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007984 if (context)
7985 {
7986 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007987 {
Geoff Langb1196682014-07-23 13:47:29 -04007988 context->recordError(gl::Error(GL_INVALID_OPERATION));
7989 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007990 }
Geoff Langbfdea662014-07-23 14:16:32 -04007991
Geoff Langb1196682014-07-23 13:47:29 -04007992 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007993 {
7994 return;
7995 }
7996
7997 if (!context->isSampler(sampler))
7998 {
Geoff Langb1196682014-07-23 13:47:29 -04007999 context->recordError(gl::Error(GL_INVALID_OPERATION));
8000 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008001 }
8002
8003 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008004 }
8005}
8006
Kenneth Russell67ea1902014-10-06 16:44:50 -07008007void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008008{
8009 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
8010
Geoff Langbfdea662014-07-23 14:16:32 -04008011 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008012 if (context)
8013 {
8014 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008015 {
Geoff Langb1196682014-07-23 13:47:29 -04008016 context->recordError(gl::Error(GL_INVALID_OPERATION));
8017 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008018 }
Geoff Langbfdea662014-07-23 14:16:32 -04008019
Geoff Langb1196682014-07-23 13:47:29 -04008020 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008021 {
8022 return;
8023 }
8024
8025 if (!context->isSampler(sampler))
8026 {
Geoff Langb1196682014-07-23 13:47:29 -04008027 context->recordError(gl::Error(GL_INVALID_OPERATION));
8028 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008029 }
8030
8031 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008032 }
8033}
8034
Kenneth Russell67ea1902014-10-06 16:44:50 -07008035void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008036{
8037 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8038
Geoff Langbfdea662014-07-23 14:16:32 -04008039 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008040 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008041 {
Geoff Langbfdea662014-07-23 14:16:32 -04008042 if (context->getClientVersion() < 3)
8043 {
Geoff Langb1196682014-07-23 13:47:29 -04008044 context->recordError(gl::Error(GL_INVALID_OPERATION));
8045 return;
8046 }
8047
8048 if (index >= gl::MAX_VERTEX_ATTRIBS)
8049 {
8050 context->recordError(gl::Error(GL_INVALID_VALUE));
8051 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008052 }
8053
8054 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008055 }
8056}
8057
Kenneth Russell67ea1902014-10-06 16:44:50 -07008058void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008059{
8060 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8061
Geoff Langbfdea662014-07-23 14:16:32 -04008062 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008063 if (context)
8064 {
8065 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008066 {
Geoff Langb1196682014-07-23 13:47:29 -04008067 context->recordError(gl::Error(GL_INVALID_OPERATION));
8068 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008069 }
Geoff Langbfdea662014-07-23 14:16:32 -04008070
8071 switch (target)
8072 {
8073 case GL_TRANSFORM_FEEDBACK:
8074 {
8075 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8076 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8077 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8078 {
Geoff Langb1196682014-07-23 13:47:29 -04008079 context->recordError(gl::Error(GL_INVALID_OPERATION));
8080 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008081 }
8082
8083 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8084 if (context->getTransformFeedback(id) == NULL)
8085 {
Geoff Langb1196682014-07-23 13:47:29 -04008086 context->recordError(gl::Error(GL_INVALID_OPERATION));
8087 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008088 }
8089
8090 context->bindTransformFeedback(id);
8091 }
8092 break;
8093
8094 default:
Geoff Langb1196682014-07-23 13:47:29 -04008095 context->recordError(gl::Error(GL_INVALID_ENUM));
8096 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008097 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008098 }
8099}
8100
Kenneth Russell67ea1902014-10-06 16:44:50 -07008101void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008102{
8103 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8104
Geoff Langbfdea662014-07-23 14:16:32 -04008105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008106 if (context)
8107 {
8108 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008109 {
Geoff Langb1196682014-07-23 13:47:29 -04008110 context->recordError(gl::Error(GL_INVALID_OPERATION));
8111 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008112 }
Geoff Langbfdea662014-07-23 14:16:32 -04008113
8114 for (int i = 0; i < n; i++)
8115 {
8116 context->deleteTransformFeedback(ids[i]);
8117 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008118 }
8119}
8120
Kenneth Russell67ea1902014-10-06 16:44:50 -07008121void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008122{
8123 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8124
Geoff Langbfdea662014-07-23 14:16:32 -04008125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008126 if (context)
8127 {
8128 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008129 {
Geoff Langb1196682014-07-23 13:47:29 -04008130 context->recordError(gl::Error(GL_INVALID_OPERATION));
8131 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008132 }
Geoff Langbfdea662014-07-23 14:16:32 -04008133
8134 for (int i = 0; i < n; i++)
8135 {
8136 ids[i] = context->createTransformFeedback();
8137 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008138 }
8139}
8140
Kenneth Russell67ea1902014-10-06 16:44:50 -07008141GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008142{
8143 EVENT("(GLuint id = %u)", id);
8144
Geoff Langbfdea662014-07-23 14:16:32 -04008145 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008146 if (context)
8147 {
8148 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008149 {
Geoff Langb1196682014-07-23 13:47:29 -04008150 context->recordError(gl::Error(GL_INVALID_OPERATION));
8151 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008152 }
Geoff Langbfdea662014-07-23 14:16:32 -04008153
8154 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008155 }
8156
8157 return GL_FALSE;
8158}
8159
Kenneth Russell67ea1902014-10-06 16:44:50 -07008160void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008161{
8162 EVENT("(void)");
8163
Geoff Langbfdea662014-07-23 14:16:32 -04008164 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008165 if (context)
8166 {
8167 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008168 {
Geoff Langb1196682014-07-23 13:47:29 -04008169 context->recordError(gl::Error(GL_INVALID_OPERATION));
8170 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008171 }
Geoff Langbfdea662014-07-23 14:16:32 -04008172
8173 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8174 ASSERT(transformFeedback != NULL);
8175
8176 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8177 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8178 {
Geoff Langb1196682014-07-23 13:47:29 -04008179 context->recordError(gl::Error(GL_INVALID_OPERATION));
8180 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008181 }
8182
8183 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008184 }
8185}
8186
Kenneth Russell67ea1902014-10-06 16:44:50 -07008187void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008188{
8189 EVENT("(void)");
8190
Geoff Langbfdea662014-07-23 14:16:32 -04008191 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008192 if (context)
8193 {
8194 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008195 {
Geoff Langb1196682014-07-23 13:47:29 -04008196 context->recordError(gl::Error(GL_INVALID_OPERATION));
8197 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008198 }
Geoff Langbfdea662014-07-23 14:16:32 -04008199
8200 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8201 ASSERT(transformFeedback != NULL);
8202
8203 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8204 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8205 {
Geoff Langb1196682014-07-23 13:47:29 -04008206 context->recordError(gl::Error(GL_INVALID_OPERATION));
8207 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008208 }
8209
8210 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008211 }
8212}
8213
Kenneth Russell67ea1902014-10-06 16:44:50 -07008214void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008215{
8216 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8217 program, bufSize, length, binaryFormat, binary);
8218
Geoff Langbfdea662014-07-23 14:16:32 -04008219 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008220 if (context)
8221 {
8222 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008223 {
Geoff Langb1196682014-07-23 13:47:29 -04008224 context->recordError(gl::Error(GL_INVALID_OPERATION));
8225 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008226 }
Geoff Langbfdea662014-07-23 14:16:32 -04008227
8228 // glGetProgramBinary
8229 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008230 }
8231}
8232
Kenneth Russell67ea1902014-10-06 16:44:50 -07008233void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008234{
8235 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8236 program, binaryFormat, binary, length);
8237
Geoff Langbfdea662014-07-23 14:16:32 -04008238 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008239 if (context)
8240 {
8241 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008242 {
Geoff Langb1196682014-07-23 13:47:29 -04008243 context->recordError(gl::Error(GL_INVALID_OPERATION));
8244 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008245 }
Geoff Langbfdea662014-07-23 14:16:32 -04008246
8247 // glProgramBinary
8248 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008249 }
8250}
8251
Kenneth Russell67ea1902014-10-06 16:44:50 -07008252void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008253{
8254 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8255 program, pname, value);
8256
Geoff Langbfdea662014-07-23 14:16:32 -04008257 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008258 if (context)
8259 {
8260 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008261 {
Geoff Langb1196682014-07-23 13:47:29 -04008262 context->recordError(gl::Error(GL_INVALID_OPERATION));
8263 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008264 }
Geoff Langbfdea662014-07-23 14:16:32 -04008265
8266 // glProgramParameteri
8267 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008268 }
8269}
8270
Kenneth Russell67ea1902014-10-06 16:44:50 -07008271void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008272{
8273 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8274 target, numAttachments, attachments);
8275
Geoff Langbfdea662014-07-23 14:16:32 -04008276 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008277 if (context)
8278 {
8279 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008280 {
Geoff Langb1196682014-07-23 13:47:29 -04008281 context->recordError(gl::Error(GL_INVALID_OPERATION));
8282 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008283 }
Geoff Langbfdea662014-07-23 14:16:32 -04008284
8285 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8286 {
8287 return;
8288 }
8289
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008290 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8291 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8292 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008293 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8294 if (error.isError())
8295 {
8296 context->recordError(error);
8297 return;
8298 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008299 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008300 }
8301}
8302
Kenneth Russell67ea1902014-10-06 16:44:50 -07008303void 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 +00008304{
8305 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8306 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8307 target, numAttachments, attachments, x, y, width, height);
8308
Geoff Langbfdea662014-07-23 14:16:32 -04008309 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008310 if (context)
8311 {
8312 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008313 {
Geoff Langb1196682014-07-23 13:47:29 -04008314 context->recordError(gl::Error(GL_INVALID_OPERATION));
8315 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008316 }
Geoff Langbfdea662014-07-23 14:16:32 -04008317
8318 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8319 {
8320 return;
8321 }
8322
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008323 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8324 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8325 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008326 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8327 if (error.isError())
8328 {
8329 context->recordError(error);
8330 return;
8331 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008332 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008333 }
8334}
8335
Kenneth Russell67ea1902014-10-06 16:44:50 -07008336void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008337{
8338 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8339 target, levels, internalformat, width, height);
8340
Geoff Langbfdea662014-07-23 14:16:32 -04008341 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008342 if (context)
8343 {
8344 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008345 {
Geoff Langb1196682014-07-23 13:47:29 -04008346 context->recordError(gl::Error(GL_INVALID_OPERATION));
8347 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008348 }
Geoff Langbfdea662014-07-23 14:16:32 -04008349
8350 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8351 {
8352 return;
8353 }
8354
8355 switch (target)
8356 {
8357 case GL_TEXTURE_2D:
8358 {
8359 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008360 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8361 if (error.isError())
8362 {
8363 context->recordError(error);
8364 return;
8365 }
Geoff Langbfdea662014-07-23 14:16:32 -04008366 }
8367 break;
8368
8369 case GL_TEXTURE_CUBE_MAP:
8370 {
8371 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008372 gl::Error error = textureCube->storage(levels, internalformat, width);
8373 if (error.isError())
8374 {
8375 context->recordError(error);
8376 return;
8377 }
Geoff Langbfdea662014-07-23 14:16:32 -04008378 }
8379 break;
8380
8381 default:
Geoff Langb1196682014-07-23 13:47:29 -04008382 context->recordError(gl::Error(GL_INVALID_ENUM));
8383 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008384 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008385 }
8386}
8387
Kenneth Russell67ea1902014-10-06 16:44:50 -07008388void 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 +00008389{
8390 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8391 "GLsizei height = %d, GLsizei depth = %d)",
8392 target, levels, internalformat, width, height, depth);
8393
Geoff Langbfdea662014-07-23 14:16:32 -04008394 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008395 if (context)
8396 {
8397 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008398 {
Geoff Langb1196682014-07-23 13:47:29 -04008399 context->recordError(gl::Error(GL_INVALID_OPERATION));
8400 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008401 }
Geoff Langbfdea662014-07-23 14:16:32 -04008402
8403 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8404 {
8405 return;
8406 }
8407
8408 switch (target)
8409 {
8410 case GL_TEXTURE_3D:
8411 {
8412 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008413 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8414 if (error.isError())
8415 {
8416 context->recordError(error);
8417 return;
8418 }
Geoff Langbfdea662014-07-23 14:16:32 -04008419 }
8420 break;
8421
8422 case GL_TEXTURE_2D_ARRAY:
8423 {
8424 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008425 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8426 if (error.isError())
8427 {
8428 context->recordError(error);
8429 return;
8430 }
Geoff Langbfdea662014-07-23 14:16:32 -04008431 }
8432 break;
8433
8434 default:
8435 UNREACHABLE();
8436 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008437 }
8438}
8439
Kenneth Russell67ea1902014-10-06 16:44:50 -07008440void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008441{
8442 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8443 "GLint* params = 0x%0.8p)",
8444 target, internalformat, pname, bufSize, params);
8445
Geoff Langbfdea662014-07-23 14:16:32 -04008446 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008447 if (context)
8448 {
8449 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008450 {
Geoff Langb1196682014-07-23 13:47:29 -04008451 context->recordError(gl::Error(GL_INVALID_OPERATION));
8452 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008453 }
Geoff Langbfdea662014-07-23 14:16:32 -04008454
8455 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8456 if (!formatCaps.renderable)
8457 {
Geoff Langb1196682014-07-23 13:47:29 -04008458 context->recordError(gl::Error(GL_INVALID_ENUM));
8459 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008460 }
8461
8462 if (target != GL_RENDERBUFFER)
8463 {
Geoff Langb1196682014-07-23 13:47:29 -04008464 context->recordError(gl::Error(GL_INVALID_ENUM));
8465 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008466 }
8467
8468 if (bufSize < 0)
8469 {
Geoff Langb1196682014-07-23 13:47:29 -04008470 context->recordError(gl::Error(GL_INVALID_VALUE));
8471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008472 }
8473
8474 switch (pname)
8475 {
8476 case GL_NUM_SAMPLE_COUNTS:
8477 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008478 {
8479 *params = formatCaps.sampleCounts.size();
8480 }
Geoff Langbfdea662014-07-23 14:16:32 -04008481 break;
Geoff Langb1196682014-07-23 13:47:29 -04008482
Geoff Langbfdea662014-07-23 14:16:32 -04008483 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008484 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008485 break;
Geoff Langb1196682014-07-23 13:47:29 -04008486
Geoff Langbfdea662014-07-23 14:16:32 -04008487 default:
Geoff Langb1196682014-07-23 13:47:29 -04008488 context->recordError(gl::Error(GL_INVALID_ENUM));
8489 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008490 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008491 }
8492}
8493
8494// Extension functions
8495
Kenneth Russell67ea1902014-10-06 16:44:50 -07008496void 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 +00008497 GLbitfield mask, GLenum filter)
8498{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008499 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008500 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8501 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8502 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8503
Geoff Langbfdea662014-07-23 14:16:32 -04008504 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008505 if (context)
8506 {
8507 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8508 dstX0, dstY0, dstX1, dstY1, mask, filter,
8509 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008510 {
Geoff Langbfdea662014-07-23 14:16:32 -04008511 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008512 }
Geoff Langbfdea662014-07-23 14:16:32 -04008513
Geoff Lang64839152014-08-26 16:23:25 -04008514 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8515 mask, filter);
8516 if (error.isError())
8517 {
8518 context->recordError(error);
8519 return;
8520 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008521 }
8522}
8523
Kenneth Russell67ea1902014-10-06 16:44:50 -07008524void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008525 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008526{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008527 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008528 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008529 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008530 target, level, internalformat, width, height, depth, border, format, type, pixels);
8531
Geoff Langbfdea662014-07-23 14:16:32 -04008532 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008533}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008534
Kenneth Russell67ea1902014-10-06 16:44:50 -07008535void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008536 GLenum *binaryFormat, void *binary)
8537{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008538 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 +00008539 program, bufSize, length, binaryFormat, binary);
8540
Geoff Langbfdea662014-07-23 14:16:32 -04008541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008542 if (context)
8543 {
8544 gl::Program *programObject = context->getProgram(program);
8545
8546 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008547 {
Geoff Langb1196682014-07-23 13:47:29 -04008548 context->recordError(gl::Error(GL_INVALID_OPERATION));
8549 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008550 }
Geoff Langbfdea662014-07-23 14:16:32 -04008551
8552 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8553
8554 if (!programBinary)
8555 {
Geoff Langb1196682014-07-23 13:47:29 -04008556 context->recordError(gl::Error(GL_INVALID_OPERATION));
8557 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008558 }
8559
Geoff Langb543aff2014-09-30 14:52:54 -04008560 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8561 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008562 {
Geoff Langb543aff2014-09-30 14:52:54 -04008563 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008564 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008565 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008566 }
8567}
8568
Kenneth Russell67ea1902014-10-06 16:44:50 -07008569void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008570 const void *binary, GLint length)
8571{
8572 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8573 program, binaryFormat, binary, length);
8574
Geoff Langbfdea662014-07-23 14:16:32 -04008575 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008576 if (context)
8577 {
Geoff Lang900013c2014-07-07 11:32:19 -04008578 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8579 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008580 {
Geoff Langb1196682014-07-23 13:47:29 -04008581 context->recordError(gl::Error(GL_INVALID_ENUM));
8582 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008583 }
Geoff Langbfdea662014-07-23 14:16:32 -04008584
8585 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008586 if (!programObject)
8587 {
Geoff Langb1196682014-07-23 13:47:29 -04008588 context->recordError(gl::Error(GL_INVALID_OPERATION));
8589 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008590 }
8591
Geoff Langb543aff2014-09-30 14:52:54 -04008592 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8593 if (error.isError())
8594 {
8595 context->recordError(error);
8596 return;
8597 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008598 }
8599}
8600
Kenneth Russell67ea1902014-10-06 16:44:50 -07008601void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008602{
8603 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8604
Geoff Langbfdea662014-07-23 14:16:32 -04008605 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008606 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008607 {
Geoff Langbfdea662014-07-23 14:16:32 -04008608 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008609 {
Geoff Langb1196682014-07-23 13:47:29 -04008610 context->recordError(gl::Error(GL_INVALID_VALUE));
8611 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008612 }
8613
8614 if (context->getState().getDrawFramebuffer()->id() == 0)
8615 {
8616 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008617 {
Geoff Langb1196682014-07-23 13:47:29 -04008618 context->recordError(gl::Error(GL_INVALID_OPERATION));
8619 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008620 }
8621
Geoff Langbfdea662014-07-23 14:16:32 -04008622 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008623 {
Geoff Langb1196682014-07-23 13:47:29 -04008624 context->recordError(gl::Error(GL_INVALID_OPERATION));
8625 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008626 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008627 }
Geoff Langbfdea662014-07-23 14:16:32 -04008628 else
8629 {
8630 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8631 {
8632 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8633 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8634 {
Geoff Langb1196682014-07-23 13:47:29 -04008635 context->recordError(gl::Error(GL_INVALID_OPERATION));
8636 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008637 }
8638 }
8639 }
8640
8641 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
8642
8643 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8644 {
8645 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8646 }
8647
8648 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8649 {
8650 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8651 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008652 }
8653}
8654
Kenneth Russell67ea1902014-10-06 16:44:50 -07008655void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008656{
8657 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8658
Geoff Langbfdea662014-07-23 14:16:32 -04008659 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008660 if (context)
8661 {
8662 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008663 {
Geoff Langb1196682014-07-23 13:47:29 -04008664 context->recordError(gl::Error(GL_INVALID_ENUM));
8665 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008666 }
Geoff Langbfdea662014-07-23 14:16:32 -04008667
8668 if (pname != GL_BUFFER_MAP_POINTER)
8669 {
Geoff Langb1196682014-07-23 13:47:29 -04008670 context->recordError(gl::Error(GL_INVALID_ENUM));
8671 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008672 }
8673
8674 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8675
8676 if (!buffer || !buffer->isMapped())
8677 {
8678 *params = NULL;
8679 }
8680 else
8681 {
8682 *params = buffer->getMapPointer();
8683 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008684 }
8685}
8686
Kenneth Russell67ea1902014-10-06 16:44:50 -07008687void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008688{
8689 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8690
Geoff Langbfdea662014-07-23 14:16:32 -04008691 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008692 if (context)
8693 {
8694 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008695 {
Geoff Langb1196682014-07-23 13:47:29 -04008696 context->recordError(gl::Error(GL_INVALID_ENUM));
8697 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008698 }
Geoff Langbfdea662014-07-23 14:16:32 -04008699
8700 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8701
8702 if (buffer == NULL)
8703 {
Geoff Langb1196682014-07-23 13:47:29 -04008704 context->recordError(gl::Error(GL_INVALID_OPERATION));
8705 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008706 }
8707
8708 if (access != GL_WRITE_ONLY_OES)
8709 {
Geoff Langb1196682014-07-23 13:47:29 -04008710 context->recordError(gl::Error(GL_INVALID_ENUM));
8711 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008712 }
8713
8714 if (buffer->isMapped())
8715 {
Geoff Langb1196682014-07-23 13:47:29 -04008716 context->recordError(gl::Error(GL_INVALID_OPERATION));
8717 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008718 }
8719
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008720 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8721 if (error.isError())
8722 {
8723 context->recordError(error);
8724 return NULL;
8725 }
8726
8727 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008728 }
8729
8730 return NULL;
8731}
8732
Kenneth Russell67ea1902014-10-06 16:44:50 -07008733GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008734{
8735 EVENT("(GLenum target = 0x%X)", target);
8736
Geoff Langbfdea662014-07-23 14:16:32 -04008737 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008738 if (context)
8739 {
8740 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008741 {
Geoff Langb1196682014-07-23 13:47:29 -04008742 context->recordError(gl::Error(GL_INVALID_ENUM));
8743 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008744 }
Geoff Langbfdea662014-07-23 14:16:32 -04008745
8746 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8747
8748 if (buffer == NULL || !buffer->isMapped())
8749 {
Geoff Langb1196682014-07-23 13:47:29 -04008750 context->recordError(gl::Error(GL_INVALID_OPERATION));
8751 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008752 }
8753
8754 // TODO: detect if we had corruption. if so, throw an error and return false.
8755
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008756 gl::Error error = buffer->unmap();
8757 if (error.isError())
8758 {
8759 context->recordError(error);
8760 return GL_FALSE;
8761 }
Geoff Langbfdea662014-07-23 14:16:32 -04008762
8763 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008764 }
8765
8766 return GL_FALSE;
8767}
8768
Kenneth Russell67ea1902014-10-06 16:44:50 -07008769void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008770{
8771 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8772 target, offset, length, access);
8773
Geoff Langbfdea662014-07-23 14:16:32 -04008774 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008775 if (context)
8776 {
8777 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008778 {
Geoff Langb1196682014-07-23 13:47:29 -04008779 context->recordError(gl::Error(GL_INVALID_ENUM));
8780 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008781 }
Geoff Langbfdea662014-07-23 14:16:32 -04008782
8783 if (offset < 0 || length < 0)
8784 {
Geoff Langb1196682014-07-23 13:47:29 -04008785 context->recordError(gl::Error(GL_INVALID_VALUE));
8786 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008787 }
8788
8789 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8790
8791 if (buffer == NULL)
8792 {
Geoff Langb1196682014-07-23 13:47:29 -04008793 context->recordError(gl::Error(GL_INVALID_OPERATION));
8794 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008795 }
8796
8797 // Check for buffer overflow
8798 size_t offsetSize = static_cast<size_t>(offset);
8799 size_t lengthSize = static_cast<size_t>(length);
8800
8801 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8802 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8803 {
Geoff Langb1196682014-07-23 13:47:29 -04008804 context->recordError(gl::Error(GL_INVALID_VALUE));
8805 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008806 }
8807
8808 // Check for invalid bits in the mask
8809 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8810 GL_MAP_WRITE_BIT |
8811 GL_MAP_INVALIDATE_RANGE_BIT |
8812 GL_MAP_INVALIDATE_BUFFER_BIT |
8813 GL_MAP_FLUSH_EXPLICIT_BIT |
8814 GL_MAP_UNSYNCHRONIZED_BIT;
8815
8816 if (access & ~(allAccessBits))
8817 {
Geoff Langb1196682014-07-23 13:47:29 -04008818 context->recordError(gl::Error(GL_INVALID_VALUE));
8819 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008820 }
8821
8822 if (length == 0 || buffer->isMapped())
8823 {
Geoff Langb1196682014-07-23 13:47:29 -04008824 context->recordError(gl::Error(GL_INVALID_OPERATION));
8825 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008826 }
8827
8828 // Check for invalid bit combinations
8829 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8830 {
Geoff Langb1196682014-07-23 13:47:29 -04008831 context->recordError(gl::Error(GL_INVALID_OPERATION));
8832 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008833 }
8834
8835 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8836 GL_MAP_INVALIDATE_BUFFER_BIT |
8837 GL_MAP_UNSYNCHRONIZED_BIT;
8838
8839 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8840 {
Geoff Langb1196682014-07-23 13:47:29 -04008841 context->recordError(gl::Error(GL_INVALID_OPERATION));
8842 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008843 }
8844
8845 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_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
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008851 gl::Error error = buffer->mapRange(offset, length, access);
8852 if (error.isError())
8853 {
8854 context->recordError(error);
8855 return NULL;
8856 }
8857
8858 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008859 }
8860
8861 return NULL;
8862}
8863
Kenneth Russell67ea1902014-10-06 16:44:50 -07008864void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008865{
8866 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8867
Geoff Langbfdea662014-07-23 14:16:32 -04008868 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008869 if (context)
8870 {
8871 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008872 {
Geoff Langb1196682014-07-23 13:47:29 -04008873 context->recordError(gl::Error(GL_INVALID_VALUE));
8874 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008875 }
Geoff Langbfdea662014-07-23 14:16:32 -04008876
8877 if (!gl::ValidBufferTarget(context, target))
8878 {
Geoff Langb1196682014-07-23 13:47:29 -04008879 context->recordError(gl::Error(GL_INVALID_ENUM));
8880 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008881 }
8882
8883 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8884
8885 if (buffer == NULL)
8886 {
Geoff Langb1196682014-07-23 13:47:29 -04008887 context->recordError(gl::Error(GL_INVALID_OPERATION));
8888 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008889 }
8890
8891 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8892 {
Geoff Langb1196682014-07-23 13:47:29 -04008893 context->recordError(gl::Error(GL_INVALID_OPERATION));
8894 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008895 }
8896
8897 // Check for buffer overflow
8898 size_t offsetSize = static_cast<size_t>(offset);
8899 size_t lengthSize = static_cast<size_t>(length);
8900
8901 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8902 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8903 {
Geoff Langb1196682014-07-23 13:47:29 -04008904 context->recordError(gl::Error(GL_INVALID_VALUE));
8905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008906 }
8907
8908 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008909 }
8910}
8911
Kenneth Russell67ea1902014-10-06 16:44:50 -07008912__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008913{
8914 struct Extension
8915 {
8916 const char *name;
8917 __eglMustCastToProperFunctionPointerType address;
8918 };
8919
8920 static const Extension glExtensions[] =
8921 {
8922 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008923 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008924 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008925 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8926 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8927 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8928 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8929 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8930 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8931 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008932 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008933 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008934 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8935 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8936 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8937 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008938 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8939 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8940 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8941 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8942 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8943 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8944 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008945 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008946 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8947 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8948 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008949 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008950 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8951 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8952 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008953 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8954 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8955 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008956
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008957 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008958 {
8959 if (strcmp(procname, glExtensions[ext].name) == 0)
8960 {
8961 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8962 }
8963 }
8964
8965 return NULL;
8966}
8967
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008968// Non-public functions used by EGL
8969
Kenneth Russell67ea1902014-10-06 16:44:50 -07008970bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008971{
8972 EVENT("(egl::Surface* surface = 0x%0.8p)",
8973 surface);
8974
Geoff Langbfdea662014-07-23 14:16:32 -04008975 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008976 if (context)
8977 {
8978 gl::Texture2D *textureObject = context->getTexture2D();
8979 ASSERT(textureObject != NULL);
8980
8981 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008982 {
Geoff Langbfdea662014-07-23 14:16:32 -04008983 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008984 }
Geoff Langbfdea662014-07-23 14:16:32 -04008985
8986 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008987 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008988
8989 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008990}
8991
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008992}