blob: 230616877e03155365db8be11050434ae31d0fff [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
Jamie Madill48faf802014-11-06 15:27:22 -0500624
625 return framebuffer->completeness(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000626 }
627
628 return 0;
629}
630
Kenneth Russell67ea1902014-10-06 16:44:50 -0700631void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000632{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000633 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000634
Geoff Langbfdea662014-07-23 14:16:32 -0400635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400636 if (context)
637 {
638 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -0500639 ASSERT(framebufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -0400640
Jamie Madill48faf802014-11-06 15:27:22 -0500641 if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000642 {
Geoff Langb1196682014-07-23 13:47:29 -0400643 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
644 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000645 }
Geoff Langbfdea662014-07-23 14:16:32 -0400646
647 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
648 {
Geoff Langb1196682014-07-23 13:47:29 -0400649 context->recordError(gl::Error(GL_INVALID_VALUE));
650 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400651 }
652
Geoff Langcc79b8c2014-07-25 13:48:02 -0400653 gl::Error error = context->clear(mask);
654 if (error.isError())
655 {
656 context->recordError(error);
657 return;
658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000659 }
660}
661
Kenneth Russell67ea1902014-10-06 16:44:50 -0700662void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000664 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000665 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000666
Geoff Langbfdea662014-07-23 14:16:32 -0400667 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400668 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 {
Geoff Langbfdea662014-07-23 14:16:32 -0400670 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 }
672}
673
Kenneth Russell67ea1902014-10-06 16:44:50 -0700674void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000676 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000677
Geoff Langbfdea662014-07-23 14:16:32 -0400678 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400679 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 {
Geoff Langbfdea662014-07-23 14:16:32 -0400681 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000682 }
683}
684
Kenneth Russell67ea1902014-10-06 16:44:50 -0700685void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000687 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000688
Geoff Langbfdea662014-07-23 14:16:32 -0400689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400690 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 {
Geoff Langbfdea662014-07-23 14:16:32 -0400692 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000693 }
694}
695
Kenneth Russell67ea1902014-10-06 16:44:50 -0700696void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000697{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000698 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000699 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000700
Geoff Langbfdea662014-07-23 14:16:32 -0400701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400702 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 {
Geoff Langbfdea662014-07-23 14:16:32 -0400704 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000705 }
706}
707
Kenneth Russell67ea1902014-10-06 16:44:50 -0700708void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000710 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000711
Geoff Langbfdea662014-07-23 14:16:32 -0400712 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400713 if (context)
714 {
715 gl::Shader *shaderObject = context->getShader(shader);
716
717 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langbfdea662014-07-23 14:16:32 -0400719 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000720 {
Geoff Langb1196682014-07-23 13:47:29 -0400721 context->recordError(gl::Error(GL_INVALID_OPERATION));
722 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000723 }
Geoff Langbfdea662014-07-23 14:16:32 -0400724 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000725 {
Geoff Langb1196682014-07-23 13:47:29 -0400726 context->recordError(gl::Error(GL_INVALID_VALUE));
727 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000728 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000729 }
Geoff Langbfdea662014-07-23 14:16:32 -0400730
Jamie Madill245d3602014-11-13 10:03:30 -0500731 shaderObject->compile(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000732 }
Geoff Langbfdea662014-07-23 14:16:32 -0400733}
734
Kenneth Russell67ea1902014-10-06 16:44:50 -0700735void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400736 GLint border, GLsizei imageSize, const GLvoid* data)
737{
738 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
739 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
740 target, level, internalformat, width, height, border, imageSize, data);
741
742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000744 {
Geoff Langbfdea662014-07-23 14:16:32 -0400745 if (context->getClientVersion() < 3 &&
746 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
747 0, 0, width, height, border, GL_NONE, GL_NONE, data))
748 {
749 return;
750 }
751
752 if (context->getClientVersion() >= 3 &&
753 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
754 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
755 {
756 return;
757 }
758
Geoff Lang5d601382014-07-22 15:14:06 -0400759 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
760 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400761 {
Geoff Langb1196682014-07-23 13:47:29 -0400762 context->recordError(gl::Error(GL_INVALID_VALUE));
763 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400764 }
765
766 switch (target)
767 {
768 case GL_TEXTURE_2D:
769 {
770 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400771 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400772 if (error.isError())
773 {
774 context->recordError(error);
775 return;
776 }
Geoff Langbfdea662014-07-23 14:16:32 -0400777 }
778 break;
779
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
784 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
785 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
786 {
787 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400788 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400789 if (error.isError())
790 {
791 context->recordError(error);
792 return;
793 }
Geoff Langbfdea662014-07-23 14:16:32 -0400794 }
795 break;
796
797 default:
Geoff Langb1196682014-07-23 13:47:29 -0400798 context->recordError(gl::Error(GL_INVALID_ENUM));
799 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400800 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000801 }
802}
803
Kenneth Russell67ea1902014-10-06 16:44:50 -0700804void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000805 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000806{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000807 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000808 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000809 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000810 target, level, xoffset, yoffset, width, height, format, imageSize, data);
811
Geoff Langbfdea662014-07-23 14:16:32 -0400812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400813 if (context)
814 {
815 if (context->getClientVersion() < 3 &&
816 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
817 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 {
Geoff Langbfdea662014-07-23 14:16:32 -0400819 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000820 }
Geoff Langbfdea662014-07-23 14:16:32 -0400821
822 if (context->getClientVersion() >= 3 &&
823 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
824 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
825 {
826 return;
827 }
828
Geoff Lang5d601382014-07-22 15:14:06 -0400829 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
830 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400831 {
Geoff Langb1196682014-07-23 13:47:29 -0400832 context->recordError(gl::Error(GL_INVALID_VALUE));
833 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400834 }
835
836 switch (target)
837 {
838 case GL_TEXTURE_2D:
839 {
840 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400841 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400842 if (error.isError())
843 {
844 context->recordError(error);
845 return;
846 }
Geoff Langbfdea662014-07-23 14:16:32 -0400847 }
848 break;
849
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
854 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
855 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
856 {
857 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400858 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400859 if (error.isError())
860 {
861 context->recordError(error);
862 return;
863 }
Geoff Langbfdea662014-07-23 14:16:32 -0400864 }
865 break;
866
867 default:
Geoff Langb1196682014-07-23 13:47:29 -0400868 context->recordError(gl::Error(GL_INVALID_ENUM));
869 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400870 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000871 }
872}
873
Kenneth Russell67ea1902014-10-06 16:44:50 -0700874void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000876 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000877 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000878 target, level, internalformat, x, y, width, height, border);
879
Geoff Langbfdea662014-07-23 14:16:32 -0400880 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400881 if (context)
882 {
883 if (context->getClientVersion() < 3 &&
884 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
885 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 {
Geoff Langbfdea662014-07-23 14:16:32 -0400887 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000888 }
Geoff Langbfdea662014-07-23 14:16:32 -0400889
890 if (context->getClientVersion() >= 3 &&
891 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
892 0, 0, 0, x, y, width, height, border))
893 {
894 return;
895 }
896
897 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
898
899 switch (target)
900 {
901 case GL_TEXTURE_2D:
902 {
903 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400904 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
905 if (error.isError())
906 {
907 context->recordError(error);
908 return;
909 }
Geoff Langbfdea662014-07-23 14:16:32 -0400910 }
911 break;
912
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
917 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
918 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
919 {
920 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400921 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
922 if (error.isError())
923 {
924 context->recordError(error);
925 return;
926 }
Geoff Langbfdea662014-07-23 14:16:32 -0400927 }
928 break;
929
Geoff Langb1196682014-07-23 13:47:29 -0400930 default:
931 context->recordError(gl::Error(GL_INVALID_ENUM));
932 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400933 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000934 }
935}
936
Kenneth Russell67ea1902014-10-06 16:44:50 -0700937void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000938{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000939 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000940 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000941 target, level, xoffset, yoffset, x, y, width, height);
942
Geoff Langbfdea662014-07-23 14:16:32 -0400943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400944 if (context)
945 {
946 if (context->getClientVersion() < 3 &&
947 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
948 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 {
Geoff Langbfdea662014-07-23 14:16:32 -0400950 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000951 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000952
Geoff Langbfdea662014-07-23 14:16:32 -0400953 if (context->getClientVersion() >= 3 &&
954 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
955 xoffset, yoffset, 0, x, y, width, height, 0))
956 {
957 return;
958 }
959
960 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
961
962 switch (target)
963 {
964 case GL_TEXTURE_2D:
965 {
966 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400967 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
968 if (error.isError())
969 {
970 context->recordError(error);
971 return;
972 }
Geoff Langbfdea662014-07-23 14:16:32 -0400973 }
974 break;
975
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
980 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
981 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
982 {
983 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400984 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
985 if (error.isError())
986 {
987 context->recordError(error);
988 return;
989 }
Geoff Langbfdea662014-07-23 14:16:32 -0400990 }
991 break;
992
993 default:
Geoff Langb1196682014-07-23 13:47:29 -0400994 context->recordError(gl::Error(GL_INVALID_ENUM));
995 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400996 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000997 }
998}
999
Kenneth Russell67ea1902014-10-06 16:44:50 -07001000GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001002 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001003
Geoff Langbfdea662014-07-23 14:16:32 -04001004 gl::Context *context = gl::getNonLostContext();
1005 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 {
Geoff Langbfdea662014-07-23 14:16:32 -04001007 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001008 }
1009
1010 return 0;
1011}
1012
Kenneth Russell67ea1902014-10-06 16:44:50 -07001013GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001015 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001016
Geoff Langbfdea662014-07-23 14:16:32 -04001017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001018 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001019 {
Geoff Langbfdea662014-07-23 14:16:32 -04001020 switch (type)
1021 {
1022 case GL_FRAGMENT_SHADER:
1023 case GL_VERTEX_SHADER:
1024 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001025
Geoff Langbfdea662014-07-23 14:16:32 -04001026 default:
Geoff Langb1196682014-07-23 13:47:29 -04001027 context->recordError(gl::Error(GL_INVALID_ENUM));
1028 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001029 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001030 }
1031
1032 return 0;
1033}
1034
Kenneth Russell67ea1902014-10-06 16:44:50 -07001035void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001037 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001038
Geoff Langb1196682014-07-23 13:47:29 -04001039 gl::Context *context = gl::getNonLostContext();
1040 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001043 {
Geoff Langb1196682014-07-23 13:47:29 -04001044 case GL_FRONT:
1045 case GL_BACK:
1046 case GL_FRONT_AND_BACK:
1047 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001048
Geoff Langb1196682014-07-23 13:47:29 -04001049 default:
1050 context->recordError(gl::Error(GL_INVALID_ENUM));
1051 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001052 }
Geoff Langb1196682014-07-23 13:47:29 -04001053
1054 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001055 }
1056}
1057
Kenneth Russell67ea1902014-10-06 16:44:50 -07001058void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001060 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001061
Geoff Langbfdea662014-07-23 14:16:32 -04001062 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001063 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001064 {
Geoff Langb1196682014-07-23 13:47:29 -04001065 if (n < 0)
1066 {
1067 context->recordError(gl::Error(GL_INVALID_VALUE));
1068 return;
1069 }
1070
Geoff Langbfdea662014-07-23 14:16:32 -04001071 for (int i = 0; i < n; i++)
1072 {
1073 context->deleteBuffer(buffers[i]);
1074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001075 }
1076}
1077
Kenneth Russell67ea1902014-10-06 16:44:50 -07001078void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001080 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001081
Geoff Langbfdea662014-07-23 14:16:32 -04001082 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001083 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001084 {
Geoff Langb1196682014-07-23 13:47:29 -04001085 if (n < 0)
1086 {
1087 context->recordError(gl::Error(GL_INVALID_VALUE));
1088 return;
1089 }
1090
Geoff Langbfdea662014-07-23 14:16:32 -04001091 for (int i = 0; i < n; i++)
1092 {
1093 context->deleteFenceNV(fences[i]);
1094 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001095 }
1096}
1097
Kenneth Russell67ea1902014-10-06 16:44:50 -07001098void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001100 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001101
Geoff Langbfdea662014-07-23 14:16:32 -04001102 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001103 if (context)
1104 {
Geoff Langb1196682014-07-23 13:47:29 -04001105 if (n < 0)
1106 {
1107 context->recordError(gl::Error(GL_INVALID_VALUE));
1108 return;
1109 }
1110
Geoff Langbfdea662014-07-23 14:16:32 -04001111 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 {
Geoff Langbfdea662014-07-23 14:16:32 -04001115 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001116 }
1117 }
1118 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001119}
1120
Kenneth Russell67ea1902014-10-06 16:44:50 -07001121void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001123 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001124
Geoff Langbfdea662014-07-23 14:16:32 -04001125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001126 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001127 {
Geoff Langb1196682014-07-23 13:47:29 -04001128 if (program == 0)
1129 {
1130 return;
1131 }
1132
Geoff Langbfdea662014-07-23 14:16:32 -04001133 if (!context->getProgram(program))
1134 {
1135 if(context->getShader(program))
1136 {
Geoff Langb1196682014-07-23 13:47:29 -04001137 context->recordError(gl::Error(GL_INVALID_OPERATION));
1138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001139 }
1140 else
1141 {
Geoff Langb1196682014-07-23 13:47:29 -04001142 context->recordError(gl::Error(GL_INVALID_VALUE));
1143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001144 }
1145 }
1146
1147 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001148 }
1149}
1150
Kenneth Russell67ea1902014-10-06 16:44:50 -07001151void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001152{
1153 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1154
Geoff Langbfdea662014-07-23 14:16:32 -04001155 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001156 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001157 {
Geoff Langb1196682014-07-23 13:47:29 -04001158 if (n < 0)
1159 {
1160 context->recordError(gl::Error(GL_INVALID_VALUE));
1161 return;
1162 }
1163
Geoff Langbfdea662014-07-23 14:16:32 -04001164 for (int i = 0; i < n; i++)
1165 {
1166 context->deleteQuery(ids[i]);
1167 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001168 }
1169}
1170
Kenneth Russell67ea1902014-10-06 16:44:50 -07001171void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001173 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001174
Geoff Langbfdea662014-07-23 14:16:32 -04001175 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001176 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001177 {
Geoff Langb1196682014-07-23 13:47:29 -04001178 if (n < 0)
1179 {
1180 context->recordError(gl::Error(GL_INVALID_VALUE));
1181 return;
1182 }
1183
Geoff Langbfdea662014-07-23 14:16:32 -04001184 for (int i = 0; i < n; i++)
1185 {
1186 context->deleteRenderbuffer(renderbuffers[i]);
1187 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001188 }
1189}
1190
Kenneth Russell67ea1902014-10-06 16:44:50 -07001191void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001193 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001194
Geoff Langbfdea662014-07-23 14:16:32 -04001195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001196 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001197 {
Geoff Langb1196682014-07-23 13:47:29 -04001198 if (shader == 0)
1199 {
1200 return;
1201 }
1202
Geoff Langbfdea662014-07-23 14:16:32 -04001203 if (!context->getShader(shader))
1204 {
1205 if(context->getProgram(shader))
1206 {
Geoff Langb1196682014-07-23 13:47:29 -04001207 context->recordError(gl::Error(GL_INVALID_OPERATION));
1208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001209 }
1210 else
1211 {
Geoff Langb1196682014-07-23 13:47:29 -04001212 context->recordError(gl::Error(GL_INVALID_VALUE));
1213 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001214 }
1215 }
1216
1217 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001218 }
1219}
1220
Kenneth Russell67ea1902014-10-06 16:44:50 -07001221void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001223 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001224
Geoff Langbfdea662014-07-23 14:16:32 -04001225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001226 if (context)
1227 {
Geoff Langb1196682014-07-23 13:47:29 -04001228 if (n < 0)
1229 {
1230 context->recordError(gl::Error(GL_INVALID_VALUE));
1231 return;
1232 }
1233
Geoff Langbfdea662014-07-23 14:16:32 -04001234 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 {
Geoff Langbfdea662014-07-23 14:16:32 -04001238 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001239 }
1240 }
1241 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001242}
1243
Kenneth Russell67ea1902014-10-06 16:44:50 -07001244void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001246 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001247
Geoff Langbfdea662014-07-23 14:16:32 -04001248 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001249 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001250 {
Geoff Langb1196682014-07-23 13:47:29 -04001251 switch (func)
1252 {
1253 case GL_NEVER:
1254 case GL_ALWAYS:
1255 case GL_LESS:
1256 case GL_LEQUAL:
1257 case GL_EQUAL:
1258 case GL_GREATER:
1259 case GL_GEQUAL:
1260 case GL_NOTEQUAL:
1261 context->getState().setDepthFunc(func);
1262 break;
1263
1264 default:
1265 context->recordError(gl::Error(GL_INVALID_ENUM));
1266 return;
1267 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001268 }
1269}
1270
Kenneth Russell67ea1902014-10-06 16:44:50 -07001271void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001273 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001274
Geoff Langbfdea662014-07-23 14:16:32 -04001275 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001276 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 {
Geoff Langbfdea662014-07-23 14:16:32 -04001278 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001279 }
1280}
1281
Kenneth Russell67ea1902014-10-06 16:44:50 -07001282void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001284 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001285
Geoff Langbfdea662014-07-23 14:16:32 -04001286 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001287 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 {
Geoff Langbfdea662014-07-23 14:16:32 -04001289 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001290 }
1291}
1292
Kenneth Russell67ea1902014-10-06 16:44:50 -07001293void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001295 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001296
Geoff Langbfdea662014-07-23 14:16:32 -04001297 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001298 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001299 {
Geoff Langbfdea662014-07-23 14:16:32 -04001300 gl::Program *programObject = context->getProgram(program);
1301 gl::Shader *shaderObject = context->getShader(shader);
1302
1303 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001304 {
Geoff Langbfdea662014-07-23 14:16:32 -04001305 gl::Shader *shaderByProgramHandle;
1306 shaderByProgramHandle = context->getShader(program);
1307 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001308 {
Geoff Langb1196682014-07-23 13:47:29 -04001309 context->recordError(gl::Error(GL_INVALID_VALUE));
1310 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001311 }
Geoff Langbfdea662014-07-23 14:16:32 -04001312 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001313 {
Geoff Langb1196682014-07-23 13:47:29 -04001314 context->recordError(gl::Error(GL_INVALID_OPERATION));
1315 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001317 }
Geoff Langbfdea662014-07-23 14:16:32 -04001318
1319 if (!shaderObject)
1320 {
1321 gl::Program *programByShaderHandle = context->getProgram(shader);
1322 if (!programByShaderHandle)
1323 {
Geoff Langb1196682014-07-23 13:47:29 -04001324 context->recordError(gl::Error(GL_INVALID_VALUE));
1325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001326 }
1327 else
1328 {
Geoff Langb1196682014-07-23 13:47:29 -04001329 context->recordError(gl::Error(GL_INVALID_OPERATION));
1330 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001331 }
1332 }
1333
1334 if (!programObject->detachShader(shaderObject))
1335 {
Geoff Langb1196682014-07-23 13:47:29 -04001336 context->recordError(gl::Error(GL_INVALID_OPERATION));
1337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001338 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001339 }
1340}
1341
Kenneth Russell67ea1902014-10-06 16:44:50 -07001342void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001344 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001345
Geoff Langbfdea662014-07-23 14:16:32 -04001346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001347 if (context)
1348 {
1349 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001350 {
Geoff Langb1196682014-07-23 13:47:29 -04001351 context->recordError(gl::Error(GL_INVALID_ENUM));
1352 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001353 }
Geoff Langbfdea662014-07-23 14:16:32 -04001354
1355 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001356 }
1357}
1358
Kenneth Russell67ea1902014-10-06 16:44:50 -07001359void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001361 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001362
Geoff Langbfdea662014-07-23 14:16:32 -04001363 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001364 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001365 {
Geoff Langb1196682014-07-23 13:47:29 -04001366 if (index >= gl::MAX_VERTEX_ATTRIBS)
1367 {
1368 context->recordError(gl::Error(GL_INVALID_VALUE));
1369 return;
1370 }
1371
Geoff Langbfdea662014-07-23 14:16:32 -04001372 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001373 }
1374}
1375
Kenneth Russell67ea1902014-10-06 16:44:50 -07001376void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001378 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001379
Geoff Langbfdea662014-07-23 14:16:32 -04001380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001381 if (context)
1382 {
Jamie Madill2b976812014-08-25 15:47:49 -04001383 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 {
Geoff Langbfdea662014-07-23 14:16:32 -04001385 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001386 }
Geoff Langbfdea662014-07-23 14:16:32 -04001387
Geoff Langc77e8c32014-09-08 16:28:24 -04001388 gl::Error error = context->drawArrays(mode, first, count, 0);
1389 if (error.isError())
1390 {
1391 context->recordError(error);
1392 return;
1393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001394 }
1395}
1396
Kenneth Russell67ea1902014-10-06 16:44:50 -07001397void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001398{
1399 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1400
Geoff Langbfdea662014-07-23 14:16:32 -04001401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001402 if (context)
1403 {
Geoff Lang87a93302014-09-16 13:29:43 -04001404 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 {
Geoff Langbfdea662014-07-23 14:16:32 -04001406 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001407 }
Geoff Langbfdea662014-07-23 14:16:32 -04001408
Geoff Langc77e8c32014-09-08 16:28:24 -04001409 gl::Error error = context->drawArrays(mode, first, count, primcount);
1410 if (error.isError())
1411 {
1412 context->recordError(error);
1413 return;
1414 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001415 }
1416}
1417
Kenneth Russell67ea1902014-10-06 16:44:50 -07001418void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001419{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001420 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001421 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001422
Geoff Langbfdea662014-07-23 14:16:32 -04001423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001424 if (context)
1425 {
Jamie Madill2b976812014-08-25 15:47:49 -04001426 rx::RangeUI indexRange;
1427 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 {
Geoff Langbfdea662014-07-23 14:16:32 -04001429 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001430 }
Geoff Langbfdea662014-07-23 14:16:32 -04001431
Geoff Langc77e8c32014-09-08 16:28:24 -04001432 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1433 if (error.isError())
1434 {
1435 context->recordError(error);
1436 return;
1437 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001438 }
1439}
1440
Kenneth Russell67ea1902014-10-06 16:44:50 -07001441void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001442{
1443 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1444 mode, count, type, indices, primcount);
1445
Geoff Langbfdea662014-07-23 14:16:32 -04001446 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001447 if (context)
1448 {
Jamie Madill2b976812014-08-25 15:47:49 -04001449 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001450 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 {
Geoff Langbfdea662014-07-23 14:16:32 -04001452 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001453 }
Geoff Langbfdea662014-07-23 14:16:32 -04001454
Geoff Langc77e8c32014-09-08 16:28:24 -04001455 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1456 if (error.isError())
1457 {
1458 context->recordError(error);
1459 return;
1460 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001461 }
1462}
1463
Kenneth Russell67ea1902014-10-06 16:44:50 -07001464void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001466 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001467
Geoff Langbfdea662014-07-23 14:16:32 -04001468 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001469 if (context)
1470 {
1471 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001472 {
Geoff Langb1196682014-07-23 13:47:29 -04001473 context->recordError(gl::Error(GL_INVALID_ENUM));
1474 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001475 }
Geoff Langbfdea662014-07-23 14:16:32 -04001476
1477 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001478 }
1479}
1480
Kenneth Russell67ea1902014-10-06 16:44:50 -07001481void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001483 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001484
Geoff Langbfdea662014-07-23 14:16:32 -04001485 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001486 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001487 {
Geoff Langb1196682014-07-23 13:47:29 -04001488 if (index >= gl::MAX_VERTEX_ATTRIBS)
1489 {
1490 context->recordError(gl::Error(GL_INVALID_VALUE));
1491 return;
1492 }
1493
Geoff Langbfdea662014-07-23 14:16:32 -04001494 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001495 }
1496}
1497
Kenneth Russell67ea1902014-10-06 16:44:50 -07001498void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001499{
1500 EVENT("GLenum target = 0x%X)", target);
1501
Geoff Langbfdea662014-07-23 14:16:32 -04001502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001503 if (context)
1504 {
1505 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 {
Geoff Langbfdea662014-07-23 14:16:32 -04001507 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001508 }
Geoff Langbfdea662014-07-23 14:16:32 -04001509
Geoff Lang5aad9672014-09-08 11:10:42 -04001510 gl::Error error = context->endQuery(target);
1511 if (error.isError())
1512 {
1513 context->recordError(error);
1514 return;
1515 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001516 }
1517}
1518
Kenneth Russell67ea1902014-10-06 16:44:50 -07001519void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001521 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001522
Geoff Langbfdea662014-07-23 14:16:32 -04001523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001524 if (context)
1525 {
1526 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1527
1528 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001529 {
Geoff Langb1196682014-07-23 13:47:29 -04001530 context->recordError(gl::Error(GL_INVALID_OPERATION));
1531 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001532 }
Geoff Langbfdea662014-07-23 14:16:32 -04001533
1534 if (fenceObject->isFence() != GL_TRUE)
1535 {
Geoff Langb1196682014-07-23 13:47:29 -04001536 context->recordError(gl::Error(GL_INVALID_OPERATION));
1537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001538 }
1539
1540 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001541 }
1542}
1543
Kenneth Russell67ea1902014-10-06 16:44:50 -07001544void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001546 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547
Geoff Langbfdea662014-07-23 14:16:32 -04001548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001549 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001550 {
Geoff Lang26298562014-10-01 10:49:03 -04001551 gl::Error error = context->sync(true);
1552 if (error.isError())
1553 {
1554 context->recordError(error);
1555 return;
1556 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557 }
1558}
1559
Kenneth Russell67ea1902014-10-06 16:44:50 -07001560void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001562 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001563
Geoff Langbfdea662014-07-23 14:16:32 -04001564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001565 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001566 {
Geoff Lang26298562014-10-01 10:49:03 -04001567 gl::Error error = context->sync(false);
1568 if (error.isError())
1569 {
1570 context->recordError(error);
1571 return;
1572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573 }
1574}
1575
Kenneth Russell67ea1902014-10-06 16:44:50 -07001576void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001578 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001579 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001580
Geoff Langbfdea662014-07-23 14:16:32 -04001581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001582 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583 {
Geoff Langb1196682014-07-23 13:47:29 -04001584 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1585 {
1586 context->recordError(gl::Error(GL_INVALID_ENUM));
1587 return;
1588 }
1589
Geoff Langbfdea662014-07-23 14:16:32 -04001590 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1591 {
1592 return;
1593 }
1594
1595 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1596 ASSERT(framebuffer);
1597
Geoff Langab75a052014-10-15 12:56:37 -04001598 if (renderbuffer != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001599 {
Geoff Langab75a052014-10-15 12:56:37 -04001600 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
1601 framebuffer->setRenderbufferAttachment(attachment, renderbufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -04001602 }
1603 else
1604 {
Geoff Langab75a052014-10-15 12:56:37 -04001605 framebuffer->setNULLAttachment(attachment);
Geoff Langbfdea662014-07-23 14:16:32 -04001606 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001607 }
1608}
1609
Kenneth Russell67ea1902014-10-06 16:44:50 -07001610void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001611{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001612 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001613 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001614
Geoff Langbfdea662014-07-23 14:16:32 -04001615 gl::Context *context = gl::getNonLostContext();
1616 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001617 {
Geoff Langbfdea662014-07-23 14:16:32 -04001618 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 {
Geoff Langbfdea662014-07-23 14:16:32 -04001620 return;
1621 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001622
Geoff Langbfdea662014-07-23 14:16:32 -04001623 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05001624 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625
Geoff Langab75a052014-10-15 12:56:37 -04001626 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04001627 {
Geoff Langab75a052014-10-15 12:56:37 -04001628 gl::Texture *textureObj = context->getTexture(texture);
1629 gl::ImageIndex index(textarget, level, gl::ImageIndex::ENTIRE_LEVEL);
1630 framebuffer->setTextureAttachment(attachment, textureObj, index);
Geoff Langbfdea662014-07-23 14:16:32 -04001631 }
1632 else
1633 {
Geoff Langab75a052014-10-15 12:56:37 -04001634 framebuffer->setNULLAttachment(attachment);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001635 }
1636 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001637}
1638
Kenneth Russell67ea1902014-10-06 16:44:50 -07001639void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001640{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001641 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001642
Geoff Langb1196682014-07-23 13:47:29 -04001643 gl::Context *context = gl::getNonLostContext();
1644 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001645 {
Geoff Langb1196682014-07-23 13:47:29 -04001646 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001647 {
Geoff Langb1196682014-07-23 13:47:29 -04001648 case GL_CW:
1649 case GL_CCW:
1650 context->getState().setFrontFace(mode);
1651 break;
1652 default:
1653 context->recordError(gl::Error(GL_INVALID_ENUM));
1654 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001656 }
1657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langbfdea662014-07-23 14:16:32 -04001663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 if (n < 0)
1667 {
1668 context->recordError(gl::Error(GL_INVALID_VALUE));
1669 return;
1670 }
1671
Geoff Langbfdea662014-07-23 14:16:32 -04001672 for (int i = 0; i < n; i++)
1673 {
1674 buffers[i] = context->createBuffer();
1675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
1685 {
1686 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001687 {
Geoff Langb1196682014-07-23 13:47:29 -04001688 context->recordError(gl::Error(GL_INVALID_ENUM));
1689 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001690 }
Geoff Langbfdea662014-07-23 14:16:32 -04001691
1692 gl::Texture *texture = context->getTargetTexture(target);
1693
1694 if (texture == NULL)
1695 {
Geoff Langb1196682014-07-23 13:47:29 -04001696 context->recordError(gl::Error(GL_INVALID_OPERATION));
1697 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001698 }
1699
1700 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1701 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001702 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001703
1704 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1705 // unsized formats or that are color renderable and filterable. Since we do not track if
1706 // the texture was created with sized or unsized format (only sized formats are stored),
1707 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1708 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1709 // textures since they're the only texture format that can be created with unsized formats
1710 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1711 // was the last version to use add them.
1712 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1713 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1714 internalFormat == GL_ALPHA8_EXT;
1715
Geoff Lang5d601382014-07-22 15:14:06 -04001716 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1717 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001718 {
Geoff Langb1196682014-07-23 13:47:29 -04001719 context->recordError(gl::Error(GL_INVALID_OPERATION));
1720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001721 }
1722
1723 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001724 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001725 {
Geoff Langb1196682014-07-23 13:47:29 -04001726 context->recordError(gl::Error(GL_INVALID_OPERATION));
1727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001728 }
1729
1730 // Non-power of 2 ES2 check
1731 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1732 {
1733 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001734 context->recordError(gl::Error(GL_INVALID_OPERATION));
1735 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001736 }
1737
1738 // Cube completeness check
1739 if (target == GL_TEXTURE_CUBE_MAP)
1740 {
1741 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1742 if (!textureCube->isCubeComplete())
1743 {
Geoff Langb1196682014-07-23 13:47:29 -04001744 context->recordError(gl::Error(GL_INVALID_OPERATION));
1745 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001746 }
1747 }
1748
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001749 gl::Error error = texture->generateMipmaps();
1750 if (error.isError())
1751 {
1752 context->recordError(error);
1753 return;
1754 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001755 }
1756}
1757
Kenneth Russell67ea1902014-10-06 16:44:50 -07001758void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001760 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001761
Geoff Langbfdea662014-07-23 14:16:32 -04001762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001763 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001764 {
Geoff Langb1196682014-07-23 13:47:29 -04001765 if (n < 0)
1766 {
1767 context->recordError(gl::Error(GL_INVALID_VALUE));
1768 return;
1769 }
1770
Geoff Langbfdea662014-07-23 14:16:32 -04001771 for (int i = 0; i < n; i++)
1772 {
1773 fences[i] = context->createFenceNV();
1774 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001775 }
1776}
1777
Kenneth Russell67ea1902014-10-06 16:44:50 -07001778void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001779{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001780 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001781
Geoff Langbfdea662014-07-23 14:16:32 -04001782 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001783 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001784 {
Geoff Langb1196682014-07-23 13:47:29 -04001785 if (n < 0)
1786 {
1787 context->recordError(gl::Error(GL_INVALID_VALUE));
1788 return;
1789 }
1790
Geoff Langbfdea662014-07-23 14:16:32 -04001791 for (int i = 0; i < n; i++)
1792 {
1793 framebuffers[i] = context->createFramebuffer();
1794 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001795 }
1796}
1797
Kenneth Russell67ea1902014-10-06 16:44:50 -07001798void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001799{
1800 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1801
Geoff Langbfdea662014-07-23 14:16:32 -04001802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001803 if (context)
1804 {
1805 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001806 {
Geoff Langb1196682014-07-23 13:47:29 -04001807 context->recordError(gl::Error(GL_INVALID_VALUE));
1808 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001809 }
Geoff Langbfdea662014-07-23 14:16:32 -04001810
1811 for (GLsizei i = 0; i < n; i++)
1812 {
1813 ids[i] = context->createQuery();
1814 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001815 }
1816}
1817
Kenneth Russell67ea1902014-10-06 16:44:50 -07001818void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001819{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001820 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001821
Geoff Langbfdea662014-07-23 14:16:32 -04001822 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001823 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001824 {
Geoff Langb1196682014-07-23 13:47:29 -04001825 if (n < 0)
1826 {
1827 context->recordError(gl::Error(GL_INVALID_VALUE));
1828 return;
1829 }
1830
Geoff Langbfdea662014-07-23 14:16:32 -04001831 for (int i = 0; i < n; i++)
1832 {
1833 renderbuffers[i] = context->createRenderbuffer();
1834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835 }
1836}
1837
Kenneth Russell67ea1902014-10-06 16:44:50 -07001838void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001840 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001841
Geoff Langbfdea662014-07-23 14:16:32 -04001842 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001843 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844 {
Geoff Langb1196682014-07-23 13:47:29 -04001845 if (n < 0)
1846 {
1847 context->recordError(gl::Error(GL_INVALID_VALUE));
1848 return;
1849 }
1850
Geoff Langbfdea662014-07-23 14:16:32 -04001851 for (int i = 0; i < n; i++)
1852 {
1853 textures[i] = context->createTexture();
1854 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001855 }
1856}
1857
Kenneth Russell67ea1902014-10-06 16:44:50 -07001858void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001860 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001861 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862 program, index, bufsize, length, size, type, name);
1863
Geoff Langbfdea662014-07-23 14:16:32 -04001864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001865 if (context)
1866 {
Geoff Langb1196682014-07-23 13:47:29 -04001867 if (bufsize < 0)
1868 {
1869 context->recordError(gl::Error(GL_INVALID_VALUE));
1870 return;
1871 }
1872
Geoff Langbfdea662014-07-23 14:16:32 -04001873 gl::Program *programObject = context->getProgram(program);
1874
1875 if (!programObject)
1876 {
1877 if (context->getShader(program))
1878 {
Geoff Langb1196682014-07-23 13:47:29 -04001879 context->recordError(gl::Error(GL_INVALID_OPERATION));
1880 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001881 }
1882 else
1883 {
Geoff Langb1196682014-07-23 13:47:29 -04001884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001886 }
1887 }
1888
1889 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001890 {
Geoff Langb1196682014-07-23 13:47:29 -04001891 context->recordError(gl::Error(GL_INVALID_VALUE));
1892 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001893 }
1894
Geoff Langbfdea662014-07-23 14:16:32 -04001895 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001896 }
1897}
1898
Kenneth Russell67ea1902014-10-06 16:44:50 -07001899void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001901 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001902 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001903 program, index, bufsize, length, size, type, name);
1904
Geoff Langbfdea662014-07-23 14:16:32 -04001905
1906 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001907 if (context)
1908 {
Geoff Langb1196682014-07-23 13:47:29 -04001909 if (bufsize < 0)
1910 {
1911 context->recordError(gl::Error(GL_INVALID_VALUE));
1912 return;
1913 }
1914
Geoff Langbfdea662014-07-23 14:16:32 -04001915 gl::Program *programObject = context->getProgram(program);
1916
1917 if (!programObject)
1918 {
1919 if (context->getShader(program))
1920 {
Geoff Langb1196682014-07-23 13:47:29 -04001921 context->recordError(gl::Error(GL_INVALID_OPERATION));
1922 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001923 }
1924 else
1925 {
Geoff Langb1196682014-07-23 13:47:29 -04001926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001928 }
1929 }
1930
1931 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001932 {
Geoff Langb1196682014-07-23 13:47:29 -04001933 context->recordError(gl::Error(GL_INVALID_VALUE));
1934 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001935 }
1936
Geoff Langbfdea662014-07-23 14:16:32 -04001937 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001938 }
1939}
1940
Kenneth Russell67ea1902014-10-06 16:44:50 -07001941void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001942{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001943 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001944 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001945
Geoff Langbfdea662014-07-23 14:16:32 -04001946 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001947 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001948 {
Geoff Langb1196682014-07-23 13:47:29 -04001949 if (maxcount < 0)
1950 {
1951 context->recordError(gl::Error(GL_INVALID_VALUE));
1952 return;
1953 }
1954
Geoff Langbfdea662014-07-23 14:16:32 -04001955 gl::Program *programObject = context->getProgram(program);
1956
1957 if (!programObject)
1958 {
1959 if (context->getShader(program))
1960 {
Geoff Langb1196682014-07-23 13:47:29 -04001961 context->recordError(gl::Error(GL_INVALID_OPERATION));
1962 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001963 }
1964 else
1965 {
Geoff Langb1196682014-07-23 13:47:29 -04001966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001968 }
1969 }
1970
1971 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001972 }
1973}
1974
Kenneth Russell67ea1902014-10-06 16:44:50 -07001975GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001976{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001977 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001978
Geoff Langbfdea662014-07-23 14:16:32 -04001979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001980 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001981 {
Geoff Langbfdea662014-07-23 14:16:32 -04001982 gl::Program *programObject = context->getProgram(program);
1983
1984 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001985 {
Geoff Langbfdea662014-07-23 14:16:32 -04001986 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001987 {
Geoff Langb1196682014-07-23 13:47:29 -04001988 context->recordError(gl::Error(GL_INVALID_OPERATION));
1989 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001990 }
Geoff Langbfdea662014-07-23 14:16:32 -04001991 else
1992 {
Geoff Langb1196682014-07-23 13:47:29 -04001993 context->recordError(gl::Error(GL_INVALID_VALUE));
1994 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04001995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 }
Geoff Langbfdea662014-07-23 14:16:32 -04001997
1998 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
1999 if (!programObject->isLinked() || !programBinary)
2000 {
Geoff Langb1196682014-07-23 13:47:29 -04002001 context->recordError(gl::Error(GL_INVALID_OPERATION));
2002 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002003 }
2004
2005 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002006 }
2007
2008 return -1;
2009}
2010
Kenneth Russell67ea1902014-10-06 16:44:50 -07002011void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002013 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002014
Geoff Langbfdea662014-07-23 14:16:32 -04002015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002016 if (context)
2017 {
2018 GLenum nativeType;
2019 unsigned int numParams = 0;
2020 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 {
Geoff Langbfdea662014-07-23 14:16:32 -04002022 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002023 }
Geoff Langbfdea662014-07-23 14:16:32 -04002024
2025 if (nativeType == GL_BOOL)
2026 {
2027 context->getBooleanv(pname, params);
2028 }
2029 else
2030 {
2031 CastStateValues(context, nativeType, pname, numParams, params);
2032 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002033 }
2034}
2035
Kenneth Russell67ea1902014-10-06 16:44:50 -07002036void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002037{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002038 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002039
Geoff Langbfdea662014-07-23 14:16:32 -04002040 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002041 if (context)
2042 {
2043 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002044 {
Geoff Langb1196682014-07-23 13:47:29 -04002045 context->recordError(gl::Error(GL_INVALID_ENUM));
2046 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002047 }
Geoff Langbfdea662014-07-23 14:16:32 -04002048
2049 if (!gl::ValidBufferParameter(context, pname))
2050 {
Geoff Langb1196682014-07-23 13:47:29 -04002051 context->recordError(gl::Error(GL_INVALID_ENUM));
2052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002053 }
2054
2055 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2056
2057 if (!buffer)
2058 {
2059 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_OPERATION));
2061 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002062 }
2063
2064 switch (pname)
2065 {
2066 case GL_BUFFER_USAGE:
2067 *params = static_cast<GLint>(buffer->getUsage());
2068 break;
2069 case GL_BUFFER_SIZE:
2070 *params = gl::clampCast<GLint>(buffer->getSize());
2071 break;
2072 case GL_BUFFER_ACCESS_FLAGS:
2073 *params = buffer->getAccessFlags();
2074 break;
2075 case GL_BUFFER_MAPPED:
2076 *params = static_cast<GLint>(buffer->isMapped());
2077 break;
2078 case GL_BUFFER_MAP_OFFSET:
2079 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2080 break;
2081 case GL_BUFFER_MAP_LENGTH:
2082 *params = gl::clampCast<GLint>(buffer->getMapLength());
2083 break;
2084 default: UNREACHABLE(); break;
2085 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002086 }
2087}
2088
Kenneth Russell67ea1902014-10-06 16:44:50 -07002089GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002090{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002091 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002092
2093 gl::Context *context = gl::getContext();
2094
2095 if (context)
2096 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002097 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002098 }
2099
2100 return GL_NO_ERROR;
2101}
2102
Kenneth Russell67ea1902014-10-06 16:44:50 -07002103void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002104{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002105 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002106
Geoff Langbfdea662014-07-23 14:16:32 -04002107 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002108 if (context)
2109 {
2110 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2111
2112 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002113 {
Geoff Langb1196682014-07-23 13:47:29 -04002114 context->recordError(gl::Error(GL_INVALID_OPERATION));
2115 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002116 }
Geoff Langbfdea662014-07-23 14:16:32 -04002117
2118 if (fenceObject->isFence() != GL_TRUE)
2119 {
Geoff Langb1196682014-07-23 13:47:29 -04002120 context->recordError(gl::Error(GL_INVALID_OPERATION));
2121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002122 }
2123
2124 switch (pname)
2125 {
2126 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002127 {
2128 // GL_NV_fence spec:
2129 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2130 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2131 GLboolean status = GL_TRUE;
2132 if (fenceObject->getStatus() != GL_TRUE)
2133 {
2134 gl::Error error = fenceObject->testFence(&status);
2135 if (error.isError())
2136 {
2137 context->recordError(error);
2138 return;
2139 }
2140 }
2141 *params = status;
2142 break;
2143 }
2144
Geoff Langbfdea662014-07-23 14:16:32 -04002145 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002146 {
2147 *params = fenceObject->getCondition();
2148 break;
2149 }
Geoff Langbfdea662014-07-23 14:16:32 -04002150
Geoff Langb1196682014-07-23 13:47:29 -04002151 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002152 {
2153 context->recordError(gl::Error(GL_INVALID_ENUM));
2154 return;
2155 }
Geoff Lang882033e2014-09-30 11:26:07 -04002156 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002157 }
2158}
2159
Kenneth Russell67ea1902014-10-06 16:44:50 -07002160void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002161{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002162 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002163
Geoff Langbfdea662014-07-23 14:16:32 -04002164 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002165 if (context)
2166 {
2167 GLenum nativeType;
2168 unsigned int numParams = 0;
2169 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002170 {
Geoff Langbfdea662014-07-23 14:16:32 -04002171 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002172 }
Geoff Langbfdea662014-07-23 14:16:32 -04002173
2174 if (nativeType == GL_FLOAT)
2175 {
2176 context->getFloatv(pname, params);
2177 }
2178 else
2179 {
2180 CastStateValues(context, nativeType, pname, numParams, params);
2181 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002182 }
2183}
2184
Kenneth Russell67ea1902014-10-06 16:44:50 -07002185void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002186{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002187 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002188 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002189
Geoff Langbfdea662014-07-23 14:16:32 -04002190 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002191 if (context)
2192 {
2193 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002194 {
Geoff Langb1196682014-07-23 13:47:29 -04002195 context->recordError(gl::Error(GL_INVALID_ENUM));
2196 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002197 }
2198
2199 int clientVersion = context->getClientVersion();
2200
2201 switch (pname)
2202 {
2203 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2204 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2205 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2206 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2207 break;
Geoff Langb1196682014-07-23 13:47:29 -04002208
Geoff Langbfdea662014-07-23 14:16:32 -04002209 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2210 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002211 {
Geoff Langb1196682014-07-23 13:47:29 -04002212 context->recordError(gl::Error(GL_INVALID_ENUM));
2213 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002214 }
Geoff Langbfdea662014-07-23 14:16:32 -04002215 break;
Geoff Langb1196682014-07-23 13:47:29 -04002216
Geoff Langbfdea662014-07-23 14:16:32 -04002217 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2218 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2220 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2221 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2222 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2223 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2224 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2225 if (clientVersion < 3)
2226 {
Geoff Langb1196682014-07-23 13:47:29 -04002227 context->recordError(gl::Error(GL_INVALID_ENUM));
2228 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002229 }
2230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 default:
Geoff Langb1196682014-07-23 13:47:29 -04002233 context->recordError(gl::Error(GL_INVALID_ENUM));
2234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002235 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002236
Geoff Langbfdea662014-07-23 14:16:32 -04002237 // Determine if the attachment is a valid enum
2238 switch (attachment)
2239 {
2240 case GL_BACK:
2241 case GL_FRONT:
2242 case GL_DEPTH:
2243 case GL_STENCIL:
2244 case GL_DEPTH_STENCIL_ATTACHMENT:
2245 if (clientVersion < 3)
2246 {
Geoff Langb1196682014-07-23 13:47:29 -04002247 context->recordError(gl::Error(GL_INVALID_ENUM));
2248 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002249 }
2250 break;
2251
2252 case GL_DEPTH_ATTACHMENT:
2253 case GL_STENCIL_ATTACHMENT:
2254 break;
2255
2256 default:
2257 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2258 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2259 {
Geoff Langb1196682014-07-23 13:47:29 -04002260 context->recordError(gl::Error(GL_INVALID_ENUM));
2261 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002262 }
2263 break;
2264 }
2265
2266 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2267 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
Jamie Madill48faf802014-11-06 15:27:22 -05002268 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04002269
2270 if (framebufferHandle == 0)
2271 {
2272 if (clientVersion < 3)
2273 {
Geoff Langb1196682014-07-23 13:47:29 -04002274 context->recordError(gl::Error(GL_INVALID_OPERATION));
2275 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002276 }
2277
2278 switch (attachment)
2279 {
2280 case GL_BACK:
2281 case GL_DEPTH:
2282 case GL_STENCIL:
2283 break;
Geoff Langb1196682014-07-23 13:47:29 -04002284
Geoff Langbfdea662014-07-23 14:16:32 -04002285 default:
Geoff Langb1196682014-07-23 13:47:29 -04002286 context->recordError(gl::Error(GL_INVALID_OPERATION));
2287 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002288 }
2289 }
2290 else
2291 {
2292 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2293 {
2294 // Valid attachment query
2295 }
2296 else
2297 {
2298 switch (attachment)
2299 {
2300 case GL_DEPTH_ATTACHMENT:
2301 case GL_STENCIL_ATTACHMENT:
2302 break;
Geoff Langb1196682014-07-23 13:47:29 -04002303
Geoff Langbfdea662014-07-23 14:16:32 -04002304 case GL_DEPTH_STENCIL_ATTACHMENT:
2305 if (framebuffer->hasValidDepthStencil())
2306 {
Geoff Langb1196682014-07-23 13:47:29 -04002307 context->recordError(gl::Error(GL_INVALID_OPERATION));
2308 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002309 }
2310 break;
Geoff Langb1196682014-07-23 13:47:29 -04002311
Geoff Langbfdea662014-07-23 14:16:32 -04002312 default:
Geoff Langb1196682014-07-23 13:47:29 -04002313 context->recordError(gl::Error(GL_INVALID_OPERATION));
2314 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002315 }
2316 }
2317 }
2318
2319 GLenum attachmentType = GL_NONE;
2320 GLuint attachmentHandle = 0;
2321 GLuint attachmentLevel = 0;
2322 GLuint attachmentLayer = 0;
2323
2324 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2325
2326 if (attachmentObject)
2327 {
2328 attachmentType = attachmentObject->type();
2329 attachmentHandle = attachmentObject->id();
2330 attachmentLevel = attachmentObject->mipLevel();
2331 attachmentLayer = attachmentObject->layer();
2332 }
2333
2334 GLenum attachmentObjectType; // Type category
2335 if (framebufferHandle == 0)
2336 {
2337 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2338 }
2339 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2340 {
2341 attachmentObjectType = attachmentType;
2342 }
2343 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2344 {
2345 attachmentObjectType = GL_TEXTURE;
2346 }
2347 else
2348 {
2349 UNREACHABLE();
2350 return;
2351 }
2352
2353 if (attachmentObjectType == GL_NONE)
2354 {
2355 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2356 // is NONE, then querying any other pname will generate INVALID_ENUM.
2357
2358 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2359 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2360 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002361
Geoff Lang646559f2013-08-15 11:08:15 -04002362 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002363 {
Geoff Lang646559f2013-08-15 11:08:15 -04002364 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002365 *params = attachmentObjectType;
2366 break;
2367
Geoff Lang646559f2013-08-15 11:08:15 -04002368 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002369 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002370 {
Geoff Langb1196682014-07-23 13:47:29 -04002371 context->recordError(gl::Error(GL_INVALID_ENUM));
2372 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002373 }
Geoff Langbfdea662014-07-23 14:16:32 -04002374 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002375 break;
2376
2377 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002378 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002379 {
Geoff Langb1196682014-07-23 13:47:29 -04002380 context->recordError(gl::Error(GL_INVALID_ENUM));
2381 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002382 }
2383 else
2384 {
Geoff Langb1196682014-07-23 13:47:29 -04002385 context->recordError(gl::Error(GL_INVALID_OPERATION));
2386 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002387 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002388 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002389 }
Geoff Langbfdea662014-07-23 14:16:32 -04002390 else
2391 {
2392 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2393 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2394 ASSERT(attachmentObject != NULL);
2395
2396 switch (pname)
2397 {
2398 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2399 *params = attachmentObjectType;
2400 break;
2401
2402 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2403 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2404 {
Geoff Langb1196682014-07-23 13:47:29 -04002405 context->recordError(gl::Error(GL_INVALID_ENUM));
2406 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002407 }
2408 *params = attachmentHandle;
2409 break;
2410
2411 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2412 if (attachmentObjectType != GL_TEXTURE)
2413 {
Geoff Langb1196682014-07-23 13:47:29 -04002414 context->recordError(gl::Error(GL_INVALID_ENUM));
2415 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002416 }
2417 *params = attachmentLevel;
2418 break;
2419
2420 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2421 if (attachmentObjectType != GL_TEXTURE)
2422 {
Geoff Langb1196682014-07-23 13:47:29 -04002423 context->recordError(gl::Error(GL_INVALID_ENUM));
2424 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002425 }
2426 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2427 break;
2428
2429 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2430 *params = attachmentObject->getRedSize();
2431 break;
2432
2433 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2434 *params = attachmentObject->getGreenSize();
2435 break;
2436
2437 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2438 *params = attachmentObject->getBlueSize();
2439 break;
2440
2441 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2442 *params = attachmentObject->getAlphaSize();
2443 break;
2444
2445 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2446 *params = attachmentObject->getDepthSize();
2447 break;
2448
2449 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2450 *params = attachmentObject->getStencilSize();
2451 break;
2452
2453 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002454 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002455 {
Geoff Langb1196682014-07-23 13:47:29 -04002456 context->recordError(gl::Error(GL_INVALID_OPERATION));
2457 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002458 }
2459 *params = attachmentObject->getComponentType();
2460 break;
2461
2462 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2463 *params = attachmentObject->getColorEncoding();
2464 break;
2465
2466 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2467 if (attachmentObjectType != GL_TEXTURE)
2468 {
Geoff Langb1196682014-07-23 13:47:29 -04002469 context->recordError(gl::Error(GL_INVALID_ENUM));
2470 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002471 }
2472 *params = attachmentLayer;
2473 break;
2474
2475 default:
2476 UNREACHABLE();
2477 break;
2478 }
2479 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002480 }
2481}
2482
Kenneth Russell67ea1902014-10-06 16:44:50 -07002483GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002484{
2485 EVENT("()");
2486
Geoff Langbfdea662014-07-23 14:16:32 -04002487 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002488
Geoff Langbfdea662014-07-23 14:16:32 -04002489 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002490 {
Geoff Langbfdea662014-07-23 14:16:32 -04002491 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002492 }
Geoff Langbfdea662014-07-23 14:16:32 -04002493
2494 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002495}
2496
Kenneth Russell67ea1902014-10-06 16:44:50 -07002497void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002498{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002499 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002500
Geoff Langbfdea662014-07-23 14:16:32 -04002501 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002502 if (context)
2503 {
2504 GLenum nativeType;
2505 unsigned int numParams = 0;
2506
2507 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002508 {
Geoff Langbfdea662014-07-23 14:16:32 -04002509 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002510 }
Geoff Langbfdea662014-07-23 14:16:32 -04002511
2512 if (nativeType == GL_INT)
2513 {
2514 context->getIntegerv(pname, params);
2515 }
2516 else
2517 {
2518 CastStateValues(context, nativeType, pname, numParams, params);
2519 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002520 }
2521}
2522
Kenneth Russell67ea1902014-10-06 16:44:50 -07002523void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002524{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002525 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002526
Geoff Langbfdea662014-07-23 14:16:32 -04002527 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002528 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529 {
Geoff Langbfdea662014-07-23 14:16:32 -04002530 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531
Geoff Langbfdea662014-07-23 14:16:32 -04002532 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 {
Geoff Langb1196682014-07-23 13:47:29 -04002534 context->recordError(gl::Error(GL_INVALID_VALUE));
2535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002536 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002537
Geoff Langbfdea662014-07-23 14:16:32 -04002538 if (context->getClientVersion() < 3)
2539 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002540 switch (pname)
2541 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002542 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002543 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002544 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002545 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002546 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002547 context->recordError(gl::Error(GL_INVALID_ENUM));
2548 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549 }
2550 }
Geoff Langbfdea662014-07-23 14:16:32 -04002551
2552 switch (pname)
2553 {
2554 case GL_DELETE_STATUS:
2555 *params = programObject->isFlaggedForDeletion();
2556 return;
2557 case GL_LINK_STATUS:
2558 *params = programObject->isLinked();
2559 return;
2560 case GL_VALIDATE_STATUS:
2561 *params = programObject->isValidated();
2562 return;
2563 case GL_INFO_LOG_LENGTH:
2564 *params = programObject->getInfoLogLength();
2565 return;
2566 case GL_ATTACHED_SHADERS:
2567 *params = programObject->getAttachedShadersCount();
2568 return;
2569 case GL_ACTIVE_ATTRIBUTES:
2570 *params = programObject->getActiveAttributeCount();
2571 return;
2572 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2573 *params = programObject->getActiveAttributeMaxLength();
2574 return;
2575 case GL_ACTIVE_UNIFORMS:
2576 *params = programObject->getActiveUniformCount();
2577 return;
2578 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2579 *params = programObject->getActiveUniformMaxLength();
2580 return;
2581 case GL_PROGRAM_BINARY_LENGTH_OES:
2582 *params = programObject->getProgramBinaryLength();
2583 return;
2584 case GL_ACTIVE_UNIFORM_BLOCKS:
2585 *params = programObject->getActiveUniformBlockCount();
2586 return;
2587 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2588 *params = programObject->getActiveUniformBlockMaxLength();
2589 break;
2590 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2591 *params = programObject->getTransformFeedbackBufferMode();
2592 break;
2593 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2594 *params = programObject->getTransformFeedbackVaryingCount();
2595 break;
2596 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2597 *params = programObject->getTransformFeedbackVaryingMaxLength();
2598 break;
Geoff Langb1196682014-07-23 13:47:29 -04002599
Geoff Langbfdea662014-07-23 14:16:32 -04002600 default:
Geoff Langb1196682014-07-23 13:47:29 -04002601 context->recordError(gl::Error(GL_INVALID_ENUM));
2602 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002603 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002604 }
2605}
2606
Kenneth Russell67ea1902014-10-06 16:44:50 -07002607void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002608{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002609 EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002610 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002611
Geoff Langbfdea662014-07-23 14:16:32 -04002612 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002613 if (context)
2614 {
Geoff Langb1196682014-07-23 13:47:29 -04002615 if (bufsize < 0)
2616 {
2617 context->recordError(gl::Error(GL_INVALID_VALUE));
2618 return;
2619 }
2620
Geoff Langbfdea662014-07-23 14:16:32 -04002621 gl::Program *programObject = context->getProgram(program);
2622
2623 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002624 {
Geoff Langb1196682014-07-23 13:47:29 -04002625 context->recordError(gl::Error(GL_INVALID_VALUE));
2626 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627 }
2628
Geoff Langbfdea662014-07-23 14:16:32 -04002629 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002630 }
2631}
2632
Kenneth Russell67ea1902014-10-06 16:44:50 -07002633void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002634{
2635 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2636
Geoff Langbfdea662014-07-23 14:16:32 -04002637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002638 if (context)
2639 {
2640 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002641 {
Geoff Langb1196682014-07-23 13:47:29 -04002642 context->recordError(gl::Error(GL_INVALID_ENUM));
2643 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002644 }
Geoff Langbfdea662014-07-23 14:16:32 -04002645
2646 switch (pname)
2647 {
2648 case GL_CURRENT_QUERY_EXT:
2649 params[0] = context->getState().getActiveQueryId(target);
2650 break;
2651
2652 default:
Geoff Langb1196682014-07-23 13:47:29 -04002653 context->recordError(gl::Error(GL_INVALID_ENUM));
2654 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002655 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002656 }
2657}
2658
Kenneth Russell67ea1902014-10-06 16:44:50 -07002659void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002660{
2661 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2662
Geoff Langbfdea662014-07-23 14:16:32 -04002663 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002664 if (context)
2665 {
2666 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2667
2668 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002669 {
Geoff Langb1196682014-07-23 13:47:29 -04002670 context->recordError(gl::Error(GL_INVALID_OPERATION));
2671 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002672 }
Geoff Langbfdea662014-07-23 14:16:32 -04002673
2674 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2675 {
Geoff Langb1196682014-07-23 13:47:29 -04002676 context->recordError(gl::Error(GL_INVALID_OPERATION));
2677 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002678 }
2679
2680 switch(pname)
2681 {
2682 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002683 {
2684 gl::Error error = queryObject->getResult(params);
2685 if (error.isError())
2686 {
2687 context->recordError(error);
2688 return;
2689 }
2690 }
Geoff Langbfdea662014-07-23 14:16:32 -04002691 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002692
Geoff Langbfdea662014-07-23 14:16:32 -04002693 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002694 {
2695 gl::Error error = queryObject->isResultAvailable(params);
2696 if (error.isError())
2697 {
2698 context->recordError(error);
2699 return;
2700 }
2701 }
Geoff Langbfdea662014-07-23 14:16:32 -04002702 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002703
Geoff Langbfdea662014-07-23 14:16:32 -04002704 default:
Geoff Langb1196682014-07-23 13:47:29 -04002705 context->recordError(gl::Error(GL_INVALID_ENUM));
2706 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002707 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002708 }
2709}
2710
Kenneth Russell67ea1902014-10-06 16:44:50 -07002711void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002712{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002713 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002714
Geoff Langbfdea662014-07-23 14:16:32 -04002715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002716 if (context)
2717 {
2718 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002719 {
Geoff Langb1196682014-07-23 13:47:29 -04002720 context->recordError(gl::Error(GL_INVALID_ENUM));
2721 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002722 }
Geoff Langbfdea662014-07-23 14:16:32 -04002723
2724 if (context->getState().getRenderbufferId() == 0)
2725 {
Geoff Langb1196682014-07-23 13:47:29 -04002726 context->recordError(gl::Error(GL_INVALID_OPERATION));
2727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002728 }
2729
2730 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2731
2732 switch (pname)
2733 {
2734 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2735 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2736 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2737 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2738 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2739 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2740 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2741 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2742 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002743
Geoff Langbfdea662014-07-23 14:16:32 -04002744 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2745 if (!context->getExtensions().framebufferMultisample)
2746 {
Geoff Langb1196682014-07-23 13:47:29 -04002747 context->recordError(gl::Error(GL_INVALID_ENUM));
2748 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002749 }
2750 *params = renderbuffer->getSamples();
2751 break;
Geoff Langb1196682014-07-23 13:47:29 -04002752
Geoff Langbfdea662014-07-23 14:16:32 -04002753 default:
Geoff Langb1196682014-07-23 13:47:29 -04002754 context->recordError(gl::Error(GL_INVALID_ENUM));
2755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002756 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002757 }
2758}
2759
Kenneth Russell67ea1902014-10-06 16:44:50 -07002760void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002761{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002762 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002763
Geoff Langbfdea662014-07-23 14:16:32 -04002764 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002765 if (context)
2766 {
2767 gl::Shader *shaderObject = context->getShader(shader);
2768
2769 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002770 {
Geoff Langb1196682014-07-23 13:47:29 -04002771 context->recordError(gl::Error(GL_INVALID_VALUE));
2772 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002773 }
Geoff Langbfdea662014-07-23 14:16:32 -04002774
2775 switch (pname)
2776 {
2777 case GL_SHADER_TYPE:
2778 *params = shaderObject->getType();
2779 return;
2780 case GL_DELETE_STATUS:
2781 *params = shaderObject->isFlaggedForDeletion();
2782 return;
2783 case GL_COMPILE_STATUS:
2784 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2785 return;
2786 case GL_INFO_LOG_LENGTH:
2787 *params = shaderObject->getInfoLogLength();
2788 return;
2789 case GL_SHADER_SOURCE_LENGTH:
2790 *params = shaderObject->getSourceLength();
2791 return;
2792 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2793 *params = shaderObject->getTranslatedSourceLength();
2794 return;
Geoff Langb1196682014-07-23 13:47:29 -04002795
Geoff Langbfdea662014-07-23 14:16:32 -04002796 default:
Geoff Langb1196682014-07-23 13:47:29 -04002797 context->recordError(gl::Error(GL_INVALID_ENUM));
2798 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002799 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002800 }
2801}
2802
Kenneth Russell67ea1902014-10-06 16:44:50 -07002803void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002805 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002806 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002807
Geoff Langbfdea662014-07-23 14:16:32 -04002808 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002809 if (context)
2810 {
Geoff Langb1196682014-07-23 13:47:29 -04002811 if (bufsize < 0)
2812 {
2813 context->recordError(gl::Error(GL_INVALID_VALUE));
2814 return;
2815 }
2816
Geoff Langbfdea662014-07-23 14:16:32 -04002817 gl::Shader *shaderObject = context->getShader(shader);
2818
2819 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002820 {
Geoff Langb1196682014-07-23 13:47:29 -04002821 context->recordError(gl::Error(GL_INVALID_VALUE));
2822 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823 }
2824
Geoff Langbfdea662014-07-23 14:16:32 -04002825 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002826 }
2827}
2828
Kenneth Russell67ea1902014-10-06 16:44:50 -07002829void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002830{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002831 EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002832 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002833
Geoff Langb1196682014-07-23 13:47:29 -04002834 gl::Context *context = gl::getNonLostContext();
2835 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836 {
Geoff Langb1196682014-07-23 13:47:29 -04002837 switch (shadertype)
2838 {
2839 case GL_VERTEX_SHADER:
2840 case GL_FRAGMENT_SHADER:
2841 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002842
Geoff Langb1196682014-07-23 13:47:29 -04002843 default:
2844 context->recordError(gl::Error(GL_INVALID_ENUM));
2845 return;
2846 }
2847
2848 switch (precisiontype)
2849 {
2850 case GL_LOW_FLOAT:
2851 case GL_MEDIUM_FLOAT:
2852 case GL_HIGH_FLOAT:
2853 // Assume IEEE 754 precision
2854 range[0] = 127;
2855 range[1] = 127;
2856 *precision = 23;
2857 break;
2858
2859 case GL_LOW_INT:
2860 case GL_MEDIUM_INT:
2861 case GL_HIGH_INT:
2862 // Some (most) hardware only supports single-precision floating-point numbers,
2863 // which can accurately represent integers up to +/-16777216
2864 range[0] = 24;
2865 range[1] = 24;
2866 *precision = 0;
2867 break;
2868
2869 default:
2870 context->recordError(gl::Error(GL_INVALID_ENUM));
2871 return;
2872 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002873 }
2874}
2875
Kenneth Russell67ea1902014-10-06 16:44:50 -07002876void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002877{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002878 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002879 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002880
Geoff Langbfdea662014-07-23 14:16:32 -04002881 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002882 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002883 {
Geoff Langb1196682014-07-23 13:47:29 -04002884 if (bufsize < 0)
2885 {
2886 context->recordError(gl::Error(GL_INVALID_VALUE));
2887 return;
2888 }
2889
Geoff Langbfdea662014-07-23 14:16:32 -04002890 gl::Shader *shaderObject = context->getShader(shader);
2891
2892 if (!shaderObject)
2893 {
Geoff Langb1196682014-07-23 13:47:29 -04002894 context->recordError(gl::Error(GL_INVALID_OPERATION));
2895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002896 }
2897
2898 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002899 }
2900}
2901
Kenneth Russell67ea1902014-10-06 16:44:50 -07002902void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002903{
2904 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2905 shader, bufsize, length, source);
2906
Geoff Langbfdea662014-07-23 14:16:32 -04002907 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002908 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002909 {
Geoff Langb1196682014-07-23 13:47:29 -04002910 if (bufsize < 0)
2911 {
2912 context->recordError(gl::Error(GL_INVALID_VALUE));
2913 return;
2914 }
2915
Geoff Langbfdea662014-07-23 14:16:32 -04002916 gl::Shader *shaderObject = context->getShader(shader);
2917
2918 if (!shaderObject)
2919 {
Geoff Langb1196682014-07-23 13:47:29 -04002920 context->recordError(gl::Error(GL_INVALID_OPERATION));
2921 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002922 }
2923
Tibor den Ouden97049c62014-10-06 21:39:16 +02002924 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2925 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002926 }
2927}
2928
Kenneth Russell67ea1902014-10-06 16:44:50 -07002929const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002930{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002931 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002932
Geoff Langbfdea662014-07-23 14:16:32 -04002933 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002934
Geoff Langbfdea662014-07-23 14:16:32 -04002935 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002936 {
Geoff Langbfdea662014-07-23 14:16:32 -04002937 case GL_VENDOR:
2938 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002939
Geoff Langbfdea662014-07-23 14:16:32 -04002940 case GL_RENDERER:
2941 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002942
Geoff Langbfdea662014-07-23 14:16:32 -04002943 case GL_VERSION:
2944 if (context->getClientVersion() == 2)
2945 {
2946 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2947 }
2948 else
2949 {
2950 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2951 }
Geoff Langb1196682014-07-23 13:47:29 -04002952
Geoff Langbfdea662014-07-23 14:16:32 -04002953 case GL_SHADING_LANGUAGE_VERSION:
2954 if (context->getClientVersion() == 2)
2955 {
2956 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2957 }
2958 else
2959 {
2960 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2961 }
Geoff Langb1196682014-07-23 13:47:29 -04002962
Geoff Langbfdea662014-07-23 14:16:32 -04002963 case GL_EXTENSIONS:
2964 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002965
Geoff Langbfdea662014-07-23 14:16:32 -04002966 default:
Geoff Langb1196682014-07-23 13:47:29 -04002967 if (context)
2968 {
2969 context->recordError(gl::Error(GL_INVALID_ENUM));
2970 }
2971 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002972 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002973}
2974
Kenneth Russell67ea1902014-10-06 16:44:50 -07002975void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002976{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002977 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002978
Geoff Langbfdea662014-07-23 14:16:32 -04002979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002980 if (context)
2981 {
2982 gl::Texture *texture = context->getTargetTexture(target);
2983
2984 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002985 {
Geoff Langb1196682014-07-23 13:47:29 -04002986 context->recordError(gl::Error(GL_INVALID_ENUM));
2987 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002988 }
Geoff Langbfdea662014-07-23 14:16:32 -04002989
2990 switch (pname)
2991 {
2992 case GL_TEXTURE_MAG_FILTER:
2993 *params = (GLfloat)texture->getSamplerState().magFilter;
2994 break;
2995 case GL_TEXTURE_MIN_FILTER:
2996 *params = (GLfloat)texture->getSamplerState().minFilter;
2997 break;
2998 case GL_TEXTURE_WRAP_S:
2999 *params = (GLfloat)texture->getSamplerState().wrapS;
3000 break;
3001 case GL_TEXTURE_WRAP_T:
3002 *params = (GLfloat)texture->getSamplerState().wrapT;
3003 break;
3004 case GL_TEXTURE_WRAP_R:
3005 if (context->getClientVersion() < 3)
3006 {
Geoff Langb1196682014-07-23 13:47:29 -04003007 context->recordError(gl::Error(GL_INVALID_ENUM));
3008 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003009 }
3010 *params = (GLfloat)texture->getSamplerState().wrapR;
3011 break;
3012 case GL_TEXTURE_IMMUTABLE_FORMAT:
3013 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3014 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3015 break;
3016 case GL_TEXTURE_IMMUTABLE_LEVELS:
3017 if (context->getClientVersion() < 3)
3018 {
Geoff Langb1196682014-07-23 13:47:29 -04003019 context->recordError(gl::Error(GL_INVALID_ENUM));
3020 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003021 }
3022 *params = (GLfloat)texture->immutableLevelCount();
3023 break;
3024 case GL_TEXTURE_USAGE_ANGLE:
3025 *params = (GLfloat)texture->getUsage();
3026 break;
3027 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3028 if (!context->getExtensions().textureFilterAnisotropic)
3029 {
Geoff Langb1196682014-07-23 13:47:29 -04003030 context->recordError(gl::Error(GL_INVALID_ENUM));
3031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003032 }
3033 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3034 break;
3035 case GL_TEXTURE_SWIZZLE_R:
3036 if (context->getClientVersion() < 3)
3037 {
Geoff Langb1196682014-07-23 13:47:29 -04003038 context->recordError(gl::Error(GL_INVALID_ENUM));
3039 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003040 }
3041 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3042 break;
3043 case GL_TEXTURE_SWIZZLE_G:
3044 if (context->getClientVersion() < 3)
3045 {
Geoff Langb1196682014-07-23 13:47:29 -04003046 context->recordError(gl::Error(GL_INVALID_ENUM));
3047 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003048 }
3049 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3050 break;
3051 case GL_TEXTURE_SWIZZLE_B:
3052 if (context->getClientVersion() < 3)
3053 {
Geoff Langb1196682014-07-23 13:47:29 -04003054 context->recordError(gl::Error(GL_INVALID_ENUM));
3055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003056 }
3057 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3058 break;
3059 case GL_TEXTURE_SWIZZLE_A:
3060 if (context->getClientVersion() < 3)
3061 {
Geoff Langb1196682014-07-23 13:47:29 -04003062 context->recordError(gl::Error(GL_INVALID_ENUM));
3063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003064 }
3065 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3066 break;
3067 case GL_TEXTURE_BASE_LEVEL:
3068 if (context->getClientVersion() < 3)
3069 {
Geoff Langb1196682014-07-23 13:47:29 -04003070 context->recordError(gl::Error(GL_INVALID_ENUM));
3071 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003072 }
3073 *params = (GLfloat)texture->getSamplerState().baseLevel;
3074 break;
3075 case GL_TEXTURE_MAX_LEVEL:
3076 if (context->getClientVersion() < 3)
3077 {
Geoff Langb1196682014-07-23 13:47:29 -04003078 context->recordError(gl::Error(GL_INVALID_ENUM));
3079 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003080 }
3081 *params = (GLfloat)texture->getSamplerState().maxLevel;
3082 break;
3083 case GL_TEXTURE_MIN_LOD:
3084 if (context->getClientVersion() < 3)
3085 {
Geoff Langb1196682014-07-23 13:47:29 -04003086 context->recordError(gl::Error(GL_INVALID_ENUM));
3087 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003088 }
3089 *params = texture->getSamplerState().minLod;
3090 break;
3091 case GL_TEXTURE_MAX_LOD:
3092 if (context->getClientVersion() < 3)
3093 {
Geoff Langb1196682014-07-23 13:47:29 -04003094 context->recordError(gl::Error(GL_INVALID_ENUM));
3095 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003096 }
3097 *params = texture->getSamplerState().maxLod;
3098 break;
Geoff Langb1196682014-07-23 13:47:29 -04003099
Geoff Langbfdea662014-07-23 14:16:32 -04003100 default:
Geoff Langb1196682014-07-23 13:47:29 -04003101 context->recordError(gl::Error(GL_INVALID_ENUM));
3102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003103 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003104 }
3105}
3106
Kenneth Russell67ea1902014-10-06 16:44:50 -07003107void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003108{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003109 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003110
Geoff Langbfdea662014-07-23 14:16:32 -04003111 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003112 if (context)
3113 {
3114 gl::Texture *texture = context->getTargetTexture(target);
3115
3116 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003117 {
Geoff Langb1196682014-07-23 13:47:29 -04003118 context->recordError(gl::Error(GL_INVALID_ENUM));
3119 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003120 }
Geoff Langbfdea662014-07-23 14:16:32 -04003121
3122 switch (pname)
3123 {
3124 case GL_TEXTURE_MAG_FILTER:
3125 *params = texture->getSamplerState().magFilter;
3126 break;
3127 case GL_TEXTURE_MIN_FILTER:
3128 *params = texture->getSamplerState().minFilter;
3129 break;
3130 case GL_TEXTURE_WRAP_S:
3131 *params = texture->getSamplerState().wrapS;
3132 break;
3133 case GL_TEXTURE_WRAP_T:
3134 *params = texture->getSamplerState().wrapT;
3135 break;
3136 case GL_TEXTURE_WRAP_R:
3137 if (context->getClientVersion() < 3)
3138 {
Geoff Langb1196682014-07-23 13:47:29 -04003139 context->recordError(gl::Error(GL_INVALID_ENUM));
3140 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003141 }
3142 *params = texture->getSamplerState().wrapR;
3143 break;
3144 case GL_TEXTURE_IMMUTABLE_FORMAT:
3145 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3146 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3147 break;
3148 case GL_TEXTURE_IMMUTABLE_LEVELS:
3149 if (context->getClientVersion() < 3)
3150 {
Geoff Langb1196682014-07-23 13:47:29 -04003151 context->recordError(gl::Error(GL_INVALID_ENUM));
3152 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003153 }
Jamie Madill6948e302014-10-20 17:04:33 -04003154 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003155 break;
3156 case GL_TEXTURE_USAGE_ANGLE:
3157 *params = texture->getUsage();
3158 break;
3159 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3160 if (!context->getExtensions().textureFilterAnisotropic)
3161 {
Geoff Langb1196682014-07-23 13:47:29 -04003162 context->recordError(gl::Error(GL_INVALID_ENUM));
3163 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003164 }
3165 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3166 break;
3167 case GL_TEXTURE_SWIZZLE_R:
3168 if (context->getClientVersion() < 3)
3169 {
Geoff Langb1196682014-07-23 13:47:29 -04003170 context->recordError(gl::Error(GL_INVALID_ENUM));
3171 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003172 }
3173 *params = texture->getSamplerState().swizzleRed;
3174 break;
3175 case GL_TEXTURE_SWIZZLE_G:
3176 if (context->getClientVersion() < 3)
3177 {
Geoff Langb1196682014-07-23 13:47:29 -04003178 context->recordError(gl::Error(GL_INVALID_ENUM));
3179 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003180 }
3181 *params = texture->getSamplerState().swizzleGreen;
3182 break;
3183 case GL_TEXTURE_SWIZZLE_B:
3184 if (context->getClientVersion() < 3)
3185 {
Geoff Langb1196682014-07-23 13:47:29 -04003186 context->recordError(gl::Error(GL_INVALID_ENUM));
3187 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003188 }
3189 *params = texture->getSamplerState().swizzleBlue;
3190 break;
3191 case GL_TEXTURE_SWIZZLE_A:
3192 if (context->getClientVersion() < 3)
3193 {
Geoff Langb1196682014-07-23 13:47:29 -04003194 context->recordError(gl::Error(GL_INVALID_ENUM));
3195 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003196 }
3197 *params = texture->getSamplerState().swizzleAlpha;
3198 break;
3199 case GL_TEXTURE_BASE_LEVEL:
3200 if (context->getClientVersion() < 3)
3201 {
Geoff Langb1196682014-07-23 13:47:29 -04003202 context->recordError(gl::Error(GL_INVALID_ENUM));
3203 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003204 }
3205 *params = texture->getSamplerState().baseLevel;
3206 break;
3207 case GL_TEXTURE_MAX_LEVEL:
3208 if (context->getClientVersion() < 3)
3209 {
Geoff Langb1196682014-07-23 13:47:29 -04003210 context->recordError(gl::Error(GL_INVALID_ENUM));
3211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003212 }
3213 *params = texture->getSamplerState().maxLevel;
3214 break;
3215 case GL_TEXTURE_MIN_LOD:
3216 if (context->getClientVersion() < 3)
3217 {
Geoff Langb1196682014-07-23 13:47:29 -04003218 context->recordError(gl::Error(GL_INVALID_ENUM));
3219 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003220 }
3221 *params = (GLint)texture->getSamplerState().minLod;
3222 break;
3223 case GL_TEXTURE_MAX_LOD:
3224 if (context->getClientVersion() < 3)
3225 {
Geoff Langb1196682014-07-23 13:47:29 -04003226 context->recordError(gl::Error(GL_INVALID_ENUM));
3227 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003228 }
3229 *params = (GLint)texture->getSamplerState().maxLod;
3230 break;
Geoff Langb1196682014-07-23 13:47:29 -04003231
Geoff Langbfdea662014-07-23 14:16:32 -04003232 default:
Geoff Langb1196682014-07-23 13:47:29 -04003233 context->recordError(gl::Error(GL_INVALID_ENUM));
3234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003235 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003236 }
3237}
3238
Kenneth Russell67ea1902014-10-06 16:44:50 -07003239void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003240{
3241 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3242 program, location, bufSize, params);
3243
Geoff Langbfdea662014-07-23 14:16:32 -04003244 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003245 if (context)
3246 {
Jamie Madill0063c512014-08-25 15:47:53 -04003247 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003248 {
Jamie Madill0063c512014-08-25 15:47:53 -04003249 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003250 }
3251
Jamie Madilla502c742014-08-28 17:19:13 -04003252 gl::Program *programObject = context->getProgram(program);
3253 ASSERT(programObject);
3254 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003255 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003256
Jamie Madill99a1e982014-08-25 15:47:54 -04003257 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003258 }
3259}
3260
Kenneth Russell67ea1902014-10-06 16:44:50 -07003261void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003262{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003263 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003264
Geoff Langbfdea662014-07-23 14:16:32 -04003265 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003266 if (context)
3267 {
Jamie Madill0063c512014-08-25 15:47:53 -04003268 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003269 {
Jamie Madill0063c512014-08-25 15:47:53 -04003270 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003271 }
Geoff Langbfdea662014-07-23 14:16:32 -04003272
Jamie Madilla502c742014-08-28 17:19:13 -04003273 gl::Program *programObject = context->getProgram(program);
3274 ASSERT(programObject);
3275 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003276 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003277
Jamie Madill99a1e982014-08-25 15:47:54 -04003278 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003279 }
3280}
3281
Kenneth Russell67ea1902014-10-06 16:44:50 -07003282void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003283{
Geoff Langbfdea662014-07-23 14:16:32 -04003284 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003285 program, location, bufSize, params);
3286
Geoff Langbfdea662014-07-23 14:16:32 -04003287 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003288 if (context)
3289 {
Jamie Madill0063c512014-08-25 15:47:53 -04003290 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003291 {
Jamie Madill0063c512014-08-25 15:47:53 -04003292 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003293 }
3294
Jamie Madilla502c742014-08-28 17:19:13 -04003295 gl::Program *programObject = context->getProgram(program);
3296 ASSERT(programObject);
3297 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003298 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003299
Jamie Madill99a1e982014-08-25 15:47:54 -04003300 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003301 }
3302}
3303
Kenneth Russell67ea1902014-10-06 16:44:50 -07003304void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003305{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003306 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003307
Geoff Langbfdea662014-07-23 14:16:32 -04003308 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003309 if (context)
3310 {
Jamie Madill0063c512014-08-25 15:47:53 -04003311 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003312 {
Jamie Madill0063c512014-08-25 15:47:53 -04003313 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003314 }
Geoff Langbfdea662014-07-23 14:16:32 -04003315
Jamie Madilla502c742014-08-28 17:19:13 -04003316 gl::Program *programObject = context->getProgram(program);
3317 ASSERT(programObject);
3318 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003319 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003320
Jamie Madill99a1e982014-08-25 15:47:54 -04003321 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003322 }
3323}
3324
Kenneth Russell67ea1902014-10-06 16:44:50 -07003325GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003327 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003328
Geoff Langbfdea662014-07-23 14:16:32 -04003329 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003330 if (context)
3331 {
Geoff Langb1196682014-07-23 13:47:29 -04003332 if (strstr(name, "gl_") == name)
3333 {
3334 return -1;
3335 }
3336
Geoff Langbfdea662014-07-23 14:16:32 -04003337 gl::Program *programObject = context->getProgram(program);
3338
3339 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003340 {
Geoff Langbfdea662014-07-23 14:16:32 -04003341 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342 {
Geoff Langb1196682014-07-23 13:47:29 -04003343 context->recordError(gl::Error(GL_INVALID_OPERATION));
3344 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003345 }
Geoff Langbfdea662014-07-23 14:16:32 -04003346 else
3347 {
Geoff Langb1196682014-07-23 13:47:29 -04003348 context->recordError(gl::Error(GL_INVALID_VALUE));
3349 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003350 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351 }
Geoff Langbfdea662014-07-23 14:16:32 -04003352
3353 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3354 if (!programObject->isLinked() || !programBinary)
3355 {
Geoff Langb1196682014-07-23 13:47:29 -04003356 context->recordError(gl::Error(GL_INVALID_OPERATION));
3357 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003358 }
3359
3360 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003361 }
3362
3363 return -1;
3364}
3365
Kenneth Russell67ea1902014-10-06 16:44:50 -07003366void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003367{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003368 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003369
Geoff Langbfdea662014-07-23 14:16:32 -04003370 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003371 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003372 {
Geoff Langbfdea662014-07-23 14:16:32 -04003373 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003374 {
Geoff Langb1196682014-07-23 13:47:29 -04003375 context->recordError(gl::Error(GL_INVALID_VALUE));
3376 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003377 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003378
Geoff Langbfdea662014-07-23 14:16:32 -04003379 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003380 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003381 {
3382 return;
3383 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003384
Geoff Langbfdea662014-07-23 14:16:32 -04003385 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3386 {
3387 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3388 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003389 {
Geoff Langbfdea662014-07-23 14:16:32 -04003390 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003391 }
3392 }
Geoff Langbfdea662014-07-23 14:16:32 -04003393 else
3394 {
3395 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3396 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003397 }
3398}
3399
Kenneth Russell67ea1902014-10-06 16:44:50 -07003400void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003401{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003402 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003403
Geoff Langbfdea662014-07-23 14:16:32 -04003404 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003405 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003406 {
Geoff Langbfdea662014-07-23 14:16:32 -04003407 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003408 {
Geoff Langb1196682014-07-23 13:47:29 -04003409 context->recordError(gl::Error(GL_INVALID_VALUE));
3410 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003411 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003412
Geoff Langbfdea662014-07-23 14:16:32 -04003413 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003414
Geoff Langb1196682014-07-23 13:47:29 -04003415 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003416 {
3417 return;
3418 }
Jamie Madillaff71502013-07-02 11:57:05 -04003419
Geoff Langbfdea662014-07-23 14:16:32 -04003420 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3421 {
3422 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3423 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003424 {
Geoff Langbfdea662014-07-23 14:16:32 -04003425 float currentValue = currentValueData.FloatValues[i];
3426 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003427 }
3428 }
Geoff Langbfdea662014-07-23 14:16:32 -04003429 else
3430 {
3431 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3432 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003433 }
3434}
3435
Kenneth Russell67ea1902014-10-06 16:44:50 -07003436void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003437{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003438 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003439
Geoff Langbfdea662014-07-23 14:16:32 -04003440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003441 if (context)
3442 {
3443 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003444 {
Geoff Langb1196682014-07-23 13:47:29 -04003445 context->recordError(gl::Error(GL_INVALID_VALUE));
3446 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003447 }
Geoff Langbfdea662014-07-23 14:16:32 -04003448
3449 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3450 {
Geoff Langb1196682014-07-23 13:47:29 -04003451 context->recordError(gl::Error(GL_INVALID_ENUM));
3452 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003453 }
3454
3455 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456 }
3457}
3458
Kenneth Russell67ea1902014-10-06 16:44:50 -07003459void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003460{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003461 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462
Geoff Langbfdea662014-07-23 14:16:32 -04003463 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003464 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003465 {
Geoff Langb1196682014-07-23 13:47:29 -04003466 switch (mode)
3467 {
3468 case GL_FASTEST:
3469 case GL_NICEST:
3470 case GL_DONT_CARE:
3471 break;
3472
3473 default:
3474 context->recordError(gl::Error(GL_INVALID_ENUM));
3475 return;
3476 }
3477
3478 switch (target)
3479 {
3480 case GL_GENERATE_MIPMAP_HINT:
3481 context->getState().setGenerateMipmapHint(mode);
3482 break;
3483
3484 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3485 context->getState().setFragmentShaderDerivativeHint(mode);
3486 break;
3487
3488 default:
3489 context->recordError(gl::Error(GL_INVALID_ENUM));
3490 return;
3491 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003492 }
3493}
3494
Kenneth Russell67ea1902014-10-06 16:44:50 -07003495GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003497 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003498
Geoff Langbfdea662014-07-23 14:16:32 -04003499 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003500 if (context && buffer)
3501 {
3502 gl::Buffer *bufferObject = context->getBuffer(buffer);
3503
3504 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 {
Geoff Langbfdea662014-07-23 14:16:32 -04003506 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003507 }
3508 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003509
3510 return GL_FALSE;
3511}
3512
Kenneth Russell67ea1902014-10-06 16:44:50 -07003513GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003514{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003515 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003516
Geoff Langbfdea662014-07-23 14:16:32 -04003517 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003518 if (context)
3519 {
3520 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 {
Geoff Langb1196682014-07-23 13:47:29 -04003522 context->recordError(gl::Error(GL_INVALID_ENUM));
3523 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003524 }
Geoff Langbfdea662014-07-23 14:16:32 -04003525
3526 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003527 }
3528
3529 return false;
3530}
3531
Kenneth Russell67ea1902014-10-06 16:44:50 -07003532GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003533{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003534 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003535
Geoff Langbfdea662014-07-23 14:16:32 -04003536 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003537 if (context)
3538 {
3539 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3540
3541 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003542 {
Geoff Langbfdea662014-07-23 14:16:32 -04003543 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003544 }
Geoff Langbfdea662014-07-23 14:16:32 -04003545
3546 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003547 }
3548
3549 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003550}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003551
Kenneth Russell67ea1902014-10-06 16:44:50 -07003552GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003553{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003554 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003555
Geoff Langbfdea662014-07-23 14:16:32 -04003556 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003557 if (context && framebuffer)
3558 {
3559 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3560
3561 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003562 {
Geoff Langbfdea662014-07-23 14:16:32 -04003563 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003564 }
3565 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003566
3567 return GL_FALSE;
3568}
3569
Kenneth Russell67ea1902014-10-06 16:44:50 -07003570GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003571{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003572 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003573
Geoff Langbfdea662014-07-23 14:16:32 -04003574 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003575 if (context && program)
3576 {
3577 gl::Program *programObject = context->getProgram(program);
3578
3579 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003580 {
Geoff Langbfdea662014-07-23 14:16:32 -04003581 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003582 }
3583 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003584
3585 return GL_FALSE;
3586}
3587
Kenneth Russell67ea1902014-10-06 16:44:50 -07003588GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003589{
3590 EVENT("(GLuint id = %d)", id);
3591
Geoff Langbfdea662014-07-23 14:16:32 -04003592 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003593 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003594 {
Geoff Langbfdea662014-07-23 14:16:32 -04003595 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003596 }
3597
3598 return GL_FALSE;
3599}
3600
Kenneth Russell67ea1902014-10-06 16:44:50 -07003601GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003602{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003603 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003604
Geoff Langbfdea662014-07-23 14:16:32 -04003605 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003606 if (context && renderbuffer)
3607 {
3608 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3609
3610 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003611 {
Geoff Langbfdea662014-07-23 14:16:32 -04003612 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003613 }
3614 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003615
3616 return GL_FALSE;
3617}
3618
Kenneth Russell67ea1902014-10-06 16:44:50 -07003619GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003620{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003621 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003622
Geoff Langbfdea662014-07-23 14:16:32 -04003623 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003624 if (context && shader)
3625 {
3626 gl::Shader *shaderObject = context->getShader(shader);
3627
3628 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003629 {
Geoff Langbfdea662014-07-23 14:16:32 -04003630 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003631 }
3632 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003633
3634 return GL_FALSE;
3635}
3636
Kenneth Russell67ea1902014-10-06 16:44:50 -07003637GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003638{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003639 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003640
Geoff Langbfdea662014-07-23 14:16:32 -04003641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003642 if (context && texture)
3643 {
3644 gl::Texture *textureObject = context->getTexture(texture);
3645
3646 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003647 {
Geoff Langbfdea662014-07-23 14:16:32 -04003648 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003649 }
3650 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003651
3652 return GL_FALSE;
3653}
3654
Kenneth Russell67ea1902014-10-06 16:44:50 -07003655void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003656{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003657 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003658
Geoff Langbfdea662014-07-23 14:16:32 -04003659 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003660 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661 {
Geoff Langb1196682014-07-23 13:47:29 -04003662 if (width <= 0.0f)
3663 {
3664 context->recordError(gl::Error(GL_INVALID_VALUE));
3665 return;
3666 }
3667
Geoff Langbfdea662014-07-23 14:16:32 -04003668 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003669 }
3670}
3671
Kenneth Russell67ea1902014-10-06 16:44:50 -07003672void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003674 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003675
Geoff Langbfdea662014-07-23 14:16:32 -04003676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003677 if (context)
3678 {
3679 gl::Program *programObject = context->getProgram(program);
3680
3681 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003682 {
Geoff Langbfdea662014-07-23 14:16:32 -04003683 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684 {
Geoff Langb1196682014-07-23 13:47:29 -04003685 context->recordError(gl::Error(GL_INVALID_OPERATION));
3686 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003687 }
Geoff Langbfdea662014-07-23 14:16:32 -04003688 else
3689 {
Geoff Langb1196682014-07-23 13:47:29 -04003690 context->recordError(gl::Error(GL_INVALID_VALUE));
3691 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003692 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003693 }
Geoff Langbfdea662014-07-23 14:16:32 -04003694
Geoff Langb543aff2014-09-30 14:52:54 -04003695 gl::Error error = context->linkProgram(program);
3696 if (error.isError())
3697 {
3698 context->recordError(error);
3699 return;
3700 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003701 }
3702}
3703
Kenneth Russell67ea1902014-10-06 16:44:50 -07003704void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003705{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003706 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707
Geoff Langbfdea662014-07-23 14:16:32 -04003708 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003709 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003710 {
Geoff Langbfdea662014-07-23 14:16:32 -04003711 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003712 {
Geoff Langbfdea662014-07-23 14:16:32 -04003713 case GL_UNPACK_ALIGNMENT:
3714 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003715 {
Geoff Langb1196682014-07-23 13:47:29 -04003716 context->recordError(gl::Error(GL_INVALID_VALUE));
3717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003718 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003719
Geoff Langbfdea662014-07-23 14:16:32 -04003720 context->getState().setUnpackAlignment(param);
3721 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003722
Geoff Langbfdea662014-07-23 14:16:32 -04003723 case GL_PACK_ALIGNMENT:
3724 if (param != 1 && param != 2 && param != 4 && param != 8)
3725 {
Geoff Langb1196682014-07-23 13:47:29 -04003726 context->recordError(gl::Error(GL_INVALID_VALUE));
3727 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003728 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003729
Geoff Langbfdea662014-07-23 14:16:32 -04003730 context->getState().setPackAlignment(param);
3731 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003732
Geoff Langbfdea662014-07-23 14:16:32 -04003733 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3734 context->getState().setPackReverseRowOrder(param != 0);
3735 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003736
Geoff Langbfdea662014-07-23 14:16:32 -04003737 case GL_UNPACK_IMAGE_HEIGHT:
3738 case GL_UNPACK_SKIP_IMAGES:
3739 case GL_UNPACK_ROW_LENGTH:
3740 case GL_UNPACK_SKIP_ROWS:
3741 case GL_UNPACK_SKIP_PIXELS:
3742 case GL_PACK_ROW_LENGTH:
3743 case GL_PACK_SKIP_ROWS:
3744 case GL_PACK_SKIP_PIXELS:
3745 if (context->getClientVersion() < 3)
3746 {
Geoff Langb1196682014-07-23 13:47:29 -04003747 context->recordError(gl::Error(GL_INVALID_ENUM));
3748 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003749 }
Geoff Langbfdea662014-07-23 14:16:32 -04003750 UNIMPLEMENTED();
3751 break;
3752
3753 default:
Geoff Langb1196682014-07-23 13:47:29 -04003754 context->recordError(gl::Error(GL_INVALID_ENUM));
3755 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003756 }
3757 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003758}
3759
Kenneth Russell67ea1902014-10-06 16:44:50 -07003760void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003761{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003762 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003763
Geoff Langbfdea662014-07-23 14:16:32 -04003764 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003765 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003766 {
Geoff Langbfdea662014-07-23 14:16:32 -04003767 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003768 }
3769}
3770
Kenneth Russell67ea1902014-10-06 16:44:50 -07003771void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003772 GLenum format, GLenum type, GLsizei bufSize,
3773 GLvoid *data)
3774{
3775 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3776 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3777 x, y, width, height, format, type, bufSize, data);
3778
Geoff Langbfdea662014-07-23 14:16:32 -04003779 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003780 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003781 {
Geoff Langb1196682014-07-23 13:47:29 -04003782 if (width < 0 || height < 0 || bufSize < 0)
3783 {
3784 context->recordError(gl::Error(GL_INVALID_VALUE));
3785 return;
3786 }
3787
Geoff Langbfdea662014-07-23 14:16:32 -04003788 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3789 format, type, &bufSize, data))
3790 {
3791 return;
3792 }
3793
Geoff Lang63d2fc72014-07-25 14:51:41 -04003794 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3795 if (error.isError())
3796 {
3797 context->recordError(error);
3798 return;
3799 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003800 }
3801}
3802
Kenneth Russell67ea1902014-10-06 16:44:50 -07003803void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003804 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003805{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003806 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003807 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003808 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003809
Geoff Langbfdea662014-07-23 14:16:32 -04003810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003811 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003812 {
Geoff Langb1196682014-07-23 13:47:29 -04003813 if (width < 0 || height < 0)
3814 {
3815 context->recordError(gl::Error(GL_INVALID_VALUE));
3816 return;
3817 }
3818
Geoff Langbfdea662014-07-23 14:16:32 -04003819 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3820 format, type, NULL, pixels))
3821 {
3822 return;
3823 }
3824
Geoff Lang63d2fc72014-07-25 14:51:41 -04003825 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3826 if (error.isError())
3827 {
3828 context->recordError(error);
3829 return;
3830 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003831 }
3832}
3833
Kenneth Russell67ea1902014-10-06 16:44:50 -07003834void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003835{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003836 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003837
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003838 gl::Context *context = gl::getNonLostContext();
3839
3840 if (context)
3841 {
3842 context->releaseShaderCompiler();
3843 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003844}
3845
Kenneth Russell67ea1902014-10-06 16:44:50 -07003846void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003847{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003848 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003849 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850
Geoff Langbfdea662014-07-23 14:16:32 -04003851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003852 if (context)
3853 {
3854 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3855 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003856 {
Geoff Langbfdea662014-07-23 14:16:32 -04003857 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858 }
Geoff Langbfdea662014-07-23 14:16:32 -04003859
Shannon Woodse2632d22014-10-17 13:08:51 -04003860 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
Geoff Langbafefdf2014-10-10 14:26:35 -04003861 gl::Error error = renderbuffer->setStorage(width, height, internalformat, samples);
3862 if (error.isError())
3863 {
3864 context->recordError(error);
3865 return;
3866 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867 }
3868}
3869
Kenneth Russell67ea1902014-10-06 16:44:50 -07003870void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003871{
3872 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3873}
3874
Kenneth Russell67ea1902014-10-06 16:44:50 -07003875void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003876{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003877 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003878
Geoff Langbfdea662014-07-23 14:16:32 -04003879 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003880
Geoff Langbfdea662014-07-23 14:16:32 -04003881 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003882 {
Geoff Langbfdea662014-07-23 14:16:32 -04003883 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003884 }
3885}
3886
Kenneth Russell67ea1902014-10-06 16:44:50 -07003887void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003888{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003889 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003890
Geoff Langbfdea662014-07-23 14:16:32 -04003891 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003892 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003893 {
Geoff Langb1196682014-07-23 13:47:29 -04003894 if (condition != GL_ALL_COMPLETED_NV)
3895 {
3896 context->recordError(gl::Error(GL_INVALID_ENUM));
3897 return;
3898 }
3899
Geoff Langbfdea662014-07-23 14:16:32 -04003900 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3901
3902 if (fenceObject == NULL)
3903 {
Geoff Langb1196682014-07-23 13:47:29 -04003904 context->recordError(gl::Error(GL_INVALID_OPERATION));
3905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003906 }
3907
Geoff Lang882033e2014-09-30 11:26:07 -04003908 gl::Error error = fenceObject->setFence(condition);
3909 if (error.isError())
3910 {
3911 context->recordError(error);
3912 return;
3913 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003914 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003915}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003916
Kenneth Russell67ea1902014-10-06 16:44:50 -07003917void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003918{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003919 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003920
Geoff Langbfdea662014-07-23 14:16:32 -04003921 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003922 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003923 {
Geoff Langb1196682014-07-23 13:47:29 -04003924 if (width < 0 || height < 0)
3925 {
3926 context->recordError(gl::Error(GL_INVALID_VALUE));
3927 return;
3928 }
3929
Geoff Langbfdea662014-07-23 14:16:32 -04003930 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003931 }
3932}
3933
Kenneth Russell67ea1902014-10-06 16:44:50 -07003934void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003935{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003936 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003937 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003938 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003939
Geoff Lang900013c2014-07-07 11:32:19 -04003940 gl::Context* context = gl::getNonLostContext();
3941 if (context)
3942 {
3943 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3944 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3945 {
Geoff Langb1196682014-07-23 13:47:29 -04003946 context->recordError(gl::Error(GL_INVALID_ENUM));
3947 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003948 }
3949
3950 // No binary shader formats are supported.
3951 UNIMPLEMENTED();
3952 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953}
3954
Kenneth Russell67ea1902014-10-06 16:44:50 -07003955void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003957 EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003958 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003959
Geoff Langbfdea662014-07-23 14:16:32 -04003960 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003961 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003962 {
Geoff Langb1196682014-07-23 13:47:29 -04003963 if (count < 0)
3964 {
3965 context->recordError(gl::Error(GL_INVALID_VALUE));
3966 return;
3967 }
3968
Geoff Langbfdea662014-07-23 14:16:32 -04003969 gl::Shader *shaderObject = context->getShader(shader);
3970
3971 if (!shaderObject)
3972 {
3973 if (context->getProgram(shader))
3974 {
Geoff Langb1196682014-07-23 13:47:29 -04003975 context->recordError(gl::Error(GL_INVALID_OPERATION));
3976 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003977 }
3978 else
3979 {
Geoff Langb1196682014-07-23 13:47:29 -04003980 context->recordError(gl::Error(GL_INVALID_VALUE));
3981 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003982 }
3983 }
3984
3985 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003986 }
3987}
3988
Kenneth Russell67ea1902014-10-06 16:44:50 -07003989void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003990{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003991 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003992}
3993
Kenneth Russell67ea1902014-10-06 16:44:50 -07003994void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003995{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003996 EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003997
Geoff Langbfdea662014-07-23 14:16:32 -04003998 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003999 if (context)
4000 {
Geoff Langb1196682014-07-23 13:47:29 -04004001 switch (face)
4002 {
4003 case GL_FRONT:
4004 case GL_BACK:
4005 case GL_FRONT_AND_BACK:
4006 break;
4007
4008 default:
4009 context->recordError(gl::Error(GL_INVALID_ENUM));
4010 return;
4011 }
4012
4013 switch (func)
4014 {
4015 case GL_NEVER:
4016 case GL_ALWAYS:
4017 case GL_LESS:
4018 case GL_LEQUAL:
4019 case GL_EQUAL:
4020 case GL_GEQUAL:
4021 case GL_GREATER:
4022 case GL_NOTEQUAL:
4023 break;
4024
4025 default:
4026 context->recordError(gl::Error(GL_INVALID_ENUM));
4027 return;
4028 }
4029
Geoff Langbfdea662014-07-23 14:16:32 -04004030 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4031 {
4032 context->getState().setStencilParams(func, ref, mask);
4033 }
4034
4035 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4036 {
4037 context->getState().setStencilBackParams(func, ref, mask);
4038 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004039 }
4040}
4041
Kenneth Russell67ea1902014-10-06 16:44:50 -07004042void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004043{
4044 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4045}
4046
Kenneth Russell67ea1902014-10-06 16:44:50 -07004047void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004048{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004049 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004050
Geoff Langbfdea662014-07-23 14:16:32 -04004051 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004052 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004053 {
Geoff Langb1196682014-07-23 13:47:29 -04004054 switch (face)
4055 {
4056 case GL_FRONT:
4057 case GL_BACK:
4058 case GL_FRONT_AND_BACK:
4059 break;
4060
4061 default:
4062 context->recordError(gl::Error(GL_INVALID_ENUM));
4063 return;
4064 }
4065
Geoff Langbfdea662014-07-23 14:16:32 -04004066 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4067 {
4068 context->getState().setStencilWritemask(mask);
4069 }
4070
4071 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4072 {
4073 context->getState().setStencilBackWritemask(mask);
4074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075 }
4076}
4077
Kenneth Russell67ea1902014-10-06 16:44:50 -07004078void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004079{
4080 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4081}
4082
Kenneth Russell67ea1902014-10-06 16:44:50 -07004083void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004084{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004085 EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004086 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004087
Geoff Langbfdea662014-07-23 14:16:32 -04004088 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004089 if (context)
4090 {
Geoff Langb1196682014-07-23 13:47:29 -04004091 switch (face)
4092 {
4093 case GL_FRONT:
4094 case GL_BACK:
4095 case GL_FRONT_AND_BACK:
4096 break;
4097
4098 default:
4099 context->recordError(gl::Error(GL_INVALID_ENUM));
4100 return;
4101 }
4102
4103 switch (fail)
4104 {
4105 case GL_ZERO:
4106 case GL_KEEP:
4107 case GL_REPLACE:
4108 case GL_INCR:
4109 case GL_DECR:
4110 case GL_INVERT:
4111 case GL_INCR_WRAP:
4112 case GL_DECR_WRAP:
4113 break;
4114
4115 default:
4116 context->recordError(gl::Error(GL_INVALID_ENUM));
4117 return;
4118 }
4119
4120 switch (zfail)
4121 {
4122 case GL_ZERO:
4123 case GL_KEEP:
4124 case GL_REPLACE:
4125 case GL_INCR:
4126 case GL_DECR:
4127 case GL_INVERT:
4128 case GL_INCR_WRAP:
4129 case GL_DECR_WRAP:
4130 break;
4131
4132 default:
4133 context->recordError(gl::Error(GL_INVALID_ENUM));
4134 return;
4135 }
4136
4137 switch (zpass)
4138 {
4139 case GL_ZERO:
4140 case GL_KEEP:
4141 case GL_REPLACE:
4142 case GL_INCR:
4143 case GL_DECR:
4144 case GL_INVERT:
4145 case GL_INCR_WRAP:
4146 case GL_DECR_WRAP:
4147 break;
4148
4149 default:
4150 context->recordError(gl::Error(GL_INVALID_ENUM));
4151 return;
4152 }
4153
Geoff Langbfdea662014-07-23 14:16:32 -04004154 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4155 {
4156 context->getState().setStencilOperations(fail, zfail, zpass);
4157 }
4158
4159 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4160 {
4161 context->getState().setStencilBackOperations(fail, zfail, zpass);
4162 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004163 }
4164}
4165
Kenneth Russell67ea1902014-10-06 16:44:50 -07004166GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004167{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004168 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004169
Geoff Langbfdea662014-07-23 14:16:32 -04004170 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004171 if (context)
4172 {
4173 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4174
4175 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004176 {
Geoff Langb1196682014-07-23 13:47:29 -04004177 context->recordError(gl::Error(GL_INVALID_OPERATION));
4178 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004179 }
Geoff Langbfdea662014-07-23 14:16:32 -04004180
4181 if (fenceObject->isFence() != GL_TRUE)
4182 {
Geoff Langb1196682014-07-23 13:47:29 -04004183 context->recordError(gl::Error(GL_INVALID_OPERATION));
4184 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004185 }
4186
Geoff Lang882033e2014-09-30 11:26:07 -04004187 GLboolean result;
4188 gl::Error error = fenceObject->testFence(&result);
4189 if (error.isError())
4190 {
4191 context->recordError(error);
4192 return GL_TRUE;
4193 }
4194
4195 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004196 }
Geoff Langbfdea662014-07-23 14:16:32 -04004197
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004198 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004199}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004200
Kenneth Russell67ea1902014-10-06 16:44:50 -07004201void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004202 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004203{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004204 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004205 "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004206 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004207
Geoff Langbfdea662014-07-23 14:16:32 -04004208 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004209 if (context)
4210 {
4211 if (context->getClientVersion() < 3 &&
4212 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4213 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004214 {
Geoff Langbfdea662014-07-23 14:16:32 -04004215 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004216 }
Geoff Langbfdea662014-07-23 14:16:32 -04004217
4218 if (context->getClientVersion() >= 3 &&
4219 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4220 0, 0, 0, width, height, 1, border, format, type, pixels))
4221 {
4222 return;
4223 }
4224
4225 switch (target)
4226 {
4227 case GL_TEXTURE_2D:
4228 {
4229 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004230 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4231 if (error.isError())
4232 {
4233 context->recordError(error);
4234 return;
4235 }
Geoff Langbfdea662014-07-23 14:16:32 -04004236 }
4237 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004238
Geoff Langbfdea662014-07-23 14:16:32 -04004239 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004240 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004241 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004242 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004243 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004244 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4245 {
4246 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004247 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004248 if (error.isError())
4249 {
4250 context->recordError(error);
4251 return;
4252 }
Geoff Langbfdea662014-07-23 14:16:32 -04004253 }
4254 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004255
Geoff Langbfdea662014-07-23 14:16:32 -04004256 default: UNREACHABLE();
4257 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004258 }
4259}
4260
Kenneth Russell67ea1902014-10-06 16:44:50 -07004261void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004262{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004263 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4264
Geoff Langbfdea662014-07-23 14:16:32 -04004265 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004266 if (context)
4267 {
4268 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004269 {
Geoff Langbfdea662014-07-23 14:16:32 -04004270 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004271 }
Geoff Langbfdea662014-07-23 14:16:32 -04004272
4273 gl::Texture *texture = context->getTargetTexture(target);
4274
4275 if (!texture)
4276 {
Geoff Langb1196682014-07-23 13:47:29 -04004277 context->recordError(gl::Error(GL_INVALID_ENUM));
4278 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004279 }
4280
4281 switch (pname)
4282 {
4283 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4284 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4285 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4286 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4287 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4288 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4289 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4290 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4291 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4292 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4293 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4294 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4295 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4296 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4297 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4298 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4299 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4300 default: UNREACHABLE(); break;
4301 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004302 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004303}
4304
Kenneth Russell67ea1902014-10-06 16:44:50 -07004305void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004306{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004307 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004308}
4309
Kenneth Russell67ea1902014-10-06 16:44:50 -07004310void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004311{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004312 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004313
Geoff Langbfdea662014-07-23 14:16:32 -04004314 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004315 if (context)
4316 {
4317 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004318 {
Geoff Langbfdea662014-07-23 14:16:32 -04004319 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004320 }
Geoff Langbfdea662014-07-23 14:16:32 -04004321
4322 gl::Texture *texture = context->getTargetTexture(target);
4323
4324 if (!texture)
4325 {
Geoff Langb1196682014-07-23 13:47:29 -04004326 context->recordError(gl::Error(GL_INVALID_ENUM));
4327 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004328 }
4329
4330 switch (pname)
4331 {
4332 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4333 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4334 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4335 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4336 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4337 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4338 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4339 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4340 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4341 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4342 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4343 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4344 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4345 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4346 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4347 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4348 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4349 default: UNREACHABLE(); break;
4350 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004351 }
4352}
4353
Kenneth Russell67ea1902014-10-06 16:44:50 -07004354void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004355{
4356 glTexParameteri(target, pname, *params);
4357}
4358
Kenneth Russell67ea1902014-10-06 16:44:50 -07004359void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004360{
4361 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4362 target, levels, internalformat, width, height);
4363
Geoff Langbfdea662014-07-23 14:16:32 -04004364 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004365 if (context)
4366 {
4367 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004368 {
Geoff Langb1196682014-07-23 13:47:29 -04004369 context->recordError(gl::Error(GL_INVALID_OPERATION));
4370 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004371 }
Geoff Langbfdea662014-07-23 14:16:32 -04004372
4373 if (context->getClientVersion() < 3 &&
4374 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4375 {
4376 return;
4377 }
4378
4379 if (context->getClientVersion() >= 3 &&
4380 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4381 {
4382 return;
4383 }
4384
4385 switch (target)
4386 {
4387 case GL_TEXTURE_2D:
4388 {
4389 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004390 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4391 if (error.isError())
4392 {
4393 context->recordError(error);
4394 return;
4395 }
Geoff Langbfdea662014-07-23 14:16:32 -04004396 }
4397 break;
4398
4399 case GL_TEXTURE_CUBE_MAP:
4400 {
4401 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004402 gl::Error error = textureCube->storage(levels, internalformat, width);
4403 if (error.isError())
4404 {
4405 context->recordError(error);
4406 return;
4407 }
Geoff Langbfdea662014-07-23 14:16:32 -04004408 }
4409 break;
4410
4411 default:
Geoff Langb1196682014-07-23 13:47:29 -04004412 context->recordError(gl::Error(GL_INVALID_ENUM));
4413 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004414 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004415 }
4416}
4417
Kenneth Russell67ea1902014-10-06 16:44:50 -07004418void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004419 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004420{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004421 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004422 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004423 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004424 target, level, xoffset, yoffset, width, height, format, type, pixels);
4425
Geoff Langbfdea662014-07-23 14:16:32 -04004426 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004427 if (context)
4428 {
4429 if (context->getClientVersion() < 3 &&
4430 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4431 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004432 {
Geoff Langbfdea662014-07-23 14:16:32 -04004433 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004434 }
Geoff Langbfdea662014-07-23 14:16:32 -04004435
4436 if (context->getClientVersion() >= 3 &&
4437 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4438 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4439 {
4440 return;
4441 }
4442
4443 // Zero sized uploads are valid but no-ops
4444 if (width == 0 || height == 0)
4445 {
4446 return;
4447 }
4448
4449 switch (target)
4450 {
4451 case GL_TEXTURE_2D:
4452 {
4453 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004454 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4455 if (error.isError())
4456 {
4457 context->recordError(error);
4458 return;
4459 }
Geoff Langbfdea662014-07-23 14:16:32 -04004460 }
4461 break;
4462
4463 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4464 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4465 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4466 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4467 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4468 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4469 {
4470 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004471 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4472 if (error.isError())
4473 {
4474 context->recordError(error);
4475 return;
4476 }
Geoff Langbfdea662014-07-23 14:16:32 -04004477 }
4478 break;
4479
4480 default:
4481 UNREACHABLE();
4482 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004483 }
4484}
4485
Kenneth Russell67ea1902014-10-06 16:44:50 -07004486void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004487{
4488 glUniform1fv(location, 1, &x);
4489}
4490
Kenneth Russell67ea1902014-10-06 16:44:50 -07004491void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004493 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004494
Geoff Langbfdea662014-07-23 14:16:32 -04004495 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004496 if (context)
4497 {
4498 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004499 {
Geoff Langbfdea662014-07-23 14:16:32 -04004500 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501 }
Geoff Langbfdea662014-07-23 14:16:32 -04004502
4503 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4504 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505 }
4506}
4507
Kenneth Russell67ea1902014-10-06 16:44:50 -07004508void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004509{
4510 glUniform1iv(location, 1, &x);
4511}
4512
Kenneth Russell67ea1902014-10-06 16:44:50 -07004513void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004514{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004515 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004516
Geoff Langbfdea662014-07-23 14:16:32 -04004517 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004518 if (context)
4519 {
4520 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521 {
Geoff Langbfdea662014-07-23 14:16:32 -04004522 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523 }
Geoff Langbfdea662014-07-23 14:16:32 -04004524
4525 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4526 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004527 }
4528}
4529
Kenneth Russell67ea1902014-10-06 16:44:50 -07004530void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004531{
4532 GLfloat xy[2] = {x, y};
4533
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004534 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004535}
4536
Kenneth Russell67ea1902014-10-06 16:44:50 -07004537void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004538{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004539 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004540
Geoff Langbfdea662014-07-23 14:16:32 -04004541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004542 if (context)
4543 {
4544 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545 {
Geoff Langbfdea662014-07-23 14:16:32 -04004546 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004547 }
Geoff Langbfdea662014-07-23 14:16:32 -04004548
4549 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4550 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004551 }
4552}
4553
Kenneth Russell67ea1902014-10-06 16:44:50 -07004554void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004555{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004556 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004557
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004558 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559}
4560
Kenneth Russell67ea1902014-10-06 16:44:50 -07004561void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004562{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004563 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004564
Geoff Langbfdea662014-07-23 14:16:32 -04004565 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004566 if (context)
4567 {
4568 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004569 {
Geoff Langbfdea662014-07-23 14:16:32 -04004570 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004571 }
Geoff Langbfdea662014-07-23 14:16:32 -04004572
4573 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4574 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004575 }
4576}
4577
Kenneth Russell67ea1902014-10-06 16:44:50 -07004578void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004579{
4580 GLfloat xyz[3] = {x, y, z};
4581
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004582 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004583}
4584
Kenneth Russell67ea1902014-10-06 16:44:50 -07004585void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004586{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004587 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004588
Geoff Langbfdea662014-07-23 14:16:32 -04004589 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004590 if (context)
4591 {
4592 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593 {
Geoff Langbfdea662014-07-23 14:16:32 -04004594 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004595 }
Geoff Langbfdea662014-07-23 14:16:32 -04004596
4597 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4598 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004599 }
4600}
4601
Kenneth Russell67ea1902014-10-06 16:44:50 -07004602void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004603{
4604 GLint xyz[3] = {x, y, z};
4605
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004606 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004607}
4608
Kenneth Russell67ea1902014-10-06 16:44:50 -07004609void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004611 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004612
Geoff Langbfdea662014-07-23 14:16:32 -04004613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004614 if (context)
4615 {
4616 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004617 {
Geoff Langbfdea662014-07-23 14:16:32 -04004618 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004619 }
Geoff Langbfdea662014-07-23 14:16:32 -04004620
4621 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4622 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004623 }
4624}
4625
Kenneth Russell67ea1902014-10-06 16:44:50 -07004626void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004627{
4628 GLfloat xyzw[4] = {x, y, z, w};
4629
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004630 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004631}
4632
Kenneth Russell67ea1902014-10-06 16:44:50 -07004633void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004634{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004635 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004636
Geoff Langbfdea662014-07-23 14:16:32 -04004637 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004638 if (context)
4639 {
4640 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641 {
Geoff Langbfdea662014-07-23 14:16:32 -04004642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004643 }
Geoff Langbfdea662014-07-23 14:16:32 -04004644
4645 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4646 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004647 }
4648}
4649
Kenneth Russell67ea1902014-10-06 16:44:50 -07004650void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004651{
4652 GLint xyzw[4] = {x, y, z, w};
4653
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004654 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655}
4656
Kenneth Russell67ea1902014-10-06 16:44:50 -07004657void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004658{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004659 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004660
Geoff Langbfdea662014-07-23 14:16:32 -04004661 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004662 if (context)
4663 {
4664 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004665 {
Geoff Langbfdea662014-07-23 14:16:32 -04004666 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004667 }
Geoff Langbfdea662014-07-23 14:16:32 -04004668
4669 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4670 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004671 }
4672}
4673
Kenneth Russell67ea1902014-10-06 16:44:50 -07004674void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004675{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004676 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004677 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004678
Geoff Langbfdea662014-07-23 14:16:32 -04004679 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004680 if (context)
4681 {
4682 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004683 {
Geoff Langbfdea662014-07-23 14:16:32 -04004684 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004685 }
Geoff Langbfdea662014-07-23 14:16:32 -04004686
4687 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4688 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004689 }
4690}
4691
Kenneth Russell67ea1902014-10-06 16:44:50 -07004692void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004693{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004694 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004695 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004696
Geoff Langbfdea662014-07-23 14:16:32 -04004697 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004698 if (context)
4699 {
4700 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701 {
Geoff Langbfdea662014-07-23 14:16:32 -04004702 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703 }
Geoff Langbfdea662014-07-23 14:16:32 -04004704
4705 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4706 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004707 }
4708}
4709
Kenneth Russell67ea1902014-10-06 16:44:50 -07004710void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004712 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004713 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004714
Geoff Langbfdea662014-07-23 14:16:32 -04004715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004716 if (context)
4717 {
4718 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719 {
Geoff Langbfdea662014-07-23 14:16:32 -04004720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721 }
Geoff Langbfdea662014-07-23 14:16:32 -04004722
4723 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4724 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004725 }
4726}
4727
Kenneth Russell67ea1902014-10-06 16:44:50 -07004728void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004729{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004730 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004731
Geoff Langbfdea662014-07-23 14:16:32 -04004732 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004733 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004734 {
Geoff Langbfdea662014-07-23 14:16:32 -04004735 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004736
Geoff Langbfdea662014-07-23 14:16:32 -04004737 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004738 {
Geoff Langbfdea662014-07-23 14:16:32 -04004739 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004740 {
Geoff Langb1196682014-07-23 13:47:29 -04004741 context->recordError(gl::Error(GL_INVALID_OPERATION));
4742 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004743 }
Geoff Langbfdea662014-07-23 14:16:32 -04004744 else
4745 {
Geoff Langb1196682014-07-23 13:47:29 -04004746 context->recordError(gl::Error(GL_INVALID_VALUE));
4747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004748 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004749 }
Geoff Langbfdea662014-07-23 14:16:32 -04004750
4751 if (program != 0 && !programObject->isLinked())
4752 {
Geoff Langb1196682014-07-23 13:47:29 -04004753 context->recordError(gl::Error(GL_INVALID_OPERATION));
4754 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004755 }
4756
4757 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004758 }
4759}
4760
Kenneth Russell67ea1902014-10-06 16:44:50 -07004761void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004762{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004763 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004764
Geoff Langbfdea662014-07-23 14:16:32 -04004765 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004766 if (context)
4767 {
4768 gl::Program *programObject = context->getProgram(program);
4769
4770 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004771 {
Geoff Langbfdea662014-07-23 14:16:32 -04004772 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004773 {
Geoff Langb1196682014-07-23 13:47:29 -04004774 context->recordError(gl::Error(GL_INVALID_OPERATION));
4775 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004776 }
Geoff Langbfdea662014-07-23 14:16:32 -04004777 else
4778 {
Geoff Langb1196682014-07-23 13:47:29 -04004779 context->recordError(gl::Error(GL_INVALID_VALUE));
4780 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004781 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004782 }
Geoff Langbfdea662014-07-23 14:16:32 -04004783
Brandon Jones43a53e22014-08-28 16:23:22 -07004784 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785 }
4786}
4787
Kenneth Russell67ea1902014-10-06 16:44:50 -07004788void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004789{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004790 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004791
Geoff Langbfdea662014-07-23 14:16:32 -04004792 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004793 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794 {
Geoff Langb1196682014-07-23 13:47:29 -04004795 if (index >= gl::MAX_VERTEX_ATTRIBS)
4796 {
4797 context->recordError(gl::Error(GL_INVALID_VALUE));
4798 return;
4799 }
4800
Geoff Langbfdea662014-07-23 14:16:32 -04004801 GLfloat vals[4] = { x, 0, 0, 1 };
4802 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803 }
4804}
4805
Kenneth Russell67ea1902014-10-06 16:44:50 -07004806void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004807{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004808 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809
Geoff Langbfdea662014-07-23 14:16:32 -04004810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004811 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004812 {
Geoff Langb1196682014-07-23 13:47:29 -04004813 if (index >= gl::MAX_VERTEX_ATTRIBS)
4814 {
4815 context->recordError(gl::Error(GL_INVALID_VALUE));
4816 return;
4817 }
4818
Geoff Langbfdea662014-07-23 14:16:32 -04004819 GLfloat vals[4] = { values[0], 0, 0, 1 };
4820 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821 }
4822}
4823
Kenneth Russell67ea1902014-10-06 16:44:50 -07004824void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004825{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004826 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004827
Geoff Langbfdea662014-07-23 14:16:32 -04004828 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004829 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830 {
Geoff Langb1196682014-07-23 13:47:29 -04004831 if (index >= gl::MAX_VERTEX_ATTRIBS)
4832 {
4833 context->recordError(gl::Error(GL_INVALID_VALUE));
4834 return;
4835 }
4836
Geoff Langbfdea662014-07-23 14:16:32 -04004837 GLfloat vals[4] = { x, y, 0, 1 };
4838 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004839 }
4840}
4841
Kenneth Russell67ea1902014-10-06 16:44:50 -07004842void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004843{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004844 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004845
Geoff Langbfdea662014-07-23 14:16:32 -04004846 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004847 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004848 {
Geoff Langb1196682014-07-23 13:47:29 -04004849 if (index >= gl::MAX_VERTEX_ATTRIBS)
4850 {
4851 context->recordError(gl::Error(GL_INVALID_VALUE));
4852 return;
4853 }
4854
Geoff Langbfdea662014-07-23 14:16:32 -04004855 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4856 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857 }
4858}
4859
Kenneth Russell67ea1902014-10-06 16:44:50 -07004860void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004862 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004863
Geoff Langbfdea662014-07-23 14:16:32 -04004864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004865 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004866 {
Geoff Langb1196682014-07-23 13:47:29 -04004867 if (index >= gl::MAX_VERTEX_ATTRIBS)
4868 {
4869 context->recordError(gl::Error(GL_INVALID_VALUE));
4870 return;
4871 }
4872
Geoff Langbfdea662014-07-23 14:16:32 -04004873 GLfloat vals[4] = { x, y, z, 1 };
4874 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875 }
4876}
4877
Kenneth Russell67ea1902014-10-06 16:44:50 -07004878void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004880 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004881
Geoff Langbfdea662014-07-23 14:16:32 -04004882 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004883 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884 {
Geoff Langb1196682014-07-23 13:47:29 -04004885 if (index >= gl::MAX_VERTEX_ATTRIBS)
4886 {
4887 context->recordError(gl::Error(GL_INVALID_VALUE));
4888 return;
4889 }
4890
Geoff Langbfdea662014-07-23 14:16:32 -04004891 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4892 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 }
4894}
4895
Kenneth Russell67ea1902014-10-06 16:44:50 -07004896void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004898 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004899
Geoff Langbfdea662014-07-23 14:16:32 -04004900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004901 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004902 {
Geoff Langb1196682014-07-23 13:47:29 -04004903 if (index >= gl::MAX_VERTEX_ATTRIBS)
4904 {
4905 context->recordError(gl::Error(GL_INVALID_VALUE));
4906 return;
4907 }
4908
Geoff Langbfdea662014-07-23 14:16:32 -04004909 GLfloat vals[4] = { x, y, z, w };
4910 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004911 }
4912}
4913
Kenneth Russell67ea1902014-10-06 16:44:50 -07004914void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004916 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004917
Geoff Langbfdea662014-07-23 14:16:32 -04004918 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004919 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004920 {
Geoff Langb1196682014-07-23 13:47:29 -04004921 if (index >= gl::MAX_VERTEX_ATTRIBS)
4922 {
4923 context->recordError(gl::Error(GL_INVALID_VALUE));
4924 return;
4925 }
4926
Geoff Langbfdea662014-07-23 14:16:32 -04004927 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004928 }
4929}
4930
Kenneth Russell67ea1902014-10-06 16:44:50 -07004931void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004932{
4933 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4934
Geoff Langbfdea662014-07-23 14:16:32 -04004935 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004936 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004937 {
Geoff Langb1196682014-07-23 13:47:29 -04004938 if (index >= gl::MAX_VERTEX_ATTRIBS)
4939 {
4940 context->recordError(gl::Error(GL_INVALID_VALUE));
4941 return;
4942 }
4943
Geoff Langbfdea662014-07-23 14:16:32 -04004944 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004945 }
4946}
4947
Kenneth Russell67ea1902014-10-06 16:44:50 -07004948void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004949{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004950 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004951 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004952 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004953
Geoff Langbfdea662014-07-23 14:16:32 -04004954 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004955 if (context)
4956 {
Geoff Langb1196682014-07-23 13:47:29 -04004957 if (index >= gl::MAX_VERTEX_ATTRIBS)
4958 {
4959 context->recordError(gl::Error(GL_INVALID_VALUE));
4960 return;
4961 }
4962
4963 if (size < 1 || size > 4)
4964 {
4965 context->recordError(gl::Error(GL_INVALID_VALUE));
4966 return;
4967 }
4968
4969 switch (type)
4970 {
4971 case GL_BYTE:
4972 case GL_UNSIGNED_BYTE:
4973 case GL_SHORT:
4974 case GL_UNSIGNED_SHORT:
4975 case GL_FIXED:
4976 case GL_FLOAT:
4977 break;
4978
4979 case GL_HALF_FLOAT:
4980 case GL_INT:
4981 case GL_UNSIGNED_INT:
4982 case GL_INT_2_10_10_10_REV:
4983 case GL_UNSIGNED_INT_2_10_10_10_REV:
4984 if (context->getClientVersion() < 3)
4985 {
4986 context->recordError(gl::Error(GL_INVALID_ENUM));
4987 return;
4988 }
4989 break;
4990
4991 default:
4992 context->recordError(gl::Error(GL_INVALID_ENUM));
4993 return;
4994 }
4995
4996 if (stride < 0)
4997 {
4998 context->recordError(gl::Error(GL_INVALID_VALUE));
4999 return;
5000 }
5001
5002 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5003 {
5004 context->recordError(gl::Error(GL_INVALID_OPERATION));
5005 return;
5006 }
5007
Geoff Langbfdea662014-07-23 14:16:32 -04005008 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5009 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5010 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5011 // and the pointer argument is not NULL.
5012 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005013 {
Geoff Langb1196682014-07-23 13:47:29 -04005014 context->recordError(gl::Error(GL_INVALID_OPERATION));
5015 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005016 }
5017
Geoff Langbfdea662014-07-23 14:16:32 -04005018 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5019 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005020 }
5021}
5022
Kenneth Russell67ea1902014-10-06 16:44:50 -07005023void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005024{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005025 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005026
Geoff Langbfdea662014-07-23 14:16:32 -04005027 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005028 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005029 {
Geoff Langb1196682014-07-23 13:47:29 -04005030 if (width < 0 || height < 0)
5031 {
5032 context->recordError(gl::Error(GL_INVALID_VALUE));
5033 return;
5034 }
5035
Geoff Langbfdea662014-07-23 14:16:32 -04005036 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005037 }
5038}
5039
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005040// OpenGL ES 3.0 functions
5041
Kenneth Russell67ea1902014-10-06 16:44:50 -07005042void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005043{
5044 EVENT("(GLenum mode = 0x%X)", mode);
5045
Geoff Langbfdea662014-07-23 14:16:32 -04005046 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005047 if (context)
5048 {
5049 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005050 {
Geoff Langb1196682014-07-23 13:47:29 -04005051 context->recordError(gl::Error(GL_INVALID_OPERATION));
5052 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005053 }
Geoff Langbfdea662014-07-23 14:16:32 -04005054
5055 // glReadBuffer
5056 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005057 }
5058}
5059
Kenneth Russell67ea1902014-10-06 16:44:50 -07005060void GL_APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005061{
5062 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5063 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5064
Geoff Langbfdea662014-07-23 14:16:32 -04005065 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005066 if (context)
5067 {
5068 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005069 {
Geoff Langb1196682014-07-23 13:47:29 -04005070 context->recordError(gl::Error(GL_INVALID_OPERATION));
5071 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005072 }
Geoff Langbfdea662014-07-23 14:16:32 -04005073
5074 // glDrawRangeElements
5075 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005076 }
5077}
5078
Kenneth Russell67ea1902014-10-06 16:44:50 -07005079void GL_APIENTRY glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005080{
5081 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5082 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5083 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5084 target, level, internalformat, width, height, depth, border, format, type, pixels);
5085
Geoff Langbfdea662014-07-23 14:16:32 -04005086 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005087 if (context)
5088 {
5089 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005090 {
Geoff Langb1196682014-07-23 13:47:29 -04005091 context->recordError(gl::Error(GL_INVALID_OPERATION));
5092 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005093 }
Geoff Langbfdea662014-07-23 14:16:32 -04005094
5095 // validateES3TexImageFormat sets the error code if there is an error
5096 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5097 0, 0, 0, width, height, depth, border, format, type, pixels))
5098 {
5099 return;
5100 }
5101
5102 switch(target)
5103 {
5104 case GL_TEXTURE_3D:
5105 {
5106 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005107 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5108 if (error.isError())
5109 {
5110 context->recordError(error);
5111 return;
5112 }
Geoff Langbfdea662014-07-23 14:16:32 -04005113 }
5114 break;
5115
5116 case GL_TEXTURE_2D_ARRAY:
5117 {
5118 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005119 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5120 if (error.isError())
5121 {
5122 context->recordError(error);
5123 return;
5124 }
Geoff Langbfdea662014-07-23 14:16:32 -04005125 }
5126 break;
5127
5128 default:
Geoff Langb1196682014-07-23 13:47:29 -04005129 context->recordError(gl::Error(GL_INVALID_ENUM));
5130 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005131 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005132 }
5133}
5134
Kenneth Russell67ea1902014-10-06 16:44:50 -07005135void GL_APIENTRY glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005136{
5137 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5138 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5139 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5140 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5141
Geoff Langbfdea662014-07-23 14:16:32 -04005142 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005143 if (context)
5144 {
5145 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005146 {
Geoff Langb1196682014-07-23 13:47:29 -04005147 context->recordError(gl::Error(GL_INVALID_OPERATION));
5148 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005149 }
Geoff Langbfdea662014-07-23 14:16:32 -04005150
5151 // validateES3TexImageFormat sets the error code if there is an error
5152 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5153 xoffset, yoffset, zoffset, width, height, depth, 0,
5154 format, type, pixels))
5155 {
5156 return;
5157 }
5158
5159 // Zero sized uploads are valid but no-ops
5160 if (width == 0 || height == 0 || depth == 0)
5161 {
5162 return;
5163 }
5164
5165 switch(target)
5166 {
5167 case GL_TEXTURE_3D:
5168 {
5169 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005170 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5171 if (error.isError())
5172 {
5173 context->recordError(error);
5174 return;
5175 }
Geoff Langbfdea662014-07-23 14:16:32 -04005176 }
5177 break;
5178
5179 case GL_TEXTURE_2D_ARRAY:
5180 {
5181 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005182 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5183 if (error.isError())
5184 {
5185 context->recordError(error);
5186 return;
5187 }
Geoff Langbfdea662014-07-23 14:16:32 -04005188 }
5189 break;
5190
5191 default:
Geoff Langb1196682014-07-23 13:47:29 -04005192 context->recordError(gl::Error(GL_INVALID_ENUM));
5193 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005194 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005195 }
5196}
5197
Kenneth Russell67ea1902014-10-06 16:44:50 -07005198void GL_APIENTRY glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005199{
5200 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5201 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5202 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5203
Geoff Langbfdea662014-07-23 14:16:32 -04005204 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005205 if (context)
5206 {
5207 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005208 {
Geoff Langb1196682014-07-23 13:47:29 -04005209 context->recordError(gl::Error(GL_INVALID_OPERATION));
5210 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005211 }
Geoff Langbfdea662014-07-23 14:16:32 -04005212
5213 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5214 x, y, width, height, 0))
5215 {
5216 return;
5217 }
5218
5219 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5220 gl::Texture *texture = NULL;
5221 switch (target)
5222 {
5223 case GL_TEXTURE_3D:
5224 texture = context->getTexture3D();
5225 break;
5226
5227 case GL_TEXTURE_2D_ARRAY:
5228 texture = context->getTexture2DArray();
5229 break;
5230
5231 default:
Geoff Langb1196682014-07-23 13:47:29 -04005232 context->recordError(gl::Error(GL_INVALID_ENUM));
5233 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005234 }
5235
Geoff Langef7b0162014-09-04 13:29:23 -04005236 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5237 if (error.isError())
5238 {
5239 context->recordError(error);
5240 return;
5241 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005242 }
5243}
5244
Kenneth Russell67ea1902014-10-06 16:44:50 -07005245void GL_APIENTRY glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005246{
Geoff Langeef52cc2013-10-16 15:07:39 -04005247 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005248 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5249 "const GLvoid* data = 0x%0.8p)",
5250 target, level, internalformat, width, height, depth, border, imageSize, data);
5251
Geoff Langbfdea662014-07-23 14:16:32 -04005252 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005253 if (context)
5254 {
5255 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005256 {
Geoff Langb1196682014-07-23 13:47:29 -04005257 context->recordError(gl::Error(GL_INVALID_OPERATION));
5258 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005259 }
Geoff Langbfdea662014-07-23 14:16:32 -04005260
Geoff Lang5d601382014-07-22 15:14:06 -04005261 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5262 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005263 {
Geoff Langb1196682014-07-23 13:47:29 -04005264 context->recordError(gl::Error(GL_INVALID_VALUE));
5265 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005266 }
5267
5268 // validateES3TexImageFormat sets the error code if there is an error
5269 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5270 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5271 {
5272 return;
5273 }
5274
5275 switch(target)
5276 {
5277 case GL_TEXTURE_3D:
5278 {
5279 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005280 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005281 if (error.isError())
5282 {
5283 context->recordError(error);
5284 return;
5285 }
Geoff Langbfdea662014-07-23 14:16:32 -04005286 }
5287 break;
5288
5289 case GL_TEXTURE_2D_ARRAY:
5290 {
5291 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005292 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005293 if (error.isError())
5294 {
5295 context->recordError(error);
5296 return;
5297 }
Geoff Langbfdea662014-07-23 14:16:32 -04005298 }
5299 break;
5300
5301 default:
Geoff Langb1196682014-07-23 13:47:29 -04005302 context->recordError(gl::Error(GL_INVALID_ENUM));
5303 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005304 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005305 }
5306}
5307
Kenneth Russell67ea1902014-10-06 16:44:50 -07005308void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005309{
5310 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5311 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5312 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5313 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5314
Geoff Langbfdea662014-07-23 14:16:32 -04005315 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005316 if (context)
5317 {
5318 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005319 {
Geoff Langb1196682014-07-23 13:47:29 -04005320 context->recordError(gl::Error(GL_INVALID_OPERATION));
5321 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005322 }
Geoff Langbfdea662014-07-23 14:16:32 -04005323
Geoff Lang5d601382014-07-22 15:14:06 -04005324 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5325 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005326 {
Geoff Langb1196682014-07-23 13:47:29 -04005327 context->recordError(gl::Error(GL_INVALID_VALUE));
5328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005329 }
5330
5331 if (!data)
5332 {
Geoff Langb1196682014-07-23 13:47:29 -04005333 context->recordError(gl::Error(GL_INVALID_VALUE));
5334 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005335 }
5336
5337 // validateES3TexImageFormat sets the error code if there is an error
5338 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5339 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5340 {
5341 return;
5342 }
5343
5344 // Zero sized uploads are valid but no-ops
5345 if (width == 0 || height == 0)
5346 {
5347 return;
5348 }
5349
5350 switch(target)
5351 {
5352 case GL_TEXTURE_3D:
5353 {
5354 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005355 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005356 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005357 if (error.isError())
5358 {
5359 context->recordError(error);
5360 return;
5361 }
Geoff Langbfdea662014-07-23 14:16:32 -04005362 }
5363 break;
5364
5365 case GL_TEXTURE_2D_ARRAY:
5366 {
5367 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005368 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005369 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005370 if (error.isError())
5371 {
5372 context->recordError(error);
5373 return;
5374 }
Geoff Langbfdea662014-07-23 14:16:32 -04005375 }
5376 break;
5377
Geoff Langb1196682014-07-23 13:47:29 -04005378 default:
5379 context->recordError(gl::Error(GL_INVALID_ENUM));
5380 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005381 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005382 }
5383}
5384
Kenneth Russell67ea1902014-10-06 16:44:50 -07005385void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005386{
5387 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5388
Geoff Langbfdea662014-07-23 14:16:32 -04005389 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005390 if (context)
5391 {
5392 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005393 {
Geoff Langb1196682014-07-23 13:47:29 -04005394 context->recordError(gl::Error(GL_INVALID_OPERATION));
5395 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005396 }
Geoff Langbfdea662014-07-23 14:16:32 -04005397
5398 if (n < 0)
5399 {
Geoff Langb1196682014-07-23 13:47:29 -04005400 context->recordError(gl::Error(GL_INVALID_VALUE));
5401 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005402 }
5403
5404 for (GLsizei i = 0; i < n; i++)
5405 {
5406 ids[i] = context->createQuery();
5407 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005408 }
5409}
5410
Kenneth Russell67ea1902014-10-06 16:44:50 -07005411void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005412{
5413 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5414
Geoff Langbfdea662014-07-23 14:16:32 -04005415 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005416 if (context)
5417 {
5418 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005419 {
Geoff Langb1196682014-07-23 13:47:29 -04005420 context->recordError(gl::Error(GL_INVALID_OPERATION));
5421 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005422 }
Geoff Langbfdea662014-07-23 14:16:32 -04005423
5424 if (n < 0)
5425 {
Geoff Langb1196682014-07-23 13:47:29 -04005426 context->recordError(gl::Error(GL_INVALID_VALUE));
5427 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005428 }
5429
5430 for (GLsizei i = 0; i < n; i++)
5431 {
5432 context->deleteQuery(ids[i]);
5433 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005434 }
5435}
5436
Kenneth Russell67ea1902014-10-06 16:44:50 -07005437GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005438{
5439 EVENT("(GLuint id = %u)", id);
5440
Geoff Langbfdea662014-07-23 14:16:32 -04005441 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005442 if (context)
5443 {
5444 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005445 {
Geoff Langb1196682014-07-23 13:47:29 -04005446 context->recordError(gl::Error(GL_INVALID_OPERATION));
5447 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005448 }
Geoff Langbfdea662014-07-23 14:16:32 -04005449
5450 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005451 }
5452
5453 return GL_FALSE;
5454}
5455
Kenneth Russell67ea1902014-10-06 16:44:50 -07005456void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005457{
5458 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5459
Geoff Langbfdea662014-07-23 14:16:32 -04005460 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005461 if (context)
5462 {
5463 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005464 {
Geoff Langb1196682014-07-23 13:47:29 -04005465 context->recordError(gl::Error(GL_INVALID_OPERATION));
5466 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005467 }
Geoff Langbfdea662014-07-23 14:16:32 -04005468
5469 if (!ValidateBeginQuery(context, target, id))
5470 {
5471 return;
5472 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005473
5474 gl::Error error = context->beginQuery(target, id);
5475 if (error.isError())
5476 {
5477 context->recordError(error);
5478 return;
5479 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005480 }
5481}
5482
Kenneth Russell67ea1902014-10-06 16:44:50 -07005483void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005484{
5485 EVENT("(GLenum target = 0x%X)", target);
5486
Geoff Langbfdea662014-07-23 14:16:32 -04005487 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005488 if (context)
5489 {
5490 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005491 {
Geoff Langb1196682014-07-23 13:47:29 -04005492 context->recordError(gl::Error(GL_INVALID_OPERATION));
5493 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005494 }
Geoff Langbfdea662014-07-23 14:16:32 -04005495
5496 if (!ValidateEndQuery(context, target))
5497 {
5498 return;
5499 }
5500
Geoff Lang5aad9672014-09-08 11:10:42 -04005501 gl::Error error = context->endQuery(target);
5502 if (error.isError())
5503 {
5504 context->recordError(error);
5505 return;
5506 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005507 }
5508}
5509
Kenneth Russell67ea1902014-10-06 16:44:50 -07005510void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005511{
5512 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5513
Geoff Langbfdea662014-07-23 14:16:32 -04005514 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005515 if (context)
5516 {
5517 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005518 {
Geoff Langb1196682014-07-23 13:47:29 -04005519 context->recordError(gl::Error(GL_INVALID_OPERATION));
5520 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005521 }
Geoff Langbfdea662014-07-23 14:16:32 -04005522
5523 if (!ValidQueryType(context, target))
5524 {
Geoff Langb1196682014-07-23 13:47:29 -04005525 context->recordError(gl::Error(GL_INVALID_ENUM));
5526 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005527 }
5528
5529 switch (pname)
5530 {
5531 case GL_CURRENT_QUERY:
5532 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5533 break;
5534
5535 default:
Geoff Langb1196682014-07-23 13:47:29 -04005536 context->recordError(gl::Error(GL_INVALID_ENUM));
5537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005538 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005539 }
5540}
5541
Kenneth Russell67ea1902014-10-06 16:44:50 -07005542void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005543{
5544 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5545
Geoff Langbfdea662014-07-23 14:16:32 -04005546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005547 if (context)
5548 {
5549 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005550 {
Geoff Langb1196682014-07-23 13:47:29 -04005551 context->recordError(gl::Error(GL_INVALID_OPERATION));
5552 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005553 }
Geoff Langbfdea662014-07-23 14:16:32 -04005554
5555 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5556
5557 if (!queryObject)
5558 {
Geoff Langb1196682014-07-23 13:47:29 -04005559 context->recordError(gl::Error(GL_INVALID_OPERATION));
5560 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005561 }
5562
5563 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5564 {
Geoff Langb1196682014-07-23 13:47:29 -04005565 context->recordError(gl::Error(GL_INVALID_OPERATION));
5566 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005567 }
5568
5569 switch(pname)
5570 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005571 case GL_QUERY_RESULT_EXT:
5572 {
5573 gl::Error error = queryObject->getResult(params);
5574 if (error.isError())
5575 {
5576 context->recordError(error);
5577 return;
5578 }
5579 }
Geoff Langbfdea662014-07-23 14:16:32 -04005580 break;
Geoff Langb1196682014-07-23 13:47:29 -04005581
Geoff Lang5aad9672014-09-08 11:10:42 -04005582 case GL_QUERY_RESULT_AVAILABLE_EXT:
5583 {
5584 gl::Error error = queryObject->isResultAvailable(params);
5585 if (error.isError())
5586 {
5587 context->recordError(error);
5588 return;
5589 }
5590 }
Geoff Langbfdea662014-07-23 14:16:32 -04005591 break;
Geoff Langb1196682014-07-23 13:47:29 -04005592
Geoff Langbfdea662014-07-23 14:16:32 -04005593 default:
Geoff Langb1196682014-07-23 13:47:29 -04005594 context->recordError(gl::Error(GL_INVALID_ENUM));
5595 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005596 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005597 }
5598}
5599
Kenneth Russell67ea1902014-10-06 16:44:50 -07005600GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005601{
5602 EVENT("(GLenum target = 0x%X)", target);
5603
Geoff Langbfdea662014-07-23 14:16:32 -04005604 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005605 if (context)
5606 {
5607 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005608 {
Geoff Langb1196682014-07-23 13:47:29 -04005609 context->recordError(gl::Error(GL_INVALID_OPERATION));
5610 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005611 }
Geoff Langbfdea662014-07-23 14:16:32 -04005612
5613 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005614 }
5615
5616 return GL_FALSE;
5617}
5618
Kenneth Russell67ea1902014-10-06 16:44:50 -07005619void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005620{
5621 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5622
Geoff Langbfdea662014-07-23 14:16:32 -04005623 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005624 if (context)
5625 {
5626 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005627 {
Geoff Langb1196682014-07-23 13:47:29 -04005628 context->recordError(gl::Error(GL_INVALID_OPERATION));
5629 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005630 }
Geoff Langbfdea662014-07-23 14:16:32 -04005631
5632 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005633 }
5634}
5635
Kenneth Russell67ea1902014-10-06 16:44:50 -07005636void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005637{
Geoff Langbfdea662014-07-23 14:16:32 -04005638 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005639 if (context)
5640 {
5641 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005642 {
Geoff Langb1196682014-07-23 13:47:29 -04005643 context->recordError(gl::Error(GL_INVALID_OPERATION));
5644 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005645 }
Geoff Langbfdea662014-07-23 14:16:32 -04005646
5647 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005648 }
5649}
5650
Kenneth Russell67ea1902014-10-06 16:44:50 -07005651void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005652{
5653 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5654 location, count, transpose, value);
5655
Geoff Langbfdea662014-07-23 14:16:32 -04005656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005657 if (context)
5658 {
5659 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005660 {
Geoff Langbfdea662014-07-23 14:16:32 -04005661 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005662 }
Geoff Langbfdea662014-07-23 14:16:32 -04005663
5664 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5665 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005666 }
5667}
5668
Kenneth Russell67ea1902014-10-06 16:44:50 -07005669void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005670{
5671 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5672 location, count, transpose, value);
5673
Geoff Langbfdea662014-07-23 14:16:32 -04005674 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005675 if (context)
5676 {
5677 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005678 {
Geoff Langbfdea662014-07-23 14:16:32 -04005679 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005680 }
Geoff Langbfdea662014-07-23 14:16:32 -04005681
5682 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5683 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005684 }
5685}
5686
Kenneth Russell67ea1902014-10-06 16:44:50 -07005687void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005688{
5689 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5690 location, count, transpose, value);
5691
Geoff Langbfdea662014-07-23 14:16:32 -04005692 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005693 if (context)
5694 {
5695 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005696 {
Geoff Langbfdea662014-07-23 14:16:32 -04005697 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005698 }
Geoff Langbfdea662014-07-23 14:16:32 -04005699
5700 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5701 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005702 }
5703}
5704
Kenneth Russell67ea1902014-10-06 16:44:50 -07005705void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005706{
5707 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5708 location, count, transpose, value);
5709
Geoff Langbfdea662014-07-23 14:16:32 -04005710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005711 if (context)
5712 {
5713 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005714 {
Geoff Langbfdea662014-07-23 14:16:32 -04005715 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005716 }
Geoff Langbfdea662014-07-23 14:16:32 -04005717
5718 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5719 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005720 }
5721}
5722
Kenneth Russell67ea1902014-10-06 16:44:50 -07005723void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005724{
5725 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5726 location, count, transpose, value);
5727
Geoff Langbfdea662014-07-23 14:16:32 -04005728 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005729 if (context)
5730 {
5731 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005732 {
Geoff Langbfdea662014-07-23 14:16:32 -04005733 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005734 }
Geoff Langbfdea662014-07-23 14:16:32 -04005735
5736 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5737 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005738 }
5739}
5740
Kenneth Russell67ea1902014-10-06 16:44:50 -07005741void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005742{
5743 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5744 location, count, transpose, value);
5745
Geoff Langbfdea662014-07-23 14:16:32 -04005746 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005747 if (context)
5748 {
5749 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005750 {
Geoff Langbfdea662014-07-23 14:16:32 -04005751 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005752 }
Geoff Langbfdea662014-07-23 14:16:32 -04005753
5754 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5755 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005756 }
5757}
5758
Kenneth Russell67ea1902014-10-06 16:44:50 -07005759void GL_APIENTRY glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005760{
5761 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5762 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5763 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5764
Geoff Langbfdea662014-07-23 14:16:32 -04005765 gl::Context *context = gl::getNonLostContext();
5766 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005767 {
Geoff Langbfdea662014-07-23 14:16:32 -04005768 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005769 {
Geoff Langb1196682014-07-23 13:47:29 -04005770 context->recordError(gl::Error(GL_INVALID_OPERATION));
5771 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005772 }
Geoff Langbfdea662014-07-23 14:16:32 -04005773
5774 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5775 dstX0, dstY0, dstX1, dstY1, mask, filter,
5776 false))
5777 {
5778 return;
5779 }
5780
Geoff Lang64839152014-08-26 16:23:25 -04005781 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5782 mask, filter);
5783 if (error.isError())
5784 {
5785 context->recordError(error);
5786 return;
5787 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005788 }
5789}
5790
Kenneth Russell67ea1902014-10-06 16:44:50 -07005791void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005792{
5793 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5794 target, samples, internalformat, width, height);
5795
Geoff Langbfdea662014-07-23 14:16:32 -04005796 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005797 if (context)
5798 {
5799 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005800 {
Geoff Langb1196682014-07-23 13:47:29 -04005801 context->recordError(gl::Error(GL_INVALID_OPERATION));
5802 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005803 }
Geoff Langbfdea662014-07-23 14:16:32 -04005804
5805 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5806 width, height, false))
5807 {
5808 return;
5809 }
5810
Shannon Woodse2632d22014-10-17 13:08:51 -04005811 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5812 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005813 }
5814}
5815
Kenneth Russell67ea1902014-10-06 16:44:50 -07005816void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005817{
5818 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5819 target, attachment, texture, level, layer);
5820
Geoff Langbfdea662014-07-23 14:16:32 -04005821 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005822 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005823 {
Geoff Langbfdea662014-07-23 14:16:32 -04005824 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5825 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005826 {
Geoff Langbfdea662014-07-23 14:16:32 -04005827 return;
5828 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005829
Geoff Langbfdea662014-07-23 14:16:32 -04005830 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5831 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005832
Geoff Langab75a052014-10-15 12:56:37 -04005833 if (texture != 0)
Geoff Langbfdea662014-07-23 14:16:32 -04005834 {
Geoff Langab75a052014-10-15 12:56:37 -04005835 gl::Texture *textureObject = context->getTexture(texture);
5836 gl::ImageIndex index(textureObject->getTarget(), level, layer);
5837 framebuffer->setTextureAttachment(attachment, textureObject, index);
Geoff Langbfdea662014-07-23 14:16:32 -04005838 }
5839 else
5840 {
Geoff Langab75a052014-10-15 12:56:37 -04005841 framebuffer->setNULLAttachment(attachment);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005842 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005843 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005844}
5845
Kenneth Russell67ea1902014-10-06 16:44:50 -07005846GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005847{
5848 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5849 target, offset, length, access);
5850
Geoff Langbfdea662014-07-23 14:16:32 -04005851 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005852 if (context)
5853 {
5854 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005855 {
Geoff Langb1196682014-07-23 13:47:29 -04005856 context->recordError(gl::Error(GL_INVALID_OPERATION));
5857 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005858 }
Geoff Langbfdea662014-07-23 14:16:32 -04005859
5860 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005861 }
5862
5863 return NULL;
5864}
5865
Kenneth Russell67ea1902014-10-06 16:44:50 -07005866void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005867{
5868 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5869
Geoff Langbfdea662014-07-23 14:16:32 -04005870 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005871 if (context)
5872 {
5873 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005874 {
Geoff Langb1196682014-07-23 13:47:29 -04005875 context->recordError(gl::Error(GL_INVALID_OPERATION));
5876 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005877 }
Geoff Langbfdea662014-07-23 14:16:32 -04005878
5879 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005880 }
5881}
5882
Kenneth Russell67ea1902014-10-06 16:44:50 -07005883void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005884{
5885 EVENT("(GLuint array = %u)", array);
5886
Geoff Langbfdea662014-07-23 14:16:32 -04005887 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005888 if (context)
5889 {
5890 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005891 {
Geoff Langb1196682014-07-23 13:47:29 -04005892 context->recordError(gl::Error(GL_INVALID_OPERATION));
5893 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005894 }
Geoff Langbfdea662014-07-23 14:16:32 -04005895
5896 gl::VertexArray *vao = context->getVertexArray(array);
5897
5898 if (!vao)
5899 {
5900 // The default VAO should always exist
5901 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005902 context->recordError(gl::Error(GL_INVALID_OPERATION));
5903 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005904 }
5905
5906 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005907 }
5908}
5909
Kenneth Russell67ea1902014-10-06 16:44:50 -07005910void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005911{
5912 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5913
Geoff Langbfdea662014-07-23 14:16:32 -04005914 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005915 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005916 {
Geoff Langbfdea662014-07-23 14:16:32 -04005917 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005918 {
Geoff Langb1196682014-07-23 13:47:29 -04005919 context->recordError(gl::Error(GL_INVALID_OPERATION));
5920 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005921 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005922
Geoff Langbfdea662014-07-23 14:16:32 -04005923 if (n < 0)
5924 {
Geoff Langb1196682014-07-23 13:47:29 -04005925 context->recordError(gl::Error(GL_INVALID_VALUE));
5926 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005927 }
Jamie Madilld1028542013-07-02 11:57:04 -04005928
Geoff Langbfdea662014-07-23 14:16:32 -04005929 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5930 {
5931 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005932 {
Geoff Langbfdea662014-07-23 14:16:32 -04005933 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005934 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005936 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005937}
5938
Kenneth Russell67ea1902014-10-06 16:44:50 -07005939void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005940{
5941 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5942
Geoff Langbfdea662014-07-23 14:16:32 -04005943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005944 if (context)
5945 {
5946 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005947 {
Geoff Langb1196682014-07-23 13:47:29 -04005948 context->recordError(gl::Error(GL_INVALID_OPERATION));
5949 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005950 }
Geoff Langbfdea662014-07-23 14:16:32 -04005951
5952 if (n < 0)
5953 {
Geoff Langb1196682014-07-23 13:47:29 -04005954 context->recordError(gl::Error(GL_INVALID_VALUE));
5955 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005956 }
5957
5958 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5959 {
5960 arrays[arrayIndex] = context->createVertexArray();
5961 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005962 }
5963}
5964
Kenneth Russell67ea1902014-10-06 16:44:50 -07005965GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005966{
5967 EVENT("(GLuint array = %u)", array);
5968
Geoff Langbfdea662014-07-23 14:16:32 -04005969 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005970 if (context)
5971 {
5972 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005973 {
Geoff Langb1196682014-07-23 13:47:29 -04005974 context->recordError(gl::Error(GL_INVALID_OPERATION));
5975 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005976 }
Geoff Langbfdea662014-07-23 14:16:32 -04005977
5978 if (array == 0)
5979 {
5980 return GL_FALSE;
5981 }
5982
5983 gl::VertexArray *vao = context->getVertexArray(array);
5984
5985 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005986 }
5987
5988 return GL_FALSE;
5989}
5990
Kenneth Russell67ea1902014-10-06 16:44:50 -07005991void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005992{
5993 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
5994 target, index, data);
5995
Geoff Langbfdea662014-07-23 14:16:32 -04005996 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005997 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005998 {
Geoff Langbfdea662014-07-23 14:16:32 -04005999 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006000 {
Geoff Langb1196682014-07-23 13:47:29 -04006001 context->recordError(gl::Error(GL_INVALID_OPERATION));
6002 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006003 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006004
Geoff Lang3a61c322014-07-10 13:01:54 -04006005 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006006 switch (target)
6007 {
6008 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6009 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6010 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006011 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6012 {
Geoff Langb1196682014-07-23 13:47:29 -04006013 context->recordError(gl::Error(GL_INVALID_VALUE));
6014 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006015 }
Geoff Langbfdea662014-07-23 14:16:32 -04006016 break;
Geoff Langb1196682014-07-23 13:47:29 -04006017
Geoff Langbfdea662014-07-23 14:16:32 -04006018 case GL_UNIFORM_BUFFER_START:
6019 case GL_UNIFORM_BUFFER_SIZE:
6020 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006021 if (index >= caps.maxCombinedUniformBlocks)
6022 {
Geoff Langb1196682014-07-23 13:47:29 -04006023 context->recordError(gl::Error(GL_INVALID_VALUE));
6024 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006025 }
Geoff Langbfdea662014-07-23 14:16:32 -04006026 break;
Geoff Langb1196682014-07-23 13:47:29 -04006027
Geoff Langbfdea662014-07-23 14:16:32 -04006028 default:
Geoff Langb1196682014-07-23 13:47:29 -04006029 context->recordError(gl::Error(GL_INVALID_ENUM));
6030 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006031 }
6032
6033 if (!(context->getIndexedIntegerv(target, index, data)))
6034 {
6035 GLenum nativeType;
6036 unsigned int numParams = 0;
6037 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006038 {
6039 context->recordError(gl::Error(GL_INVALID_ENUM));
6040 return;
6041 }
Shannon Woods15934d52013-08-19 14:28:49 -04006042
Geoff Langbfdea662014-07-23 14:16:32 -04006043 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006044 {
Geoff Langbfdea662014-07-23 14:16:32 -04006045 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006046 }
Geoff Langbfdea662014-07-23 14:16:32 -04006047
6048 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006049 {
Geoff Langbfdea662014-07-23 14:16:32 -04006050 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6051 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6052 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006053
Geoff Langbfdea662014-07-23 14:16:32 -04006054 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006055
Geoff Langbfdea662014-07-23 14:16:32 -04006056 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006057 {
Geoff Langbfdea662014-07-23 14:16:32 -04006058 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6059 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006060 }
Geoff Langbfdea662014-07-23 14:16:32 -04006061
6062 delete [] int64Params;
6063 }
6064 else
6065 {
6066 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006067 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006068 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006069 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006070}
6071
Kenneth Russell67ea1902014-10-06 16:44:50 -07006072void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006073{
6074 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6075
Geoff Langbfdea662014-07-23 14:16:32 -04006076 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006077 if (context)
6078 {
6079 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006080 {
Geoff Langb1196682014-07-23 13:47:29 -04006081 context->recordError(gl::Error(GL_INVALID_OPERATION));
6082 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006083 }
Geoff Langbfdea662014-07-23 14:16:32 -04006084
6085 switch (primitiveMode)
6086 {
6087 case GL_TRIANGLES:
6088 case GL_LINES:
6089 case GL_POINTS:
6090 break;
Geoff Langb1196682014-07-23 13:47:29 -04006091
Geoff Langbfdea662014-07-23 14:16:32 -04006092 default:
Geoff Langb1196682014-07-23 13:47:29 -04006093 context->recordError(gl::Error(GL_INVALID_ENUM));
6094 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006095 }
6096
6097 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6098 ASSERT(transformFeedback != NULL);
6099
6100 if (transformFeedback->isStarted())
6101 {
Geoff Langb1196682014-07-23 13:47:29 -04006102 context->recordError(gl::Error(GL_INVALID_OPERATION));
6103 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006104 }
6105
6106 if (transformFeedback->isPaused())
6107 {
6108 transformFeedback->resume();
6109 }
6110 else
6111 {
6112 transformFeedback->start(primitiveMode);
6113 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006114 }
6115}
6116
Kenneth Russell67ea1902014-10-06 16:44:50 -07006117void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006118{
6119 EVENT("(void)");
6120
Geoff Langbfdea662014-07-23 14:16:32 -04006121 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006122 if (context)
6123 {
6124 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006125 {
Geoff Langb1196682014-07-23 13:47:29 -04006126 context->recordError(gl::Error(GL_INVALID_OPERATION));
6127 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006128 }
Geoff Langbfdea662014-07-23 14:16:32 -04006129
6130 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6131 ASSERT(transformFeedback != NULL);
6132
6133 if (!transformFeedback->isStarted())
6134 {
Geoff Langb1196682014-07-23 13:47:29 -04006135 context->recordError(gl::Error(GL_INVALID_OPERATION));
6136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006137 }
6138
6139 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006140 }
6141}
6142
Kenneth Russell67ea1902014-10-06 16:44:50 -07006143void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006144{
6145 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6146 target, index, buffer, offset, size);
6147
Geoff Langbfdea662014-07-23 14:16:32 -04006148 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006149 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006150 {
Geoff Langbfdea662014-07-23 14:16:32 -04006151 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006152 {
Geoff Langb1196682014-07-23 13:47:29 -04006153 context->recordError(gl::Error(GL_INVALID_OPERATION));
6154 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006155 }
6156
Geoff Lang3a61c322014-07-10 13:01:54 -04006157 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006158 switch (target)
6159 {
6160 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006161 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006162 {
Geoff Langb1196682014-07-23 13:47:29 -04006163 context->recordError(gl::Error(GL_INVALID_VALUE));
6164 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006165 }
Geoff Langbfdea662014-07-23 14:16:32 -04006166 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006167
Geoff Langbfdea662014-07-23 14:16:32 -04006168 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006169 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006170 {
Geoff Langb1196682014-07-23 13:47:29 -04006171 context->recordError(gl::Error(GL_INVALID_VALUE));
6172 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006173 }
Geoff Langbfdea662014-07-23 14:16:32 -04006174 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006175
Geoff Langbfdea662014-07-23 14:16:32 -04006176 default:
Geoff Langb1196682014-07-23 13:47:29 -04006177 context->recordError(gl::Error(GL_INVALID_ENUM));
6178 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006179 }
6180
6181 if (buffer != 0 && size <= 0)
6182 {
Geoff Langb1196682014-07-23 13:47:29 -04006183 context->recordError(gl::Error(GL_INVALID_VALUE));
6184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006185 }
6186
6187 switch (target)
6188 {
6189 case GL_TRANSFORM_FEEDBACK_BUFFER:
6190
6191 // size and offset must be a multiple of 4
6192 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006193 {
Geoff Langb1196682014-07-23 13:47:29 -04006194 context->recordError(gl::Error(GL_INVALID_VALUE));
6195 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006196 }
6197
Geoff Langbfdea662014-07-23 14:16:32 -04006198 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6199 context->bindGenericTransformFeedbackBuffer(buffer);
6200 break;
6201
6202 case GL_UNIFORM_BUFFER:
6203
6204 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006205 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006206 {
Geoff Langb1196682014-07-23 13:47:29 -04006207 context->recordError(gl::Error(GL_INVALID_VALUE));
6208 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006209 }
Geoff Langbfdea662014-07-23 14:16:32 -04006210
6211 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6212 context->bindGenericUniformBuffer(buffer);
6213 break;
6214
6215 default:
6216 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006217 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006218 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006219}
6220
Kenneth Russell67ea1902014-10-06 16:44:50 -07006221void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006222{
6223 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6224 target, index, buffer);
6225
Geoff Langbfdea662014-07-23 14:16:32 -04006226 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006227 if (context)
6228 {
6229 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006230 {
Geoff Langb1196682014-07-23 13:47:29 -04006231 context->recordError(gl::Error(GL_INVALID_OPERATION));
6232 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006233 }
Geoff Langbfdea662014-07-23 14:16:32 -04006234
Geoff Lang3a61c322014-07-10 13:01:54 -04006235 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006236 switch (target)
6237 {
6238 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006239 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006240 {
Geoff Langb1196682014-07-23 13:47:29 -04006241 context->recordError(gl::Error(GL_INVALID_VALUE));
6242 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006243 }
6244 break;
6245
6246 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006247 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006248 {
Geoff Langb1196682014-07-23 13:47:29 -04006249 context->recordError(gl::Error(GL_INVALID_VALUE));
6250 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006251 }
6252 break;
6253
6254 default:
Geoff Langb1196682014-07-23 13:47:29 -04006255 context->recordError(gl::Error(GL_INVALID_ENUM));
6256 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006257 }
6258
6259 switch (target)
6260 {
6261 case GL_TRANSFORM_FEEDBACK_BUFFER:
6262 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6263 context->bindGenericTransformFeedbackBuffer(buffer);
6264 break;
6265
6266 case GL_UNIFORM_BUFFER:
6267 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6268 context->bindGenericUniformBuffer(buffer);
6269 break;
6270
6271 default:
6272 UNREACHABLE();
6273 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006274 }
6275}
6276
Kenneth Russell67ea1902014-10-06 16:44:50 -07006277void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006278{
6279 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6280 program, count, varyings, bufferMode);
6281
Geoff Langbfdea662014-07-23 14:16:32 -04006282 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006283 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006284 {
Geoff Langbfdea662014-07-23 14:16:32 -04006285 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006286 {
Geoff Langb1196682014-07-23 13:47:29 -04006287 context->recordError(gl::Error(GL_INVALID_OPERATION));
6288 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006289 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006290
Geoff Langbfdea662014-07-23 14:16:32 -04006291 if (count < 0)
6292 {
Geoff Langb1196682014-07-23 13:47:29 -04006293 context->recordError(gl::Error(GL_INVALID_VALUE));
6294 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006295 }
6296
Geoff Lang05881a02014-07-10 14:05:30 -04006297 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006298 switch (bufferMode)
6299 {
6300 case GL_INTERLEAVED_ATTRIBS:
6301 break;
6302 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006303 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006304 {
Geoff Langb1196682014-07-23 13:47:29 -04006305 context->recordError(gl::Error(GL_INVALID_VALUE));
6306 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006307 }
Geoff Langbfdea662014-07-23 14:16:32 -04006308 break;
6309 default:
Geoff Langb1196682014-07-23 13:47:29 -04006310 context->recordError(gl::Error(GL_INVALID_ENUM));
6311 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006312 }
Geoff Langbfdea662014-07-23 14:16:32 -04006313
6314 if (!gl::ValidProgram(context, program))
6315 {
6316 return;
6317 }
6318
6319 gl::Program *programObject = context->getProgram(program);
6320 ASSERT(programObject);
6321
6322 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006323 }
6324}
6325
Kenneth Russell67ea1902014-10-06 16:44:50 -07006326void 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 +00006327{
6328 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6329 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6330 program, index, bufSize, length, size, type, name);
6331
Geoff Langbfdea662014-07-23 14:16:32 -04006332 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006333 if (context)
6334 {
6335 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006336 {
Geoff Langb1196682014-07-23 13:47:29 -04006337 context->recordError(gl::Error(GL_INVALID_OPERATION));
6338 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006339 }
Geoff Langbfdea662014-07-23 14:16:32 -04006340
6341 if (bufSize < 0)
6342 {
Geoff Langb1196682014-07-23 13:47:29 -04006343 context->recordError(gl::Error(GL_INVALID_VALUE));
6344 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006345 }
6346
6347 if (!gl::ValidProgram(context, program))
6348 {
6349 return;
6350 }
6351
6352 gl::Program *programObject = context->getProgram(program);
6353 ASSERT(programObject);
6354
6355 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6356 {
Geoff Langb1196682014-07-23 13:47:29 -04006357 context->recordError(gl::Error(GL_INVALID_VALUE));
6358 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006359 }
6360
6361 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006362 }
6363}
6364
Kenneth Russell67ea1902014-10-06 16:44:50 -07006365void 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 +00006366{
6367 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6368 index, size, type, stride, pointer);
6369
Geoff Langbfdea662014-07-23 14:16:32 -04006370 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006371 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006372 {
Geoff Langbfdea662014-07-23 14:16:32 -04006373 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006374 {
Geoff Langb1196682014-07-23 13:47:29 -04006375 context->recordError(gl::Error(GL_INVALID_OPERATION));
6376 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006377 }
6378
Geoff Langb1196682014-07-23 13:47:29 -04006379 if (index >= gl::MAX_VERTEX_ATTRIBS)
6380 {
6381 context->recordError(gl::Error(GL_INVALID_VALUE));
6382 return;
6383 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006384
Geoff Langb1196682014-07-23 13:47:29 -04006385 if (size < 1 || size > 4)
6386 {
6387 context->recordError(gl::Error(GL_INVALID_VALUE));
6388 return;
6389 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006390
Geoff Langb1196682014-07-23 13:47:29 -04006391 switch (type)
6392 {
6393 case GL_BYTE:
6394 case GL_UNSIGNED_BYTE:
6395 case GL_SHORT:
6396 case GL_UNSIGNED_SHORT:
6397 case GL_INT:
6398 case GL_UNSIGNED_INT:
6399 case GL_INT_2_10_10_10_REV:
6400 case GL_UNSIGNED_INT_2_10_10_10_REV:
6401 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006402
Geoff Langb1196682014-07-23 13:47:29 -04006403 default:
6404 context->recordError(gl::Error(GL_INVALID_ENUM));
6405 return;
6406 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006407
Geoff Langb1196682014-07-23 13:47:29 -04006408 if (stride < 0)
6409 {
6410 context->recordError(gl::Error(GL_INVALID_VALUE));
6411 return;
6412 }
Geoff Langbfdea662014-07-23 14:16:32 -04006413
Geoff Langb1196682014-07-23 13:47:29 -04006414 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6415 {
6416 context->recordError(gl::Error(GL_INVALID_OPERATION));
6417 return;
6418 }
6419
Geoff Langbfdea662014-07-23 14:16:32 -04006420 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6421 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6422 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6423 // and the pointer argument is not NULL.
6424 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006425 {
Geoff Langb1196682014-07-23 13:47:29 -04006426 context->recordError(gl::Error(GL_INVALID_OPERATION));
6427 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006428 }
6429
Geoff Langbfdea662014-07-23 14:16:32 -04006430 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6431 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006432 }
6433}
6434
Kenneth Russell67ea1902014-10-06 16:44:50 -07006435void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006436{
6437 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6438 index, pname, params);
6439
Geoff Langbfdea662014-07-23 14:16:32 -04006440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006441 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006442 {
Geoff Langbfdea662014-07-23 14:16:32 -04006443 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006444 {
Geoff Langb1196682014-07-23 13:47:29 -04006445 context->recordError(gl::Error(GL_INVALID_OPERATION));
6446 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006447 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006448
Geoff Langbfdea662014-07-23 14:16:32 -04006449 if (index >= gl::MAX_VERTEX_ATTRIBS)
6450 {
Geoff Langb1196682014-07-23 13:47:29 -04006451 context->recordError(gl::Error(GL_INVALID_VALUE));
6452 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006453 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006454
Geoff Langbfdea662014-07-23 14:16:32 -04006455 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006456
Geoff Langb1196682014-07-23 13:47:29 -04006457 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006458 {
6459 return;
6460 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006461
Geoff Langbfdea662014-07-23 14:16:32 -04006462 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6463 {
6464 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6465 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006466 {
Geoff Langbfdea662014-07-23 14:16:32 -04006467 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006468 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006469 }
Geoff Langbfdea662014-07-23 14:16:32 -04006470 else
6471 {
6472 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6473 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006474 }
6475}
6476
Kenneth Russell67ea1902014-10-06 16:44:50 -07006477void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006478{
6479 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6480 index, pname, params);
6481
Geoff Langbfdea662014-07-23 14:16:32 -04006482 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006483 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006484 {
Geoff Langbfdea662014-07-23 14:16:32 -04006485 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006486 {
Geoff Langb1196682014-07-23 13:47:29 -04006487 context->recordError(gl::Error(GL_INVALID_OPERATION));
6488 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006489 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006490
Geoff Langbfdea662014-07-23 14:16:32 -04006491 if (index >= gl::MAX_VERTEX_ATTRIBS)
6492 {
Geoff Langb1196682014-07-23 13:47:29 -04006493 context->recordError(gl::Error(GL_INVALID_VALUE));
6494 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006495 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006496
Geoff Langbfdea662014-07-23 14:16:32 -04006497 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006498
Geoff Langb1196682014-07-23 13:47:29 -04006499 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006500 {
6501 return;
6502 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006503
Geoff Langbfdea662014-07-23 14:16:32 -04006504 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6505 {
6506 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6507 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006508 {
Geoff Langbfdea662014-07-23 14:16:32 -04006509 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006510 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006511 }
Geoff Langbfdea662014-07-23 14:16:32 -04006512 else
6513 {
6514 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6515 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006516 }
6517}
6518
Kenneth Russell67ea1902014-10-06 16:44:50 -07006519void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006520{
6521 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6522 index, x, y, z, w);
6523
Geoff Langbfdea662014-07-23 14:16:32 -04006524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006525 if (context)
6526 {
6527 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006528 {
Geoff Langb1196682014-07-23 13:47:29 -04006529 context->recordError(gl::Error(GL_INVALID_OPERATION));
6530 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006531 }
Geoff Langbfdea662014-07-23 14:16:32 -04006532
6533 if (index >= gl::MAX_VERTEX_ATTRIBS)
6534 {
Geoff Langb1196682014-07-23 13:47:29 -04006535 context->recordError(gl::Error(GL_INVALID_VALUE));
6536 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006537 }
6538
6539 GLint vals[4] = { x, y, z, w };
6540 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541 }
6542}
6543
Kenneth Russell67ea1902014-10-06 16:44:50 -07006544void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006545{
6546 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6547 index, x, y, z, w);
6548
Geoff Langbfdea662014-07-23 14:16:32 -04006549 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006550 if (context)
6551 {
6552 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006553 {
Geoff Langb1196682014-07-23 13:47:29 -04006554 context->recordError(gl::Error(GL_INVALID_OPERATION));
6555 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006556 }
Geoff Langbfdea662014-07-23 14:16:32 -04006557
6558 if (index >= gl::MAX_VERTEX_ATTRIBS)
6559 {
Geoff Langb1196682014-07-23 13:47:29 -04006560 context->recordError(gl::Error(GL_INVALID_VALUE));
6561 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006562 }
6563
6564 GLuint vals[4] = { x, y, z, w };
6565 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006566 }
6567}
6568
Kenneth Russell67ea1902014-10-06 16:44:50 -07006569void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006570{
6571 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6572
Geoff Langbfdea662014-07-23 14:16:32 -04006573 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006574 if (context)
6575 {
6576 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006577 {
Geoff Langb1196682014-07-23 13:47:29 -04006578 context->recordError(gl::Error(GL_INVALID_OPERATION));
6579 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006580 }
Geoff Langbfdea662014-07-23 14:16:32 -04006581
6582 if (index >= gl::MAX_VERTEX_ATTRIBS)
6583 {
Geoff Langb1196682014-07-23 13:47:29 -04006584 context->recordError(gl::Error(GL_INVALID_VALUE));
6585 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006586 }
6587
6588 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006589 }
6590}
6591
Kenneth Russell67ea1902014-10-06 16:44:50 -07006592void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006593{
6594 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6595
Geoff Langbfdea662014-07-23 14:16:32 -04006596 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006597 if (context)
6598 {
6599 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006600 {
Geoff Langb1196682014-07-23 13:47:29 -04006601 context->recordError(gl::Error(GL_INVALID_OPERATION));
6602 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006603 }
Geoff Langbfdea662014-07-23 14:16:32 -04006604
6605 if (index >= gl::MAX_VERTEX_ATTRIBS)
6606 {
Geoff Langb1196682014-07-23 13:47:29 -04006607 context->recordError(gl::Error(GL_INVALID_VALUE));
6608 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006609 }
6610
6611 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006612 }
6613}
6614
Kenneth Russell67ea1902014-10-06 16:44:50 -07006615void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006616{
6617 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6618 program, location, params);
6619
Geoff Langbfdea662014-07-23 14:16:32 -04006620 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006621 if (context)
6622 {
Jamie Madill0063c512014-08-25 15:47:53 -04006623 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006624 {
Jamie Madill0063c512014-08-25 15:47:53 -04006625 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006626 }
Geoff Langbfdea662014-07-23 14:16:32 -04006627
Jamie Madilla502c742014-08-28 17:19:13 -04006628 gl::Program *programObject = context->getProgram(program);
6629 ASSERT(programObject);
6630 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006631 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006632
Jamie Madill99a1e982014-08-25 15:47:54 -04006633 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006634 }
6635}
6636
Kenneth Russell67ea1902014-10-06 16:44:50 -07006637GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006638{
6639 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6640 program, name);
6641
Geoff Langbfdea662014-07-23 14:16:32 -04006642 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006643 if (context)
6644 {
6645 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006646 {
Geoff Langb1196682014-07-23 13:47:29 -04006647 context->recordError(gl::Error(GL_INVALID_OPERATION));
6648 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006649 }
Geoff Langbfdea662014-07-23 14:16:32 -04006650
6651 if (program == 0)
6652 {
Geoff Langb1196682014-07-23 13:47:29 -04006653 context->recordError(gl::Error(GL_INVALID_VALUE));
6654 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006655 }
6656
6657 gl::Program *programObject = context->getProgram(program);
6658
6659 if (!programObject || !programObject->isLinked())
6660 {
Geoff Langb1196682014-07-23 13:47:29 -04006661 context->recordError(gl::Error(GL_INVALID_OPERATION));
6662 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006663 }
6664
6665 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6666 if (!programBinary)
6667 {
Geoff Langb1196682014-07-23 13:47:29 -04006668 context->recordError(gl::Error(GL_INVALID_OPERATION));
6669 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006670 }
6671
6672 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006673 }
6674
6675 return 0;
6676}
6677
Kenneth Russell67ea1902014-10-06 16:44:50 -07006678void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006679{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006680 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006681}
6682
Kenneth Russell67ea1902014-10-06 16:44:50 -07006683void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006684{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006685 const GLuint xy[] = { v0, v1 };
6686 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006687}
6688
Kenneth Russell67ea1902014-10-06 16:44:50 -07006689void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006690{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006691 const GLuint xyz[] = { v0, v1, v2 };
6692 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006693}
6694
Kenneth Russell67ea1902014-10-06 16:44:50 -07006695void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006696{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006697 const GLuint xyzw[] = { v0, v1, v2, v3 };
6698 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006699}
6700
Kenneth Russell67ea1902014-10-06 16:44:50 -07006701void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006702{
6703 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6704 location, count, value);
6705
Geoff Langbfdea662014-07-23 14:16:32 -04006706 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006707 if (context)
6708 {
6709 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006710 {
Geoff Langbfdea662014-07-23 14:16:32 -04006711 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006712 }
Geoff Langbfdea662014-07-23 14:16:32 -04006713
6714 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6715 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006716 }
6717}
6718
Kenneth Russell67ea1902014-10-06 16:44:50 -07006719void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006720{
6721 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6722 location, count, value);
6723
Geoff Langbfdea662014-07-23 14:16:32 -04006724 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006725 if (context)
6726 {
6727 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006728 {
Geoff Langbfdea662014-07-23 14:16:32 -04006729 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006730 }
Geoff Langbfdea662014-07-23 14:16:32 -04006731
6732 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6733 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006734 }
6735}
6736
Kenneth Russell67ea1902014-10-06 16:44:50 -07006737void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006738{
6739 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6740 location, count, value);
6741
Geoff Langbfdea662014-07-23 14:16:32 -04006742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006743 if (context)
6744 {
6745 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006746 {
Geoff Langbfdea662014-07-23 14:16:32 -04006747 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006748 }
Geoff Langbfdea662014-07-23 14:16:32 -04006749
6750 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6751 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006752 }
6753}
6754
Kenneth Russell67ea1902014-10-06 16:44:50 -07006755void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006756{
6757 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6758 location, count, value);
6759
Geoff Langbfdea662014-07-23 14:16:32 -04006760 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006761 if (context)
6762 {
6763 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006764 {
Geoff Langbfdea662014-07-23 14:16:32 -04006765 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006766 }
Geoff Langbfdea662014-07-23 14:16:32 -04006767
6768 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6769 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006770 }
6771}
6772
Kenneth Russell67ea1902014-10-06 16:44:50 -07006773void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006774{
6775 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6776 buffer, drawbuffer, value);
6777
Geoff Langbfdea662014-07-23 14:16:32 -04006778 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006779 if (context)
6780 {
6781 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006782 {
Geoff Langbfdea662014-07-23 14:16:32 -04006783 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006784 }
Geoff Langbfdea662014-07-23 14:16:32 -04006785
6786 switch (buffer)
6787 {
6788 case GL_COLOR:
6789 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6790 {
Geoff Langb1196682014-07-23 13:47:29 -04006791 context->recordError(gl::Error(GL_INVALID_VALUE));
6792 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006793 }
6794 break;
Geoff Langb1196682014-07-23 13:47:29 -04006795
Geoff Langbfdea662014-07-23 14:16:32 -04006796 case GL_STENCIL:
6797 if (drawbuffer != 0)
6798 {
Geoff Langb1196682014-07-23 13:47:29 -04006799 context->recordError(gl::Error(GL_INVALID_VALUE));
6800 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006801 }
6802 break;
Geoff Langb1196682014-07-23 13:47:29 -04006803
Geoff Langbfdea662014-07-23 14:16:32 -04006804 default:
Geoff Langb1196682014-07-23 13:47:29 -04006805 context->recordError(gl::Error(GL_INVALID_ENUM));
6806 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006807 }
6808
Geoff Langcc79b8c2014-07-25 13:48:02 -04006809 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6810 if (error.isError())
6811 {
6812 context->recordError(error);
6813 return;
6814 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006815 }
6816}
6817
Kenneth Russell67ea1902014-10-06 16:44:50 -07006818void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006819{
6820 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6821 buffer, drawbuffer, value);
6822
Geoff Langbfdea662014-07-23 14:16:32 -04006823 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006824 if (context)
6825 {
6826 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006827 {
Geoff Langbfdea662014-07-23 14:16:32 -04006828 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006829 }
Geoff Langbfdea662014-07-23 14:16:32 -04006830
6831 switch (buffer)
6832 {
6833 case GL_COLOR:
6834 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6835 {
Geoff Langb1196682014-07-23 13:47:29 -04006836 context->recordError(gl::Error(GL_INVALID_VALUE));
6837 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006838 }
6839 break;
Geoff Langb1196682014-07-23 13:47:29 -04006840
Geoff Langbfdea662014-07-23 14:16:32 -04006841 default:
Geoff Langb1196682014-07-23 13:47:29 -04006842 context->recordError(gl::Error(GL_INVALID_ENUM));
6843 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006844 }
6845
Geoff Langcc79b8c2014-07-25 13:48:02 -04006846 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6847 if (error.isError())
6848 {
6849 context->recordError(error);
6850 return;
6851 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006852 }
6853}
6854
Kenneth Russell67ea1902014-10-06 16:44:50 -07006855void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006856{
6857 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6858 buffer, drawbuffer, value);
6859
Geoff Langbfdea662014-07-23 14:16:32 -04006860 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006861 if (context)
6862 {
6863 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006864 {
Geoff Langbfdea662014-07-23 14:16:32 -04006865 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006866 }
Geoff Langbfdea662014-07-23 14:16:32 -04006867
6868 switch (buffer)
6869 {
6870 case GL_COLOR:
6871 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6872 {
Geoff Langb1196682014-07-23 13:47:29 -04006873 context->recordError(gl::Error(GL_INVALID_VALUE));
6874 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006875 }
6876 break;
Geoff Langb1196682014-07-23 13:47:29 -04006877
Geoff Langbfdea662014-07-23 14:16:32 -04006878 case GL_DEPTH:
6879 if (drawbuffer != 0)
6880 {
Geoff Langb1196682014-07-23 13:47:29 -04006881 context->recordError(gl::Error(GL_INVALID_VALUE));
6882 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006883 }
6884 break;
Geoff Langb1196682014-07-23 13:47:29 -04006885
Geoff Langbfdea662014-07-23 14:16:32 -04006886 default:
Geoff Langb1196682014-07-23 13:47:29 -04006887 context->recordError(gl::Error(GL_INVALID_ENUM));
6888 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006889 }
6890
Geoff Langcc79b8c2014-07-25 13:48:02 -04006891 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6892 if (error.isError())
6893 {
6894 context->recordError(error);
6895 return;
6896 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006897 }
6898}
6899
Kenneth Russell67ea1902014-10-06 16:44:50 -07006900void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006901{
6902 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6903 buffer, drawbuffer, depth, stencil);
6904
Geoff Langbfdea662014-07-23 14:16:32 -04006905 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006906 if (context)
6907 {
6908 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006909 {
Geoff Langbfdea662014-07-23 14:16:32 -04006910 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006911 }
Geoff Langbfdea662014-07-23 14:16:32 -04006912
6913 switch (buffer)
6914 {
6915 case GL_DEPTH_STENCIL:
6916 if (drawbuffer != 0)
6917 {
Geoff Langb1196682014-07-23 13:47:29 -04006918 context->recordError(gl::Error(GL_INVALID_VALUE));
6919 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006920 }
6921 break;
Geoff Langb1196682014-07-23 13:47:29 -04006922
Geoff Langbfdea662014-07-23 14:16:32 -04006923 default:
Geoff Langb1196682014-07-23 13:47:29 -04006924 context->recordError(gl::Error(GL_INVALID_ENUM));
6925 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006926 }
6927
Geoff Langcc79b8c2014-07-25 13:48:02 -04006928 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6929 if (error.isError())
6930 {
6931 context->recordError(error);
6932 return;
6933 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006934 }
6935}
6936
Kenneth Russell67ea1902014-10-06 16:44:50 -07006937const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006938{
6939 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6940
Geoff Langbfdea662014-07-23 14:16:32 -04006941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006942 if (context)
6943 {
6944 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006945 {
Geoff Langb1196682014-07-23 13:47:29 -04006946 context->recordError(gl::Error(GL_INVALID_OPERATION));
6947 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006948 }
Geoff Langbfdea662014-07-23 14:16:32 -04006949
6950 if (name != GL_EXTENSIONS)
6951 {
Geoff Langb1196682014-07-23 13:47:29 -04006952 context->recordError(gl::Error(GL_INVALID_ENUM));
6953 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006954 }
6955
6956 if (index >= context->getExtensionStringCount())
6957 {
Geoff Langb1196682014-07-23 13:47:29 -04006958 context->recordError(gl::Error(GL_INVALID_VALUE));
6959 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006960 }
6961
6962 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006963 }
6964
6965 return NULL;
6966}
6967
Kenneth Russell67ea1902014-10-06 16:44:50 -07006968void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006969{
6970 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6971 readTarget, writeTarget, readOffset, writeOffset, size);
6972
Geoff Langbfdea662014-07-23 14:16:32 -04006973 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006974 if (context)
6975 {
6976 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006977 {
Geoff Langb1196682014-07-23 13:47:29 -04006978 context->recordError(gl::Error(GL_INVALID_OPERATION));
6979 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006980 }
Geoff Langbfdea662014-07-23 14:16:32 -04006981
Jamie Madill24e83192014-10-20 11:00:53 -04006982 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04006983 {
Geoff Langb1196682014-07-23 13:47:29 -04006984 context->recordError(gl::Error(GL_INVALID_ENUM));
6985 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006986 }
6987
6988 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
6989 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
6990
6991 if (!readBuffer || !writeBuffer)
6992 {
Geoff Langb1196682014-07-23 13:47:29 -04006993 context->recordError(gl::Error(GL_INVALID_OPERATION));
6994 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006995 }
6996
Jamie Madillcfaaf722014-07-31 10:47:54 -04006997 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04006998 if (readBuffer->isMapped() || writeBuffer->isMapped())
6999 {
Geoff Langb1196682014-07-23 13:47:29 -04007000 context->recordError(gl::Error(GL_INVALID_OPERATION));
7001 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007002 }
7003
7004 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7005 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7006 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7007 {
Geoff Langb1196682014-07-23 13:47:29 -04007008 context->recordError(gl::Error(GL_INVALID_VALUE));
7009 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007010 }
7011
Kenneth Russell67ea1902014-10-06 16:44:50 -07007012 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007013 {
Geoff Langb1196682014-07-23 13:47:29 -04007014 context->recordError(gl::Error(GL_INVALID_VALUE));
7015 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007016 }
7017
Geoff Langbfdea662014-07-23 14:16:32 -04007018 // if size is zero, the copy is a successful no-op
7019 if (size > 0)
7020 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007021 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7022 if (error.isError())
7023 {
7024 context->recordError(error);
7025 return;
7026 }
Geoff Langbfdea662014-07-23 14:16:32 -04007027 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007028 }
7029}
7030
Kenneth Russell67ea1902014-10-06 16:44:50 -07007031void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007032{
7033 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7034 program, uniformCount, uniformNames, uniformIndices);
7035
Geoff Langbfdea662014-07-23 14:16:32 -04007036 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007037 if (context)
7038 {
7039 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007040 {
Geoff Langb1196682014-07-23 13:47:29 -04007041 context->recordError(gl::Error(GL_INVALID_OPERATION));
7042 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007043 }
7044
7045 if (uniformCount < 0)
7046 {
Geoff Langb1196682014-07-23 13:47:29 -04007047 context->recordError(gl::Error(GL_INVALID_VALUE));
7048 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007049 }
7050
7051 gl::Program *programObject = context->getProgram(program);
7052
7053 if (!programObject)
7054 {
7055 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007056 {
Geoff Langb1196682014-07-23 13:47:29 -04007057 context->recordError(gl::Error(GL_INVALID_OPERATION));
7058 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007059 }
Geoff Langbfdea662014-07-23 14:16:32 -04007060 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007061 {
Geoff Langb1196682014-07-23 13:47:29 -04007062 context->recordError(gl::Error(GL_INVALID_VALUE));
7063 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007064 }
Geoff Langbfdea662014-07-23 14:16:32 -04007065 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007066
Geoff Langbfdea662014-07-23 14:16:32 -04007067 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7068 if (!programObject->isLinked() || !programBinary)
7069 {
7070 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007071 {
Geoff Langbfdea662014-07-23 14:16:32 -04007072 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007073 }
7074 }
Geoff Langbfdea662014-07-23 14:16:32 -04007075 else
7076 {
7077 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7078 {
7079 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7080 }
7081 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007082 }
7083}
7084
Kenneth Russell67ea1902014-10-06 16:44:50 -07007085void 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 +00007086{
7087 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7088 program, uniformCount, uniformIndices, pname, params);
7089
Geoff Langbfdea662014-07-23 14:16:32 -04007090 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007091 if (context)
7092 {
7093 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007094 {
Geoff Langb1196682014-07-23 13:47:29 -04007095 context->recordError(gl::Error(GL_INVALID_OPERATION));
7096 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007097 }
7098
7099 if (uniformCount < 0)
7100 {
Geoff Langb1196682014-07-23 13:47:29 -04007101 context->recordError(gl::Error(GL_INVALID_VALUE));
7102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007103 }
7104
7105 gl::Program *programObject = context->getProgram(program);
7106
7107 if (!programObject)
7108 {
7109 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007110 {
Geoff Langb1196682014-07-23 13:47:29 -04007111 context->recordError(gl::Error(GL_INVALID_OPERATION));
7112 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007113 }
Geoff Langbfdea662014-07-23 14:16:32 -04007114 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007115 {
Geoff Langb1196682014-07-23 13:47:29 -04007116 context->recordError(gl::Error(GL_INVALID_VALUE));
7117 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007118 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007119 }
Geoff Langbfdea662014-07-23 14:16:32 -04007120
7121 switch (pname)
7122 {
7123 case GL_UNIFORM_TYPE:
7124 case GL_UNIFORM_SIZE:
7125 case GL_UNIFORM_NAME_LENGTH:
7126 case GL_UNIFORM_BLOCK_INDEX:
7127 case GL_UNIFORM_OFFSET:
7128 case GL_UNIFORM_ARRAY_STRIDE:
7129 case GL_UNIFORM_MATRIX_STRIDE:
7130 case GL_UNIFORM_IS_ROW_MAJOR:
7131 break;
Geoff Langb1196682014-07-23 13:47:29 -04007132
Geoff Langbfdea662014-07-23 14:16:32 -04007133 default:
Geoff Langb1196682014-07-23 13:47:29 -04007134 context->recordError(gl::Error(GL_INVALID_ENUM));
7135 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007136 }
7137
7138 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7139
7140 if (!programBinary && uniformCount > 0)
7141 {
Geoff Langb1196682014-07-23 13:47:29 -04007142 context->recordError(gl::Error(GL_INVALID_VALUE));
7143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007144 }
7145
7146 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7147 {
7148 const GLuint index = uniformIndices[uniformId];
7149
7150 if (index >= (GLuint)programBinary->getActiveUniformCount())
7151 {
Geoff Langb1196682014-07-23 13:47:29 -04007152 context->recordError(gl::Error(GL_INVALID_VALUE));
7153 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007154 }
7155 }
7156
7157 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7158 {
7159 const GLuint index = uniformIndices[uniformId];
7160 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7161 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007162 }
7163}
7164
Kenneth Russell67ea1902014-10-06 16:44:50 -07007165GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007166{
7167 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7168
Geoff Langbfdea662014-07-23 14:16:32 -04007169 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007170 if (context)
7171 {
7172 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007173 {
Geoff Langb1196682014-07-23 13:47:29 -04007174 context->recordError(gl::Error(GL_INVALID_OPERATION));
7175 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007176 }
7177
7178 gl::Program *programObject = context->getProgram(program);
7179
7180 if (!programObject)
7181 {
7182 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007183 {
Geoff Langb1196682014-07-23 13:47:29 -04007184 context->recordError(gl::Error(GL_INVALID_OPERATION));
7185 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007186 }
Geoff Langbfdea662014-07-23 14:16:32 -04007187 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007188 {
Geoff Langb1196682014-07-23 13:47:29 -04007189 context->recordError(gl::Error(GL_INVALID_VALUE));
7190 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007191 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007192 }
Geoff Langbfdea662014-07-23 14:16:32 -04007193
7194 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7195 if (!programBinary)
7196 {
7197 return GL_INVALID_INDEX;
7198 }
7199
7200 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007201 }
7202
7203 return 0;
7204}
7205
Kenneth Russell67ea1902014-10-06 16:44:50 -07007206void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007207{
7208 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7209 program, uniformBlockIndex, pname, params);
7210
Geoff Langbfdea662014-07-23 14:16:32 -04007211 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007212 if (context)
7213 {
7214 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007215 {
Geoff Langb1196682014-07-23 13:47:29 -04007216 context->recordError(gl::Error(GL_INVALID_OPERATION));
7217 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007218 }
7219 gl::Program *programObject = context->getProgram(program);
7220
7221 if (!programObject)
7222 {
7223 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007224 {
Geoff Langb1196682014-07-23 13:47:29 -04007225 context->recordError(gl::Error(GL_INVALID_OPERATION));
7226 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007227 }
Geoff Langbfdea662014-07-23 14:16:32 -04007228 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007229 {
Geoff Langb1196682014-07-23 13:47:29 -04007230 context->recordError(gl::Error(GL_INVALID_VALUE));
7231 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007232 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007233 }
Geoff Langbfdea662014-07-23 14:16:32 -04007234
7235 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7236
7237 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7238 {
Geoff Langb1196682014-07-23 13:47:29 -04007239 context->recordError(gl::Error(GL_INVALID_VALUE));
7240 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007241 }
7242
7243 switch (pname)
7244 {
7245 case GL_UNIFORM_BLOCK_BINDING:
7246 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7247 break;
7248
7249 case GL_UNIFORM_BLOCK_DATA_SIZE:
7250 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7251 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7252 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7253 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7254 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7255 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7256 break;
7257
7258 default:
Geoff Langb1196682014-07-23 13:47:29 -04007259 context->recordError(gl::Error(GL_INVALID_ENUM));
7260 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007261 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007262 }
7263}
7264
Kenneth Russell67ea1902014-10-06 16:44:50 -07007265void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007266{
7267 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7268 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7269
Geoff Langbfdea662014-07-23 14:16:32 -04007270 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007271 if (context)
7272 {
7273 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007274 {
Geoff Langb1196682014-07-23 13:47:29 -04007275 context->recordError(gl::Error(GL_INVALID_OPERATION));
7276 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007277 }
7278
7279 gl::Program *programObject = context->getProgram(program);
7280
7281 if (!programObject)
7282 {
7283 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007284 {
Geoff Langb1196682014-07-23 13:47:29 -04007285 context->recordError(gl::Error(GL_INVALID_OPERATION));
7286 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007287 }
Geoff Langbfdea662014-07-23 14:16:32 -04007288 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007289 {
Geoff Langb1196682014-07-23 13:47:29 -04007290 context->recordError(gl::Error(GL_INVALID_VALUE));
7291 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007292 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007293 }
Geoff Langbfdea662014-07-23 14:16:32 -04007294
7295 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7296
7297 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7298 {
Geoff Langb1196682014-07-23 13:47:29 -04007299 context->recordError(gl::Error(GL_INVALID_VALUE));
7300 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007301 }
7302
7303 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007304 }
7305}
7306
Kenneth Russell67ea1902014-10-06 16:44:50 -07007307void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007308{
7309 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7310 program, uniformBlockIndex, uniformBlockBinding);
7311
Geoff Langbfdea662014-07-23 14:16:32 -04007312 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007313 if (context)
7314 {
7315 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007316 {
Geoff Langb1196682014-07-23 13:47:29 -04007317 context->recordError(gl::Error(GL_INVALID_OPERATION));
7318 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007319 }
7320
Geoff Lang3a61c322014-07-10 13:01:54 -04007321 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007322 {
Geoff Langb1196682014-07-23 13:47:29 -04007323 context->recordError(gl::Error(GL_INVALID_VALUE));
7324 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007325 }
7326
7327 gl::Program *programObject = context->getProgram(program);
7328
7329 if (!programObject)
7330 {
7331 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007332 {
Geoff Langb1196682014-07-23 13:47:29 -04007333 context->recordError(gl::Error(GL_INVALID_OPERATION));
7334 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007335 }
Geoff Langbfdea662014-07-23 14:16:32 -04007336 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007337 {
Geoff Langb1196682014-07-23 13:47:29 -04007338 context->recordError(gl::Error(GL_INVALID_VALUE));
7339 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007340 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007341 }
Geoff Langbfdea662014-07-23 14:16:32 -04007342
7343 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7344
7345 // if never linked, there won't be any uniform blocks
7346 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7347 {
Geoff Langb1196682014-07-23 13:47:29 -04007348 context->recordError(gl::Error(GL_INVALID_VALUE));
7349 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007350 }
7351
7352 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007353 }
7354}
7355
Kenneth Russell67ea1902014-10-06 16:44:50 -07007356void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007357{
7358 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7359 mode, first, count, instanceCount);
7360
Geoff Langbfdea662014-07-23 14:16:32 -04007361 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007362 if (context)
7363 {
7364 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007365 {
Geoff Langb1196682014-07-23 13:47:29 -04007366 context->recordError(gl::Error(GL_INVALID_OPERATION));
7367 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007368 }
Geoff Langbfdea662014-07-23 14:16:32 -04007369
7370 // glDrawArraysInstanced
7371 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007372 }
7373}
7374
Kenneth Russell67ea1902014-10-06 16:44:50 -07007375void 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 +00007376{
7377 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7378 mode, count, type, indices, instanceCount);
7379
Geoff Langbfdea662014-07-23 14:16:32 -04007380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007381 if (context)
7382 {
7383 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007384 {
Geoff Langb1196682014-07-23 13:47:29 -04007385 context->recordError(gl::Error(GL_INVALID_OPERATION));
7386 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007387 }
Geoff Langbfdea662014-07-23 14:16:32 -04007388
7389 // glDrawElementsInstanced
7390 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007391 }
7392}
7393
Kenneth Russell67ea1902014-10-06 16:44:50 -07007394GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007395{
7396 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7397
Geoff Langbfdea662014-07-23 14:16:32 -04007398 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007399 if (context)
7400 {
7401 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007402 {
Geoff Langb1196682014-07-23 13:47:29 -04007403 context->recordError(gl::Error(GL_INVALID_OPERATION));
7404 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007405 }
Geoff Langbfdea662014-07-23 14:16:32 -04007406
7407 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7408 {
Geoff Langb1196682014-07-23 13:47:29 -04007409 context->recordError(gl::Error(GL_INVALID_ENUM));
7410 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007411 }
7412
7413 if (flags != 0)
7414 {
Geoff Langb1196682014-07-23 13:47:29 -04007415 context->recordError(gl::Error(GL_INVALID_VALUE));
7416 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007417 }
7418
Geoff Lang882033e2014-09-30 11:26:07 -04007419 GLsync fenceSync = context->createFenceSync();
7420
7421 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7422 gl::Error error = fenceSyncObject->set(condition);
7423 if (error.isError())
7424 {
7425 context->deleteFenceSync(fenceSync);
7426 context->recordError(error);
7427 return NULL;
7428 }
7429
7430 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007431 }
7432
7433 return NULL;
7434}
7435
Kenneth Russell67ea1902014-10-06 16:44:50 -07007436GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007437{
7438 EVENT("(GLsync sync = 0x%0.8p)", sync);
7439
Geoff Langbfdea662014-07-23 14:16:32 -04007440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007441 if (context)
7442 {
7443 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007444 {
Geoff Langb1196682014-07-23 13:47:29 -04007445 context->recordError(gl::Error(GL_INVALID_OPERATION));
7446 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007447 }
Geoff Langbfdea662014-07-23 14:16:32 -04007448
7449 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007450 }
7451
7452 return GL_FALSE;
7453}
7454
Kenneth Russell67ea1902014-10-06 16:44:50 -07007455void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007456{
7457 EVENT("(GLsync sync = 0x%0.8p)", sync);
7458
Geoff Langbfdea662014-07-23 14:16:32 -04007459 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007460 if (context)
7461 {
7462 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007463 {
Geoff Langb1196682014-07-23 13:47:29 -04007464 context->recordError(gl::Error(GL_INVALID_OPERATION));
7465 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007466 }
Geoff Langbfdea662014-07-23 14:16:32 -04007467
7468 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7469 {
Geoff Langb1196682014-07-23 13:47:29 -04007470 context->recordError(gl::Error(GL_INVALID_VALUE));
7471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007472 }
7473
7474 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007475 }
7476}
7477
Kenneth Russell67ea1902014-10-06 16:44:50 -07007478GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007479{
7480 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7481 sync, flags, timeout);
7482
Geoff Langbfdea662014-07-23 14:16:32 -04007483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007484 if (context)
7485 {
7486 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007487 {
Geoff Langb1196682014-07-23 13:47:29 -04007488 context->recordError(gl::Error(GL_INVALID_OPERATION));
7489 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007490 }
Geoff Langbfdea662014-07-23 14:16:32 -04007491
7492 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7493 {
Geoff Langb1196682014-07-23 13:47:29 -04007494 context->recordError(gl::Error(GL_INVALID_VALUE));
7495 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007496 }
7497
7498 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7499
7500 if (!fenceSync)
7501 {
Geoff Langb1196682014-07-23 13:47:29 -04007502 context->recordError(gl::Error(GL_INVALID_VALUE));
7503 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007504 }
7505
Geoff Lang882033e2014-09-30 11:26:07 -04007506 GLenum result = GL_WAIT_FAILED;
7507 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7508 if (error.isError())
7509 {
7510 context->recordError(error);
7511 return GL_WAIT_FAILED;
7512 }
7513
7514 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007515 }
7516
7517 return GL_FALSE;
7518}
7519
Kenneth Russell67ea1902014-10-06 16:44:50 -07007520void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007521{
7522 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7523 sync, flags, timeout);
7524
Geoff Langbfdea662014-07-23 14:16:32 -04007525 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007526 if (context)
7527 {
7528 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007529 {
Geoff Langb1196682014-07-23 13:47:29 -04007530 context->recordError(gl::Error(GL_INVALID_OPERATION));
7531 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007532 }
Geoff Langbfdea662014-07-23 14:16:32 -04007533
7534 if (flags != 0)
7535 {
Geoff Langb1196682014-07-23 13:47:29 -04007536 context->recordError(gl::Error(GL_INVALID_VALUE));
7537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007538 }
7539
7540 if (timeout != GL_TIMEOUT_IGNORED)
7541 {
Geoff Langb1196682014-07-23 13:47:29 -04007542 context->recordError(gl::Error(GL_INVALID_VALUE));
7543 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007544 }
7545
7546 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7547
7548 if (!fenceSync)
7549 {
Geoff Langb1196682014-07-23 13:47:29 -04007550 context->recordError(gl::Error(GL_INVALID_VALUE));
7551 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007552 }
7553
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007554 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007555 if (error.isError())
7556 {
7557 context->recordError(error);
7558 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007559 }
7560}
7561
Kenneth Russell67ea1902014-10-06 16:44:50 -07007562void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007563{
7564 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7565 pname, params);
7566
Geoff Langbfdea662014-07-23 14:16:32 -04007567 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007568 if (context)
7569 {
7570 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007571 {
Geoff Langb1196682014-07-23 13:47:29 -04007572 context->recordError(gl::Error(GL_INVALID_OPERATION));
7573 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007574 }
Geoff Langbfdea662014-07-23 14:16:32 -04007575
7576 GLenum nativeType;
7577 unsigned int numParams = 0;
7578 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7579 {
7580 return;
7581 }
7582
7583 if (nativeType == GL_INT_64_ANGLEX)
7584 {
7585 context->getInteger64v(pname, params);
7586 }
7587 else
7588 {
7589 CastStateValues(context, nativeType, pname, numParams, params);
7590 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007591 }
7592}
7593
Kenneth Russell67ea1902014-10-06 16:44:50 -07007594void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007595{
7596 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7597 sync, pname, bufSize, length, values);
7598
Geoff Langbfdea662014-07-23 14:16:32 -04007599 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007600 if (context)
7601 {
7602 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007603 {
Geoff Langb1196682014-07-23 13:47:29 -04007604 context->recordError(gl::Error(GL_INVALID_OPERATION));
7605 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007606 }
Geoff Langbfdea662014-07-23 14:16:32 -04007607
7608 if (bufSize < 0)
7609 {
Geoff Langb1196682014-07-23 13:47:29 -04007610 context->recordError(gl::Error(GL_INVALID_VALUE));
7611 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007612 }
7613
7614 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7615
7616 if (!fenceSync)
7617 {
Geoff Langb1196682014-07-23 13:47:29 -04007618 context->recordError(gl::Error(GL_INVALID_VALUE));
7619 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007620 }
7621
7622 switch (pname)
7623 {
7624 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007625 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7626 case GL_SYNC_FLAGS: values[0] = 0; break;
7627
Geoff Lang882033e2014-09-30 11:26:07 -04007628 case GL_SYNC_STATUS:
7629 {
7630 gl::Error error = fenceSync->getStatus(values);
7631 if (error.isError())
7632 {
7633 context->recordError(error);
7634 return;
7635 }
7636 break;
7637 }
7638
Geoff Langbfdea662014-07-23 14:16:32 -04007639 default:
Geoff Langb1196682014-07-23 13:47:29 -04007640 context->recordError(gl::Error(GL_INVALID_ENUM));
7641 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007642 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007643 }
7644}
7645
Kenneth Russell67ea1902014-10-06 16:44:50 -07007646void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007647{
7648 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7649 target, index, data);
7650
Geoff Langbfdea662014-07-23 14:16:32 -04007651 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007652 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007653 {
Geoff Langbfdea662014-07-23 14:16:32 -04007654 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007655 {
Geoff Langb1196682014-07-23 13:47:29 -04007656 context->recordError(gl::Error(GL_INVALID_OPERATION));
7657 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007658 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007659
Geoff Lang3a61c322014-07-10 13:01:54 -04007660 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007661 switch (target)
7662 {
7663 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7664 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7665 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007666 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7667 {
Geoff Langb1196682014-07-23 13:47:29 -04007668 context->recordError(gl::Error(GL_INVALID_VALUE));
7669 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007670 }
Geoff Langbfdea662014-07-23 14:16:32 -04007671 break;
Geoff Langb1196682014-07-23 13:47:29 -04007672
Geoff Langbfdea662014-07-23 14:16:32 -04007673 case GL_UNIFORM_BUFFER_START:
7674 case GL_UNIFORM_BUFFER_SIZE:
7675 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007676 if (index >= caps.maxUniformBufferBindings)
7677 {
Geoff Langb1196682014-07-23 13:47:29 -04007678 context->recordError(gl::Error(GL_INVALID_VALUE));
7679 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007680 }
Geoff Langbfdea662014-07-23 14:16:32 -04007681 break;
Geoff Langb1196682014-07-23 13:47:29 -04007682
Geoff Langbfdea662014-07-23 14:16:32 -04007683 default:
Geoff Langb1196682014-07-23 13:47:29 -04007684 context->recordError(gl::Error(GL_INVALID_ENUM));
7685 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007686 }
7687
7688 if (!(context->getIndexedInteger64v(target, index, data)))
7689 {
7690 GLenum nativeType;
7691 unsigned int numParams = 0;
7692 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007693 {
7694 context->recordError(gl::Error(GL_INVALID_ENUM));
7695 return;
7696 }
Shannon Woods15934d52013-08-19 14:28:49 -04007697
Geoff Langbfdea662014-07-23 14:16:32 -04007698 if (numParams == 0)
7699 return; // it is known that pname is valid, but there are no parameters to return
7700
7701 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007702 {
Geoff Langbfdea662014-07-23 14:16:32 -04007703 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007704
Geoff Langbfdea662014-07-23 14:16:32 -04007705 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007706
Geoff Langbfdea662014-07-23 14:16:32 -04007707 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007708 {
Geoff Langbfdea662014-07-23 14:16:32 -04007709 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007710 }
Geoff Langbfdea662014-07-23 14:16:32 -04007711
7712 delete [] intParams;
7713 }
7714 else
7715 {
7716 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007717 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007718 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007719 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007720}
7721
Kenneth Russell67ea1902014-10-06 16:44:50 -07007722void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007723{
7724 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7725 target, pname, params);
7726
Geoff Langbfdea662014-07-23 14:16:32 -04007727 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007728 if (context)
7729 {
7730 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007731 {
Geoff Langb1196682014-07-23 13:47:29 -04007732 context->recordError(gl::Error(GL_INVALID_OPERATION));
7733 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007734 }
Geoff Langbfdea662014-07-23 14:16:32 -04007735
7736 if (!gl::ValidBufferTarget(context, target))
7737 {
Geoff Langb1196682014-07-23 13:47:29 -04007738 context->recordError(gl::Error(GL_INVALID_ENUM));
7739 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007740 }
7741
7742 if (!gl::ValidBufferParameter(context, pname))
7743 {
Geoff Langb1196682014-07-23 13:47:29 -04007744 context->recordError(gl::Error(GL_INVALID_ENUM));
7745 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007746 }
7747
7748 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7749
7750 if (!buffer)
7751 {
7752 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007753 context->recordError(gl::Error(GL_INVALID_OPERATION));
7754 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007755 }
7756
7757 switch (pname)
7758 {
7759 case GL_BUFFER_USAGE:
7760 *params = static_cast<GLint64>(buffer->getUsage());
7761 break;
7762 case GL_BUFFER_SIZE:
7763 *params = buffer->getSize();
7764 break;
7765 case GL_BUFFER_ACCESS_FLAGS:
7766 *params = static_cast<GLint64>(buffer->getAccessFlags());
7767 break;
7768 case GL_BUFFER_MAPPED:
7769 *params = static_cast<GLint64>(buffer->isMapped());
7770 break;
7771 case GL_BUFFER_MAP_OFFSET:
7772 *params = buffer->getMapOffset();
7773 break;
7774 case GL_BUFFER_MAP_LENGTH:
7775 *params = buffer->getMapLength();
7776 break;
7777 default: UNREACHABLE(); break;
7778 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007779 }
7780}
7781
Kenneth Russell67ea1902014-10-06 16:44:50 -07007782void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007783{
7784 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7785
Geoff Langbfdea662014-07-23 14:16:32 -04007786 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007787 if (context)
7788 {
7789 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007790 {
Geoff Langb1196682014-07-23 13:47:29 -04007791 context->recordError(gl::Error(GL_INVALID_OPERATION));
7792 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007793 }
Geoff Langbfdea662014-07-23 14:16:32 -04007794
7795 if (count < 0)
7796 {
Geoff Langb1196682014-07-23 13:47:29 -04007797 context->recordError(gl::Error(GL_INVALID_VALUE));
7798 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007799 }
7800
7801 for (int i = 0; i < count; i++)
7802 {
7803 samplers[i] = context->createSampler();
7804 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007805 }
7806}
7807
Kenneth Russell67ea1902014-10-06 16:44:50 -07007808void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007809{
7810 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7811
Geoff Langbfdea662014-07-23 14:16:32 -04007812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007813 if (context)
7814 {
7815 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007816 {
Geoff Langb1196682014-07-23 13:47:29 -04007817 context->recordError(gl::Error(GL_INVALID_OPERATION));
7818 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007819 }
Geoff Langbfdea662014-07-23 14:16:32 -04007820
7821 if (count < 0)
7822 {
Geoff Langb1196682014-07-23 13:47:29 -04007823 context->recordError(gl::Error(GL_INVALID_VALUE));
7824 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007825 }
7826
7827 for (int i = 0; i < count; i++)
7828 {
7829 context->deleteSampler(samplers[i]);
7830 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007831 }
7832}
7833
Kenneth Russell67ea1902014-10-06 16:44:50 -07007834GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007835{
7836 EVENT("(GLuint sampler = %u)", sampler);
7837
Geoff Langbfdea662014-07-23 14:16:32 -04007838 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007839 if (context)
7840 {
7841 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007842 {
Geoff Langb1196682014-07-23 13:47:29 -04007843 context->recordError(gl::Error(GL_INVALID_OPERATION));
7844 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007845 }
Geoff Langbfdea662014-07-23 14:16:32 -04007846
7847 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007848 }
7849
7850 return GL_FALSE;
7851}
7852
Kenneth Russell67ea1902014-10-06 16:44:50 -07007853void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007854{
7855 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7856
Geoff Langbfdea662014-07-23 14:16:32 -04007857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007858 if (context)
7859 {
7860 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007861 {
Geoff Langb1196682014-07-23 13:47:29 -04007862 context->recordError(gl::Error(GL_INVALID_OPERATION));
7863 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007864 }
Geoff Langbfdea662014-07-23 14:16:32 -04007865
7866 if (sampler != 0 && !context->isSampler(sampler))
7867 {
Geoff Langb1196682014-07-23 13:47:29 -04007868 context->recordError(gl::Error(GL_INVALID_OPERATION));
7869 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007870 }
7871
Geoff Lang3a61c322014-07-10 13:01:54 -04007872 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007873 {
Geoff Langb1196682014-07-23 13:47:29 -04007874 context->recordError(gl::Error(GL_INVALID_VALUE));
7875 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007876 }
7877
7878 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007879 }
7880}
7881
Kenneth Russell67ea1902014-10-06 16:44:50 -07007882void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007883{
7884 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7885
Geoff Langbfdea662014-07-23 14:16:32 -04007886 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007887 if (context)
7888 {
7889 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007890 {
Geoff Langb1196682014-07-23 13:47:29 -04007891 context->recordError(gl::Error(GL_INVALID_OPERATION));
7892 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007893 }
Geoff Langbfdea662014-07-23 14:16:32 -04007894
Geoff Langb1196682014-07-23 13:47:29 -04007895 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007896 {
7897 return;
7898 }
7899
7900 if (!gl::ValidateTexParamParameters(context, pname, param))
7901 {
7902 return;
7903 }
7904
7905 if (!context->isSampler(sampler))
7906 {
Geoff Langb1196682014-07-23 13:47:29 -04007907 context->recordError(gl::Error(GL_INVALID_OPERATION));
7908 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007909 }
7910
7911 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007912 }
7913}
7914
Kenneth Russell67ea1902014-10-06 16:44:50 -07007915void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007916{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007917 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007918}
7919
Kenneth Russell67ea1902014-10-06 16:44:50 -07007920void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007921{
7922 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7923
Geoff Langbfdea662014-07-23 14:16:32 -04007924 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007925 if (context)
7926 {
7927 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007928 {
Geoff Langb1196682014-07-23 13:47:29 -04007929 context->recordError(gl::Error(GL_INVALID_OPERATION));
7930 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007931 }
Geoff Langbfdea662014-07-23 14:16:32 -04007932
Geoff Langb1196682014-07-23 13:47:29 -04007933 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007934 {
7935 return;
7936 }
7937
7938 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7939 {
7940 return;
7941 }
7942
7943 if (!context->isSampler(sampler))
7944 {
Geoff Langb1196682014-07-23 13:47:29 -04007945 context->recordError(gl::Error(GL_INVALID_OPERATION));
7946 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007947 }
7948
7949 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007950 }
7951}
7952
Kenneth Russell67ea1902014-10-06 16:44:50 -07007953void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007954{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007955 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007956}
7957
Kenneth Russell67ea1902014-10-06 16:44:50 -07007958void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007959{
7960 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7961
Geoff Langbfdea662014-07-23 14:16:32 -04007962 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007963 if (context)
7964 {
7965 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007966 {
Geoff Langb1196682014-07-23 13:47:29 -04007967 context->recordError(gl::Error(GL_INVALID_OPERATION));
7968 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007969 }
Geoff Langbfdea662014-07-23 14:16:32 -04007970
Geoff Langb1196682014-07-23 13:47:29 -04007971 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007972 {
7973 return;
7974 }
7975
7976 if (!context->isSampler(sampler))
7977 {
Geoff Langb1196682014-07-23 13:47:29 -04007978 context->recordError(gl::Error(GL_INVALID_OPERATION));
7979 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007980 }
7981
7982 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007983 }
7984}
7985
Kenneth Russell67ea1902014-10-06 16:44:50 -07007986void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007987{
7988 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
7989
Geoff Langbfdea662014-07-23 14:16:32 -04007990 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007991 if (context)
7992 {
7993 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007994 {
Geoff Langb1196682014-07-23 13:47:29 -04007995 context->recordError(gl::Error(GL_INVALID_OPERATION));
7996 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007997 }
Geoff Langbfdea662014-07-23 14:16:32 -04007998
Geoff Langb1196682014-07-23 13:47:29 -04007999 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008000 {
8001 return;
8002 }
8003
8004 if (!context->isSampler(sampler))
8005 {
Geoff Langb1196682014-07-23 13:47:29 -04008006 context->recordError(gl::Error(GL_INVALID_OPERATION));
8007 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008008 }
8009
8010 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008011 }
8012}
8013
Kenneth Russell67ea1902014-10-06 16:44:50 -07008014void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008015{
8016 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8017
Geoff Langbfdea662014-07-23 14:16:32 -04008018 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008019 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008020 {
Geoff Langbfdea662014-07-23 14:16:32 -04008021 if (context->getClientVersion() < 3)
8022 {
Geoff Langb1196682014-07-23 13:47:29 -04008023 context->recordError(gl::Error(GL_INVALID_OPERATION));
8024 return;
8025 }
8026
8027 if (index >= gl::MAX_VERTEX_ATTRIBS)
8028 {
8029 context->recordError(gl::Error(GL_INVALID_VALUE));
8030 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008031 }
8032
8033 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008034 }
8035}
8036
Kenneth Russell67ea1902014-10-06 16:44:50 -07008037void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008038{
8039 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8040
Geoff Langbfdea662014-07-23 14:16:32 -04008041 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008042 if (context)
8043 {
8044 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008045 {
Geoff Langb1196682014-07-23 13:47:29 -04008046 context->recordError(gl::Error(GL_INVALID_OPERATION));
8047 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008048 }
Geoff Langbfdea662014-07-23 14:16:32 -04008049
8050 switch (target)
8051 {
8052 case GL_TRANSFORM_FEEDBACK:
8053 {
8054 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8055 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8056 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8057 {
Geoff Langb1196682014-07-23 13:47:29 -04008058 context->recordError(gl::Error(GL_INVALID_OPERATION));
8059 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008060 }
8061
8062 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8063 if (context->getTransformFeedback(id) == NULL)
8064 {
Geoff Langb1196682014-07-23 13:47:29 -04008065 context->recordError(gl::Error(GL_INVALID_OPERATION));
8066 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008067 }
8068
8069 context->bindTransformFeedback(id);
8070 }
8071 break;
8072
8073 default:
Geoff Langb1196682014-07-23 13:47:29 -04008074 context->recordError(gl::Error(GL_INVALID_ENUM));
8075 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008076 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008077 }
8078}
8079
Kenneth Russell67ea1902014-10-06 16:44:50 -07008080void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008081{
8082 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8083
Geoff Langbfdea662014-07-23 14:16:32 -04008084 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008085 if (context)
8086 {
8087 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008088 {
Geoff Langb1196682014-07-23 13:47:29 -04008089 context->recordError(gl::Error(GL_INVALID_OPERATION));
8090 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008091 }
Geoff Langbfdea662014-07-23 14:16:32 -04008092
8093 for (int i = 0; i < n; i++)
8094 {
8095 context->deleteTransformFeedback(ids[i]);
8096 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008097 }
8098}
8099
Kenneth Russell67ea1902014-10-06 16:44:50 -07008100void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008101{
8102 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8103
Geoff Langbfdea662014-07-23 14:16:32 -04008104 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008105 if (context)
8106 {
8107 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008108 {
Geoff Langb1196682014-07-23 13:47:29 -04008109 context->recordError(gl::Error(GL_INVALID_OPERATION));
8110 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008111 }
Geoff Langbfdea662014-07-23 14:16:32 -04008112
8113 for (int i = 0; i < n; i++)
8114 {
8115 ids[i] = context->createTransformFeedback();
8116 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008117 }
8118}
8119
Kenneth Russell67ea1902014-10-06 16:44:50 -07008120GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008121{
8122 EVENT("(GLuint id = %u)", id);
8123
Geoff Langbfdea662014-07-23 14:16:32 -04008124 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008125 if (context)
8126 {
8127 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008128 {
Geoff Langb1196682014-07-23 13:47:29 -04008129 context->recordError(gl::Error(GL_INVALID_OPERATION));
8130 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008131 }
Geoff Langbfdea662014-07-23 14:16:32 -04008132
8133 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008134 }
8135
8136 return GL_FALSE;
8137}
8138
Kenneth Russell67ea1902014-10-06 16:44:50 -07008139void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008140{
8141 EVENT("(void)");
8142
Geoff Langbfdea662014-07-23 14:16:32 -04008143 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008144 if (context)
8145 {
8146 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008147 {
Geoff Langb1196682014-07-23 13:47:29 -04008148 context->recordError(gl::Error(GL_INVALID_OPERATION));
8149 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008150 }
Geoff Langbfdea662014-07-23 14:16:32 -04008151
8152 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8153 ASSERT(transformFeedback != NULL);
8154
8155 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8156 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8157 {
Geoff Langb1196682014-07-23 13:47:29 -04008158 context->recordError(gl::Error(GL_INVALID_OPERATION));
8159 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008160 }
8161
8162 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008163 }
8164}
8165
Kenneth Russell67ea1902014-10-06 16:44:50 -07008166void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008167{
8168 EVENT("(void)");
8169
Geoff Langbfdea662014-07-23 14:16:32 -04008170 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008171 if (context)
8172 {
8173 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008174 {
Geoff Langb1196682014-07-23 13:47:29 -04008175 context->recordError(gl::Error(GL_INVALID_OPERATION));
8176 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008177 }
Geoff Langbfdea662014-07-23 14:16:32 -04008178
8179 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8180 ASSERT(transformFeedback != NULL);
8181
8182 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8183 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8184 {
Geoff Langb1196682014-07-23 13:47:29 -04008185 context->recordError(gl::Error(GL_INVALID_OPERATION));
8186 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008187 }
8188
8189 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008190 }
8191}
8192
Kenneth Russell67ea1902014-10-06 16:44:50 -07008193void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008194{
8195 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8196 program, bufSize, length, binaryFormat, binary);
8197
Geoff Langbfdea662014-07-23 14:16:32 -04008198 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008199 if (context)
8200 {
8201 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008202 {
Geoff Langb1196682014-07-23 13:47:29 -04008203 context->recordError(gl::Error(GL_INVALID_OPERATION));
8204 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008205 }
Geoff Langbfdea662014-07-23 14:16:32 -04008206
8207 // glGetProgramBinary
8208 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008209 }
8210}
8211
Kenneth Russell67ea1902014-10-06 16:44:50 -07008212void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008213{
8214 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8215 program, binaryFormat, binary, length);
8216
Geoff Langbfdea662014-07-23 14:16:32 -04008217 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008218 if (context)
8219 {
8220 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008221 {
Geoff Langb1196682014-07-23 13:47:29 -04008222 context->recordError(gl::Error(GL_INVALID_OPERATION));
8223 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008224 }
Geoff Langbfdea662014-07-23 14:16:32 -04008225
8226 // glProgramBinary
8227 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008228 }
8229}
8230
Kenneth Russell67ea1902014-10-06 16:44:50 -07008231void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008232{
8233 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8234 program, pname, value);
8235
Geoff Langbfdea662014-07-23 14:16:32 -04008236 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008237 if (context)
8238 {
8239 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008240 {
Geoff Langb1196682014-07-23 13:47:29 -04008241 context->recordError(gl::Error(GL_INVALID_OPERATION));
8242 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008243 }
Geoff Langbfdea662014-07-23 14:16:32 -04008244
8245 // glProgramParameteri
8246 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008247 }
8248}
8249
Kenneth Russell67ea1902014-10-06 16:44:50 -07008250void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008251{
8252 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8253 target, numAttachments, attachments);
8254
Geoff Langbfdea662014-07-23 14:16:32 -04008255 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008256 if (context)
8257 {
8258 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008259 {
Geoff Langb1196682014-07-23 13:47:29 -04008260 context->recordError(gl::Error(GL_INVALID_OPERATION));
8261 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008262 }
Geoff Langbfdea662014-07-23 14:16:32 -04008263
8264 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8265 {
8266 return;
8267 }
8268
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008269 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008270 ASSERT(framebuffer);
8271
8272 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008273 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008274 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8275 if (error.isError())
8276 {
8277 context->recordError(error);
8278 return;
8279 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008281 }
8282}
8283
Kenneth Russell67ea1902014-10-06 16:44:50 -07008284void GL_APIENTRY 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 +00008285{
8286 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8287 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8288 target, numAttachments, attachments, x, y, width, height);
8289
Geoff Langbfdea662014-07-23 14:16:32 -04008290 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008291 if (context)
8292 {
8293 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008294 {
Geoff Langb1196682014-07-23 13:47:29 -04008295 context->recordError(gl::Error(GL_INVALID_OPERATION));
8296 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008297 }
Geoff Langbfdea662014-07-23 14:16:32 -04008298
8299 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8300 {
8301 return;
8302 }
8303
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008304 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008305 ASSERT(framebuffer);
8306
8307 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008308 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008309 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8310 if (error.isError())
8311 {
8312 context->recordError(error);
8313 return;
8314 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008315 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008316 }
8317}
8318
Kenneth Russell67ea1902014-10-06 16:44:50 -07008319void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008320{
8321 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8322 target, levels, internalformat, width, height);
8323
Geoff Langbfdea662014-07-23 14:16:32 -04008324 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008325 if (context)
8326 {
8327 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008328 {
Geoff Langb1196682014-07-23 13:47:29 -04008329 context->recordError(gl::Error(GL_INVALID_OPERATION));
8330 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008331 }
Geoff Langbfdea662014-07-23 14:16:32 -04008332
8333 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8334 {
8335 return;
8336 }
8337
8338 switch (target)
8339 {
8340 case GL_TEXTURE_2D:
8341 {
8342 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008343 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8344 if (error.isError())
8345 {
8346 context->recordError(error);
8347 return;
8348 }
Geoff Langbfdea662014-07-23 14:16:32 -04008349 }
8350 break;
8351
8352 case GL_TEXTURE_CUBE_MAP:
8353 {
8354 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008355 gl::Error error = textureCube->storage(levels, internalformat, width);
8356 if (error.isError())
8357 {
8358 context->recordError(error);
8359 return;
8360 }
Geoff Langbfdea662014-07-23 14:16:32 -04008361 }
8362 break;
8363
8364 default:
Geoff Langb1196682014-07-23 13:47:29 -04008365 context->recordError(gl::Error(GL_INVALID_ENUM));
8366 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008367 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008368 }
8369}
8370
Kenneth Russell67ea1902014-10-06 16:44:50 -07008371void 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 +00008372{
8373 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8374 "GLsizei height = %d, GLsizei depth = %d)",
8375 target, levels, internalformat, width, height, depth);
8376
Geoff Langbfdea662014-07-23 14:16:32 -04008377 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008378 if (context)
8379 {
8380 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008381 {
Geoff Langb1196682014-07-23 13:47:29 -04008382 context->recordError(gl::Error(GL_INVALID_OPERATION));
8383 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008384 }
Geoff Langbfdea662014-07-23 14:16:32 -04008385
8386 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8387 {
8388 return;
8389 }
8390
8391 switch (target)
8392 {
8393 case GL_TEXTURE_3D:
8394 {
8395 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008396 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8397 if (error.isError())
8398 {
8399 context->recordError(error);
8400 return;
8401 }
Geoff Langbfdea662014-07-23 14:16:32 -04008402 }
8403 break;
8404
8405 case GL_TEXTURE_2D_ARRAY:
8406 {
8407 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008408 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8409 if (error.isError())
8410 {
8411 context->recordError(error);
8412 return;
8413 }
Geoff Langbfdea662014-07-23 14:16:32 -04008414 }
8415 break;
8416
8417 default:
8418 UNREACHABLE();
8419 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008420 }
8421}
8422
Kenneth Russell67ea1902014-10-06 16:44:50 -07008423void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008424{
8425 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8426 "GLint* params = 0x%0.8p)",
8427 target, internalformat, pname, bufSize, params);
8428
Geoff Langbfdea662014-07-23 14:16:32 -04008429 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008430 if (context)
8431 {
8432 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008433 {
Geoff Langb1196682014-07-23 13:47:29 -04008434 context->recordError(gl::Error(GL_INVALID_OPERATION));
8435 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008436 }
Geoff Langbfdea662014-07-23 14:16:32 -04008437
8438 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8439 if (!formatCaps.renderable)
8440 {
Geoff Langb1196682014-07-23 13:47:29 -04008441 context->recordError(gl::Error(GL_INVALID_ENUM));
8442 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008443 }
8444
8445 if (target != GL_RENDERBUFFER)
8446 {
Geoff Langb1196682014-07-23 13:47:29 -04008447 context->recordError(gl::Error(GL_INVALID_ENUM));
8448 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008449 }
8450
8451 if (bufSize < 0)
8452 {
Geoff Langb1196682014-07-23 13:47:29 -04008453 context->recordError(gl::Error(GL_INVALID_VALUE));
8454 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008455 }
8456
8457 switch (pname)
8458 {
8459 case GL_NUM_SAMPLE_COUNTS:
8460 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008461 {
8462 *params = formatCaps.sampleCounts.size();
8463 }
Geoff Langbfdea662014-07-23 14:16:32 -04008464 break;
Geoff Langb1196682014-07-23 13:47:29 -04008465
Geoff Langbfdea662014-07-23 14:16:32 -04008466 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008467 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008468 break;
Geoff Langb1196682014-07-23 13:47:29 -04008469
Geoff Langbfdea662014-07-23 14:16:32 -04008470 default:
Geoff Langb1196682014-07-23 13:47:29 -04008471 context->recordError(gl::Error(GL_INVALID_ENUM));
8472 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008473 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008474 }
8475}
8476
8477// Extension functions
8478
Kenneth Russell67ea1902014-10-06 16:44:50 -07008479void 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 +00008480 GLbitfield mask, GLenum filter)
8481{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008482 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008483 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8484 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8485 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8486
Geoff Langbfdea662014-07-23 14:16:32 -04008487 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008488 if (context)
8489 {
8490 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8491 dstX0, dstY0, dstX1, dstY1, mask, filter,
8492 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008493 {
Geoff Langbfdea662014-07-23 14:16:32 -04008494 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008495 }
Geoff Langbfdea662014-07-23 14:16:32 -04008496
Geoff Lang64839152014-08-26 16:23:25 -04008497 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8498 mask, filter);
8499 if (error.isError())
8500 {
8501 context->recordError(error);
8502 return;
8503 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008504 }
8505}
8506
Kenneth Russell67ea1902014-10-06 16:44:50 -07008507void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008508 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008509{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008510 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008511 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008512 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008513 target, level, internalformat, width, height, depth, border, format, type, pixels);
8514
Geoff Langbfdea662014-07-23 14:16:32 -04008515 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008516}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008517
Kenneth Russell67ea1902014-10-06 16:44:50 -07008518void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008519 GLenum *binaryFormat, void *binary)
8520{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008521 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 +00008522 program, bufSize, length, binaryFormat, binary);
8523
Geoff Langbfdea662014-07-23 14:16:32 -04008524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008525 if (context)
8526 {
8527 gl::Program *programObject = context->getProgram(program);
8528
8529 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008530 {
Geoff Langb1196682014-07-23 13:47:29 -04008531 context->recordError(gl::Error(GL_INVALID_OPERATION));
8532 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008533 }
Geoff Langbfdea662014-07-23 14:16:32 -04008534
8535 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8536
8537 if (!programBinary)
8538 {
Geoff Langb1196682014-07-23 13:47:29 -04008539 context->recordError(gl::Error(GL_INVALID_OPERATION));
8540 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008541 }
8542
Geoff Langb543aff2014-09-30 14:52:54 -04008543 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8544 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008545 {
Geoff Langb543aff2014-09-30 14:52:54 -04008546 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008547 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008548 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008549 }
8550}
8551
Kenneth Russell67ea1902014-10-06 16:44:50 -07008552void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008553 const void *binary, GLint length)
8554{
8555 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8556 program, binaryFormat, binary, length);
8557
Geoff Langbfdea662014-07-23 14:16:32 -04008558 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008559 if (context)
8560 {
Geoff Lang900013c2014-07-07 11:32:19 -04008561 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8562 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008563 {
Geoff Langb1196682014-07-23 13:47:29 -04008564 context->recordError(gl::Error(GL_INVALID_ENUM));
8565 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008566 }
Geoff Langbfdea662014-07-23 14:16:32 -04008567
8568 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008569 if (!programObject)
8570 {
Geoff Langb1196682014-07-23 13:47:29 -04008571 context->recordError(gl::Error(GL_INVALID_OPERATION));
8572 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008573 }
8574
Geoff Langb543aff2014-09-30 14:52:54 -04008575 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8576 if (error.isError())
8577 {
8578 context->recordError(error);
8579 return;
8580 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008581 }
8582}
8583
Kenneth Russell67ea1902014-10-06 16:44:50 -07008584void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008585{
8586 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8587
Geoff Langbfdea662014-07-23 14:16:32 -04008588 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008589 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008590 {
Geoff Langbfdea662014-07-23 14:16:32 -04008591 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008592 {
Geoff Langb1196682014-07-23 13:47:29 -04008593 context->recordError(gl::Error(GL_INVALID_VALUE));
8594 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008595 }
8596
Jamie Madill48faf802014-11-06 15:27:22 -05008597 ASSERT(context->getState().getDrawFramebuffer());
8598
Geoff Langbfdea662014-07-23 14:16:32 -04008599 if (context->getState().getDrawFramebuffer()->id() == 0)
8600 {
8601 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008602 {
Geoff Langb1196682014-07-23 13:47:29 -04008603 context->recordError(gl::Error(GL_INVALID_OPERATION));
8604 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008605 }
8606
Geoff Langbfdea662014-07-23 14:16:32 -04008607 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008608 {
Geoff Langb1196682014-07-23 13:47:29 -04008609 context->recordError(gl::Error(GL_INVALID_OPERATION));
8610 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008611 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008612 }
Geoff Langbfdea662014-07-23 14:16:32 -04008613 else
8614 {
8615 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8616 {
8617 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8618 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8619 {
Geoff Langb1196682014-07-23 13:47:29 -04008620 context->recordError(gl::Error(GL_INVALID_OPERATION));
8621 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008622 }
8623 }
8624 }
8625
8626 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -05008627 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04008628
8629 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8630 {
8631 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8632 }
8633
8634 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8635 {
8636 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8637 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008638 }
8639}
8640
Kenneth Russell67ea1902014-10-06 16:44:50 -07008641void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008642{
8643 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8644
Geoff Langbfdea662014-07-23 14:16:32 -04008645 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008646 if (context)
8647 {
8648 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008649 {
Geoff Langb1196682014-07-23 13:47:29 -04008650 context->recordError(gl::Error(GL_INVALID_ENUM));
8651 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008652 }
Geoff Langbfdea662014-07-23 14:16:32 -04008653
8654 if (pname != GL_BUFFER_MAP_POINTER)
8655 {
Geoff Langb1196682014-07-23 13:47:29 -04008656 context->recordError(gl::Error(GL_INVALID_ENUM));
8657 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008658 }
8659
8660 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8661
8662 if (!buffer || !buffer->isMapped())
8663 {
8664 *params = NULL;
8665 }
8666 else
8667 {
8668 *params = buffer->getMapPointer();
8669 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008670 }
8671}
8672
Kenneth Russell67ea1902014-10-06 16:44:50 -07008673void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008674{
8675 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8676
Geoff Langbfdea662014-07-23 14:16:32 -04008677 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008678 if (context)
8679 {
8680 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008681 {
Geoff Langb1196682014-07-23 13:47:29 -04008682 context->recordError(gl::Error(GL_INVALID_ENUM));
8683 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008684 }
Geoff Langbfdea662014-07-23 14:16:32 -04008685
8686 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8687
8688 if (buffer == NULL)
8689 {
Geoff Langb1196682014-07-23 13:47:29 -04008690 context->recordError(gl::Error(GL_INVALID_OPERATION));
8691 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008692 }
8693
8694 if (access != GL_WRITE_ONLY_OES)
8695 {
Geoff Langb1196682014-07-23 13:47:29 -04008696 context->recordError(gl::Error(GL_INVALID_ENUM));
8697 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008698 }
8699
8700 if (buffer->isMapped())
8701 {
Geoff Langb1196682014-07-23 13:47:29 -04008702 context->recordError(gl::Error(GL_INVALID_OPERATION));
8703 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008704 }
8705
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008706 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8707 if (error.isError())
8708 {
8709 context->recordError(error);
8710 return NULL;
8711 }
8712
8713 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008714 }
8715
8716 return NULL;
8717}
8718
Kenneth Russell67ea1902014-10-06 16:44:50 -07008719GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008720{
8721 EVENT("(GLenum target = 0x%X)", target);
8722
Geoff Langbfdea662014-07-23 14:16:32 -04008723 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008724 if (context)
8725 {
8726 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008727 {
Geoff Langb1196682014-07-23 13:47:29 -04008728 context->recordError(gl::Error(GL_INVALID_ENUM));
8729 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008730 }
Geoff Langbfdea662014-07-23 14:16:32 -04008731
8732 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8733
8734 if (buffer == NULL || !buffer->isMapped())
8735 {
Geoff Langb1196682014-07-23 13:47:29 -04008736 context->recordError(gl::Error(GL_INVALID_OPERATION));
8737 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008738 }
8739
8740 // TODO: detect if we had corruption. if so, throw an error and return false.
8741
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008742 gl::Error error = buffer->unmap();
8743 if (error.isError())
8744 {
8745 context->recordError(error);
8746 return GL_FALSE;
8747 }
Geoff Langbfdea662014-07-23 14:16:32 -04008748
8749 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008750 }
8751
8752 return GL_FALSE;
8753}
8754
Kenneth Russell67ea1902014-10-06 16:44:50 -07008755void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008756{
8757 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8758 target, offset, length, access);
8759
Geoff Langbfdea662014-07-23 14:16:32 -04008760 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008761 if (context)
8762 {
8763 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008764 {
Geoff Langb1196682014-07-23 13:47:29 -04008765 context->recordError(gl::Error(GL_INVALID_ENUM));
8766 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008767 }
Geoff Langbfdea662014-07-23 14:16:32 -04008768
8769 if (offset < 0 || length < 0)
8770 {
Geoff Langb1196682014-07-23 13:47:29 -04008771 context->recordError(gl::Error(GL_INVALID_VALUE));
8772 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008773 }
8774
8775 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8776
8777 if (buffer == NULL)
8778 {
Geoff Langb1196682014-07-23 13:47:29 -04008779 context->recordError(gl::Error(GL_INVALID_OPERATION));
8780 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008781 }
8782
8783 // Check for buffer overflow
8784 size_t offsetSize = static_cast<size_t>(offset);
8785 size_t lengthSize = static_cast<size_t>(length);
8786
8787 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8788 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8789 {
Geoff Langb1196682014-07-23 13:47:29 -04008790 context->recordError(gl::Error(GL_INVALID_VALUE));
8791 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008792 }
8793
8794 // Check for invalid bits in the mask
8795 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8796 GL_MAP_WRITE_BIT |
8797 GL_MAP_INVALIDATE_RANGE_BIT |
8798 GL_MAP_INVALIDATE_BUFFER_BIT |
8799 GL_MAP_FLUSH_EXPLICIT_BIT |
8800 GL_MAP_UNSYNCHRONIZED_BIT;
8801
8802 if (access & ~(allAccessBits))
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 if (length == 0 || buffer->isMapped())
8809 {
Geoff Langb1196682014-07-23 13:47:29 -04008810 context->recordError(gl::Error(GL_INVALID_OPERATION));
8811 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008812 }
8813
8814 // Check for invalid bit combinations
8815 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8816 {
Geoff Langb1196682014-07-23 13:47:29 -04008817 context->recordError(gl::Error(GL_INVALID_OPERATION));
8818 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008819 }
8820
8821 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8822 GL_MAP_INVALIDATE_BUFFER_BIT |
8823 GL_MAP_UNSYNCHRONIZED_BIT;
8824
8825 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8826 {
Geoff Langb1196682014-07-23 13:47:29 -04008827 context->recordError(gl::Error(GL_INVALID_OPERATION));
8828 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008829 }
8830
8831 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8832 {
Geoff Langb1196682014-07-23 13:47:29 -04008833 context->recordError(gl::Error(GL_INVALID_OPERATION));
8834 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008835 }
8836
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008837 gl::Error error = buffer->mapRange(offset, length, access);
8838 if (error.isError())
8839 {
8840 context->recordError(error);
8841 return NULL;
8842 }
8843
8844 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008845 }
8846
8847 return NULL;
8848}
8849
Kenneth Russell67ea1902014-10-06 16:44:50 -07008850void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008851{
8852 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8853
Geoff Langbfdea662014-07-23 14:16:32 -04008854 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008855 if (context)
8856 {
8857 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008858 {
Geoff Langb1196682014-07-23 13:47:29 -04008859 context->recordError(gl::Error(GL_INVALID_VALUE));
8860 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008861 }
Geoff Langbfdea662014-07-23 14:16:32 -04008862
8863 if (!gl::ValidBufferTarget(context, target))
8864 {
Geoff Langb1196682014-07-23 13:47:29 -04008865 context->recordError(gl::Error(GL_INVALID_ENUM));
8866 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008867 }
8868
8869 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8870
8871 if (buffer == NULL)
8872 {
Geoff Langb1196682014-07-23 13:47:29 -04008873 context->recordError(gl::Error(GL_INVALID_OPERATION));
8874 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008875 }
8876
8877 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8878 {
Geoff Langb1196682014-07-23 13:47:29 -04008879 context->recordError(gl::Error(GL_INVALID_OPERATION));
8880 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008881 }
8882
8883 // Check for buffer overflow
8884 size_t offsetSize = static_cast<size_t>(offset);
8885 size_t lengthSize = static_cast<size_t>(length);
8886
8887 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8888 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8889 {
Geoff Langb1196682014-07-23 13:47:29 -04008890 context->recordError(gl::Error(GL_INVALID_VALUE));
8891 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008892 }
8893
8894 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008895 }
8896}
8897
Kenneth Russell67ea1902014-10-06 16:44:50 -07008898__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008899{
8900 struct Extension
8901 {
8902 const char *name;
8903 __eglMustCastToProperFunctionPointerType address;
8904 };
8905
8906 static const Extension glExtensions[] =
8907 {
8908 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008909 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008910 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008911 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8912 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8913 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8914 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8915 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8916 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8917 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008918 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008919 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008920 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8921 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8922 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8923 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008924 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8925 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8926 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8927 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8928 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8929 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8930 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008931 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008932 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8933 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8934 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008935 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008936 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8937 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8938 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008939 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8940 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8941 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008942
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008943 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008944 {
8945 if (strcmp(procname, glExtensions[ext].name) == 0)
8946 {
8947 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8948 }
8949 }
8950
8951 return NULL;
8952}
8953
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008954// Non-public functions used by EGL
8955
Kenneth Russell67ea1902014-10-06 16:44:50 -07008956bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008957{
8958 EVENT("(egl::Surface* surface = 0x%0.8p)",
8959 surface);
8960
Geoff Langbfdea662014-07-23 14:16:32 -04008961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008962 if (context)
8963 {
8964 gl::Texture2D *textureObject = context->getTexture2D();
8965 ASSERT(textureObject != NULL);
8966
8967 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008968 {
Geoff Langbfdea662014-07-23 14:16:32 -04008969 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008970 }
Geoff Langbfdea662014-07-23 14:16:32 -04008971
8972 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008973 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008974
8975 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008976}
8977
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008978}