blob: f5282229f4cb6dddd3fbbf380b7f1891ee6230cd [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
624 return framebuffer->completeness();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000625 }
626
627 return 0;
628}
629
Kenneth Russell67ea1902014-10-06 16:44:50 -0700630void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000631{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000632 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000633
Geoff Langbfdea662014-07-23 14:16:32 -0400634 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400635 if (context)
636 {
637 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
638
639 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000640 {
Geoff Langb1196682014-07-23 13:47:29 -0400641 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000643 }
Geoff Langbfdea662014-07-23 14:16:32 -0400644
645 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
646 {
Geoff Langb1196682014-07-23 13:47:29 -0400647 context->recordError(gl::Error(GL_INVALID_VALUE));
648 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400649 }
650
Geoff Langcc79b8c2014-07-25 13:48:02 -0400651 gl::Error error = context->clear(mask);
652 if (error.isError())
653 {
654 context->recordError(error);
655 return;
656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000657 }
658}
659
Kenneth Russell67ea1902014-10-06 16:44:50 -0700660void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000662 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000663 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000664
Geoff Langbfdea662014-07-23 14:16:32 -0400665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400666 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000667 {
Geoff Langbfdea662014-07-23 14:16:32 -0400668 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 }
670}
671
Kenneth Russell67ea1902014-10-06 16:44:50 -0700672void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000673{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000674 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675
Geoff Langbfdea662014-07-23 14:16:32 -0400676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400677 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000678 {
Geoff Langbfdea662014-07-23 14:16:32 -0400679 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 }
681}
682
Kenneth Russell67ea1902014-10-06 16:44:50 -0700683void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000685 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686
Geoff Langbfdea662014-07-23 14:16:32 -0400687 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400688 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000689 {
Geoff Langbfdea662014-07-23 14:16:32 -0400690 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 }
692}
693
Kenneth Russell67ea1902014-10-06 16:44:50 -0700694void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000695{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000696 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000697 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000698
Geoff Langbfdea662014-07-23 14:16:32 -0400699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400700 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000701 {
Geoff Langbfdea662014-07-23 14:16:32 -0400702 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 }
704}
705
Kenneth Russell67ea1902014-10-06 16:44:50 -0700706void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000707{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000708 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709
Geoff Langbfdea662014-07-23 14:16:32 -0400710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400711 if (context)
712 {
713 gl::Shader *shaderObject = context->getShader(shader);
714
715 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000716 {
Geoff Langbfdea662014-07-23 14:16:32 -0400717 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langb1196682014-07-23 13:47:29 -0400719 context->recordError(gl::Error(GL_INVALID_OPERATION));
720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000721 }
Geoff Langbfdea662014-07-23 14:16:32 -0400722 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000723 {
Geoff Langb1196682014-07-23 13:47:29 -0400724 context->recordError(gl::Error(GL_INVALID_VALUE));
725 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000726 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000727 }
Geoff Langbfdea662014-07-23 14:16:32 -0400728
729 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000730 }
Geoff Langbfdea662014-07-23 14:16:32 -0400731}
732
Kenneth Russell67ea1902014-10-06 16:44:50 -0700733void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400734 GLint border, GLsizei imageSize, const GLvoid* data)
735{
736 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
737 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
738 target, level, internalformat, width, height, border, imageSize, data);
739
740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400741 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000742 {
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context->getClientVersion() < 3 &&
744 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
745 0, 0, width, height, border, GL_NONE, GL_NONE, data))
746 {
747 return;
748 }
749
750 if (context->getClientVersion() >= 3 &&
751 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
752 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
753 {
754 return;
755 }
756
Geoff Lang5d601382014-07-22 15:14:06 -0400757 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
758 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400759 {
Geoff Langb1196682014-07-23 13:47:29 -0400760 context->recordError(gl::Error(GL_INVALID_VALUE));
761 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400762 }
763
764 switch (target)
765 {
766 case GL_TEXTURE_2D:
767 {
768 gl::Texture2D *texture = context->getTexture2D();
Geoff Langb5348332014-09-02 13:16:34 -0400769 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
770 if (error.isError())
771 {
772 context->recordError(error);
773 return;
774 }
Geoff Langbfdea662014-07-23 14:16:32 -0400775 }
776 break;
777
778 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
779 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
784 {
785 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langb5348332014-09-02 13:16:34 -0400786 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
787 if (error.isError())
788 {
789 context->recordError(error);
790 return;
791 }
Geoff Langbfdea662014-07-23 14:16:32 -0400792 }
793 break;
794
795 default:
Geoff Langb1196682014-07-23 13:47:29 -0400796 context->recordError(gl::Error(GL_INVALID_ENUM));
797 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400798 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000799 }
800}
801
Kenneth Russell67ea1902014-10-06 16:44:50 -0700802void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000803 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000804{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000805 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000806 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000807 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000808 target, level, xoffset, yoffset, width, height, format, imageSize, data);
809
Geoff Langbfdea662014-07-23 14:16:32 -0400810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400811 if (context)
812 {
813 if (context->getClientVersion() < 3 &&
814 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
815 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000816 {
Geoff Langbfdea662014-07-23 14:16:32 -0400817 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 }
Geoff Langbfdea662014-07-23 14:16:32 -0400819
820 if (context->getClientVersion() >= 3 &&
821 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
822 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
823 {
824 return;
825 }
826
Geoff Lang5d601382014-07-22 15:14:06 -0400827 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
828 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400829 {
Geoff Langb1196682014-07-23 13:47:29 -0400830 context->recordError(gl::Error(GL_INVALID_VALUE));
831 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400832 }
833
834 switch (target)
835 {
836 case GL_TEXTURE_2D:
837 {
838 gl::Texture2D *texture = context->getTexture2D();
Geoff Langb5348332014-09-02 13:16:34 -0400839 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
840 if (error.isError())
841 {
842 context->recordError(error);
843 return;
844 }
Geoff Langbfdea662014-07-23 14:16:32 -0400845 }
846 break;
847
848 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
849 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
854 {
855 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langb5348332014-09-02 13:16:34 -0400856 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
857 if (error.isError())
858 {
859 context->recordError(error);
860 return;
861 }
Geoff Langbfdea662014-07-23 14:16:32 -0400862 }
863 break;
864
865 default:
Geoff Langb1196682014-07-23 13:47:29 -0400866 context->recordError(gl::Error(GL_INVALID_ENUM));
867 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400868 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000869 }
870}
871
Kenneth Russell67ea1902014-10-06 16:44:50 -0700872void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000874 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000875 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000876 target, level, internalformat, x, y, width, height, border);
877
Geoff Langbfdea662014-07-23 14:16:32 -0400878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400879 if (context)
880 {
881 if (context->getClientVersion() < 3 &&
882 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
883 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000884 {
Geoff Langbfdea662014-07-23 14:16:32 -0400885 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 }
Geoff Langbfdea662014-07-23 14:16:32 -0400887
888 if (context->getClientVersion() >= 3 &&
889 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
890 0, 0, 0, x, y, width, height, border))
891 {
892 return;
893 }
894
895 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
896
897 switch (target)
898 {
899 case GL_TEXTURE_2D:
900 {
901 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400902 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
903 if (error.isError())
904 {
905 context->recordError(error);
906 return;
907 }
Geoff Langbfdea662014-07-23 14:16:32 -0400908 }
909 break;
910
911 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
912 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
917 {
918 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400919 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
920 if (error.isError())
921 {
922 context->recordError(error);
923 return;
924 }
Geoff Langbfdea662014-07-23 14:16:32 -0400925 }
926 break;
927
Geoff Langb1196682014-07-23 13:47:29 -0400928 default:
929 context->recordError(gl::Error(GL_INVALID_ENUM));
930 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400931 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000932 }
933}
934
Kenneth Russell67ea1902014-10-06 16:44:50 -0700935void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000937 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000938 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000939 target, level, xoffset, yoffset, x, y, width, height);
940
Geoff Langbfdea662014-07-23 14:16:32 -0400941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400942 if (context)
943 {
944 if (context->getClientVersion() < 3 &&
945 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
946 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000947 {
Geoff Langbfdea662014-07-23 14:16:32 -0400948 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000950
Geoff Langbfdea662014-07-23 14:16:32 -0400951 if (context->getClientVersion() >= 3 &&
952 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
953 xoffset, yoffset, 0, x, y, width, height, 0))
954 {
955 return;
956 }
957
958 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
959
960 switch (target)
961 {
962 case GL_TEXTURE_2D:
963 {
964 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400965 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
966 if (error.isError())
967 {
968 context->recordError(error);
969 return;
970 }
Geoff Langbfdea662014-07-23 14:16:32 -0400971 }
972 break;
973
974 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
975 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
980 {
981 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400982 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
983 if (error.isError())
984 {
985 context->recordError(error);
986 return;
987 }
Geoff Langbfdea662014-07-23 14:16:32 -0400988 }
989 break;
990
991 default:
Geoff Langb1196682014-07-23 13:47:29 -0400992 context->recordError(gl::Error(GL_INVALID_ENUM));
993 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400994 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000995 }
996}
997
Kenneth Russell67ea1902014-10-06 16:44:50 -0700998GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001000 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001
Geoff Langbfdea662014-07-23 14:16:32 -04001002 gl::Context *context = gl::getNonLostContext();
1003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001004 {
Geoff Langbfdea662014-07-23 14:16:32 -04001005 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 }
1007
1008 return 0;
1009}
1010
Kenneth Russell67ea1902014-10-06 16:44:50 -07001011GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001012{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001013 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014
Geoff Langbfdea662014-07-23 14:16:32 -04001015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001016 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001017 {
Geoff Langbfdea662014-07-23 14:16:32 -04001018 switch (type)
1019 {
1020 case GL_FRAGMENT_SHADER:
1021 case GL_VERTEX_SHADER:
1022 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001023
Geoff Langbfdea662014-07-23 14:16:32 -04001024 default:
Geoff Langb1196682014-07-23 13:47:29 -04001025 context->recordError(gl::Error(GL_INVALID_ENUM));
1026 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001027 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001028 }
1029
1030 return 0;
1031}
1032
Kenneth Russell67ea1902014-10-06 16:44:50 -07001033void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001034{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001035 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036
Geoff Langb1196682014-07-23 13:47:29 -04001037 gl::Context *context = gl::getNonLostContext();
1038 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001039 {
Geoff Langb1196682014-07-23 13:47:29 -04001040 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 case GL_FRONT:
1043 case GL_BACK:
1044 case GL_FRONT_AND_BACK:
1045 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001046
Geoff Langb1196682014-07-23 13:47:29 -04001047 default:
1048 context->recordError(gl::Error(GL_INVALID_ENUM));
1049 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001050 }
Geoff Langb1196682014-07-23 13:47:29 -04001051
1052 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001053 }
1054}
1055
Kenneth Russell67ea1902014-10-06 16:44:50 -07001056void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001057{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001058 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059
Geoff Langbfdea662014-07-23 14:16:32 -04001060 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001061 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001062 {
Geoff Langb1196682014-07-23 13:47:29 -04001063 if (n < 0)
1064 {
1065 context->recordError(gl::Error(GL_INVALID_VALUE));
1066 return;
1067 }
1068
Geoff Langbfdea662014-07-23 14:16:32 -04001069 for (int i = 0; i < n; i++)
1070 {
1071 context->deleteBuffer(buffers[i]);
1072 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001073 }
1074}
1075
Kenneth Russell67ea1902014-10-06 16:44:50 -07001076void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001077{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001078 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079
Geoff Langbfdea662014-07-23 14:16:32 -04001080 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001081 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001082 {
Geoff Langb1196682014-07-23 13:47:29 -04001083 if (n < 0)
1084 {
1085 context->recordError(gl::Error(GL_INVALID_VALUE));
1086 return;
1087 }
1088
Geoff Langbfdea662014-07-23 14:16:32 -04001089 for (int i = 0; i < n; i++)
1090 {
1091 context->deleteFenceNV(fences[i]);
1092 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001093 }
1094}
1095
Kenneth Russell67ea1902014-10-06 16:44:50 -07001096void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001097{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001098 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099
Geoff Langbfdea662014-07-23 14:16:32 -04001100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001101 if (context)
1102 {
Geoff Langb1196682014-07-23 13:47:29 -04001103 if (n < 0)
1104 {
1105 context->recordError(gl::Error(GL_INVALID_VALUE));
1106 return;
1107 }
1108
Geoff Langbfdea662014-07-23 14:16:32 -04001109 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001110 {
Geoff Langbfdea662014-07-23 14:16:32 -04001111 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 }
1115 }
1116 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001117}
1118
Kenneth Russell67ea1902014-10-06 16:44:50 -07001119void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001120{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001121 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122
Geoff Langbfdea662014-07-23 14:16:32 -04001123 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001124 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001125 {
Geoff Langb1196682014-07-23 13:47:29 -04001126 if (program == 0)
1127 {
1128 return;
1129 }
1130
Geoff Langbfdea662014-07-23 14:16:32 -04001131 if (!context->getProgram(program))
1132 {
1133 if(context->getShader(program))
1134 {
Geoff Langb1196682014-07-23 13:47:29 -04001135 context->recordError(gl::Error(GL_INVALID_OPERATION));
1136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001137 }
1138 else
1139 {
Geoff Langb1196682014-07-23 13:47:29 -04001140 context->recordError(gl::Error(GL_INVALID_VALUE));
1141 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001142 }
1143 }
1144
1145 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146 }
1147}
1148
Kenneth Russell67ea1902014-10-06 16:44:50 -07001149void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001150{
1151 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1152
Geoff Langbfdea662014-07-23 14:16:32 -04001153 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001154 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001155 {
Geoff Langb1196682014-07-23 13:47:29 -04001156 if (n < 0)
1157 {
1158 context->recordError(gl::Error(GL_INVALID_VALUE));
1159 return;
1160 }
1161
Geoff Langbfdea662014-07-23 14:16:32 -04001162 for (int i = 0; i < n; i++)
1163 {
1164 context->deleteQuery(ids[i]);
1165 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001166 }
1167}
1168
Kenneth Russell67ea1902014-10-06 16:44:50 -07001169void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001170{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001171 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172
Geoff Langbfdea662014-07-23 14:16:32 -04001173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001174 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001175 {
Geoff Langb1196682014-07-23 13:47:29 -04001176 if (n < 0)
1177 {
1178 context->recordError(gl::Error(GL_INVALID_VALUE));
1179 return;
1180 }
1181
Geoff Langbfdea662014-07-23 14:16:32 -04001182 for (int i = 0; i < n; i++)
1183 {
1184 context->deleteRenderbuffer(renderbuffers[i]);
1185 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001186 }
1187}
1188
Kenneth Russell67ea1902014-10-06 16:44:50 -07001189void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001190{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001191 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192
Geoff Langbfdea662014-07-23 14:16:32 -04001193 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001194 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001195 {
Geoff Langb1196682014-07-23 13:47:29 -04001196 if (shader == 0)
1197 {
1198 return;
1199 }
1200
Geoff Langbfdea662014-07-23 14:16:32 -04001201 if (!context->getShader(shader))
1202 {
1203 if(context->getProgram(shader))
1204 {
Geoff Langb1196682014-07-23 13:47:29 -04001205 context->recordError(gl::Error(GL_INVALID_OPERATION));
1206 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001207 }
1208 else
1209 {
Geoff Langb1196682014-07-23 13:47:29 -04001210 context->recordError(gl::Error(GL_INVALID_VALUE));
1211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001212 }
1213 }
1214
1215 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001216 }
1217}
1218
Kenneth Russell67ea1902014-10-06 16:44:50 -07001219void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001220{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001221 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222
Geoff Langbfdea662014-07-23 14:16:32 -04001223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001224 if (context)
1225 {
Geoff Langb1196682014-07-23 13:47:29 -04001226 if (n < 0)
1227 {
1228 context->recordError(gl::Error(GL_INVALID_VALUE));
1229 return;
1230 }
1231
Geoff Langbfdea662014-07-23 14:16:32 -04001232 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001233 {
Geoff Langbfdea662014-07-23 14:16:32 -04001234 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 }
1238 }
1239 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001240}
1241
Kenneth Russell67ea1902014-10-06 16:44:50 -07001242void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001243{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001244 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245
Geoff Langbfdea662014-07-23 14:16:32 -04001246 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001247 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001248 {
Geoff Langb1196682014-07-23 13:47:29 -04001249 switch (func)
1250 {
1251 case GL_NEVER:
1252 case GL_ALWAYS:
1253 case GL_LESS:
1254 case GL_LEQUAL:
1255 case GL_EQUAL:
1256 case GL_GREATER:
1257 case GL_GEQUAL:
1258 case GL_NOTEQUAL:
1259 context->getState().setDepthFunc(func);
1260 break;
1261
1262 default:
1263 context->recordError(gl::Error(GL_INVALID_ENUM));
1264 return;
1265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001266 }
1267}
1268
Kenneth Russell67ea1902014-10-06 16:44:50 -07001269void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001270{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001271 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272
Geoff Langbfdea662014-07-23 14:16:32 -04001273 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001274 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001275 {
Geoff Langbfdea662014-07-23 14:16:32 -04001276 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 }
1278}
1279
Kenneth Russell67ea1902014-10-06 16:44:50 -07001280void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001282 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283
Geoff Langbfdea662014-07-23 14:16:32 -04001284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001285 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001286 {
Geoff Langbfdea662014-07-23 14:16:32 -04001287 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 }
1289}
1290
Kenneth Russell67ea1902014-10-06 16:44:50 -07001291void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001293 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294
Geoff Langbfdea662014-07-23 14:16:32 -04001295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001297 {
Geoff Langbfdea662014-07-23 14:16:32 -04001298 gl::Program *programObject = context->getProgram(program);
1299 gl::Shader *shaderObject = context->getShader(shader);
1300
1301 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001302 {
Geoff Langbfdea662014-07-23 14:16:32 -04001303 gl::Shader *shaderByProgramHandle;
1304 shaderByProgramHandle = context->getShader(program);
1305 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001306 {
Geoff Langb1196682014-07-23 13:47:29 -04001307 context->recordError(gl::Error(GL_INVALID_VALUE));
1308 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001309 }
Geoff Langbfdea662014-07-23 14:16:32 -04001310 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001311 {
Geoff Langb1196682014-07-23 13:47:29 -04001312 context->recordError(gl::Error(GL_INVALID_OPERATION));
1313 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001314 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001315 }
Geoff Langbfdea662014-07-23 14:16:32 -04001316
1317 if (!shaderObject)
1318 {
1319 gl::Program *programByShaderHandle = context->getProgram(shader);
1320 if (!programByShaderHandle)
1321 {
Geoff Langb1196682014-07-23 13:47:29 -04001322 context->recordError(gl::Error(GL_INVALID_VALUE));
1323 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001324 }
1325 else
1326 {
Geoff Langb1196682014-07-23 13:47:29 -04001327 context->recordError(gl::Error(GL_INVALID_OPERATION));
1328 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001329 }
1330 }
1331
1332 if (!programObject->detachShader(shaderObject))
1333 {
Geoff Langb1196682014-07-23 13:47:29 -04001334 context->recordError(gl::Error(GL_INVALID_OPERATION));
1335 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001336 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001337 }
1338}
1339
Kenneth Russell67ea1902014-10-06 16:44:50 -07001340void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001342 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343
Geoff Langbfdea662014-07-23 14:16:32 -04001344 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001345 if (context)
1346 {
1347 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001348 {
Geoff Langb1196682014-07-23 13:47:29 -04001349 context->recordError(gl::Error(GL_INVALID_ENUM));
1350 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001351 }
Geoff Langbfdea662014-07-23 14:16:32 -04001352
1353 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001354 }
1355}
1356
Kenneth Russell67ea1902014-10-06 16:44:50 -07001357void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001359 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360
Geoff Langbfdea662014-07-23 14:16:32 -04001361 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001362 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001363 {
Geoff Langb1196682014-07-23 13:47:29 -04001364 if (index >= gl::MAX_VERTEX_ATTRIBS)
1365 {
1366 context->recordError(gl::Error(GL_INVALID_VALUE));
1367 return;
1368 }
1369
Geoff Langbfdea662014-07-23 14:16:32 -04001370 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001371 }
1372}
1373
Kenneth Russell67ea1902014-10-06 16:44:50 -07001374void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001375{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001376 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377
Geoff Langbfdea662014-07-23 14:16:32 -04001378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001379 if (context)
1380 {
Jamie Madill2b976812014-08-25 15:47:49 -04001381 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001382 {
Geoff Langbfdea662014-07-23 14:16:32 -04001383 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 }
Geoff Langbfdea662014-07-23 14:16:32 -04001385
Geoff Langc77e8c32014-09-08 16:28:24 -04001386 gl::Error error = context->drawArrays(mode, first, count, 0);
1387 if (error.isError())
1388 {
1389 context->recordError(error);
1390 return;
1391 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001392 }
1393}
1394
Kenneth Russell67ea1902014-10-06 16:44:50 -07001395void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001396{
1397 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1398
Geoff Langbfdea662014-07-23 14:16:32 -04001399 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001400 if (context)
1401 {
Geoff Lang87a93302014-09-16 13:29:43 -04001402 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001403 {
Geoff Langbfdea662014-07-23 14:16:32 -04001404 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 }
Geoff Langbfdea662014-07-23 14:16:32 -04001406
Geoff Langc77e8c32014-09-08 16:28:24 -04001407 gl::Error error = context->drawArrays(mode, first, count, primcount);
1408 if (error.isError())
1409 {
1410 context->recordError(error);
1411 return;
1412 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001413 }
1414}
1415
Kenneth Russell67ea1902014-10-06 16:44:50 -07001416void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001417{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001418 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001419 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001420
Geoff Langbfdea662014-07-23 14:16:32 -04001421 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001422 if (context)
1423 {
Jamie Madill2b976812014-08-25 15:47:49 -04001424 rx::RangeUI indexRange;
1425 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001426 {
Geoff Langbfdea662014-07-23 14:16:32 -04001427 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 }
Geoff Langbfdea662014-07-23 14:16:32 -04001429
Geoff Langc77e8c32014-09-08 16:28:24 -04001430 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1431 if (error.isError())
1432 {
1433 context->recordError(error);
1434 return;
1435 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001436 }
1437}
1438
Kenneth Russell67ea1902014-10-06 16:44:50 -07001439void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001440{
1441 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1442 mode, count, type, indices, primcount);
1443
Geoff Langbfdea662014-07-23 14:16:32 -04001444 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001445 if (context)
1446 {
Jamie Madill2b976812014-08-25 15:47:49 -04001447 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001448 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001449 {
Geoff Langbfdea662014-07-23 14:16:32 -04001450 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 }
Geoff Langbfdea662014-07-23 14:16:32 -04001452
Geoff Langc77e8c32014-09-08 16:28:24 -04001453 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1454 if (error.isError())
1455 {
1456 context->recordError(error);
1457 return;
1458 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001459 }
1460}
1461
Kenneth Russell67ea1902014-10-06 16:44:50 -07001462void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001463{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001464 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465
Geoff Langbfdea662014-07-23 14:16:32 -04001466 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001467 if (context)
1468 {
1469 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001470 {
Geoff Langb1196682014-07-23 13:47:29 -04001471 context->recordError(gl::Error(GL_INVALID_ENUM));
1472 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001473 }
Geoff Langbfdea662014-07-23 14:16:32 -04001474
1475 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001476 }
1477}
1478
Kenneth Russell67ea1902014-10-06 16:44:50 -07001479void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001481 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
Geoff Langbfdea662014-07-23 14:16:32 -04001483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001484 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001485 {
Geoff Langb1196682014-07-23 13:47:29 -04001486 if (index >= gl::MAX_VERTEX_ATTRIBS)
1487 {
1488 context->recordError(gl::Error(GL_INVALID_VALUE));
1489 return;
1490 }
1491
Geoff Langbfdea662014-07-23 14:16:32 -04001492 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001493 }
1494}
1495
Kenneth Russell67ea1902014-10-06 16:44:50 -07001496void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001497{
1498 EVENT("GLenum target = 0x%X)", target);
1499
Geoff Langbfdea662014-07-23 14:16:32 -04001500 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001501 if (context)
1502 {
1503 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001504 {
Geoff Langbfdea662014-07-23 14:16:32 -04001505 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 }
Geoff Langbfdea662014-07-23 14:16:32 -04001507
Geoff Lang5aad9672014-09-08 11:10:42 -04001508 gl::Error error = context->endQuery(target);
1509 if (error.isError())
1510 {
1511 context->recordError(error);
1512 return;
1513 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001514 }
1515}
1516
Kenneth Russell67ea1902014-10-06 16:44:50 -07001517void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001518{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001519 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520
Geoff Langbfdea662014-07-23 14:16:32 -04001521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001522 if (context)
1523 {
1524 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1525
1526 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001527 {
Geoff Langb1196682014-07-23 13:47:29 -04001528 context->recordError(gl::Error(GL_INVALID_OPERATION));
1529 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001530 }
Geoff Langbfdea662014-07-23 14:16:32 -04001531
1532 if (fenceObject->isFence() != GL_TRUE)
1533 {
Geoff Langb1196682014-07-23 13:47:29 -04001534 context->recordError(gl::Error(GL_INVALID_OPERATION));
1535 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001536 }
1537
1538 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001539 }
1540}
1541
Kenneth Russell67ea1902014-10-06 16:44:50 -07001542void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001543{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001544 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545
Geoff Langbfdea662014-07-23 14:16:32 -04001546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001547 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001548 {
Geoff Lang26298562014-10-01 10:49:03 -04001549 gl::Error error = context->sync(true);
1550 if (error.isError())
1551 {
1552 context->recordError(error);
1553 return;
1554 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555 }
1556}
1557
Kenneth Russell67ea1902014-10-06 16:44:50 -07001558void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001559{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001560 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561
Geoff Langbfdea662014-07-23 14:16:32 -04001562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001563 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001564 {
Geoff Lang26298562014-10-01 10:49:03 -04001565 gl::Error error = context->sync(false);
1566 if (error.isError())
1567 {
1568 context->recordError(error);
1569 return;
1570 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 }
1572}
1573
Kenneth Russell67ea1902014-10-06 16:44:50 -07001574void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001575{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001576 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001577 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001578
Geoff Langbfdea662014-07-23 14:16:32 -04001579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001580 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
Geoff Langb1196682014-07-23 13:47:29 -04001582 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1583 {
1584 context->recordError(gl::Error(GL_INVALID_ENUM));
1585 return;
1586 }
1587
Geoff Langbfdea662014-07-23 14:16:32 -04001588 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1589 {
1590 return;
1591 }
1592
1593 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1594 ASSERT(framebuffer);
1595
1596 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1597 {
1598 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1599 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1600 }
1601 else
1602 {
1603 switch (attachment)
1604 {
1605 case GL_DEPTH_ATTACHMENT:
1606 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1607 break;
1608 case GL_STENCIL_ATTACHMENT:
1609 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1610 break;
1611 case GL_DEPTH_STENCIL_ATTACHMENT:
1612 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1613 break;
1614 default:
1615 UNREACHABLE();
1616 break;
1617 }
1618 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001619 }
1620}
1621
Kenneth Russell67ea1902014-10-06 16:44:50 -07001622void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001623{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001624 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001625 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001626
Geoff Langbfdea662014-07-23 14:16:32 -04001627 gl::Context *context = gl::getNonLostContext();
1628 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001629 {
Geoff Langbfdea662014-07-23 14:16:32 -04001630 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 return;
1633 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001634
Geoff Langbfdea662014-07-23 14:16:32 -04001635 if (texture == 0)
1636 {
1637 textarget = GL_NONE;
1638 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001639
Geoff Langbfdea662014-07-23 14:16:32 -04001640 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1643 {
1644 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1645 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1646 }
1647 else
1648 {
1649 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001650 {
Geoff Langbfdea662014-07-23 14:16:32 -04001651 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1652 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1653 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001654 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001655 }
1656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001657}
1658
Kenneth Russell67ea1902014-10-06 16:44:50 -07001659void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001661 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001662
Geoff Langb1196682014-07-23 13:47:29 -04001663 gl::Context *context = gl::getNonLostContext();
1664 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665 {
Geoff Langb1196682014-07-23 13:47:29 -04001666 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001667 {
Geoff Langb1196682014-07-23 13:47:29 -04001668 case GL_CW:
1669 case GL_CCW:
1670 context->getState().setFrontFace(mode);
1671 break;
1672 default:
1673 context->recordError(gl::Error(GL_INVALID_ENUM));
1674 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001675 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001676 }
1677}
1678
Kenneth Russell67ea1902014-10-06 16:44:50 -07001679void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001680{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001681 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001682
Geoff Langbfdea662014-07-23 14:16:32 -04001683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001684 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685 {
Geoff Langb1196682014-07-23 13:47:29 -04001686 if (n < 0)
1687 {
1688 context->recordError(gl::Error(GL_INVALID_VALUE));
1689 return;
1690 }
1691
Geoff Langbfdea662014-07-23 14:16:32 -04001692 for (int i = 0; i < n; i++)
1693 {
1694 buffers[i] = context->createBuffer();
1695 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001696 }
1697}
1698
Kenneth Russell67ea1902014-10-06 16:44:50 -07001699void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001700{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001701 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001702
Geoff Langbfdea662014-07-23 14:16:32 -04001703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001704 if (context)
1705 {
1706 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001707 {
Geoff Langb1196682014-07-23 13:47:29 -04001708 context->recordError(gl::Error(GL_INVALID_ENUM));
1709 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 }
Geoff Langbfdea662014-07-23 14:16:32 -04001711
1712 gl::Texture *texture = context->getTargetTexture(target);
1713
1714 if (texture == NULL)
1715 {
Geoff Langb1196682014-07-23 13:47:29 -04001716 context->recordError(gl::Error(GL_INVALID_OPERATION));
1717 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001718 }
1719
1720 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1721 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001722 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001723
1724 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1725 // unsized formats or that are color renderable and filterable. Since we do not track if
1726 // the texture was created with sized or unsized format (only sized formats are stored),
1727 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1728 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1729 // textures since they're the only texture format that can be created with unsized formats
1730 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1731 // was the last version to use add them.
1732 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1733 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1734 internalFormat == GL_ALPHA8_EXT;
1735
Geoff Lang5d601382014-07-22 15:14:06 -04001736 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1737 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001738 {
Geoff Langb1196682014-07-23 13:47:29 -04001739 context->recordError(gl::Error(GL_INVALID_OPERATION));
1740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001741 }
1742
1743 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001744 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001745 {
Geoff Langb1196682014-07-23 13:47:29 -04001746 context->recordError(gl::Error(GL_INVALID_OPERATION));
1747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001748 }
1749
1750 // Non-power of 2 ES2 check
1751 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1752 {
1753 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001754 context->recordError(gl::Error(GL_INVALID_OPERATION));
1755 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001756 }
1757
1758 // Cube completeness check
1759 if (target == GL_TEXTURE_CUBE_MAP)
1760 {
1761 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1762 if (!textureCube->isCubeComplete())
1763 {
Geoff Langb1196682014-07-23 13:47:29 -04001764 context->recordError(gl::Error(GL_INVALID_OPERATION));
1765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001766 }
1767 }
1768
1769 texture->generateMipmaps();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001770 }
1771}
1772
Kenneth Russell67ea1902014-10-06 16:44:50 -07001773void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001774{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001775 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001776
Geoff Langbfdea662014-07-23 14:16:32 -04001777 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001778 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001779 {
Geoff Langb1196682014-07-23 13:47:29 -04001780 if (n < 0)
1781 {
1782 context->recordError(gl::Error(GL_INVALID_VALUE));
1783 return;
1784 }
1785
Geoff Langbfdea662014-07-23 14:16:32 -04001786 for (int i = 0; i < n; i++)
1787 {
1788 fences[i] = context->createFenceNV();
1789 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001790 }
1791}
1792
Kenneth Russell67ea1902014-10-06 16:44:50 -07001793void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001794{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001795 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001796
Geoff Langbfdea662014-07-23 14:16:32 -04001797 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001798 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799 {
Geoff Langb1196682014-07-23 13:47:29 -04001800 if (n < 0)
1801 {
1802 context->recordError(gl::Error(GL_INVALID_VALUE));
1803 return;
1804 }
1805
Geoff Langbfdea662014-07-23 14:16:32 -04001806 for (int i = 0; i < n; i++)
1807 {
1808 framebuffers[i] = context->createFramebuffer();
1809 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001810 }
1811}
1812
Kenneth Russell67ea1902014-10-06 16:44:50 -07001813void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001814{
1815 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1816
Geoff Langbfdea662014-07-23 14:16:32 -04001817 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001818 if (context)
1819 {
1820 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001821 {
Geoff Langb1196682014-07-23 13:47:29 -04001822 context->recordError(gl::Error(GL_INVALID_VALUE));
1823 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001824 }
Geoff Langbfdea662014-07-23 14:16:32 -04001825
1826 for (GLsizei i = 0; i < n; i++)
1827 {
1828 ids[i] = context->createQuery();
1829 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001830 }
1831}
1832
Kenneth Russell67ea1902014-10-06 16:44:50 -07001833void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001834{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001835 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001836
Geoff Langbfdea662014-07-23 14:16:32 -04001837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001838 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001839 {
Geoff Langb1196682014-07-23 13:47:29 -04001840 if (n < 0)
1841 {
1842 context->recordError(gl::Error(GL_INVALID_VALUE));
1843 return;
1844 }
1845
Geoff Langbfdea662014-07-23 14:16:32 -04001846 for (int i = 0; i < n; i++)
1847 {
1848 renderbuffers[i] = context->createRenderbuffer();
1849 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001850 }
1851}
1852
Kenneth Russell67ea1902014-10-06 16:44:50 -07001853void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001854{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001855 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001856
Geoff Langbfdea662014-07-23 14:16:32 -04001857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001858 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001859 {
Geoff Langb1196682014-07-23 13:47:29 -04001860 if (n < 0)
1861 {
1862 context->recordError(gl::Error(GL_INVALID_VALUE));
1863 return;
1864 }
1865
Geoff Langbfdea662014-07-23 14:16:32 -04001866 for (int i = 0; i < n; i++)
1867 {
1868 textures[i] = context->createTexture();
1869 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001870 }
1871}
1872
Kenneth Russell67ea1902014-10-06 16:44:50 -07001873void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001874{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001875 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001876 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001877 program, index, bufsize, length, size, type, name);
1878
Geoff Langbfdea662014-07-23 14:16:32 -04001879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001880 if (context)
1881 {
Geoff Langb1196682014-07-23 13:47:29 -04001882 if (bufsize < 0)
1883 {
1884 context->recordError(gl::Error(GL_INVALID_VALUE));
1885 return;
1886 }
1887
Geoff Langbfdea662014-07-23 14:16:32 -04001888 gl::Program *programObject = context->getProgram(program);
1889
1890 if (!programObject)
1891 {
1892 if (context->getShader(program))
1893 {
Geoff Langb1196682014-07-23 13:47:29 -04001894 context->recordError(gl::Error(GL_INVALID_OPERATION));
1895 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001896 }
1897 else
1898 {
Geoff Langb1196682014-07-23 13:47:29 -04001899 context->recordError(gl::Error(GL_INVALID_VALUE));
1900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001901 }
1902 }
1903
1904 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001905 {
Geoff Langb1196682014-07-23 13:47:29 -04001906 context->recordError(gl::Error(GL_INVALID_VALUE));
1907 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001908 }
1909
Geoff Langbfdea662014-07-23 14:16:32 -04001910 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911 }
1912}
1913
Kenneth Russell67ea1902014-10-06 16:44:50 -07001914void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001916 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001917 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001918 program, index, bufsize, length, size, type, name);
1919
Geoff Langbfdea662014-07-23 14:16:32 -04001920
1921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001922 if (context)
1923 {
Geoff Langb1196682014-07-23 13:47:29 -04001924 if (bufsize < 0)
1925 {
1926 context->recordError(gl::Error(GL_INVALID_VALUE));
1927 return;
1928 }
1929
Geoff Langbfdea662014-07-23 14:16:32 -04001930 gl::Program *programObject = context->getProgram(program);
1931
1932 if (!programObject)
1933 {
1934 if (context->getShader(program))
1935 {
Geoff Langb1196682014-07-23 13:47:29 -04001936 context->recordError(gl::Error(GL_INVALID_OPERATION));
1937 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001938 }
1939 else
1940 {
Geoff Langb1196682014-07-23 13:47:29 -04001941 context->recordError(gl::Error(GL_INVALID_VALUE));
1942 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001943 }
1944 }
1945
1946 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001947 {
Geoff Langb1196682014-07-23 13:47:29 -04001948 context->recordError(gl::Error(GL_INVALID_VALUE));
1949 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001950 }
1951
Geoff Langbfdea662014-07-23 14:16:32 -04001952 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001953 }
1954}
1955
Kenneth Russell67ea1902014-10-06 16:44:50 -07001956void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001957{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001958 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001959 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001960
Geoff Langbfdea662014-07-23 14:16:32 -04001961 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001962 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001963 {
Geoff Langb1196682014-07-23 13:47:29 -04001964 if (maxcount < 0)
1965 {
1966 context->recordError(gl::Error(GL_INVALID_VALUE));
1967 return;
1968 }
1969
Geoff Langbfdea662014-07-23 14:16:32 -04001970 gl::Program *programObject = context->getProgram(program);
1971
1972 if (!programObject)
1973 {
1974 if (context->getShader(program))
1975 {
Geoff Langb1196682014-07-23 13:47:29 -04001976 context->recordError(gl::Error(GL_INVALID_OPERATION));
1977 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001978 }
1979 else
1980 {
Geoff Langb1196682014-07-23 13:47:29 -04001981 context->recordError(gl::Error(GL_INVALID_VALUE));
1982 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001983 }
1984 }
1985
1986 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001987 }
1988}
1989
Kenneth Russell67ea1902014-10-06 16:44:50 -07001990GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001991{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001992 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001993
Geoff Langbfdea662014-07-23 14:16:32 -04001994 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001995 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001996 {
Geoff Langbfdea662014-07-23 14:16:32 -04001997 gl::Program *programObject = context->getProgram(program);
1998
1999 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002000 {
Geoff Langbfdea662014-07-23 14:16:32 -04002001 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002002 {
Geoff Langb1196682014-07-23 13:47:29 -04002003 context->recordError(gl::Error(GL_INVALID_OPERATION));
2004 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002005 }
Geoff Langbfdea662014-07-23 14:16:32 -04002006 else
2007 {
Geoff Langb1196682014-07-23 13:47:29 -04002008 context->recordError(gl::Error(GL_INVALID_VALUE));
2009 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002010 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002011 }
Geoff Langbfdea662014-07-23 14:16:32 -04002012
2013 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2014 if (!programObject->isLinked() || !programBinary)
2015 {
Geoff Langb1196682014-07-23 13:47:29 -04002016 context->recordError(gl::Error(GL_INVALID_OPERATION));
2017 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002018 }
2019
2020 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002021 }
2022
2023 return -1;
2024}
2025
Kenneth Russell67ea1902014-10-06 16:44:50 -07002026void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002027{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002028 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029
Geoff Langbfdea662014-07-23 14:16:32 -04002030 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002031 if (context)
2032 {
2033 GLenum nativeType;
2034 unsigned int numParams = 0;
2035 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002036 {
Geoff Langbfdea662014-07-23 14:16:32 -04002037 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002038 }
Geoff Langbfdea662014-07-23 14:16:32 -04002039
2040 if (nativeType == GL_BOOL)
2041 {
2042 context->getBooleanv(pname, params);
2043 }
2044 else
2045 {
2046 CastStateValues(context, nativeType, pname, numParams, params);
2047 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002048 }
2049}
2050
Kenneth Russell67ea1902014-10-06 16:44:50 -07002051void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002052{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002053 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002054
Geoff Langbfdea662014-07-23 14:16:32 -04002055 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002056 if (context)
2057 {
2058 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002059 {
Geoff Langb1196682014-07-23 13:47:29 -04002060 context->recordError(gl::Error(GL_INVALID_ENUM));
2061 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002062 }
Geoff Langbfdea662014-07-23 14:16:32 -04002063
2064 if (!gl::ValidBufferParameter(context, pname))
2065 {
Geoff Langb1196682014-07-23 13:47:29 -04002066 context->recordError(gl::Error(GL_INVALID_ENUM));
2067 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002068 }
2069
2070 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2071
2072 if (!buffer)
2073 {
2074 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002075 context->recordError(gl::Error(GL_INVALID_OPERATION));
2076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002077 }
2078
2079 switch (pname)
2080 {
2081 case GL_BUFFER_USAGE:
2082 *params = static_cast<GLint>(buffer->getUsage());
2083 break;
2084 case GL_BUFFER_SIZE:
2085 *params = gl::clampCast<GLint>(buffer->getSize());
2086 break;
2087 case GL_BUFFER_ACCESS_FLAGS:
2088 *params = buffer->getAccessFlags();
2089 break;
2090 case GL_BUFFER_MAPPED:
2091 *params = static_cast<GLint>(buffer->isMapped());
2092 break;
2093 case GL_BUFFER_MAP_OFFSET:
2094 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2095 break;
2096 case GL_BUFFER_MAP_LENGTH:
2097 *params = gl::clampCast<GLint>(buffer->getMapLength());
2098 break;
2099 default: UNREACHABLE(); break;
2100 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002101 }
2102}
2103
Kenneth Russell67ea1902014-10-06 16:44:50 -07002104GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002105{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002106 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002107
2108 gl::Context *context = gl::getContext();
2109
2110 if (context)
2111 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002112 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113 }
2114
2115 return GL_NO_ERROR;
2116}
2117
Kenneth Russell67ea1902014-10-06 16:44:50 -07002118void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002119{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002120 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002121
Geoff Langbfdea662014-07-23 14:16:32 -04002122 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002123 if (context)
2124 {
2125 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2126
2127 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002128 {
Geoff Langb1196682014-07-23 13:47:29 -04002129 context->recordError(gl::Error(GL_INVALID_OPERATION));
2130 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002131 }
Geoff Langbfdea662014-07-23 14:16:32 -04002132
2133 if (fenceObject->isFence() != GL_TRUE)
2134 {
Geoff Langb1196682014-07-23 13:47:29 -04002135 context->recordError(gl::Error(GL_INVALID_OPERATION));
2136 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002137 }
2138
2139 switch (pname)
2140 {
2141 case GL_FENCE_STATUS_NV:
2142 case GL_FENCE_CONDITION_NV:
2143 break;
2144
Geoff Langb1196682014-07-23 13:47:29 -04002145 default:
2146 context->recordError(gl::Error(GL_INVALID_ENUM));
2147 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002148 }
2149
Geoff Lang882033e2014-09-30 11:26:07 -04002150 gl::Error error = fenceObject->getFencei(pname, params);
2151 if (error.isError())
2152 {
2153 context->recordError(error);
2154 return;
2155 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002156 }
2157}
2158
Kenneth Russell67ea1902014-10-06 16:44:50 -07002159void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002160{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002161 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002162
Geoff Langbfdea662014-07-23 14:16:32 -04002163 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002164 if (context)
2165 {
2166 GLenum nativeType;
2167 unsigned int numParams = 0;
2168 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002169 {
Geoff Langbfdea662014-07-23 14:16:32 -04002170 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002171 }
Geoff Langbfdea662014-07-23 14:16:32 -04002172
2173 if (nativeType == GL_FLOAT)
2174 {
2175 context->getFloatv(pname, params);
2176 }
2177 else
2178 {
2179 CastStateValues(context, nativeType, pname, numParams, params);
2180 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002181 }
2182}
2183
Kenneth Russell67ea1902014-10-06 16:44:50 -07002184void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002185{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002186 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 +00002187 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002188
Geoff Langbfdea662014-07-23 14:16:32 -04002189 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002190 if (context)
2191 {
2192 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002193 {
Geoff Langb1196682014-07-23 13:47:29 -04002194 context->recordError(gl::Error(GL_INVALID_ENUM));
2195 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002196 }
2197
2198 int clientVersion = context->getClientVersion();
2199
2200 switch (pname)
2201 {
2202 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2203 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2204 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2205 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2206 break;
Geoff Langb1196682014-07-23 13:47:29 -04002207
Geoff Langbfdea662014-07-23 14:16:32 -04002208 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2209 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002210 {
Geoff Langb1196682014-07-23 13:47:29 -04002211 context->recordError(gl::Error(GL_INVALID_ENUM));
2212 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002213 }
Geoff Langbfdea662014-07-23 14:16:32 -04002214 break;
Geoff Langb1196682014-07-23 13:47:29 -04002215
Geoff Langbfdea662014-07-23 14:16:32 -04002216 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2217 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2218 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2219 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2220 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2221 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2222 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2223 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2224 if (clientVersion < 3)
2225 {
Geoff Langb1196682014-07-23 13:47:29 -04002226 context->recordError(gl::Error(GL_INVALID_ENUM));
2227 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002228 }
2229 break;
Geoff Langb1196682014-07-23 13:47:29 -04002230
Geoff Langbfdea662014-07-23 14:16:32 -04002231 default:
Geoff Langb1196682014-07-23 13:47:29 -04002232 context->recordError(gl::Error(GL_INVALID_ENUM));
2233 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002234 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002235
Geoff Langbfdea662014-07-23 14:16:32 -04002236 // Determine if the attachment is a valid enum
2237 switch (attachment)
2238 {
2239 case GL_BACK:
2240 case GL_FRONT:
2241 case GL_DEPTH:
2242 case GL_STENCIL:
2243 case GL_DEPTH_STENCIL_ATTACHMENT:
2244 if (clientVersion < 3)
2245 {
Geoff Langb1196682014-07-23 13:47:29 -04002246 context->recordError(gl::Error(GL_INVALID_ENUM));
2247 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002248 }
2249 break;
2250
2251 case GL_DEPTH_ATTACHMENT:
2252 case GL_STENCIL_ATTACHMENT:
2253 break;
2254
2255 default:
2256 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2257 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2258 {
Geoff Langb1196682014-07-23 13:47:29 -04002259 context->recordError(gl::Error(GL_INVALID_ENUM));
2260 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002261 }
2262 break;
2263 }
2264
2265 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2266 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2267
2268 if (framebufferHandle == 0)
2269 {
2270 if (clientVersion < 3)
2271 {
Geoff Langb1196682014-07-23 13:47:29 -04002272 context->recordError(gl::Error(GL_INVALID_OPERATION));
2273 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002274 }
2275
2276 switch (attachment)
2277 {
2278 case GL_BACK:
2279 case GL_DEPTH:
2280 case GL_STENCIL:
2281 break;
Geoff Langb1196682014-07-23 13:47:29 -04002282
Geoff Langbfdea662014-07-23 14:16:32 -04002283 default:
Geoff Langb1196682014-07-23 13:47:29 -04002284 context->recordError(gl::Error(GL_INVALID_OPERATION));
2285 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002286 }
2287 }
2288 else
2289 {
2290 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2291 {
2292 // Valid attachment query
2293 }
2294 else
2295 {
2296 switch (attachment)
2297 {
2298 case GL_DEPTH_ATTACHMENT:
2299 case GL_STENCIL_ATTACHMENT:
2300 break;
Geoff Langb1196682014-07-23 13:47:29 -04002301
Geoff Langbfdea662014-07-23 14:16:32 -04002302 case GL_DEPTH_STENCIL_ATTACHMENT:
2303 if (framebuffer->hasValidDepthStencil())
2304 {
Geoff Langb1196682014-07-23 13:47:29 -04002305 context->recordError(gl::Error(GL_INVALID_OPERATION));
2306 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002307 }
2308 break;
Geoff Langb1196682014-07-23 13:47:29 -04002309
Geoff Langbfdea662014-07-23 14:16:32 -04002310 default:
Geoff Langb1196682014-07-23 13:47:29 -04002311 context->recordError(gl::Error(GL_INVALID_OPERATION));
2312 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002313 }
2314 }
2315 }
2316
2317 GLenum attachmentType = GL_NONE;
2318 GLuint attachmentHandle = 0;
2319 GLuint attachmentLevel = 0;
2320 GLuint attachmentLayer = 0;
2321
2322 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2323
2324 if (attachmentObject)
2325 {
2326 attachmentType = attachmentObject->type();
2327 attachmentHandle = attachmentObject->id();
2328 attachmentLevel = attachmentObject->mipLevel();
2329 attachmentLayer = attachmentObject->layer();
2330 }
2331
2332 GLenum attachmentObjectType; // Type category
2333 if (framebufferHandle == 0)
2334 {
2335 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2336 }
2337 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2338 {
2339 attachmentObjectType = attachmentType;
2340 }
2341 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2342 {
2343 attachmentObjectType = GL_TEXTURE;
2344 }
2345 else
2346 {
2347 UNREACHABLE();
2348 return;
2349 }
2350
2351 if (attachmentObjectType == GL_NONE)
2352 {
2353 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2354 // is NONE, then querying any other pname will generate INVALID_ENUM.
2355
2356 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2357 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2358 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002359
Geoff Lang646559f2013-08-15 11:08:15 -04002360 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002361 {
Geoff Lang646559f2013-08-15 11:08:15 -04002362 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002363 *params = attachmentObjectType;
2364 break;
2365
Geoff Lang646559f2013-08-15 11:08:15 -04002366 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002367 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002368 {
Geoff Langb1196682014-07-23 13:47:29 -04002369 context->recordError(gl::Error(GL_INVALID_ENUM));
2370 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002371 }
Geoff Langbfdea662014-07-23 14:16:32 -04002372 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002373 break;
2374
2375 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002376 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002377 {
Geoff Langb1196682014-07-23 13:47:29 -04002378 context->recordError(gl::Error(GL_INVALID_ENUM));
2379 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002380 }
2381 else
2382 {
Geoff Langb1196682014-07-23 13:47:29 -04002383 context->recordError(gl::Error(GL_INVALID_OPERATION));
2384 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002385 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002386 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002387 }
Geoff Langbfdea662014-07-23 14:16:32 -04002388 else
2389 {
2390 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2391 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2392 ASSERT(attachmentObject != NULL);
2393
2394 switch (pname)
2395 {
2396 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2397 *params = attachmentObjectType;
2398 break;
2399
2400 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2401 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2402 {
Geoff Langb1196682014-07-23 13:47:29 -04002403 context->recordError(gl::Error(GL_INVALID_ENUM));
2404 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002405 }
2406 *params = attachmentHandle;
2407 break;
2408
2409 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2410 if (attachmentObjectType != GL_TEXTURE)
2411 {
Geoff Langb1196682014-07-23 13:47:29 -04002412 context->recordError(gl::Error(GL_INVALID_ENUM));
2413 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002414 }
2415 *params = attachmentLevel;
2416 break;
2417
2418 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2419 if (attachmentObjectType != GL_TEXTURE)
2420 {
Geoff Langb1196682014-07-23 13:47:29 -04002421 context->recordError(gl::Error(GL_INVALID_ENUM));
2422 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002423 }
2424 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2425 break;
2426
2427 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2428 *params = attachmentObject->getRedSize();
2429 break;
2430
2431 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2432 *params = attachmentObject->getGreenSize();
2433 break;
2434
2435 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2436 *params = attachmentObject->getBlueSize();
2437 break;
2438
2439 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2440 *params = attachmentObject->getAlphaSize();
2441 break;
2442
2443 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2444 *params = attachmentObject->getDepthSize();
2445 break;
2446
2447 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2448 *params = attachmentObject->getStencilSize();
2449 break;
2450
2451 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002452 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002453 {
Geoff Langb1196682014-07-23 13:47:29 -04002454 context->recordError(gl::Error(GL_INVALID_OPERATION));
2455 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002456 }
2457 *params = attachmentObject->getComponentType();
2458 break;
2459
2460 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2461 *params = attachmentObject->getColorEncoding();
2462 break;
2463
2464 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2465 if (attachmentObjectType != GL_TEXTURE)
2466 {
Geoff Langb1196682014-07-23 13:47:29 -04002467 context->recordError(gl::Error(GL_INVALID_ENUM));
2468 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002469 }
2470 *params = attachmentLayer;
2471 break;
2472
2473 default:
2474 UNREACHABLE();
2475 break;
2476 }
2477 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002478 }
2479}
2480
Kenneth Russell67ea1902014-10-06 16:44:50 -07002481GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002482{
2483 EVENT("()");
2484
Geoff Langbfdea662014-07-23 14:16:32 -04002485 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002486
Geoff Langbfdea662014-07-23 14:16:32 -04002487 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002488 {
Geoff Langbfdea662014-07-23 14:16:32 -04002489 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002490 }
Geoff Langbfdea662014-07-23 14:16:32 -04002491
2492 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002493}
2494
Kenneth Russell67ea1902014-10-06 16:44:50 -07002495void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002496{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002497 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002498
Geoff Langbfdea662014-07-23 14:16:32 -04002499 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002500 if (context)
2501 {
2502 GLenum nativeType;
2503 unsigned int numParams = 0;
2504
2505 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002506 {
Geoff Langbfdea662014-07-23 14:16:32 -04002507 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002508 }
Geoff Langbfdea662014-07-23 14:16:32 -04002509
2510 if (nativeType == GL_INT)
2511 {
2512 context->getIntegerv(pname, params);
2513 }
2514 else
2515 {
2516 CastStateValues(context, nativeType, pname, numParams, params);
2517 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002518 }
2519}
2520
Kenneth Russell67ea1902014-10-06 16:44:50 -07002521void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002522{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002523 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002524
Geoff Langbfdea662014-07-23 14:16:32 -04002525 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002526 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002527 {
Geoff Langbfdea662014-07-23 14:16:32 -04002528 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002529
Geoff Langbfdea662014-07-23 14:16:32 -04002530 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531 {
Geoff Langb1196682014-07-23 13:47:29 -04002532 context->recordError(gl::Error(GL_INVALID_VALUE));
2533 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002534 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002535
Geoff Langbfdea662014-07-23 14:16:32 -04002536 if (context->getClientVersion() < 3)
2537 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002538 switch (pname)
2539 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002540 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002541 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002542 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002543 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002544 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002545 context->recordError(gl::Error(GL_INVALID_ENUM));
2546 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002547 }
2548 }
Geoff Langbfdea662014-07-23 14:16:32 -04002549
2550 switch (pname)
2551 {
2552 case GL_DELETE_STATUS:
2553 *params = programObject->isFlaggedForDeletion();
2554 return;
2555 case GL_LINK_STATUS:
2556 *params = programObject->isLinked();
2557 return;
2558 case GL_VALIDATE_STATUS:
2559 *params = programObject->isValidated();
2560 return;
2561 case GL_INFO_LOG_LENGTH:
2562 *params = programObject->getInfoLogLength();
2563 return;
2564 case GL_ATTACHED_SHADERS:
2565 *params = programObject->getAttachedShadersCount();
2566 return;
2567 case GL_ACTIVE_ATTRIBUTES:
2568 *params = programObject->getActiveAttributeCount();
2569 return;
2570 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2571 *params = programObject->getActiveAttributeMaxLength();
2572 return;
2573 case GL_ACTIVE_UNIFORMS:
2574 *params = programObject->getActiveUniformCount();
2575 return;
2576 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2577 *params = programObject->getActiveUniformMaxLength();
2578 return;
2579 case GL_PROGRAM_BINARY_LENGTH_OES:
2580 *params = programObject->getProgramBinaryLength();
2581 return;
2582 case GL_ACTIVE_UNIFORM_BLOCKS:
2583 *params = programObject->getActiveUniformBlockCount();
2584 return;
2585 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2586 *params = programObject->getActiveUniformBlockMaxLength();
2587 break;
2588 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2589 *params = programObject->getTransformFeedbackBufferMode();
2590 break;
2591 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2592 *params = programObject->getTransformFeedbackVaryingCount();
2593 break;
2594 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2595 *params = programObject->getTransformFeedbackVaryingMaxLength();
2596 break;
Geoff Langb1196682014-07-23 13:47:29 -04002597
Geoff Langbfdea662014-07-23 14:16:32 -04002598 default:
Geoff Langb1196682014-07-23 13:47:29 -04002599 context->recordError(gl::Error(GL_INVALID_ENUM));
2600 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002601 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002602 }
2603}
2604
Kenneth Russell67ea1902014-10-06 16:44:50 -07002605void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002606{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002607 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 +00002608 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002609
Geoff Langbfdea662014-07-23 14:16:32 -04002610 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002611 if (context)
2612 {
Geoff Langb1196682014-07-23 13:47:29 -04002613 if (bufsize < 0)
2614 {
2615 context->recordError(gl::Error(GL_INVALID_VALUE));
2616 return;
2617 }
2618
Geoff Langbfdea662014-07-23 14:16:32 -04002619 gl::Program *programObject = context->getProgram(program);
2620
2621 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002622 {
Geoff Langb1196682014-07-23 13:47:29 -04002623 context->recordError(gl::Error(GL_INVALID_VALUE));
2624 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002625 }
2626
Geoff Langbfdea662014-07-23 14:16:32 -04002627 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002628 }
2629}
2630
Kenneth Russell67ea1902014-10-06 16:44:50 -07002631void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002632{
2633 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2634
Geoff Langbfdea662014-07-23 14:16:32 -04002635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002636 if (context)
2637 {
2638 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002639 {
Geoff Langb1196682014-07-23 13:47:29 -04002640 context->recordError(gl::Error(GL_INVALID_ENUM));
2641 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002642 }
Geoff Langbfdea662014-07-23 14:16:32 -04002643
2644 switch (pname)
2645 {
2646 case GL_CURRENT_QUERY_EXT:
2647 params[0] = context->getState().getActiveQueryId(target);
2648 break;
2649
2650 default:
Geoff Langb1196682014-07-23 13:47:29 -04002651 context->recordError(gl::Error(GL_INVALID_ENUM));
2652 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002653 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002654 }
2655}
2656
Kenneth Russell67ea1902014-10-06 16:44:50 -07002657void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002658{
2659 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2660
Geoff Langbfdea662014-07-23 14:16:32 -04002661 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002662 if (context)
2663 {
2664 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2665
2666 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002667 {
Geoff Langb1196682014-07-23 13:47:29 -04002668 context->recordError(gl::Error(GL_INVALID_OPERATION));
2669 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002670 }
Geoff Langbfdea662014-07-23 14:16:32 -04002671
2672 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2673 {
Geoff Langb1196682014-07-23 13:47:29 -04002674 context->recordError(gl::Error(GL_INVALID_OPERATION));
2675 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002676 }
2677
2678 switch(pname)
2679 {
2680 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002681 {
2682 gl::Error error = queryObject->getResult(params);
2683 if (error.isError())
2684 {
2685 context->recordError(error);
2686 return;
2687 }
2688 }
Geoff Langbfdea662014-07-23 14:16:32 -04002689 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002690
Geoff Langbfdea662014-07-23 14:16:32 -04002691 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002692 {
2693 gl::Error error = queryObject->isResultAvailable(params);
2694 if (error.isError())
2695 {
2696 context->recordError(error);
2697 return;
2698 }
2699 }
Geoff Langbfdea662014-07-23 14:16:32 -04002700 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002701
Geoff Langbfdea662014-07-23 14:16:32 -04002702 default:
Geoff Langb1196682014-07-23 13:47:29 -04002703 context->recordError(gl::Error(GL_INVALID_ENUM));
2704 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002705 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002706 }
2707}
2708
Kenneth Russell67ea1902014-10-06 16:44:50 -07002709void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002710{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002711 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 +00002712
Geoff Langbfdea662014-07-23 14:16:32 -04002713 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002714 if (context)
2715 {
2716 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002717 {
Geoff Langb1196682014-07-23 13:47:29 -04002718 context->recordError(gl::Error(GL_INVALID_ENUM));
2719 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002720 }
Geoff Langbfdea662014-07-23 14:16:32 -04002721
2722 if (context->getState().getRenderbufferId() == 0)
2723 {
Geoff Langb1196682014-07-23 13:47:29 -04002724 context->recordError(gl::Error(GL_INVALID_OPERATION));
2725 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002726 }
2727
2728 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2729
2730 switch (pname)
2731 {
2732 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2733 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2734 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2735 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2736 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2737 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2738 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2739 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2740 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002741
Geoff Langbfdea662014-07-23 14:16:32 -04002742 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2743 if (!context->getExtensions().framebufferMultisample)
2744 {
Geoff Langb1196682014-07-23 13:47:29 -04002745 context->recordError(gl::Error(GL_INVALID_ENUM));
2746 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002747 }
2748 *params = renderbuffer->getSamples();
2749 break;
Geoff Langb1196682014-07-23 13:47:29 -04002750
Geoff Langbfdea662014-07-23 14:16:32 -04002751 default:
Geoff Langb1196682014-07-23 13:47:29 -04002752 context->recordError(gl::Error(GL_INVALID_ENUM));
2753 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002754 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002755 }
2756}
2757
Kenneth Russell67ea1902014-10-06 16:44:50 -07002758void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002760 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002761
Geoff Langbfdea662014-07-23 14:16:32 -04002762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002763 if (context)
2764 {
2765 gl::Shader *shaderObject = context->getShader(shader);
2766
2767 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002768 {
Geoff Langb1196682014-07-23 13:47:29 -04002769 context->recordError(gl::Error(GL_INVALID_VALUE));
2770 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002771 }
Geoff Langbfdea662014-07-23 14:16:32 -04002772
2773 switch (pname)
2774 {
2775 case GL_SHADER_TYPE:
2776 *params = shaderObject->getType();
2777 return;
2778 case GL_DELETE_STATUS:
2779 *params = shaderObject->isFlaggedForDeletion();
2780 return;
2781 case GL_COMPILE_STATUS:
2782 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2783 return;
2784 case GL_INFO_LOG_LENGTH:
2785 *params = shaderObject->getInfoLogLength();
2786 return;
2787 case GL_SHADER_SOURCE_LENGTH:
2788 *params = shaderObject->getSourceLength();
2789 return;
2790 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2791 *params = shaderObject->getTranslatedSourceLength();
2792 return;
Geoff Langb1196682014-07-23 13:47:29 -04002793
Geoff Langbfdea662014-07-23 14:16:32 -04002794 default:
Geoff Langb1196682014-07-23 13:47:29 -04002795 context->recordError(gl::Error(GL_INVALID_ENUM));
2796 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002797 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002798 }
2799}
2800
Kenneth Russell67ea1902014-10-06 16:44:50 -07002801void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002802{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002803 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 +00002804 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002805
Geoff Langbfdea662014-07-23 14:16:32 -04002806 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002807 if (context)
2808 {
Geoff Langb1196682014-07-23 13:47:29 -04002809 if (bufsize < 0)
2810 {
2811 context->recordError(gl::Error(GL_INVALID_VALUE));
2812 return;
2813 }
2814
Geoff Langbfdea662014-07-23 14:16:32 -04002815 gl::Shader *shaderObject = context->getShader(shader);
2816
2817 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002818 {
Geoff Langb1196682014-07-23 13:47:29 -04002819 context->recordError(gl::Error(GL_INVALID_VALUE));
2820 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002821 }
2822
Geoff Langbfdea662014-07-23 14:16:32 -04002823 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002824 }
2825}
2826
Kenneth Russell67ea1902014-10-06 16:44:50 -07002827void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002828{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002829 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 +00002830 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002831
Geoff Langb1196682014-07-23 13:47:29 -04002832 gl::Context *context = gl::getNonLostContext();
2833 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002834 {
Geoff Langb1196682014-07-23 13:47:29 -04002835 switch (shadertype)
2836 {
2837 case GL_VERTEX_SHADER:
2838 case GL_FRAGMENT_SHADER:
2839 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002840
Geoff Langb1196682014-07-23 13:47:29 -04002841 default:
2842 context->recordError(gl::Error(GL_INVALID_ENUM));
2843 return;
2844 }
2845
2846 switch (precisiontype)
2847 {
2848 case GL_LOW_FLOAT:
2849 case GL_MEDIUM_FLOAT:
2850 case GL_HIGH_FLOAT:
2851 // Assume IEEE 754 precision
2852 range[0] = 127;
2853 range[1] = 127;
2854 *precision = 23;
2855 break;
2856
2857 case GL_LOW_INT:
2858 case GL_MEDIUM_INT:
2859 case GL_HIGH_INT:
2860 // Some (most) hardware only supports single-precision floating-point numbers,
2861 // which can accurately represent integers up to +/-16777216
2862 range[0] = 24;
2863 range[1] = 24;
2864 *precision = 0;
2865 break;
2866
2867 default:
2868 context->recordError(gl::Error(GL_INVALID_ENUM));
2869 return;
2870 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002871 }
2872}
2873
Kenneth Russell67ea1902014-10-06 16:44:50 -07002874void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002876 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 +00002877 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002878
Geoff Langbfdea662014-07-23 14:16:32 -04002879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002880 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002881 {
Geoff Langb1196682014-07-23 13:47:29 -04002882 if (bufsize < 0)
2883 {
2884 context->recordError(gl::Error(GL_INVALID_VALUE));
2885 return;
2886 }
2887
Geoff Langbfdea662014-07-23 14:16:32 -04002888 gl::Shader *shaderObject = context->getShader(shader);
2889
2890 if (!shaderObject)
2891 {
Geoff Langb1196682014-07-23 13:47:29 -04002892 context->recordError(gl::Error(GL_INVALID_OPERATION));
2893 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002894 }
2895
2896 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002897 }
2898}
2899
Kenneth Russell67ea1902014-10-06 16:44:50 -07002900void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002901{
2902 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2903 shader, bufsize, length, source);
2904
Geoff Langbfdea662014-07-23 14:16:32 -04002905 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002906 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002907 {
Geoff Langb1196682014-07-23 13:47:29 -04002908 if (bufsize < 0)
2909 {
2910 context->recordError(gl::Error(GL_INVALID_VALUE));
2911 return;
2912 }
2913
Geoff Langbfdea662014-07-23 14:16:32 -04002914 gl::Shader *shaderObject = context->getShader(shader);
2915
2916 if (!shaderObject)
2917 {
Geoff Langb1196682014-07-23 13:47:29 -04002918 context->recordError(gl::Error(GL_INVALID_OPERATION));
2919 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002920 }
2921
2922 shaderObject->getTranslatedSource(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002923 }
2924}
2925
Kenneth Russell67ea1902014-10-06 16:44:50 -07002926const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002927{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002928 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002929
Geoff Langbfdea662014-07-23 14:16:32 -04002930 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002931
Geoff Langbfdea662014-07-23 14:16:32 -04002932 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002933 {
Geoff Langbfdea662014-07-23 14:16:32 -04002934 case GL_VENDOR:
2935 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002936
Geoff Langbfdea662014-07-23 14:16:32 -04002937 case GL_RENDERER:
2938 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002939
Geoff Langbfdea662014-07-23 14:16:32 -04002940 case GL_VERSION:
2941 if (context->getClientVersion() == 2)
2942 {
2943 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2944 }
2945 else
2946 {
2947 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2948 }
Geoff Langb1196682014-07-23 13:47:29 -04002949
Geoff Langbfdea662014-07-23 14:16:32 -04002950 case GL_SHADING_LANGUAGE_VERSION:
2951 if (context->getClientVersion() == 2)
2952 {
2953 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2954 }
2955 else
2956 {
2957 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2958 }
Geoff Langb1196682014-07-23 13:47:29 -04002959
Geoff Langbfdea662014-07-23 14:16:32 -04002960 case GL_EXTENSIONS:
2961 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002962
Geoff Langbfdea662014-07-23 14:16:32 -04002963 default:
Geoff Langb1196682014-07-23 13:47:29 -04002964 if (context)
2965 {
2966 context->recordError(gl::Error(GL_INVALID_ENUM));
2967 }
2968 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002969 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002970}
2971
Kenneth Russell67ea1902014-10-06 16:44:50 -07002972void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002973{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002974 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 +00002975
Geoff Langbfdea662014-07-23 14:16:32 -04002976 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002977 if (context)
2978 {
2979 gl::Texture *texture = context->getTargetTexture(target);
2980
2981 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002982 {
Geoff Langb1196682014-07-23 13:47:29 -04002983 context->recordError(gl::Error(GL_INVALID_ENUM));
2984 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002985 }
Geoff Langbfdea662014-07-23 14:16:32 -04002986
2987 switch (pname)
2988 {
2989 case GL_TEXTURE_MAG_FILTER:
2990 *params = (GLfloat)texture->getSamplerState().magFilter;
2991 break;
2992 case GL_TEXTURE_MIN_FILTER:
2993 *params = (GLfloat)texture->getSamplerState().minFilter;
2994 break;
2995 case GL_TEXTURE_WRAP_S:
2996 *params = (GLfloat)texture->getSamplerState().wrapS;
2997 break;
2998 case GL_TEXTURE_WRAP_T:
2999 *params = (GLfloat)texture->getSamplerState().wrapT;
3000 break;
3001 case GL_TEXTURE_WRAP_R:
3002 if (context->getClientVersion() < 3)
3003 {
Geoff Langb1196682014-07-23 13:47:29 -04003004 context->recordError(gl::Error(GL_INVALID_ENUM));
3005 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003006 }
3007 *params = (GLfloat)texture->getSamplerState().wrapR;
3008 break;
3009 case GL_TEXTURE_IMMUTABLE_FORMAT:
3010 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3011 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3012 break;
3013 case GL_TEXTURE_IMMUTABLE_LEVELS:
3014 if (context->getClientVersion() < 3)
3015 {
Geoff Langb1196682014-07-23 13:47:29 -04003016 context->recordError(gl::Error(GL_INVALID_ENUM));
3017 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003018 }
3019 *params = (GLfloat)texture->immutableLevelCount();
3020 break;
3021 case GL_TEXTURE_USAGE_ANGLE:
3022 *params = (GLfloat)texture->getUsage();
3023 break;
3024 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3025 if (!context->getExtensions().textureFilterAnisotropic)
3026 {
Geoff Langb1196682014-07-23 13:47:29 -04003027 context->recordError(gl::Error(GL_INVALID_ENUM));
3028 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003029 }
3030 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3031 break;
3032 case GL_TEXTURE_SWIZZLE_R:
3033 if (context->getClientVersion() < 3)
3034 {
Geoff Langb1196682014-07-23 13:47:29 -04003035 context->recordError(gl::Error(GL_INVALID_ENUM));
3036 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003037 }
3038 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3039 break;
3040 case GL_TEXTURE_SWIZZLE_G:
3041 if (context->getClientVersion() < 3)
3042 {
Geoff Langb1196682014-07-23 13:47:29 -04003043 context->recordError(gl::Error(GL_INVALID_ENUM));
3044 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003045 }
3046 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3047 break;
3048 case GL_TEXTURE_SWIZZLE_B:
3049 if (context->getClientVersion() < 3)
3050 {
Geoff Langb1196682014-07-23 13:47:29 -04003051 context->recordError(gl::Error(GL_INVALID_ENUM));
3052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003053 }
3054 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3055 break;
3056 case GL_TEXTURE_SWIZZLE_A:
3057 if (context->getClientVersion() < 3)
3058 {
Geoff Langb1196682014-07-23 13:47:29 -04003059 context->recordError(gl::Error(GL_INVALID_ENUM));
3060 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003061 }
3062 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3063 break;
3064 case GL_TEXTURE_BASE_LEVEL:
3065 if (context->getClientVersion() < 3)
3066 {
Geoff Langb1196682014-07-23 13:47:29 -04003067 context->recordError(gl::Error(GL_INVALID_ENUM));
3068 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003069 }
3070 *params = (GLfloat)texture->getSamplerState().baseLevel;
3071 break;
3072 case GL_TEXTURE_MAX_LEVEL:
3073 if (context->getClientVersion() < 3)
3074 {
Geoff Langb1196682014-07-23 13:47:29 -04003075 context->recordError(gl::Error(GL_INVALID_ENUM));
3076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003077 }
3078 *params = (GLfloat)texture->getSamplerState().maxLevel;
3079 break;
3080 case GL_TEXTURE_MIN_LOD:
3081 if (context->getClientVersion() < 3)
3082 {
Geoff Langb1196682014-07-23 13:47:29 -04003083 context->recordError(gl::Error(GL_INVALID_ENUM));
3084 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003085 }
3086 *params = texture->getSamplerState().minLod;
3087 break;
3088 case GL_TEXTURE_MAX_LOD:
3089 if (context->getClientVersion() < 3)
3090 {
Geoff Langb1196682014-07-23 13:47:29 -04003091 context->recordError(gl::Error(GL_INVALID_ENUM));
3092 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003093 }
3094 *params = texture->getSamplerState().maxLod;
3095 break;
Geoff Langb1196682014-07-23 13:47:29 -04003096
Geoff Langbfdea662014-07-23 14:16:32 -04003097 default:
Geoff Langb1196682014-07-23 13:47:29 -04003098 context->recordError(gl::Error(GL_INVALID_ENUM));
3099 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003100 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003101 }
3102}
3103
Kenneth Russell67ea1902014-10-06 16:44:50 -07003104void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003105{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003106 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 +00003107
Geoff Langbfdea662014-07-23 14:16:32 -04003108 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003109 if (context)
3110 {
3111 gl::Texture *texture = context->getTargetTexture(target);
3112
3113 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003114 {
Geoff Langb1196682014-07-23 13:47:29 -04003115 context->recordError(gl::Error(GL_INVALID_ENUM));
3116 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003117 }
Geoff Langbfdea662014-07-23 14:16:32 -04003118
3119 switch (pname)
3120 {
3121 case GL_TEXTURE_MAG_FILTER:
3122 *params = texture->getSamplerState().magFilter;
3123 break;
3124 case GL_TEXTURE_MIN_FILTER:
3125 *params = texture->getSamplerState().minFilter;
3126 break;
3127 case GL_TEXTURE_WRAP_S:
3128 *params = texture->getSamplerState().wrapS;
3129 break;
3130 case GL_TEXTURE_WRAP_T:
3131 *params = texture->getSamplerState().wrapT;
3132 break;
3133 case GL_TEXTURE_WRAP_R:
3134 if (context->getClientVersion() < 3)
3135 {
Geoff Langb1196682014-07-23 13:47:29 -04003136 context->recordError(gl::Error(GL_INVALID_ENUM));
3137 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003138 }
3139 *params = texture->getSamplerState().wrapR;
3140 break;
3141 case GL_TEXTURE_IMMUTABLE_FORMAT:
3142 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3143 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3144 break;
3145 case GL_TEXTURE_IMMUTABLE_LEVELS:
3146 if (context->getClientVersion() < 3)
3147 {
Geoff Langb1196682014-07-23 13:47:29 -04003148 context->recordError(gl::Error(GL_INVALID_ENUM));
3149 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003150 }
3151 *params = texture->immutableLevelCount();
3152 break;
3153 case GL_TEXTURE_USAGE_ANGLE:
3154 *params = texture->getUsage();
3155 break;
3156 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3157 if (!context->getExtensions().textureFilterAnisotropic)
3158 {
Geoff Langb1196682014-07-23 13:47:29 -04003159 context->recordError(gl::Error(GL_INVALID_ENUM));
3160 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003161 }
3162 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3163 break;
3164 case GL_TEXTURE_SWIZZLE_R:
3165 if (context->getClientVersion() < 3)
3166 {
Geoff Langb1196682014-07-23 13:47:29 -04003167 context->recordError(gl::Error(GL_INVALID_ENUM));
3168 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003169 }
3170 *params = texture->getSamplerState().swizzleRed;
3171 break;
3172 case GL_TEXTURE_SWIZZLE_G:
3173 if (context->getClientVersion() < 3)
3174 {
Geoff Langb1196682014-07-23 13:47:29 -04003175 context->recordError(gl::Error(GL_INVALID_ENUM));
3176 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003177 }
3178 *params = texture->getSamplerState().swizzleGreen;
3179 break;
3180 case GL_TEXTURE_SWIZZLE_B:
3181 if (context->getClientVersion() < 3)
3182 {
Geoff Langb1196682014-07-23 13:47:29 -04003183 context->recordError(gl::Error(GL_INVALID_ENUM));
3184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003185 }
3186 *params = texture->getSamplerState().swizzleBlue;
3187 break;
3188 case GL_TEXTURE_SWIZZLE_A:
3189 if (context->getClientVersion() < 3)
3190 {
Geoff Langb1196682014-07-23 13:47:29 -04003191 context->recordError(gl::Error(GL_INVALID_ENUM));
3192 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003193 }
3194 *params = texture->getSamplerState().swizzleAlpha;
3195 break;
3196 case GL_TEXTURE_BASE_LEVEL:
3197 if (context->getClientVersion() < 3)
3198 {
Geoff Langb1196682014-07-23 13:47:29 -04003199 context->recordError(gl::Error(GL_INVALID_ENUM));
3200 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003201 }
3202 *params = texture->getSamplerState().baseLevel;
3203 break;
3204 case GL_TEXTURE_MAX_LEVEL:
3205 if (context->getClientVersion() < 3)
3206 {
Geoff Langb1196682014-07-23 13:47:29 -04003207 context->recordError(gl::Error(GL_INVALID_ENUM));
3208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003209 }
3210 *params = texture->getSamplerState().maxLevel;
3211 break;
3212 case GL_TEXTURE_MIN_LOD:
3213 if (context->getClientVersion() < 3)
3214 {
Geoff Langb1196682014-07-23 13:47:29 -04003215 context->recordError(gl::Error(GL_INVALID_ENUM));
3216 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003217 }
3218 *params = (GLint)texture->getSamplerState().minLod;
3219 break;
3220 case GL_TEXTURE_MAX_LOD:
3221 if (context->getClientVersion() < 3)
3222 {
Geoff Langb1196682014-07-23 13:47:29 -04003223 context->recordError(gl::Error(GL_INVALID_ENUM));
3224 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003225 }
3226 *params = (GLint)texture->getSamplerState().maxLod;
3227 break;
Geoff Langb1196682014-07-23 13:47:29 -04003228
Geoff Langbfdea662014-07-23 14:16:32 -04003229 default:
Geoff Langb1196682014-07-23 13:47:29 -04003230 context->recordError(gl::Error(GL_INVALID_ENUM));
3231 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003232 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003233 }
3234}
3235
Kenneth Russell67ea1902014-10-06 16:44:50 -07003236void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003237{
3238 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3239 program, location, bufSize, params);
3240
Geoff Langbfdea662014-07-23 14:16:32 -04003241 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003242 if (context)
3243 {
Jamie Madill0063c512014-08-25 15:47:53 -04003244 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003245 {
Jamie Madill0063c512014-08-25 15:47:53 -04003246 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003247 }
3248
Jamie Madilla502c742014-08-28 17:19:13 -04003249 gl::Program *programObject = context->getProgram(program);
3250 ASSERT(programObject);
3251 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003252 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003253
Jamie Madill99a1e982014-08-25 15:47:54 -04003254 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003255 }
3256}
3257
Kenneth Russell67ea1902014-10-06 16:44:50 -07003258void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003259{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003260 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003261
Geoff Langbfdea662014-07-23 14:16:32 -04003262 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003263 if (context)
3264 {
Jamie Madill0063c512014-08-25 15:47:53 -04003265 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003266 {
Jamie Madill0063c512014-08-25 15:47:53 -04003267 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003268 }
Geoff Langbfdea662014-07-23 14:16:32 -04003269
Jamie Madilla502c742014-08-28 17:19:13 -04003270 gl::Program *programObject = context->getProgram(program);
3271 ASSERT(programObject);
3272 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003273 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003274
Jamie Madill99a1e982014-08-25 15:47:54 -04003275 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003276 }
3277}
3278
Kenneth Russell67ea1902014-10-06 16:44:50 -07003279void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003280{
Geoff Langbfdea662014-07-23 14:16:32 -04003281 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003282 program, location, bufSize, params);
3283
Geoff Langbfdea662014-07-23 14:16:32 -04003284 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003285 if (context)
3286 {
Jamie Madill0063c512014-08-25 15:47:53 -04003287 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003288 {
Jamie Madill0063c512014-08-25 15:47:53 -04003289 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003290 }
3291
Jamie Madilla502c742014-08-28 17:19:13 -04003292 gl::Program *programObject = context->getProgram(program);
3293 ASSERT(programObject);
3294 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003295 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003296
Jamie Madill99a1e982014-08-25 15:47:54 -04003297 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003298 }
3299}
3300
Kenneth Russell67ea1902014-10-06 16:44:50 -07003301void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003302{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003303 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003304
Geoff Langbfdea662014-07-23 14:16:32 -04003305 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003306 if (context)
3307 {
Jamie Madill0063c512014-08-25 15:47:53 -04003308 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003309 {
Jamie Madill0063c512014-08-25 15:47:53 -04003310 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003311 }
Geoff Langbfdea662014-07-23 14:16:32 -04003312
Jamie Madilla502c742014-08-28 17:19:13 -04003313 gl::Program *programObject = context->getProgram(program);
3314 ASSERT(programObject);
3315 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003316 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003317
Jamie Madill99a1e982014-08-25 15:47:54 -04003318 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003319 }
3320}
3321
Kenneth Russell67ea1902014-10-06 16:44:50 -07003322GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003323{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003324 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003325
Geoff Langbfdea662014-07-23 14:16:32 -04003326 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003327 if (context)
3328 {
Geoff Langb1196682014-07-23 13:47:29 -04003329 if (strstr(name, "gl_") == name)
3330 {
3331 return -1;
3332 }
3333
Geoff Langbfdea662014-07-23 14:16:32 -04003334 gl::Program *programObject = context->getProgram(program);
3335
3336 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003337 {
Geoff Langbfdea662014-07-23 14:16:32 -04003338 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339 {
Geoff Langb1196682014-07-23 13:47:29 -04003340 context->recordError(gl::Error(GL_INVALID_OPERATION));
3341 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342 }
Geoff Langbfdea662014-07-23 14:16:32 -04003343 else
3344 {
Geoff Langb1196682014-07-23 13:47:29 -04003345 context->recordError(gl::Error(GL_INVALID_VALUE));
3346 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003347 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003348 }
Geoff Langbfdea662014-07-23 14:16:32 -04003349
3350 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3351 if (!programObject->isLinked() || !programBinary)
3352 {
Geoff Langb1196682014-07-23 13:47:29 -04003353 context->recordError(gl::Error(GL_INVALID_OPERATION));
3354 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003355 }
3356
3357 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003358 }
3359
3360 return -1;
3361}
3362
Kenneth Russell67ea1902014-10-06 16:44:50 -07003363void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003364{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003365 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003366
Geoff Langbfdea662014-07-23 14:16:32 -04003367 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003368 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003369 {
Geoff Langbfdea662014-07-23 14:16:32 -04003370 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003371 {
Geoff Langb1196682014-07-23 13:47:29 -04003372 context->recordError(gl::Error(GL_INVALID_VALUE));
3373 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003374 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003375
Geoff Langbfdea662014-07-23 14:16:32 -04003376 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003377 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003378 {
3379 return;
3380 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003381
Geoff Langbfdea662014-07-23 14:16:32 -04003382 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3383 {
3384 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3385 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003386 {
Geoff Langbfdea662014-07-23 14:16:32 -04003387 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003388 }
3389 }
Geoff Langbfdea662014-07-23 14:16:32 -04003390 else
3391 {
3392 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003394 }
3395}
3396
Kenneth Russell67ea1902014-10-06 16:44:50 -07003397void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003398{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003399 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003400
Geoff Langbfdea662014-07-23 14:16:32 -04003401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003402 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003403 {
Geoff Langbfdea662014-07-23 14:16:32 -04003404 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003405 {
Geoff Langb1196682014-07-23 13:47:29 -04003406 context->recordError(gl::Error(GL_INVALID_VALUE));
3407 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003408 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003409
Geoff Langbfdea662014-07-23 14:16:32 -04003410 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003411
Geoff Langb1196682014-07-23 13:47:29 -04003412 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003413 {
3414 return;
3415 }
Jamie Madillaff71502013-07-02 11:57:05 -04003416
Geoff Langbfdea662014-07-23 14:16:32 -04003417 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3418 {
3419 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3420 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003421 {
Geoff Langbfdea662014-07-23 14:16:32 -04003422 float currentValue = currentValueData.FloatValues[i];
3423 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003424 }
3425 }
Geoff Langbfdea662014-07-23 14:16:32 -04003426 else
3427 {
3428 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3429 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003430 }
3431}
3432
Kenneth Russell67ea1902014-10-06 16:44:50 -07003433void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003434{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003435 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003436
Geoff Langbfdea662014-07-23 14:16:32 -04003437 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003438 if (context)
3439 {
3440 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003441 {
Geoff Langb1196682014-07-23 13:47:29 -04003442 context->recordError(gl::Error(GL_INVALID_VALUE));
3443 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003444 }
Geoff Langbfdea662014-07-23 14:16:32 -04003445
3446 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3447 {
Geoff Langb1196682014-07-23 13:47:29 -04003448 context->recordError(gl::Error(GL_INVALID_ENUM));
3449 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003450 }
3451
3452 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003453 }
3454}
3455
Kenneth Russell67ea1902014-10-06 16:44:50 -07003456void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003457{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003458 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003459
Geoff Langbfdea662014-07-23 14:16:32 -04003460 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003461 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462 {
Geoff Langb1196682014-07-23 13:47:29 -04003463 switch (mode)
3464 {
3465 case GL_FASTEST:
3466 case GL_NICEST:
3467 case GL_DONT_CARE:
3468 break;
3469
3470 default:
3471 context->recordError(gl::Error(GL_INVALID_ENUM));
3472 return;
3473 }
3474
3475 switch (target)
3476 {
3477 case GL_GENERATE_MIPMAP_HINT:
3478 context->getState().setGenerateMipmapHint(mode);
3479 break;
3480
3481 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3482 context->getState().setFragmentShaderDerivativeHint(mode);
3483 break;
3484
3485 default:
3486 context->recordError(gl::Error(GL_INVALID_ENUM));
3487 return;
3488 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003489 }
3490}
3491
Kenneth Russell67ea1902014-10-06 16:44:50 -07003492GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003493{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003494 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003495
Geoff Langbfdea662014-07-23 14:16:32 -04003496 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003497 if (context && buffer)
3498 {
3499 gl::Buffer *bufferObject = context->getBuffer(buffer);
3500
3501 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003502 {
Geoff Langbfdea662014-07-23 14:16:32 -04003503 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003504 }
3505 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003506
3507 return GL_FALSE;
3508}
3509
Kenneth Russell67ea1902014-10-06 16:44:50 -07003510GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003511{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003512 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003513
Geoff Langbfdea662014-07-23 14:16:32 -04003514 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003515 if (context)
3516 {
3517 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003518 {
Geoff Langb1196682014-07-23 13:47:29 -04003519 context->recordError(gl::Error(GL_INVALID_ENUM));
3520 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 }
Geoff Langbfdea662014-07-23 14:16:32 -04003522
3523 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003524 }
3525
3526 return false;
3527}
3528
Kenneth Russell67ea1902014-10-06 16:44:50 -07003529GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003530{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003531 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003532
Geoff Langbfdea662014-07-23 14:16:32 -04003533 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003534 if (context)
3535 {
3536 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3537
3538 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003539 {
Geoff Langbfdea662014-07-23 14:16:32 -04003540 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003541 }
Geoff Langbfdea662014-07-23 14:16:32 -04003542
3543 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003544 }
3545
3546 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003547}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003548
Kenneth Russell67ea1902014-10-06 16:44:50 -07003549GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003551 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003552
Geoff Langbfdea662014-07-23 14:16:32 -04003553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003554 if (context && framebuffer)
3555 {
3556 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3557
3558 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003559 {
Geoff Langbfdea662014-07-23 14:16:32 -04003560 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003561 }
3562 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003563
3564 return GL_FALSE;
3565}
3566
Kenneth Russell67ea1902014-10-06 16:44:50 -07003567GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003568{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003569 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003570
Geoff Langbfdea662014-07-23 14:16:32 -04003571 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003572 if (context && program)
3573 {
3574 gl::Program *programObject = context->getProgram(program);
3575
3576 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003577 {
Geoff Langbfdea662014-07-23 14:16:32 -04003578 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003579 }
3580 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003581
3582 return GL_FALSE;
3583}
3584
Kenneth Russell67ea1902014-10-06 16:44:50 -07003585GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003586{
3587 EVENT("(GLuint id = %d)", id);
3588
Geoff Langbfdea662014-07-23 14:16:32 -04003589 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003590 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003591 {
Geoff Langbfdea662014-07-23 14:16:32 -04003592 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003593 }
3594
3595 return GL_FALSE;
3596}
3597
Kenneth Russell67ea1902014-10-06 16:44:50 -07003598GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003599{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003600 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003601
Geoff Langbfdea662014-07-23 14:16:32 -04003602 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003603 if (context && renderbuffer)
3604 {
3605 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3606
3607 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003608 {
Geoff Langbfdea662014-07-23 14:16:32 -04003609 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003610 }
3611 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003612
3613 return GL_FALSE;
3614}
3615
Kenneth Russell67ea1902014-10-06 16:44:50 -07003616GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003617{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003618 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003619
Geoff Langbfdea662014-07-23 14:16:32 -04003620 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003621 if (context && shader)
3622 {
3623 gl::Shader *shaderObject = context->getShader(shader);
3624
3625 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003626 {
Geoff Langbfdea662014-07-23 14:16:32 -04003627 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003628 }
3629 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003630
3631 return GL_FALSE;
3632}
3633
Kenneth Russell67ea1902014-10-06 16:44:50 -07003634GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003635{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003636 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003637
Geoff Langbfdea662014-07-23 14:16:32 -04003638 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003639 if (context && texture)
3640 {
3641 gl::Texture *textureObject = context->getTexture(texture);
3642
3643 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003644 {
Geoff Langbfdea662014-07-23 14:16:32 -04003645 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003646 }
3647 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003648
3649 return GL_FALSE;
3650}
3651
Kenneth Russell67ea1902014-10-06 16:44:50 -07003652void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003653{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003654 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003655
Geoff Langbfdea662014-07-23 14:16:32 -04003656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003657 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003658 {
Geoff Langb1196682014-07-23 13:47:29 -04003659 if (width <= 0.0f)
3660 {
3661 context->recordError(gl::Error(GL_INVALID_VALUE));
3662 return;
3663 }
3664
Geoff Langbfdea662014-07-23 14:16:32 -04003665 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003666 }
3667}
3668
Kenneth Russell67ea1902014-10-06 16:44:50 -07003669void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003671 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003672
Geoff Langbfdea662014-07-23 14:16:32 -04003673 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003674 if (context)
3675 {
3676 gl::Program *programObject = context->getProgram(program);
3677
3678 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003679 {
Geoff Langbfdea662014-07-23 14:16:32 -04003680 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003681 {
Geoff Langb1196682014-07-23 13:47:29 -04003682 context->recordError(gl::Error(GL_INVALID_OPERATION));
3683 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684 }
Geoff Langbfdea662014-07-23 14:16:32 -04003685 else
3686 {
Geoff Langb1196682014-07-23 13:47:29 -04003687 context->recordError(gl::Error(GL_INVALID_VALUE));
3688 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003689 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003690 }
Geoff Langbfdea662014-07-23 14:16:32 -04003691
Geoff Langb543aff2014-09-30 14:52:54 -04003692 gl::Error error = context->linkProgram(program);
3693 if (error.isError())
3694 {
3695 context->recordError(error);
3696 return;
3697 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003698 }
3699}
3700
Kenneth Russell67ea1902014-10-06 16:44:50 -07003701void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003702{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003703 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003704
Geoff Langbfdea662014-07-23 14:16:32 -04003705 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003706 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707 {
Geoff Langbfdea662014-07-23 14:16:32 -04003708 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003709 {
Geoff Langbfdea662014-07-23 14:16:32 -04003710 case GL_UNPACK_ALIGNMENT:
3711 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003712 {
Geoff Langb1196682014-07-23 13:47:29 -04003713 context->recordError(gl::Error(GL_INVALID_VALUE));
3714 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003715 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003716
Geoff Langbfdea662014-07-23 14:16:32 -04003717 context->getState().setUnpackAlignment(param);
3718 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003719
Geoff Langbfdea662014-07-23 14:16:32 -04003720 case GL_PACK_ALIGNMENT:
3721 if (param != 1 && param != 2 && param != 4 && param != 8)
3722 {
Geoff Langb1196682014-07-23 13:47:29 -04003723 context->recordError(gl::Error(GL_INVALID_VALUE));
3724 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003725 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003726
Geoff Langbfdea662014-07-23 14:16:32 -04003727 context->getState().setPackAlignment(param);
3728 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003729
Geoff Langbfdea662014-07-23 14:16:32 -04003730 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3731 context->getState().setPackReverseRowOrder(param != 0);
3732 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003733
Geoff Langbfdea662014-07-23 14:16:32 -04003734 case GL_UNPACK_IMAGE_HEIGHT:
3735 case GL_UNPACK_SKIP_IMAGES:
3736 case GL_UNPACK_ROW_LENGTH:
3737 case GL_UNPACK_SKIP_ROWS:
3738 case GL_UNPACK_SKIP_PIXELS:
3739 case GL_PACK_ROW_LENGTH:
3740 case GL_PACK_SKIP_ROWS:
3741 case GL_PACK_SKIP_PIXELS:
3742 if (context->getClientVersion() < 3)
3743 {
Geoff Langb1196682014-07-23 13:47:29 -04003744 context->recordError(gl::Error(GL_INVALID_ENUM));
3745 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003746 }
Geoff Langbfdea662014-07-23 14:16:32 -04003747 UNIMPLEMENTED();
3748 break;
3749
3750 default:
Geoff Langb1196682014-07-23 13:47:29 -04003751 context->recordError(gl::Error(GL_INVALID_ENUM));
3752 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003753 }
3754 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003755}
3756
Kenneth Russell67ea1902014-10-06 16:44:50 -07003757void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003758{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003759 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003760
Geoff Langbfdea662014-07-23 14:16:32 -04003761 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003762 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003763 {
Geoff Langbfdea662014-07-23 14:16:32 -04003764 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003765 }
3766}
3767
Kenneth Russell67ea1902014-10-06 16:44:50 -07003768void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003769 GLenum format, GLenum type, GLsizei bufSize,
3770 GLvoid *data)
3771{
3772 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3773 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3774 x, y, width, height, format, type, bufSize, data);
3775
Geoff Langbfdea662014-07-23 14:16:32 -04003776 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003777 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003778 {
Geoff Langb1196682014-07-23 13:47:29 -04003779 if (width < 0 || height < 0 || bufSize < 0)
3780 {
3781 context->recordError(gl::Error(GL_INVALID_VALUE));
3782 return;
3783 }
3784
Geoff Langbfdea662014-07-23 14:16:32 -04003785 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3786 format, type, &bufSize, data))
3787 {
3788 return;
3789 }
3790
Geoff Lang63d2fc72014-07-25 14:51:41 -04003791 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3792 if (error.isError())
3793 {
3794 context->recordError(error);
3795 return;
3796 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003797 }
3798}
3799
Kenneth Russell67ea1902014-10-06 16:44:50 -07003800void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003801 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003802{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003803 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003804 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003805 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003806
Geoff Langbfdea662014-07-23 14:16:32 -04003807 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003808 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003809 {
Geoff Langb1196682014-07-23 13:47:29 -04003810 if (width < 0 || height < 0)
3811 {
3812 context->recordError(gl::Error(GL_INVALID_VALUE));
3813 return;
3814 }
3815
Geoff Langbfdea662014-07-23 14:16:32 -04003816 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3817 format, type, NULL, pixels))
3818 {
3819 return;
3820 }
3821
Geoff Lang63d2fc72014-07-25 14:51:41 -04003822 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3823 if (error.isError())
3824 {
3825 context->recordError(error);
3826 return;
3827 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828 }
3829}
3830
Kenneth Russell67ea1902014-10-06 16:44:50 -07003831void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003832{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003833 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003834
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003835 gl::Context *context = gl::getNonLostContext();
3836
3837 if (context)
3838 {
3839 context->releaseShaderCompiler();
3840 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003841}
3842
Kenneth Russell67ea1902014-10-06 16:44:50 -07003843void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003845 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 +00003846 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003847
Geoff Langbfdea662014-07-23 14:16:32 -04003848 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003849 if (context)
3850 {
3851 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3852 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003853 {
Geoff Langbfdea662014-07-23 14:16:32 -04003854 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003855 }
Geoff Langbfdea662014-07-23 14:16:32 -04003856
3857 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858 }
3859}
3860
Kenneth Russell67ea1902014-10-06 16:44:50 -07003861void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003862{
3863 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3864}
3865
Kenneth Russell67ea1902014-10-06 16:44:50 -07003866void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003868 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003869
Geoff Langbfdea662014-07-23 14:16:32 -04003870 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003871
Geoff Langbfdea662014-07-23 14:16:32 -04003872 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003873 {
Geoff Langbfdea662014-07-23 14:16:32 -04003874 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003875 }
3876}
3877
Kenneth Russell67ea1902014-10-06 16:44:50 -07003878void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003880 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003881
Geoff Langbfdea662014-07-23 14:16:32 -04003882 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003883 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003884 {
Geoff Langb1196682014-07-23 13:47:29 -04003885 if (condition != GL_ALL_COMPLETED_NV)
3886 {
3887 context->recordError(gl::Error(GL_INVALID_ENUM));
3888 return;
3889 }
3890
Geoff Langbfdea662014-07-23 14:16:32 -04003891 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3892
3893 if (fenceObject == NULL)
3894 {
Geoff Langb1196682014-07-23 13:47:29 -04003895 context->recordError(gl::Error(GL_INVALID_OPERATION));
3896 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003897 }
3898
Geoff Lang882033e2014-09-30 11:26:07 -04003899 gl::Error error = fenceObject->setFence(condition);
3900 if (error.isError())
3901 {
3902 context->recordError(error);
3903 return;
3904 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003905 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003906}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003907
Kenneth Russell67ea1902014-10-06 16:44:50 -07003908void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003909{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003910 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 +00003911
Geoff Langbfdea662014-07-23 14:16:32 -04003912 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003913 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003914 {
Geoff Langb1196682014-07-23 13:47:29 -04003915 if (width < 0 || height < 0)
3916 {
3917 context->recordError(gl::Error(GL_INVALID_VALUE));
3918 return;
3919 }
3920
Geoff Langbfdea662014-07-23 14:16:32 -04003921 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003922 }
3923}
3924
Kenneth Russell67ea1902014-10-06 16:44:50 -07003925void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003926{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003927 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003928 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003929 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003930
Geoff Lang900013c2014-07-07 11:32:19 -04003931 gl::Context* context = gl::getNonLostContext();
3932 if (context)
3933 {
3934 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3935 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3936 {
Geoff Langb1196682014-07-23 13:47:29 -04003937 context->recordError(gl::Error(GL_INVALID_ENUM));
3938 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003939 }
3940
3941 // No binary shader formats are supported.
3942 UNIMPLEMENTED();
3943 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003944}
3945
Kenneth Russell67ea1902014-10-06 16:44:50 -07003946void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003947{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003948 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 +00003949 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003950
Geoff Langbfdea662014-07-23 14:16:32 -04003951 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003952 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953 {
Geoff Langb1196682014-07-23 13:47:29 -04003954 if (count < 0)
3955 {
3956 context->recordError(gl::Error(GL_INVALID_VALUE));
3957 return;
3958 }
3959
Geoff Langbfdea662014-07-23 14:16:32 -04003960 gl::Shader *shaderObject = context->getShader(shader);
3961
3962 if (!shaderObject)
3963 {
3964 if (context->getProgram(shader))
3965 {
Geoff Langb1196682014-07-23 13:47:29 -04003966 context->recordError(gl::Error(GL_INVALID_OPERATION));
3967 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003968 }
3969 else
3970 {
Geoff Langb1196682014-07-23 13:47:29 -04003971 context->recordError(gl::Error(GL_INVALID_VALUE));
3972 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003973 }
3974 }
3975
3976 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003977 }
3978}
3979
Kenneth Russell67ea1902014-10-06 16:44:50 -07003980void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003981{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003982 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003983}
3984
Kenneth Russell67ea1902014-10-06 16:44:50 -07003985void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003986{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003987 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 +00003988
Geoff Langbfdea662014-07-23 14:16:32 -04003989 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003990 if (context)
3991 {
Geoff Langb1196682014-07-23 13:47:29 -04003992 switch (face)
3993 {
3994 case GL_FRONT:
3995 case GL_BACK:
3996 case GL_FRONT_AND_BACK:
3997 break;
3998
3999 default:
4000 context->recordError(gl::Error(GL_INVALID_ENUM));
4001 return;
4002 }
4003
4004 switch (func)
4005 {
4006 case GL_NEVER:
4007 case GL_ALWAYS:
4008 case GL_LESS:
4009 case GL_LEQUAL:
4010 case GL_EQUAL:
4011 case GL_GEQUAL:
4012 case GL_GREATER:
4013 case GL_NOTEQUAL:
4014 break;
4015
4016 default:
4017 context->recordError(gl::Error(GL_INVALID_ENUM));
4018 return;
4019 }
4020
Geoff Langbfdea662014-07-23 14:16:32 -04004021 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4022 {
4023 context->getState().setStencilParams(func, ref, mask);
4024 }
4025
4026 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4027 {
4028 context->getState().setStencilBackParams(func, ref, mask);
4029 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004030 }
4031}
4032
Kenneth Russell67ea1902014-10-06 16:44:50 -07004033void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004034{
4035 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4036}
4037
Kenneth Russell67ea1902014-10-06 16:44:50 -07004038void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004040 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004041
Geoff Langbfdea662014-07-23 14:16:32 -04004042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004043 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004044 {
Geoff Langb1196682014-07-23 13:47:29 -04004045 switch (face)
4046 {
4047 case GL_FRONT:
4048 case GL_BACK:
4049 case GL_FRONT_AND_BACK:
4050 break;
4051
4052 default:
4053 context->recordError(gl::Error(GL_INVALID_ENUM));
4054 return;
4055 }
4056
Geoff Langbfdea662014-07-23 14:16:32 -04004057 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4058 {
4059 context->getState().setStencilWritemask(mask);
4060 }
4061
4062 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4063 {
4064 context->getState().setStencilBackWritemask(mask);
4065 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004066 }
4067}
4068
Kenneth Russell67ea1902014-10-06 16:44:50 -07004069void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004070{
4071 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4072}
4073
Kenneth Russell67ea1902014-10-06 16:44:50 -07004074void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004076 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 +00004077 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004078
Geoff Langbfdea662014-07-23 14:16:32 -04004079 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004080 if (context)
4081 {
Geoff Langb1196682014-07-23 13:47:29 -04004082 switch (face)
4083 {
4084 case GL_FRONT:
4085 case GL_BACK:
4086 case GL_FRONT_AND_BACK:
4087 break;
4088
4089 default:
4090 context->recordError(gl::Error(GL_INVALID_ENUM));
4091 return;
4092 }
4093
4094 switch (fail)
4095 {
4096 case GL_ZERO:
4097 case GL_KEEP:
4098 case GL_REPLACE:
4099 case GL_INCR:
4100 case GL_DECR:
4101 case GL_INVERT:
4102 case GL_INCR_WRAP:
4103 case GL_DECR_WRAP:
4104 break;
4105
4106 default:
4107 context->recordError(gl::Error(GL_INVALID_ENUM));
4108 return;
4109 }
4110
4111 switch (zfail)
4112 {
4113 case GL_ZERO:
4114 case GL_KEEP:
4115 case GL_REPLACE:
4116 case GL_INCR:
4117 case GL_DECR:
4118 case GL_INVERT:
4119 case GL_INCR_WRAP:
4120 case GL_DECR_WRAP:
4121 break;
4122
4123 default:
4124 context->recordError(gl::Error(GL_INVALID_ENUM));
4125 return;
4126 }
4127
4128 switch (zpass)
4129 {
4130 case GL_ZERO:
4131 case GL_KEEP:
4132 case GL_REPLACE:
4133 case GL_INCR:
4134 case GL_DECR:
4135 case GL_INVERT:
4136 case GL_INCR_WRAP:
4137 case GL_DECR_WRAP:
4138 break;
4139
4140 default:
4141 context->recordError(gl::Error(GL_INVALID_ENUM));
4142 return;
4143 }
4144
Geoff Langbfdea662014-07-23 14:16:32 -04004145 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4146 {
4147 context->getState().setStencilOperations(fail, zfail, zpass);
4148 }
4149
4150 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4151 {
4152 context->getState().setStencilBackOperations(fail, zfail, zpass);
4153 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004154 }
4155}
4156
Kenneth Russell67ea1902014-10-06 16:44:50 -07004157GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004158{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004159 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004160
Geoff Langbfdea662014-07-23 14:16:32 -04004161 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004162 if (context)
4163 {
4164 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4165
4166 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004167 {
Geoff Langb1196682014-07-23 13:47:29 -04004168 context->recordError(gl::Error(GL_INVALID_OPERATION));
4169 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004170 }
Geoff Langbfdea662014-07-23 14:16:32 -04004171
4172 if (fenceObject->isFence() != GL_TRUE)
4173 {
Geoff Langb1196682014-07-23 13:47:29 -04004174 context->recordError(gl::Error(GL_INVALID_OPERATION));
4175 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004176 }
4177
Geoff Lang882033e2014-09-30 11:26:07 -04004178 GLboolean result;
4179 gl::Error error = fenceObject->testFence(&result);
4180 if (error.isError())
4181 {
4182 context->recordError(error);
4183 return GL_TRUE;
4184 }
4185
4186 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004187 }
Geoff Langbfdea662014-07-23 14:16:32 -04004188
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004189 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004190}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004191
Kenneth Russell67ea1902014-10-06 16:44:50 -07004192void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004193 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004194{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004195 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004196 "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 +00004197 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004198
Geoff Langbfdea662014-07-23 14:16:32 -04004199 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004200 if (context)
4201 {
4202 if (context->getClientVersion() < 3 &&
4203 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4204 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004205 {
Geoff Langbfdea662014-07-23 14:16:32 -04004206 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004207 }
Geoff Langbfdea662014-07-23 14:16:32 -04004208
4209 if (context->getClientVersion() >= 3 &&
4210 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4211 0, 0, 0, width, height, 1, border, format, type, pixels))
4212 {
4213 return;
4214 }
4215
4216 switch (target)
4217 {
4218 case GL_TEXTURE_2D:
4219 {
4220 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004221 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4222 if (error.isError())
4223 {
4224 context->recordError(error);
4225 return;
4226 }
Geoff Langbfdea662014-07-23 14:16:32 -04004227 }
4228 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004229
Geoff Langbfdea662014-07-23 14:16:32 -04004230 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004231 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004232 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004233 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004234 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004235 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4236 {
4237 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004238 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004239 if (error.isError())
4240 {
4241 context->recordError(error);
4242 return;
4243 }
Geoff Langbfdea662014-07-23 14:16:32 -04004244 }
4245 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004246
Geoff Langbfdea662014-07-23 14:16:32 -04004247 default: UNREACHABLE();
4248 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004249 }
4250}
4251
Kenneth Russell67ea1902014-10-06 16:44:50 -07004252void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004253{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004254 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4255
Geoff Langbfdea662014-07-23 14:16:32 -04004256 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004257 if (context)
4258 {
4259 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004260 {
Geoff Langbfdea662014-07-23 14:16:32 -04004261 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004262 }
Geoff Langbfdea662014-07-23 14:16:32 -04004263
4264 gl::Texture *texture = context->getTargetTexture(target);
4265
4266 if (!texture)
4267 {
Geoff Langb1196682014-07-23 13:47:29 -04004268 context->recordError(gl::Error(GL_INVALID_ENUM));
4269 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004270 }
4271
4272 switch (pname)
4273 {
4274 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4275 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4276 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4277 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4278 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4279 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4280 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4281 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4282 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4283 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4284 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4285 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4286 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4287 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4288 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4289 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4290 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4291 default: UNREACHABLE(); break;
4292 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004293 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004294}
4295
Kenneth Russell67ea1902014-10-06 16:44:50 -07004296void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004297{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004298 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004299}
4300
Kenneth Russell67ea1902014-10-06 16:44:50 -07004301void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004302{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004303 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004304
Geoff Langbfdea662014-07-23 14:16:32 -04004305 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004306 if (context)
4307 {
4308 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004309 {
Geoff Langbfdea662014-07-23 14:16:32 -04004310 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004311 }
Geoff Langbfdea662014-07-23 14:16:32 -04004312
4313 gl::Texture *texture = context->getTargetTexture(target);
4314
4315 if (!texture)
4316 {
Geoff Langb1196682014-07-23 13:47:29 -04004317 context->recordError(gl::Error(GL_INVALID_ENUM));
4318 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004319 }
4320
4321 switch (pname)
4322 {
4323 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4324 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4325 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4326 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4327 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4328 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4329 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4330 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4331 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4332 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4333 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4334 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4335 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4336 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4337 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4338 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4339 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4340 default: UNREACHABLE(); break;
4341 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004342 }
4343}
4344
Kenneth Russell67ea1902014-10-06 16:44:50 -07004345void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004346{
4347 glTexParameteri(target, pname, *params);
4348}
4349
Kenneth Russell67ea1902014-10-06 16:44:50 -07004350void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004351{
4352 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4353 target, levels, internalformat, width, height);
4354
Geoff Langbfdea662014-07-23 14:16:32 -04004355 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004356 if (context)
4357 {
4358 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004359 {
Geoff Langb1196682014-07-23 13:47:29 -04004360 context->recordError(gl::Error(GL_INVALID_OPERATION));
4361 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004362 }
Geoff Langbfdea662014-07-23 14:16:32 -04004363
4364 if (context->getClientVersion() < 3 &&
4365 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4366 {
4367 return;
4368 }
4369
4370 if (context->getClientVersion() >= 3 &&
4371 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4372 {
4373 return;
4374 }
4375
4376 switch (target)
4377 {
4378 case GL_TEXTURE_2D:
4379 {
4380 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004381 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4382 if (error.isError())
4383 {
4384 context->recordError(error);
4385 return;
4386 }
Geoff Langbfdea662014-07-23 14:16:32 -04004387 }
4388 break;
4389
4390 case GL_TEXTURE_CUBE_MAP:
4391 {
4392 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004393 gl::Error error = textureCube->storage(levels, internalformat, width);
4394 if (error.isError())
4395 {
4396 context->recordError(error);
4397 return;
4398 }
Geoff Langbfdea662014-07-23 14:16:32 -04004399 }
4400 break;
4401
4402 default:
Geoff Langb1196682014-07-23 13:47:29 -04004403 context->recordError(gl::Error(GL_INVALID_ENUM));
4404 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004405 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004406 }
4407}
4408
Kenneth Russell67ea1902014-10-06 16:44:50 -07004409void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004410 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004411{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004412 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004413 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004414 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004415 target, level, xoffset, yoffset, width, height, format, type, pixels);
4416
Geoff Langbfdea662014-07-23 14:16:32 -04004417 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004418 if (context)
4419 {
4420 if (context->getClientVersion() < 3 &&
4421 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4422 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004423 {
Geoff Langbfdea662014-07-23 14:16:32 -04004424 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004425 }
Geoff Langbfdea662014-07-23 14:16:32 -04004426
4427 if (context->getClientVersion() >= 3 &&
4428 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4429 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4430 {
4431 return;
4432 }
4433
4434 // Zero sized uploads are valid but no-ops
4435 if (width == 0 || height == 0)
4436 {
4437 return;
4438 }
4439
4440 switch (target)
4441 {
4442 case GL_TEXTURE_2D:
4443 {
4444 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004445 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4446 if (error.isError())
4447 {
4448 context->recordError(error);
4449 return;
4450 }
Geoff Langbfdea662014-07-23 14:16:32 -04004451 }
4452 break;
4453
4454 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4455 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4456 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4457 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4458 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4459 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4460 {
4461 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004462 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4463 if (error.isError())
4464 {
4465 context->recordError(error);
4466 return;
4467 }
Geoff Langbfdea662014-07-23 14:16:32 -04004468 }
4469 break;
4470
4471 default:
4472 UNREACHABLE();
4473 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004474 }
4475}
4476
Kenneth Russell67ea1902014-10-06 16:44:50 -07004477void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004478{
4479 glUniform1fv(location, 1, &x);
4480}
4481
Kenneth Russell67ea1902014-10-06 16:44:50 -07004482void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004483{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004484 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004485
Geoff Langbfdea662014-07-23 14:16:32 -04004486 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004487 if (context)
4488 {
4489 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004490 {
Geoff Langbfdea662014-07-23 14:16:32 -04004491 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492 }
Geoff Langbfdea662014-07-23 14:16:32 -04004493
4494 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4495 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004496 }
4497}
4498
Kenneth Russell67ea1902014-10-06 16:44:50 -07004499void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004500{
4501 glUniform1iv(location, 1, &x);
4502}
4503
Kenneth Russell67ea1902014-10-06 16:44:50 -07004504void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004506 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004507
Geoff Langbfdea662014-07-23 14:16:32 -04004508 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004509 if (context)
4510 {
4511 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004512 {
Geoff Langbfdea662014-07-23 14:16:32 -04004513 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004514 }
Geoff Langbfdea662014-07-23 14:16:32 -04004515
4516 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4517 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004518 }
4519}
4520
Kenneth Russell67ea1902014-10-06 16:44:50 -07004521void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004522{
4523 GLfloat xy[2] = {x, y};
4524
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004525 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004526}
4527
Kenneth Russell67ea1902014-10-06 16:44:50 -07004528void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004529{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004530 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004531
Geoff Langbfdea662014-07-23 14:16:32 -04004532 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004533 if (context)
4534 {
4535 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004536 {
Geoff Langbfdea662014-07-23 14:16:32 -04004537 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004538 }
Geoff Langbfdea662014-07-23 14:16:32 -04004539
4540 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4541 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004542 }
4543}
4544
Kenneth Russell67ea1902014-10-06 16:44:50 -07004545void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004546{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004547 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004548
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004549 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004550}
4551
Kenneth Russell67ea1902014-10-06 16:44:50 -07004552void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004553{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004554 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004555
Geoff Langbfdea662014-07-23 14:16:32 -04004556 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004557 if (context)
4558 {
4559 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004560 {
Geoff Langbfdea662014-07-23 14:16:32 -04004561 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004562 }
Geoff Langbfdea662014-07-23 14:16:32 -04004563
4564 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4565 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004566 }
4567}
4568
Kenneth Russell67ea1902014-10-06 16:44:50 -07004569void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570{
4571 GLfloat xyz[3] = {x, y, z};
4572
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004573 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004574}
4575
Kenneth Russell67ea1902014-10-06 16:44:50 -07004576void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004578 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004579
Geoff Langbfdea662014-07-23 14:16:32 -04004580 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004581 if (context)
4582 {
4583 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004584 {
Geoff Langbfdea662014-07-23 14:16:32 -04004585 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004586 }
Geoff Langbfdea662014-07-23 14:16:32 -04004587
4588 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4589 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004590 }
4591}
4592
Kenneth Russell67ea1902014-10-06 16:44:50 -07004593void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004594{
4595 GLint xyz[3] = {x, y, z};
4596
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004597 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004598}
4599
Kenneth Russell67ea1902014-10-06 16:44:50 -07004600void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004601{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004602 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004603
Geoff Langbfdea662014-07-23 14:16:32 -04004604 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004605 if (context)
4606 {
4607 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004608 {
Geoff Langbfdea662014-07-23 14:16:32 -04004609 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004610 }
Geoff Langbfdea662014-07-23 14:16:32 -04004611
4612 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4613 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004614 }
4615}
4616
Kenneth Russell67ea1902014-10-06 16:44:50 -07004617void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004618{
4619 GLfloat xyzw[4] = {x, y, z, w};
4620
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004621 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004622}
4623
Kenneth Russell67ea1902014-10-06 16:44:50 -07004624void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004626 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004627
Geoff Langbfdea662014-07-23 14:16:32 -04004628 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004629 if (context)
4630 {
4631 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004632 {
Geoff Langbfdea662014-07-23 14:16:32 -04004633 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004634 }
Geoff Langbfdea662014-07-23 14:16:32 -04004635
4636 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4637 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004638 }
4639}
4640
Kenneth Russell67ea1902014-10-06 16:44:50 -07004641void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004642{
4643 GLint xyzw[4] = {x, y, z, w};
4644
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004645 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004646}
4647
Kenneth Russell67ea1902014-10-06 16:44:50 -07004648void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004649{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004650 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004651
Geoff Langbfdea662014-07-23 14:16:32 -04004652 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004653 if (context)
4654 {
4655 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004656 {
Geoff Langbfdea662014-07-23 14:16:32 -04004657 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004658 }
Geoff Langbfdea662014-07-23 14:16:32 -04004659
4660 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4661 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662 }
4663}
4664
Kenneth Russell67ea1902014-10-06 16:44:50 -07004665void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004667 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004668 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004669
Geoff Langbfdea662014-07-23 14:16:32 -04004670 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004671 if (context)
4672 {
4673 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004674 {
Geoff Langbfdea662014-07-23 14:16:32 -04004675 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004676 }
Geoff Langbfdea662014-07-23 14:16:32 -04004677
4678 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4679 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680 }
4681}
4682
Kenneth Russell67ea1902014-10-06 16:44:50 -07004683void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004684{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004685 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004686 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004687
Geoff Langbfdea662014-07-23 14:16:32 -04004688 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004689 if (context)
4690 {
4691 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004692 {
Geoff Langbfdea662014-07-23 14:16:32 -04004693 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004694 }
Geoff Langbfdea662014-07-23 14:16:32 -04004695
4696 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4697 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004698 }
4699}
4700
Kenneth Russell67ea1902014-10-06 16:44:50 -07004701void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004702{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004703 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004704 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004705
Geoff Langbfdea662014-07-23 14:16:32 -04004706 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004707 if (context)
4708 {
4709 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004710 {
Geoff Langbfdea662014-07-23 14:16:32 -04004711 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004712 }
Geoff Langbfdea662014-07-23 14:16:32 -04004713
4714 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4715 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004716 }
4717}
4718
Kenneth Russell67ea1902014-10-06 16:44:50 -07004719void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004720{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004721 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004722
Geoff Langbfdea662014-07-23 14:16:32 -04004723 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004724 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004725 {
Geoff Langbfdea662014-07-23 14:16:32 -04004726 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004727
Geoff Langbfdea662014-07-23 14:16:32 -04004728 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004729 {
Geoff Langbfdea662014-07-23 14:16:32 -04004730 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004731 {
Geoff Langb1196682014-07-23 13:47:29 -04004732 context->recordError(gl::Error(GL_INVALID_OPERATION));
4733 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004734 }
Geoff Langbfdea662014-07-23 14:16:32 -04004735 else
4736 {
Geoff Langb1196682014-07-23 13:47:29 -04004737 context->recordError(gl::Error(GL_INVALID_VALUE));
4738 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004739 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004740 }
Geoff Langbfdea662014-07-23 14:16:32 -04004741
4742 if (program != 0 && !programObject->isLinked())
4743 {
Geoff Langb1196682014-07-23 13:47:29 -04004744 context->recordError(gl::Error(GL_INVALID_OPERATION));
4745 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004746 }
4747
4748 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004749 }
4750}
4751
Kenneth Russell67ea1902014-10-06 16:44:50 -07004752void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004753{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004754 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004755
Geoff Langbfdea662014-07-23 14:16:32 -04004756 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004757 if (context)
4758 {
4759 gl::Program *programObject = context->getProgram(program);
4760
4761 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004762 {
Geoff Langbfdea662014-07-23 14:16:32 -04004763 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004764 {
Geoff Langb1196682014-07-23 13:47:29 -04004765 context->recordError(gl::Error(GL_INVALID_OPERATION));
4766 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004767 }
Geoff Langbfdea662014-07-23 14:16:32 -04004768 else
4769 {
Geoff Langb1196682014-07-23 13:47:29 -04004770 context->recordError(gl::Error(GL_INVALID_VALUE));
4771 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004772 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004773 }
Geoff Langbfdea662014-07-23 14:16:32 -04004774
Brandon Jones43a53e22014-08-28 16:23:22 -07004775 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004776 }
4777}
4778
Kenneth Russell67ea1902014-10-06 16:44:50 -07004779void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004780{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004781 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004782
Geoff Langbfdea662014-07-23 14:16:32 -04004783 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004784 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785 {
Geoff Langb1196682014-07-23 13:47:29 -04004786 if (index >= gl::MAX_VERTEX_ATTRIBS)
4787 {
4788 context->recordError(gl::Error(GL_INVALID_VALUE));
4789 return;
4790 }
4791
Geoff Langbfdea662014-07-23 14:16:32 -04004792 GLfloat vals[4] = { x, 0, 0, 1 };
4793 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794 }
4795}
4796
Kenneth Russell67ea1902014-10-06 16:44:50 -07004797void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004798{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004799 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004800
Geoff Langbfdea662014-07-23 14:16:32 -04004801 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004802 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803 {
Geoff Langb1196682014-07-23 13:47:29 -04004804 if (index >= gl::MAX_VERTEX_ATTRIBS)
4805 {
4806 context->recordError(gl::Error(GL_INVALID_VALUE));
4807 return;
4808 }
4809
Geoff Langbfdea662014-07-23 14:16:32 -04004810 GLfloat vals[4] = { values[0], 0, 0, 1 };
4811 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004812 }
4813}
4814
Kenneth Russell67ea1902014-10-06 16:44:50 -07004815void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004816{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004817 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004818
Geoff Langbfdea662014-07-23 14:16:32 -04004819 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004820 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821 {
Geoff Langb1196682014-07-23 13:47:29 -04004822 if (index >= gl::MAX_VERTEX_ATTRIBS)
4823 {
4824 context->recordError(gl::Error(GL_INVALID_VALUE));
4825 return;
4826 }
4827
Geoff Langbfdea662014-07-23 14:16:32 -04004828 GLfloat vals[4] = { x, y, 0, 1 };
4829 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830 }
4831}
4832
Kenneth Russell67ea1902014-10-06 16:44:50 -07004833void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004834{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004835 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004836
Geoff Langbfdea662014-07-23 14:16:32 -04004837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004838 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004839 {
Geoff Langb1196682014-07-23 13:47:29 -04004840 if (index >= gl::MAX_VERTEX_ATTRIBS)
4841 {
4842 context->recordError(gl::Error(GL_INVALID_VALUE));
4843 return;
4844 }
4845
Geoff Langbfdea662014-07-23 14:16:32 -04004846 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4847 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004848 }
4849}
4850
Kenneth Russell67ea1902014-10-06 16:44:50 -07004851void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004852{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004853 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 +00004854
Geoff Langbfdea662014-07-23 14:16:32 -04004855 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004856 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857 {
Geoff Langb1196682014-07-23 13:47:29 -04004858 if (index >= gl::MAX_VERTEX_ATTRIBS)
4859 {
4860 context->recordError(gl::Error(GL_INVALID_VALUE));
4861 return;
4862 }
4863
Geoff Langbfdea662014-07-23 14:16:32 -04004864 GLfloat vals[4] = { x, y, z, 1 };
4865 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004866 }
4867}
4868
Kenneth Russell67ea1902014-10-06 16:44:50 -07004869void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004870{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004871 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004872
Geoff Langbfdea662014-07-23 14:16:32 -04004873 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004874 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875 {
Geoff Langb1196682014-07-23 13:47:29 -04004876 if (index >= gl::MAX_VERTEX_ATTRIBS)
4877 {
4878 context->recordError(gl::Error(GL_INVALID_VALUE));
4879 return;
4880 }
4881
Geoff Langbfdea662014-07-23 14:16:32 -04004882 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4883 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884 }
4885}
4886
Kenneth Russell67ea1902014-10-06 16:44:50 -07004887void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004888{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004889 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 +00004890
Geoff Langbfdea662014-07-23 14:16:32 -04004891 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004892 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 {
Geoff Langb1196682014-07-23 13:47:29 -04004894 if (index >= gl::MAX_VERTEX_ATTRIBS)
4895 {
4896 context->recordError(gl::Error(GL_INVALID_VALUE));
4897 return;
4898 }
4899
Geoff Langbfdea662014-07-23 14:16:32 -04004900 GLfloat vals[4] = { x, y, z, w };
4901 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004902 }
4903}
4904
Kenneth Russell67ea1902014-10-06 16:44:50 -07004905void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004906{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004907 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004908
Geoff Langbfdea662014-07-23 14:16:32 -04004909 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004910 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004911 {
Geoff Langb1196682014-07-23 13:47:29 -04004912 if (index >= gl::MAX_VERTEX_ATTRIBS)
4913 {
4914 context->recordError(gl::Error(GL_INVALID_VALUE));
4915 return;
4916 }
4917
Geoff Langbfdea662014-07-23 14:16:32 -04004918 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004919 }
4920}
4921
Kenneth Russell67ea1902014-10-06 16:44:50 -07004922void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004923{
4924 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4925
Geoff Langbfdea662014-07-23 14:16:32 -04004926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004927 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004928 {
Geoff Langb1196682014-07-23 13:47:29 -04004929 if (index >= gl::MAX_VERTEX_ATTRIBS)
4930 {
4931 context->recordError(gl::Error(GL_INVALID_VALUE));
4932 return;
4933 }
4934
Geoff Langbfdea662014-07-23 14:16:32 -04004935 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004936 }
4937}
4938
Kenneth Russell67ea1902014-10-06 16:44:50 -07004939void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004940{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004941 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004942 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004943 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004944
Geoff Langbfdea662014-07-23 14:16:32 -04004945 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004946 if (context)
4947 {
Geoff Langb1196682014-07-23 13:47:29 -04004948 if (index >= gl::MAX_VERTEX_ATTRIBS)
4949 {
4950 context->recordError(gl::Error(GL_INVALID_VALUE));
4951 return;
4952 }
4953
4954 if (size < 1 || size > 4)
4955 {
4956 context->recordError(gl::Error(GL_INVALID_VALUE));
4957 return;
4958 }
4959
4960 switch (type)
4961 {
4962 case GL_BYTE:
4963 case GL_UNSIGNED_BYTE:
4964 case GL_SHORT:
4965 case GL_UNSIGNED_SHORT:
4966 case GL_FIXED:
4967 case GL_FLOAT:
4968 break;
4969
4970 case GL_HALF_FLOAT:
4971 case GL_INT:
4972 case GL_UNSIGNED_INT:
4973 case GL_INT_2_10_10_10_REV:
4974 case GL_UNSIGNED_INT_2_10_10_10_REV:
4975 if (context->getClientVersion() < 3)
4976 {
4977 context->recordError(gl::Error(GL_INVALID_ENUM));
4978 return;
4979 }
4980 break;
4981
4982 default:
4983 context->recordError(gl::Error(GL_INVALID_ENUM));
4984 return;
4985 }
4986
4987 if (stride < 0)
4988 {
4989 context->recordError(gl::Error(GL_INVALID_VALUE));
4990 return;
4991 }
4992
4993 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
4994 {
4995 context->recordError(gl::Error(GL_INVALID_OPERATION));
4996 return;
4997 }
4998
Geoff Langbfdea662014-07-23 14:16:32 -04004999 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5000 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5001 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5002 // and the pointer argument is not NULL.
5003 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005004 {
Geoff Langb1196682014-07-23 13:47:29 -04005005 context->recordError(gl::Error(GL_INVALID_OPERATION));
5006 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005007 }
5008
Geoff Langbfdea662014-07-23 14:16:32 -04005009 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5010 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005011 }
5012}
5013
Kenneth Russell67ea1902014-10-06 16:44:50 -07005014void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005015{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005016 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 +00005017
Geoff Langbfdea662014-07-23 14:16:32 -04005018 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005019 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005020 {
Geoff Langb1196682014-07-23 13:47:29 -04005021 if (width < 0 || height < 0)
5022 {
5023 context->recordError(gl::Error(GL_INVALID_VALUE));
5024 return;
5025 }
5026
Geoff Langbfdea662014-07-23 14:16:32 -04005027 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005028 }
5029}
5030
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005031// OpenGL ES 3.0 functions
5032
Kenneth Russell67ea1902014-10-06 16:44:50 -07005033void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005034{
5035 EVENT("(GLenum mode = 0x%X)", mode);
5036
Geoff Langbfdea662014-07-23 14:16:32 -04005037 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005038 if (context)
5039 {
5040 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005041 {
Geoff Langb1196682014-07-23 13:47:29 -04005042 context->recordError(gl::Error(GL_INVALID_OPERATION));
5043 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005044 }
Geoff Langbfdea662014-07-23 14:16:32 -04005045
5046 // glReadBuffer
5047 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005048 }
5049}
5050
Kenneth Russell67ea1902014-10-06 16:44:50 -07005051void 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 +00005052{
5053 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5054 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5055
Geoff Langbfdea662014-07-23 14:16:32 -04005056 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005057 if (context)
5058 {
5059 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005060 {
Geoff Langb1196682014-07-23 13:47:29 -04005061 context->recordError(gl::Error(GL_INVALID_OPERATION));
5062 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005063 }
Geoff Langbfdea662014-07-23 14:16:32 -04005064
5065 // glDrawRangeElements
5066 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005067 }
5068}
5069
Kenneth Russell67ea1902014-10-06 16:44:50 -07005070void 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 +00005071{
5072 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5073 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5074 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5075 target, level, internalformat, width, height, depth, border, format, type, pixels);
5076
Geoff Langbfdea662014-07-23 14:16:32 -04005077 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005078 if (context)
5079 {
5080 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005081 {
Geoff Langb1196682014-07-23 13:47:29 -04005082 context->recordError(gl::Error(GL_INVALID_OPERATION));
5083 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005084 }
Geoff Langbfdea662014-07-23 14:16:32 -04005085
5086 // validateES3TexImageFormat sets the error code if there is an error
5087 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5088 0, 0, 0, width, height, depth, border, format, type, pixels))
5089 {
5090 return;
5091 }
5092
5093 switch(target)
5094 {
5095 case GL_TEXTURE_3D:
5096 {
5097 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005098 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5099 if (error.isError())
5100 {
5101 context->recordError(error);
5102 return;
5103 }
Geoff Langbfdea662014-07-23 14:16:32 -04005104 }
5105 break;
5106
5107 case GL_TEXTURE_2D_ARRAY:
5108 {
5109 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005110 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5111 if (error.isError())
5112 {
5113 context->recordError(error);
5114 return;
5115 }
Geoff Langbfdea662014-07-23 14:16:32 -04005116 }
5117 break;
5118
5119 default:
Geoff Langb1196682014-07-23 13:47:29 -04005120 context->recordError(gl::Error(GL_INVALID_ENUM));
5121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005122 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005123 }
5124}
5125
Kenneth Russell67ea1902014-10-06 16:44:50 -07005126void 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 +00005127{
5128 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5129 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5130 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5131 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5132
Geoff Langbfdea662014-07-23 14:16:32 -04005133 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005134 if (context)
5135 {
5136 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005137 {
Geoff Langb1196682014-07-23 13:47:29 -04005138 context->recordError(gl::Error(GL_INVALID_OPERATION));
5139 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005140 }
Geoff Langbfdea662014-07-23 14:16:32 -04005141
5142 // validateES3TexImageFormat sets the error code if there is an error
5143 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5144 xoffset, yoffset, zoffset, width, height, depth, 0,
5145 format, type, pixels))
5146 {
5147 return;
5148 }
5149
5150 // Zero sized uploads are valid but no-ops
5151 if (width == 0 || height == 0 || depth == 0)
5152 {
5153 return;
5154 }
5155
5156 switch(target)
5157 {
5158 case GL_TEXTURE_3D:
5159 {
5160 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005161 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5162 if (error.isError())
5163 {
5164 context->recordError(error);
5165 return;
5166 }
Geoff Langbfdea662014-07-23 14:16:32 -04005167 }
5168 break;
5169
5170 case GL_TEXTURE_2D_ARRAY:
5171 {
5172 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005173 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5174 if (error.isError())
5175 {
5176 context->recordError(error);
5177 return;
5178 }
Geoff Langbfdea662014-07-23 14:16:32 -04005179 }
5180 break;
5181
5182 default:
Geoff Langb1196682014-07-23 13:47:29 -04005183 context->recordError(gl::Error(GL_INVALID_ENUM));
5184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005185 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005186 }
5187}
5188
Kenneth Russell67ea1902014-10-06 16:44:50 -07005189void 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 +00005190{
5191 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5192 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5193 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5194
Geoff Langbfdea662014-07-23 14:16:32 -04005195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005196 if (context)
5197 {
5198 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005199 {
Geoff Langb1196682014-07-23 13:47:29 -04005200 context->recordError(gl::Error(GL_INVALID_OPERATION));
5201 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005202 }
Geoff Langbfdea662014-07-23 14:16:32 -04005203
5204 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5205 x, y, width, height, 0))
5206 {
5207 return;
5208 }
5209
5210 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5211 gl::Texture *texture = NULL;
5212 switch (target)
5213 {
5214 case GL_TEXTURE_3D:
5215 texture = context->getTexture3D();
5216 break;
5217
5218 case GL_TEXTURE_2D_ARRAY:
5219 texture = context->getTexture2DArray();
5220 break;
5221
5222 default:
Geoff Langb1196682014-07-23 13:47:29 -04005223 context->recordError(gl::Error(GL_INVALID_ENUM));
5224 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005225 }
5226
Geoff Langef7b0162014-09-04 13:29:23 -04005227 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5228 if (error.isError())
5229 {
5230 context->recordError(error);
5231 return;
5232 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005233 }
5234}
5235
Kenneth Russell67ea1902014-10-06 16:44:50 -07005236void 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 +00005237{
Geoff Langeef52cc2013-10-16 15:07:39 -04005238 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 +00005239 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5240 "const GLvoid* data = 0x%0.8p)",
5241 target, level, internalformat, width, height, depth, border, imageSize, data);
5242
Geoff Langbfdea662014-07-23 14:16:32 -04005243 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005244 if (context)
5245 {
5246 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005247 {
Geoff Langb1196682014-07-23 13:47:29 -04005248 context->recordError(gl::Error(GL_INVALID_OPERATION));
5249 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005250 }
Geoff Langbfdea662014-07-23 14:16:32 -04005251
Geoff Lang5d601382014-07-22 15:14:06 -04005252 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5253 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005254 {
Geoff Langb1196682014-07-23 13:47:29 -04005255 context->recordError(gl::Error(GL_INVALID_VALUE));
5256 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005257 }
5258
5259 // validateES3TexImageFormat sets the error code if there is an error
5260 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5261 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5262 {
5263 return;
5264 }
5265
5266 switch(target)
5267 {
5268 case GL_TEXTURE_3D:
5269 {
5270 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005271 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5272 if (error.isError())
5273 {
5274 context->recordError(error);
5275 return;
5276 }
Geoff Langbfdea662014-07-23 14:16:32 -04005277 }
5278 break;
5279
5280 case GL_TEXTURE_2D_ARRAY:
5281 {
5282 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005283 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5284 if (error.isError())
5285 {
5286 context->recordError(error);
5287 return;
5288 }
Geoff Langbfdea662014-07-23 14:16:32 -04005289 }
5290 break;
5291
5292 default:
Geoff Langb1196682014-07-23 13:47:29 -04005293 context->recordError(gl::Error(GL_INVALID_ENUM));
5294 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005295 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005296 }
5297}
5298
Kenneth Russell67ea1902014-10-06 16:44:50 -07005299void 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 +00005300{
5301 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5302 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5303 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5304 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5305
Geoff Langbfdea662014-07-23 14:16:32 -04005306 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005307 if (context)
5308 {
5309 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005310 {
Geoff Langb1196682014-07-23 13:47:29 -04005311 context->recordError(gl::Error(GL_INVALID_OPERATION));
5312 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005313 }
Geoff Langbfdea662014-07-23 14:16:32 -04005314
Geoff Lang5d601382014-07-22 15:14:06 -04005315 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5316 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005317 {
Geoff Langb1196682014-07-23 13:47:29 -04005318 context->recordError(gl::Error(GL_INVALID_VALUE));
5319 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005320 }
5321
5322 if (!data)
5323 {
Geoff Langb1196682014-07-23 13:47:29 -04005324 context->recordError(gl::Error(GL_INVALID_VALUE));
5325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005326 }
5327
5328 // validateES3TexImageFormat sets the error code if there is an error
5329 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5330 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5331 {
5332 return;
5333 }
5334
5335 // Zero sized uploads are valid but no-ops
5336 if (width == 0 || height == 0)
5337 {
5338 return;
5339 }
5340
5341 switch(target)
5342 {
5343 case GL_TEXTURE_3D:
5344 {
5345 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005346 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5347 format, imageSize, data);
5348 if (error.isError())
5349 {
5350 context->recordError(error);
5351 return;
5352 }
Geoff Langbfdea662014-07-23 14:16:32 -04005353 }
5354 break;
5355
5356 case GL_TEXTURE_2D_ARRAY:
5357 {
5358 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005359 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5360 format, imageSize, data);
5361 if (error.isError())
5362 {
5363 context->recordError(error);
5364 return;
5365 }
Geoff Langbfdea662014-07-23 14:16:32 -04005366 }
5367 break;
5368
Geoff Langb1196682014-07-23 13:47:29 -04005369 default:
5370 context->recordError(gl::Error(GL_INVALID_ENUM));
5371 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005372 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005373 }
5374}
5375
Kenneth Russell67ea1902014-10-06 16:44:50 -07005376void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005377{
5378 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5379
Geoff Langbfdea662014-07-23 14:16:32 -04005380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005381 if (context)
5382 {
5383 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005384 {
Geoff Langb1196682014-07-23 13:47:29 -04005385 context->recordError(gl::Error(GL_INVALID_OPERATION));
5386 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005387 }
Geoff Langbfdea662014-07-23 14:16:32 -04005388
5389 if (n < 0)
5390 {
Geoff Langb1196682014-07-23 13:47:29 -04005391 context->recordError(gl::Error(GL_INVALID_VALUE));
5392 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005393 }
5394
5395 for (GLsizei i = 0; i < n; i++)
5396 {
5397 ids[i] = context->createQuery();
5398 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005399 }
5400}
5401
Kenneth Russell67ea1902014-10-06 16:44:50 -07005402void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005403{
5404 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5405
Geoff Langbfdea662014-07-23 14:16:32 -04005406 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005407 if (context)
5408 {
5409 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005410 {
Geoff Langb1196682014-07-23 13:47:29 -04005411 context->recordError(gl::Error(GL_INVALID_OPERATION));
5412 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005413 }
Geoff Langbfdea662014-07-23 14:16:32 -04005414
5415 if (n < 0)
5416 {
Geoff Langb1196682014-07-23 13:47:29 -04005417 context->recordError(gl::Error(GL_INVALID_VALUE));
5418 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005419 }
5420
5421 for (GLsizei i = 0; i < n; i++)
5422 {
5423 context->deleteQuery(ids[i]);
5424 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005425 }
5426}
5427
Kenneth Russell67ea1902014-10-06 16:44:50 -07005428GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005429{
5430 EVENT("(GLuint id = %u)", id);
5431
Geoff Langbfdea662014-07-23 14:16:32 -04005432 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005433 if (context)
5434 {
5435 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005436 {
Geoff Langb1196682014-07-23 13:47:29 -04005437 context->recordError(gl::Error(GL_INVALID_OPERATION));
5438 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005439 }
Geoff Langbfdea662014-07-23 14:16:32 -04005440
5441 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005442 }
5443
5444 return GL_FALSE;
5445}
5446
Kenneth Russell67ea1902014-10-06 16:44:50 -07005447void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005448{
5449 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5450
Geoff Langbfdea662014-07-23 14:16:32 -04005451 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005452 if (context)
5453 {
5454 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005455 {
Geoff Langb1196682014-07-23 13:47:29 -04005456 context->recordError(gl::Error(GL_INVALID_OPERATION));
5457 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005458 }
Geoff Langbfdea662014-07-23 14:16:32 -04005459
5460 if (!ValidateBeginQuery(context, target, id))
5461 {
5462 return;
5463 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005464
5465 gl::Error error = context->beginQuery(target, id);
5466 if (error.isError())
5467 {
5468 context->recordError(error);
5469 return;
5470 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005471 }
5472}
5473
Kenneth Russell67ea1902014-10-06 16:44:50 -07005474void GL_APIENTRY glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005475{
5476 EVENT("(GLenum target = 0x%X)", target);
5477
Geoff Langbfdea662014-07-23 14:16:32 -04005478 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005479 if (context)
5480 {
5481 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005482 {
Geoff Langb1196682014-07-23 13:47:29 -04005483 context->recordError(gl::Error(GL_INVALID_OPERATION));
5484 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005485 }
Geoff Langbfdea662014-07-23 14:16:32 -04005486
5487 if (!ValidateEndQuery(context, target))
5488 {
5489 return;
5490 }
5491
Geoff Lang5aad9672014-09-08 11:10:42 -04005492 gl::Error error = context->endQuery(target);
5493 if (error.isError())
5494 {
5495 context->recordError(error);
5496 return;
5497 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005498 }
5499}
5500
Kenneth Russell67ea1902014-10-06 16:44:50 -07005501void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005502{
5503 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5504
Geoff Langbfdea662014-07-23 14:16:32 -04005505 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005506 if (context)
5507 {
5508 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005509 {
Geoff Langb1196682014-07-23 13:47:29 -04005510 context->recordError(gl::Error(GL_INVALID_OPERATION));
5511 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005512 }
Geoff Langbfdea662014-07-23 14:16:32 -04005513
5514 if (!ValidQueryType(context, target))
5515 {
Geoff Langb1196682014-07-23 13:47:29 -04005516 context->recordError(gl::Error(GL_INVALID_ENUM));
5517 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005518 }
5519
5520 switch (pname)
5521 {
5522 case GL_CURRENT_QUERY:
5523 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5524 break;
5525
5526 default:
Geoff Langb1196682014-07-23 13:47:29 -04005527 context->recordError(gl::Error(GL_INVALID_ENUM));
5528 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005529 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005530 }
5531}
5532
Kenneth Russell67ea1902014-10-06 16:44:50 -07005533void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005534{
5535 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5536
Geoff Langbfdea662014-07-23 14:16:32 -04005537 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005538 if (context)
5539 {
5540 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005541 {
Geoff Langb1196682014-07-23 13:47:29 -04005542 context->recordError(gl::Error(GL_INVALID_OPERATION));
5543 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005544 }
Geoff Langbfdea662014-07-23 14:16:32 -04005545
5546 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5547
5548 if (!queryObject)
5549 {
Geoff Langb1196682014-07-23 13:47:29 -04005550 context->recordError(gl::Error(GL_INVALID_OPERATION));
5551 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005552 }
5553
5554 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5555 {
Geoff Langb1196682014-07-23 13:47:29 -04005556 context->recordError(gl::Error(GL_INVALID_OPERATION));
5557 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005558 }
5559
5560 switch(pname)
5561 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005562 case GL_QUERY_RESULT_EXT:
5563 {
5564 gl::Error error = queryObject->getResult(params);
5565 if (error.isError())
5566 {
5567 context->recordError(error);
5568 return;
5569 }
5570 }
Geoff Langbfdea662014-07-23 14:16:32 -04005571 break;
Geoff Langb1196682014-07-23 13:47:29 -04005572
Geoff Lang5aad9672014-09-08 11:10:42 -04005573 case GL_QUERY_RESULT_AVAILABLE_EXT:
5574 {
5575 gl::Error error = queryObject->isResultAvailable(params);
5576 if (error.isError())
5577 {
5578 context->recordError(error);
5579 return;
5580 }
5581 }
Geoff Langbfdea662014-07-23 14:16:32 -04005582 break;
Geoff Langb1196682014-07-23 13:47:29 -04005583
Geoff Langbfdea662014-07-23 14:16:32 -04005584 default:
Geoff Langb1196682014-07-23 13:47:29 -04005585 context->recordError(gl::Error(GL_INVALID_ENUM));
5586 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005587 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005588 }
5589}
5590
Kenneth Russell67ea1902014-10-06 16:44:50 -07005591GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005592{
5593 EVENT("(GLenum target = 0x%X)", target);
5594
Geoff Langbfdea662014-07-23 14:16:32 -04005595 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005596 if (context)
5597 {
5598 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005599 {
Geoff Langb1196682014-07-23 13:47:29 -04005600 context->recordError(gl::Error(GL_INVALID_OPERATION));
5601 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005602 }
Geoff Langbfdea662014-07-23 14:16:32 -04005603
5604 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005605 }
5606
5607 return GL_FALSE;
5608}
5609
Kenneth Russell67ea1902014-10-06 16:44:50 -07005610void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005611{
5612 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5613
Geoff Langbfdea662014-07-23 14:16:32 -04005614 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005615 if (context)
5616 {
5617 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005618 {
Geoff Langb1196682014-07-23 13:47:29 -04005619 context->recordError(gl::Error(GL_INVALID_OPERATION));
5620 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005621 }
Geoff Langbfdea662014-07-23 14:16:32 -04005622
5623 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005624 }
5625}
5626
Kenneth Russell67ea1902014-10-06 16:44:50 -07005627void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005628{
Geoff Langbfdea662014-07-23 14:16:32 -04005629 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005630 if (context)
5631 {
5632 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005633 {
Geoff Langb1196682014-07-23 13:47:29 -04005634 context->recordError(gl::Error(GL_INVALID_OPERATION));
5635 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005636 }
Geoff Langbfdea662014-07-23 14:16:32 -04005637
5638 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005639 }
5640}
5641
Kenneth Russell67ea1902014-10-06 16:44:50 -07005642void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005643{
5644 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5645 location, count, transpose, value);
5646
Geoff Langbfdea662014-07-23 14:16:32 -04005647 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005648 if (context)
5649 {
5650 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005651 {
Geoff Langbfdea662014-07-23 14:16:32 -04005652 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005653 }
Geoff Langbfdea662014-07-23 14:16:32 -04005654
5655 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5656 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005657 }
5658}
5659
Kenneth Russell67ea1902014-10-06 16:44:50 -07005660void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005661{
5662 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5663 location, count, transpose, value);
5664
Geoff Langbfdea662014-07-23 14:16:32 -04005665 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005666 if (context)
5667 {
5668 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005669 {
Geoff Langbfdea662014-07-23 14:16:32 -04005670 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005671 }
Geoff Langbfdea662014-07-23 14:16:32 -04005672
5673 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5674 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005675 }
5676}
5677
Kenneth Russell67ea1902014-10-06 16:44:50 -07005678void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005679{
5680 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5681 location, count, transpose, value);
5682
Geoff Langbfdea662014-07-23 14:16:32 -04005683 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005684 if (context)
5685 {
5686 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005687 {
Geoff Langbfdea662014-07-23 14:16:32 -04005688 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005689 }
Geoff Langbfdea662014-07-23 14:16:32 -04005690
5691 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5692 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005693 }
5694}
5695
Kenneth Russell67ea1902014-10-06 16:44:50 -07005696void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005697{
5698 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5699 location, count, transpose, value);
5700
Geoff Langbfdea662014-07-23 14:16:32 -04005701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005702 if (context)
5703 {
5704 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005705 {
Geoff Langbfdea662014-07-23 14:16:32 -04005706 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005707 }
Geoff Langbfdea662014-07-23 14:16:32 -04005708
5709 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5710 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005711 }
5712}
5713
Kenneth Russell67ea1902014-10-06 16:44:50 -07005714void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005715{
5716 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5717 location, count, transpose, value);
5718
Geoff Langbfdea662014-07-23 14:16:32 -04005719 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005720 if (context)
5721 {
5722 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005723 {
Geoff Langbfdea662014-07-23 14:16:32 -04005724 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005725 }
Geoff Langbfdea662014-07-23 14:16:32 -04005726
5727 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5728 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005729 }
5730}
5731
Kenneth Russell67ea1902014-10-06 16:44:50 -07005732void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005733{
5734 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5735 location, count, transpose, value);
5736
Geoff Langbfdea662014-07-23 14:16:32 -04005737 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005738 if (context)
5739 {
5740 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005741 {
Geoff Langbfdea662014-07-23 14:16:32 -04005742 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005743 }
Geoff Langbfdea662014-07-23 14:16:32 -04005744
5745 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5746 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005747 }
5748}
5749
Kenneth Russell67ea1902014-10-06 16:44:50 -07005750void 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 +00005751{
5752 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5753 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5754 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5755
Geoff Langbfdea662014-07-23 14:16:32 -04005756 gl::Context *context = gl::getNonLostContext();
5757 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005758 {
Geoff Langbfdea662014-07-23 14:16:32 -04005759 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005760 {
Geoff Langb1196682014-07-23 13:47:29 -04005761 context->recordError(gl::Error(GL_INVALID_OPERATION));
5762 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005763 }
Geoff Langbfdea662014-07-23 14:16:32 -04005764
5765 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5766 dstX0, dstY0, dstX1, dstY1, mask, filter,
5767 false))
5768 {
5769 return;
5770 }
5771
Geoff Lang64839152014-08-26 16:23:25 -04005772 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5773 mask, filter);
5774 if (error.isError())
5775 {
5776 context->recordError(error);
5777 return;
5778 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005779 }
5780}
5781
Kenneth Russell67ea1902014-10-06 16:44:50 -07005782void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005783{
5784 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5785 target, samples, internalformat, width, height);
5786
Geoff Langbfdea662014-07-23 14:16:32 -04005787 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005788 if (context)
5789 {
5790 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005791 {
Geoff Langb1196682014-07-23 13:47:29 -04005792 context->recordError(gl::Error(GL_INVALID_OPERATION));
5793 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005794 }
Geoff Langbfdea662014-07-23 14:16:32 -04005795
5796 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5797 width, height, false))
5798 {
5799 return;
5800 }
5801
5802 context->setRenderbufferStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005803 }
5804}
5805
Kenneth Russell67ea1902014-10-06 16:44:50 -07005806void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005807{
5808 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5809 target, attachment, texture, level, layer);
5810
Geoff Langbfdea662014-07-23 14:16:32 -04005811 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005812 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005813 {
Geoff Langbfdea662014-07-23 14:16:32 -04005814 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5815 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005816 {
Geoff Langbfdea662014-07-23 14:16:32 -04005817 return;
5818 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005819
Geoff Langbfdea662014-07-23 14:16:32 -04005820 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5821 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005822
Geoff Langbfdea662014-07-23 14:16:32 -04005823 gl::Texture *textureObject = context->getTexture(texture);
5824 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005825
Geoff Langbfdea662014-07-23 14:16:32 -04005826 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5827 {
5828 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5829 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5830 }
5831 else
5832 {
5833 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005834 {
Geoff Langbfdea662014-07-23 14:16:32 -04005835 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5836 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5837 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005838 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005839 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005840 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005841}
5842
Kenneth Russell67ea1902014-10-06 16:44:50 -07005843GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005844{
5845 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5846 target, offset, length, access);
5847
Geoff Langbfdea662014-07-23 14:16:32 -04005848 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005849 if (context)
5850 {
5851 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005852 {
Geoff Langb1196682014-07-23 13:47:29 -04005853 context->recordError(gl::Error(GL_INVALID_OPERATION));
5854 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005855 }
Geoff Langbfdea662014-07-23 14:16:32 -04005856
5857 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005858 }
5859
5860 return NULL;
5861}
5862
Kenneth Russell67ea1902014-10-06 16:44:50 -07005863void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005864{
5865 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5866
Geoff Langbfdea662014-07-23 14:16:32 -04005867 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005868 if (context)
5869 {
5870 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005871 {
Geoff Langb1196682014-07-23 13:47:29 -04005872 context->recordError(gl::Error(GL_INVALID_OPERATION));
5873 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005874 }
Geoff Langbfdea662014-07-23 14:16:32 -04005875
5876 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005877 }
5878}
5879
Kenneth Russell67ea1902014-10-06 16:44:50 -07005880void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005881{
5882 EVENT("(GLuint array = %u)", array);
5883
Geoff Langbfdea662014-07-23 14:16:32 -04005884 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005885 if (context)
5886 {
5887 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005888 {
Geoff Langb1196682014-07-23 13:47:29 -04005889 context->recordError(gl::Error(GL_INVALID_OPERATION));
5890 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005891 }
Geoff Langbfdea662014-07-23 14:16:32 -04005892
5893 gl::VertexArray *vao = context->getVertexArray(array);
5894
5895 if (!vao)
5896 {
5897 // The default VAO should always exist
5898 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005899 context->recordError(gl::Error(GL_INVALID_OPERATION));
5900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005901 }
5902
5903 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005904 }
5905}
5906
Kenneth Russell67ea1902014-10-06 16:44:50 -07005907void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005908{
5909 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5910
Geoff Langbfdea662014-07-23 14:16:32 -04005911 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005912 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005913 {
Geoff Langbfdea662014-07-23 14:16:32 -04005914 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005915 {
Geoff Langb1196682014-07-23 13:47:29 -04005916 context->recordError(gl::Error(GL_INVALID_OPERATION));
5917 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005918 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005919
Geoff Langbfdea662014-07-23 14:16:32 -04005920 if (n < 0)
5921 {
Geoff Langb1196682014-07-23 13:47:29 -04005922 context->recordError(gl::Error(GL_INVALID_VALUE));
5923 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005924 }
Jamie Madilld1028542013-07-02 11:57:04 -04005925
Geoff Langbfdea662014-07-23 14:16:32 -04005926 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5927 {
5928 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005929 {
Geoff Langbfdea662014-07-23 14:16:32 -04005930 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005931 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005932 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005933 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005934}
5935
Kenneth Russell67ea1902014-10-06 16:44:50 -07005936void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005937{
5938 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5939
Geoff Langbfdea662014-07-23 14:16:32 -04005940 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005941 if (context)
5942 {
5943 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005944 {
Geoff Langb1196682014-07-23 13:47:29 -04005945 context->recordError(gl::Error(GL_INVALID_OPERATION));
5946 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005947 }
Geoff Langbfdea662014-07-23 14:16:32 -04005948
5949 if (n < 0)
5950 {
Geoff Langb1196682014-07-23 13:47:29 -04005951 context->recordError(gl::Error(GL_INVALID_VALUE));
5952 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005953 }
5954
5955 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5956 {
5957 arrays[arrayIndex] = context->createVertexArray();
5958 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005959 }
5960}
5961
Kenneth Russell67ea1902014-10-06 16:44:50 -07005962GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005963{
5964 EVENT("(GLuint array = %u)", array);
5965
Geoff Langbfdea662014-07-23 14:16:32 -04005966 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005967 if (context)
5968 {
5969 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005970 {
Geoff Langb1196682014-07-23 13:47:29 -04005971 context->recordError(gl::Error(GL_INVALID_OPERATION));
5972 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005973 }
Geoff Langbfdea662014-07-23 14:16:32 -04005974
5975 if (array == 0)
5976 {
5977 return GL_FALSE;
5978 }
5979
5980 gl::VertexArray *vao = context->getVertexArray(array);
5981
5982 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005983 }
5984
5985 return GL_FALSE;
5986}
5987
Kenneth Russell67ea1902014-10-06 16:44:50 -07005988void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005989{
5990 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
5991 target, index, data);
5992
Geoff Langbfdea662014-07-23 14:16:32 -04005993 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005994 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005995 {
Geoff Langbfdea662014-07-23 14:16:32 -04005996 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005997 {
Geoff Langb1196682014-07-23 13:47:29 -04005998 context->recordError(gl::Error(GL_INVALID_OPERATION));
5999 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006000 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006001
Geoff Lang3a61c322014-07-10 13:01:54 -04006002 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006003 switch (target)
6004 {
6005 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6006 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6007 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006008 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6009 {
Geoff Langb1196682014-07-23 13:47:29 -04006010 context->recordError(gl::Error(GL_INVALID_VALUE));
6011 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006012 }
Geoff Langbfdea662014-07-23 14:16:32 -04006013 break;
Geoff Langb1196682014-07-23 13:47:29 -04006014
Geoff Langbfdea662014-07-23 14:16:32 -04006015 case GL_UNIFORM_BUFFER_START:
6016 case GL_UNIFORM_BUFFER_SIZE:
6017 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006018 if (index >= caps.maxCombinedUniformBlocks)
6019 {
Geoff Langb1196682014-07-23 13:47:29 -04006020 context->recordError(gl::Error(GL_INVALID_VALUE));
6021 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006022 }
Geoff Langbfdea662014-07-23 14:16:32 -04006023 break;
Geoff Langb1196682014-07-23 13:47:29 -04006024
Geoff Langbfdea662014-07-23 14:16:32 -04006025 default:
Geoff Langb1196682014-07-23 13:47:29 -04006026 context->recordError(gl::Error(GL_INVALID_ENUM));
6027 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006028 }
6029
6030 if (!(context->getIndexedIntegerv(target, index, data)))
6031 {
6032 GLenum nativeType;
6033 unsigned int numParams = 0;
6034 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006035 {
6036 context->recordError(gl::Error(GL_INVALID_ENUM));
6037 return;
6038 }
Shannon Woods15934d52013-08-19 14:28:49 -04006039
Geoff Langbfdea662014-07-23 14:16:32 -04006040 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006041 {
Geoff Langbfdea662014-07-23 14:16:32 -04006042 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006043 }
Geoff Langbfdea662014-07-23 14:16:32 -04006044
6045 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006046 {
Geoff Langbfdea662014-07-23 14:16:32 -04006047 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6048 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6049 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006050
Geoff Langbfdea662014-07-23 14:16:32 -04006051 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006052
Geoff Langbfdea662014-07-23 14:16:32 -04006053 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006054 {
Geoff Langbfdea662014-07-23 14:16:32 -04006055 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6056 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006057 }
Geoff Langbfdea662014-07-23 14:16:32 -04006058
6059 delete [] int64Params;
6060 }
6061 else
6062 {
6063 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006064 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006065 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006066 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006067}
6068
Kenneth Russell67ea1902014-10-06 16:44:50 -07006069void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006070{
6071 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6072
Geoff Langbfdea662014-07-23 14:16:32 -04006073 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006074 if (context)
6075 {
6076 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006077 {
Geoff Langb1196682014-07-23 13:47:29 -04006078 context->recordError(gl::Error(GL_INVALID_OPERATION));
6079 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006080 }
Geoff Langbfdea662014-07-23 14:16:32 -04006081
6082 switch (primitiveMode)
6083 {
6084 case GL_TRIANGLES:
6085 case GL_LINES:
6086 case GL_POINTS:
6087 break;
Geoff Langb1196682014-07-23 13:47:29 -04006088
Geoff Langbfdea662014-07-23 14:16:32 -04006089 default:
Geoff Langb1196682014-07-23 13:47:29 -04006090 context->recordError(gl::Error(GL_INVALID_ENUM));
6091 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006092 }
6093
6094 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6095 ASSERT(transformFeedback != NULL);
6096
6097 if (transformFeedback->isStarted())
6098 {
Geoff Langb1196682014-07-23 13:47:29 -04006099 context->recordError(gl::Error(GL_INVALID_OPERATION));
6100 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006101 }
6102
6103 if (transformFeedback->isPaused())
6104 {
6105 transformFeedback->resume();
6106 }
6107 else
6108 {
6109 transformFeedback->start(primitiveMode);
6110 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006111 }
6112}
6113
Kenneth Russell67ea1902014-10-06 16:44:50 -07006114void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006115{
6116 EVENT("(void)");
6117
Geoff Langbfdea662014-07-23 14:16:32 -04006118 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006119 if (context)
6120 {
6121 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006122 {
Geoff Langb1196682014-07-23 13:47:29 -04006123 context->recordError(gl::Error(GL_INVALID_OPERATION));
6124 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006125 }
Geoff Langbfdea662014-07-23 14:16:32 -04006126
6127 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6128 ASSERT(transformFeedback != NULL);
6129
6130 if (!transformFeedback->isStarted())
6131 {
Geoff Langb1196682014-07-23 13:47:29 -04006132 context->recordError(gl::Error(GL_INVALID_OPERATION));
6133 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006134 }
6135
6136 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006137 }
6138}
6139
Kenneth Russell67ea1902014-10-06 16:44:50 -07006140void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006141{
6142 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6143 target, index, buffer, offset, size);
6144
Geoff Langbfdea662014-07-23 14:16:32 -04006145 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006146 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006147 {
Geoff Langbfdea662014-07-23 14:16:32 -04006148 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006149 {
Geoff Langb1196682014-07-23 13:47:29 -04006150 context->recordError(gl::Error(GL_INVALID_OPERATION));
6151 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006152 }
6153
Geoff Lang3a61c322014-07-10 13:01:54 -04006154 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006155 switch (target)
6156 {
6157 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006158 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006159 {
Geoff Langb1196682014-07-23 13:47:29 -04006160 context->recordError(gl::Error(GL_INVALID_VALUE));
6161 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006162 }
Geoff Langbfdea662014-07-23 14:16:32 -04006163 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006164
Geoff Langbfdea662014-07-23 14:16:32 -04006165 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006166 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006167 {
Geoff Langb1196682014-07-23 13:47:29 -04006168 context->recordError(gl::Error(GL_INVALID_VALUE));
6169 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006170 }
Geoff Langbfdea662014-07-23 14:16:32 -04006171 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006172
Geoff Langbfdea662014-07-23 14:16:32 -04006173 default:
Geoff Langb1196682014-07-23 13:47:29 -04006174 context->recordError(gl::Error(GL_INVALID_ENUM));
6175 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006176 }
6177
6178 if (buffer != 0 && size <= 0)
6179 {
Geoff Langb1196682014-07-23 13:47:29 -04006180 context->recordError(gl::Error(GL_INVALID_VALUE));
6181 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006182 }
6183
6184 switch (target)
6185 {
6186 case GL_TRANSFORM_FEEDBACK_BUFFER:
6187
6188 // size and offset must be a multiple of 4
6189 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006190 {
Geoff Langb1196682014-07-23 13:47:29 -04006191 context->recordError(gl::Error(GL_INVALID_VALUE));
6192 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006193 }
6194
Geoff Langbfdea662014-07-23 14:16:32 -04006195 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6196 context->bindGenericTransformFeedbackBuffer(buffer);
6197 break;
6198
6199 case GL_UNIFORM_BUFFER:
6200
6201 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006202 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006203 {
Geoff Langb1196682014-07-23 13:47:29 -04006204 context->recordError(gl::Error(GL_INVALID_VALUE));
6205 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006206 }
Geoff Langbfdea662014-07-23 14:16:32 -04006207
6208 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6209 context->bindGenericUniformBuffer(buffer);
6210 break;
6211
6212 default:
6213 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006214 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006215 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006216}
6217
Kenneth Russell67ea1902014-10-06 16:44:50 -07006218void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006219{
6220 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6221 target, index, buffer);
6222
Geoff Langbfdea662014-07-23 14:16:32 -04006223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006224 if (context)
6225 {
6226 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006227 {
Geoff Langb1196682014-07-23 13:47:29 -04006228 context->recordError(gl::Error(GL_INVALID_OPERATION));
6229 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006230 }
Geoff Langbfdea662014-07-23 14:16:32 -04006231
Geoff Lang3a61c322014-07-10 13:01:54 -04006232 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006233 switch (target)
6234 {
6235 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006236 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006237 {
Geoff Langb1196682014-07-23 13:47:29 -04006238 context->recordError(gl::Error(GL_INVALID_VALUE));
6239 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006240 }
6241 break;
6242
6243 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006244 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006245 {
Geoff Langb1196682014-07-23 13:47:29 -04006246 context->recordError(gl::Error(GL_INVALID_VALUE));
6247 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006248 }
6249 break;
6250
6251 default:
Geoff Langb1196682014-07-23 13:47:29 -04006252 context->recordError(gl::Error(GL_INVALID_ENUM));
6253 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006254 }
6255
6256 switch (target)
6257 {
6258 case GL_TRANSFORM_FEEDBACK_BUFFER:
6259 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6260 context->bindGenericTransformFeedbackBuffer(buffer);
6261 break;
6262
6263 case GL_UNIFORM_BUFFER:
6264 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6265 context->bindGenericUniformBuffer(buffer);
6266 break;
6267
6268 default:
6269 UNREACHABLE();
6270 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006271 }
6272}
6273
Kenneth Russell67ea1902014-10-06 16:44:50 -07006274void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006275{
6276 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6277 program, count, varyings, bufferMode);
6278
Geoff Langbfdea662014-07-23 14:16:32 -04006279 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006280 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006281 {
Geoff Langbfdea662014-07-23 14:16:32 -04006282 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006283 {
Geoff Langb1196682014-07-23 13:47:29 -04006284 context->recordError(gl::Error(GL_INVALID_OPERATION));
6285 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006286 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006287
Geoff Langbfdea662014-07-23 14:16:32 -04006288 if (count < 0)
6289 {
Geoff Langb1196682014-07-23 13:47:29 -04006290 context->recordError(gl::Error(GL_INVALID_VALUE));
6291 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006292 }
6293
Geoff Lang05881a02014-07-10 14:05:30 -04006294 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006295 switch (bufferMode)
6296 {
6297 case GL_INTERLEAVED_ATTRIBS:
6298 break;
6299 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006300 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006301 {
Geoff Langb1196682014-07-23 13:47:29 -04006302 context->recordError(gl::Error(GL_INVALID_VALUE));
6303 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006304 }
Geoff Langbfdea662014-07-23 14:16:32 -04006305 break;
6306 default:
Geoff Langb1196682014-07-23 13:47:29 -04006307 context->recordError(gl::Error(GL_INVALID_ENUM));
6308 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006309 }
Geoff Langbfdea662014-07-23 14:16:32 -04006310
6311 if (!gl::ValidProgram(context, program))
6312 {
6313 return;
6314 }
6315
6316 gl::Program *programObject = context->getProgram(program);
6317 ASSERT(programObject);
6318
6319 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006320 }
6321}
6322
Kenneth Russell67ea1902014-10-06 16:44:50 -07006323void 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 +00006324{
6325 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6326 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6327 program, index, bufSize, length, size, type, name);
6328
Geoff Langbfdea662014-07-23 14:16:32 -04006329 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006330 if (context)
6331 {
6332 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006333 {
Geoff Langb1196682014-07-23 13:47:29 -04006334 context->recordError(gl::Error(GL_INVALID_OPERATION));
6335 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006336 }
Geoff Langbfdea662014-07-23 14:16:32 -04006337
6338 if (bufSize < 0)
6339 {
Geoff Langb1196682014-07-23 13:47:29 -04006340 context->recordError(gl::Error(GL_INVALID_VALUE));
6341 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006342 }
6343
6344 if (!gl::ValidProgram(context, program))
6345 {
6346 return;
6347 }
6348
6349 gl::Program *programObject = context->getProgram(program);
6350 ASSERT(programObject);
6351
6352 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6353 {
Geoff Langb1196682014-07-23 13:47:29 -04006354 context->recordError(gl::Error(GL_INVALID_VALUE));
6355 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006356 }
6357
6358 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006359 }
6360}
6361
Kenneth Russell67ea1902014-10-06 16:44:50 -07006362void 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 +00006363{
6364 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6365 index, size, type, stride, pointer);
6366
Geoff Langbfdea662014-07-23 14:16:32 -04006367 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006368 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006369 {
Geoff Langbfdea662014-07-23 14:16:32 -04006370 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006371 {
Geoff Langb1196682014-07-23 13:47:29 -04006372 context->recordError(gl::Error(GL_INVALID_OPERATION));
6373 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006374 }
6375
Geoff Langb1196682014-07-23 13:47:29 -04006376 if (index >= gl::MAX_VERTEX_ATTRIBS)
6377 {
6378 context->recordError(gl::Error(GL_INVALID_VALUE));
6379 return;
6380 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006381
Geoff Langb1196682014-07-23 13:47:29 -04006382 if (size < 1 || size > 4)
6383 {
6384 context->recordError(gl::Error(GL_INVALID_VALUE));
6385 return;
6386 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006387
Geoff Langb1196682014-07-23 13:47:29 -04006388 switch (type)
6389 {
6390 case GL_BYTE:
6391 case GL_UNSIGNED_BYTE:
6392 case GL_SHORT:
6393 case GL_UNSIGNED_SHORT:
6394 case GL_INT:
6395 case GL_UNSIGNED_INT:
6396 case GL_INT_2_10_10_10_REV:
6397 case GL_UNSIGNED_INT_2_10_10_10_REV:
6398 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006399
Geoff Langb1196682014-07-23 13:47:29 -04006400 default:
6401 context->recordError(gl::Error(GL_INVALID_ENUM));
6402 return;
6403 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006404
Geoff Langb1196682014-07-23 13:47:29 -04006405 if (stride < 0)
6406 {
6407 context->recordError(gl::Error(GL_INVALID_VALUE));
6408 return;
6409 }
Geoff Langbfdea662014-07-23 14:16:32 -04006410
Geoff Langb1196682014-07-23 13:47:29 -04006411 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6412 {
6413 context->recordError(gl::Error(GL_INVALID_OPERATION));
6414 return;
6415 }
6416
Geoff Langbfdea662014-07-23 14:16:32 -04006417 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6418 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6419 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6420 // and the pointer argument is not NULL.
6421 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006422 {
Geoff Langb1196682014-07-23 13:47:29 -04006423 context->recordError(gl::Error(GL_INVALID_OPERATION));
6424 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006425 }
6426
Geoff Langbfdea662014-07-23 14:16:32 -04006427 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6428 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006429 }
6430}
6431
Kenneth Russell67ea1902014-10-06 16:44:50 -07006432void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006433{
6434 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6435 index, pname, params);
6436
Geoff Langbfdea662014-07-23 14:16:32 -04006437 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006438 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006439 {
Geoff Langbfdea662014-07-23 14:16:32 -04006440 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006441 {
Geoff Langb1196682014-07-23 13:47:29 -04006442 context->recordError(gl::Error(GL_INVALID_OPERATION));
6443 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006444 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006445
Geoff Langbfdea662014-07-23 14:16:32 -04006446 if (index >= gl::MAX_VERTEX_ATTRIBS)
6447 {
Geoff Langb1196682014-07-23 13:47:29 -04006448 context->recordError(gl::Error(GL_INVALID_VALUE));
6449 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006450 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006451
Geoff Langbfdea662014-07-23 14:16:32 -04006452 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006453
Geoff Langb1196682014-07-23 13:47:29 -04006454 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006455 {
6456 return;
6457 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006458
Geoff Langbfdea662014-07-23 14:16:32 -04006459 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6460 {
6461 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6462 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006463 {
Geoff Langbfdea662014-07-23 14:16:32 -04006464 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006465 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006466 }
Geoff Langbfdea662014-07-23 14:16:32 -04006467 else
6468 {
6469 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6470 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006471 }
6472}
6473
Kenneth Russell67ea1902014-10-06 16:44:50 -07006474void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006475{
6476 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6477 index, pname, params);
6478
Geoff Langbfdea662014-07-23 14:16:32 -04006479 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006480 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006481 {
Geoff Langbfdea662014-07-23 14:16:32 -04006482 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006483 {
Geoff Langb1196682014-07-23 13:47:29 -04006484 context->recordError(gl::Error(GL_INVALID_OPERATION));
6485 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006486 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006487
Geoff Langbfdea662014-07-23 14:16:32 -04006488 if (index >= gl::MAX_VERTEX_ATTRIBS)
6489 {
Geoff Langb1196682014-07-23 13:47:29 -04006490 context->recordError(gl::Error(GL_INVALID_VALUE));
6491 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006492 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006493
Geoff Langbfdea662014-07-23 14:16:32 -04006494 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006495
Geoff Langb1196682014-07-23 13:47:29 -04006496 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006497 {
6498 return;
6499 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006500
Geoff Langbfdea662014-07-23 14:16:32 -04006501 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6502 {
6503 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6504 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006505 {
Geoff Langbfdea662014-07-23 14:16:32 -04006506 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006507 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006508 }
Geoff Langbfdea662014-07-23 14:16:32 -04006509 else
6510 {
6511 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6512 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006513 }
6514}
6515
Kenneth Russell67ea1902014-10-06 16:44:50 -07006516void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006517{
6518 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6519 index, x, y, z, w);
6520
Geoff Langbfdea662014-07-23 14:16:32 -04006521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006522 if (context)
6523 {
6524 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006525 {
Geoff Langb1196682014-07-23 13:47:29 -04006526 context->recordError(gl::Error(GL_INVALID_OPERATION));
6527 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006528 }
Geoff Langbfdea662014-07-23 14:16:32 -04006529
6530 if (index >= gl::MAX_VERTEX_ATTRIBS)
6531 {
Geoff Langb1196682014-07-23 13:47:29 -04006532 context->recordError(gl::Error(GL_INVALID_VALUE));
6533 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006534 }
6535
6536 GLint vals[4] = { x, y, z, w };
6537 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006538 }
6539}
6540
Kenneth Russell67ea1902014-10-06 16:44:50 -07006541void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006542{
6543 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6544 index, x, y, z, w);
6545
Geoff Langbfdea662014-07-23 14:16:32 -04006546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006547 if (context)
6548 {
6549 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006550 {
Geoff Langb1196682014-07-23 13:47:29 -04006551 context->recordError(gl::Error(GL_INVALID_OPERATION));
6552 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006553 }
Geoff Langbfdea662014-07-23 14:16:32 -04006554
6555 if (index >= gl::MAX_VERTEX_ATTRIBS)
6556 {
Geoff Langb1196682014-07-23 13:47:29 -04006557 context->recordError(gl::Error(GL_INVALID_VALUE));
6558 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006559 }
6560
6561 GLuint vals[4] = { x, y, z, w };
6562 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006563 }
6564}
6565
Kenneth Russell67ea1902014-10-06 16:44:50 -07006566void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006567{
6568 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6569
Geoff Langbfdea662014-07-23 14:16:32 -04006570 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006571 if (context)
6572 {
6573 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006574 {
Geoff Langb1196682014-07-23 13:47:29 -04006575 context->recordError(gl::Error(GL_INVALID_OPERATION));
6576 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006577 }
Geoff Langbfdea662014-07-23 14:16:32 -04006578
6579 if (index >= gl::MAX_VERTEX_ATTRIBS)
6580 {
Geoff Langb1196682014-07-23 13:47:29 -04006581 context->recordError(gl::Error(GL_INVALID_VALUE));
6582 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006583 }
6584
6585 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006586 }
6587}
6588
Kenneth Russell67ea1902014-10-06 16:44:50 -07006589void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006590{
6591 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6592
Geoff Langbfdea662014-07-23 14:16:32 -04006593 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006594 if (context)
6595 {
6596 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006597 {
Geoff Langb1196682014-07-23 13:47:29 -04006598 context->recordError(gl::Error(GL_INVALID_OPERATION));
6599 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006600 }
Geoff Langbfdea662014-07-23 14:16:32 -04006601
6602 if (index >= gl::MAX_VERTEX_ATTRIBS)
6603 {
Geoff Langb1196682014-07-23 13:47:29 -04006604 context->recordError(gl::Error(GL_INVALID_VALUE));
6605 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006606 }
6607
6608 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006609 }
6610}
6611
Kenneth Russell67ea1902014-10-06 16:44:50 -07006612void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006613{
6614 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6615 program, location, params);
6616
Geoff Langbfdea662014-07-23 14:16:32 -04006617 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006618 if (context)
6619 {
Jamie Madill0063c512014-08-25 15:47:53 -04006620 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006621 {
Jamie Madill0063c512014-08-25 15:47:53 -04006622 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006623 }
Geoff Langbfdea662014-07-23 14:16:32 -04006624
Jamie Madilla502c742014-08-28 17:19:13 -04006625 gl::Program *programObject = context->getProgram(program);
6626 ASSERT(programObject);
6627 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006628 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006629
Jamie Madill99a1e982014-08-25 15:47:54 -04006630 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006631 }
6632}
6633
Kenneth Russell67ea1902014-10-06 16:44:50 -07006634GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006635{
6636 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6637 program, name);
6638
Geoff Langbfdea662014-07-23 14:16:32 -04006639 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006640 if (context)
6641 {
6642 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006643 {
Geoff Langb1196682014-07-23 13:47:29 -04006644 context->recordError(gl::Error(GL_INVALID_OPERATION));
6645 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006646 }
Geoff Langbfdea662014-07-23 14:16:32 -04006647
6648 if (program == 0)
6649 {
Geoff Langb1196682014-07-23 13:47:29 -04006650 context->recordError(gl::Error(GL_INVALID_VALUE));
6651 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006652 }
6653
6654 gl::Program *programObject = context->getProgram(program);
6655
6656 if (!programObject || !programObject->isLinked())
6657 {
Geoff Langb1196682014-07-23 13:47:29 -04006658 context->recordError(gl::Error(GL_INVALID_OPERATION));
6659 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006660 }
6661
6662 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6663 if (!programBinary)
6664 {
Geoff Langb1196682014-07-23 13:47:29 -04006665 context->recordError(gl::Error(GL_INVALID_OPERATION));
6666 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006667 }
6668
6669 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006670 }
6671
6672 return 0;
6673}
6674
Kenneth Russell67ea1902014-10-06 16:44:50 -07006675void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006676{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006677 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006678}
6679
Kenneth Russell67ea1902014-10-06 16:44:50 -07006680void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006681{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006682 const GLuint xy[] = { v0, v1 };
6683 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006684}
6685
Kenneth Russell67ea1902014-10-06 16:44:50 -07006686void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006687{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006688 const GLuint xyz[] = { v0, v1, v2 };
6689 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006690}
6691
Kenneth Russell67ea1902014-10-06 16:44:50 -07006692void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006693{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006694 const GLuint xyzw[] = { v0, v1, v2, v3 };
6695 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006696}
6697
Kenneth Russell67ea1902014-10-06 16:44:50 -07006698void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006699{
6700 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6701 location, count, value);
6702
Geoff Langbfdea662014-07-23 14:16:32 -04006703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006704 if (context)
6705 {
6706 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006707 {
Geoff Langbfdea662014-07-23 14:16:32 -04006708 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006709 }
Geoff Langbfdea662014-07-23 14:16:32 -04006710
6711 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6712 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006713 }
6714}
6715
Kenneth Russell67ea1902014-10-06 16:44:50 -07006716void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006717{
6718 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6719 location, count, value);
6720
Geoff Langbfdea662014-07-23 14:16:32 -04006721 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006722 if (context)
6723 {
6724 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006725 {
Geoff Langbfdea662014-07-23 14:16:32 -04006726 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006727 }
Geoff Langbfdea662014-07-23 14:16:32 -04006728
6729 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6730 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006731 }
6732}
6733
Kenneth Russell67ea1902014-10-06 16:44:50 -07006734void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006735{
6736 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6737 location, count, value);
6738
Geoff Langbfdea662014-07-23 14:16:32 -04006739 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006740 if (context)
6741 {
6742 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006743 {
Geoff Langbfdea662014-07-23 14:16:32 -04006744 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006745 }
Geoff Langbfdea662014-07-23 14:16:32 -04006746
6747 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6748 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006749 }
6750}
6751
Kenneth Russell67ea1902014-10-06 16:44:50 -07006752void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006753{
6754 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6755 location, count, value);
6756
Geoff Langbfdea662014-07-23 14:16:32 -04006757 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006758 if (context)
6759 {
6760 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006761 {
Geoff Langbfdea662014-07-23 14:16:32 -04006762 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006763 }
Geoff Langbfdea662014-07-23 14:16:32 -04006764
6765 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6766 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006767 }
6768}
6769
Kenneth Russell67ea1902014-10-06 16:44:50 -07006770void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006771{
6772 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6773 buffer, drawbuffer, value);
6774
Geoff Langbfdea662014-07-23 14:16:32 -04006775 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006776 if (context)
6777 {
6778 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006779 {
Geoff Langbfdea662014-07-23 14:16:32 -04006780 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006781 }
Geoff Langbfdea662014-07-23 14:16:32 -04006782
6783 switch (buffer)
6784 {
6785 case GL_COLOR:
6786 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6787 {
Geoff Langb1196682014-07-23 13:47:29 -04006788 context->recordError(gl::Error(GL_INVALID_VALUE));
6789 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006790 }
6791 break;
Geoff Langb1196682014-07-23 13:47:29 -04006792
Geoff Langbfdea662014-07-23 14:16:32 -04006793 case GL_STENCIL:
6794 if (drawbuffer != 0)
6795 {
Geoff Langb1196682014-07-23 13:47:29 -04006796 context->recordError(gl::Error(GL_INVALID_VALUE));
6797 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006798 }
6799 break;
Geoff Langb1196682014-07-23 13:47:29 -04006800
Geoff Langbfdea662014-07-23 14:16:32 -04006801 default:
Geoff Langb1196682014-07-23 13:47:29 -04006802 context->recordError(gl::Error(GL_INVALID_ENUM));
6803 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006804 }
6805
Geoff Langcc79b8c2014-07-25 13:48:02 -04006806 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6807 if (error.isError())
6808 {
6809 context->recordError(error);
6810 return;
6811 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006812 }
6813}
6814
Kenneth Russell67ea1902014-10-06 16:44:50 -07006815void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006816{
6817 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6818 buffer, drawbuffer, value);
6819
Geoff Langbfdea662014-07-23 14:16:32 -04006820 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006821 if (context)
6822 {
6823 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006824 {
Geoff Langbfdea662014-07-23 14:16:32 -04006825 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006826 }
Geoff Langbfdea662014-07-23 14:16:32 -04006827
6828 switch (buffer)
6829 {
6830 case GL_COLOR:
6831 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6832 {
Geoff Langb1196682014-07-23 13:47:29 -04006833 context->recordError(gl::Error(GL_INVALID_VALUE));
6834 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006835 }
6836 break;
Geoff Langb1196682014-07-23 13:47:29 -04006837
Geoff Langbfdea662014-07-23 14:16:32 -04006838 default:
Geoff Langb1196682014-07-23 13:47:29 -04006839 context->recordError(gl::Error(GL_INVALID_ENUM));
6840 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006841 }
6842
Geoff Langcc79b8c2014-07-25 13:48:02 -04006843 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6844 if (error.isError())
6845 {
6846 context->recordError(error);
6847 return;
6848 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006849 }
6850}
6851
Kenneth Russell67ea1902014-10-06 16:44:50 -07006852void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006853{
6854 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6855 buffer, drawbuffer, value);
6856
Geoff Langbfdea662014-07-23 14:16:32 -04006857 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006858 if (context)
6859 {
6860 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006861 {
Geoff Langbfdea662014-07-23 14:16:32 -04006862 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006863 }
Geoff Langbfdea662014-07-23 14:16:32 -04006864
6865 switch (buffer)
6866 {
6867 case GL_COLOR:
6868 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6869 {
Geoff Langb1196682014-07-23 13:47:29 -04006870 context->recordError(gl::Error(GL_INVALID_VALUE));
6871 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006872 }
6873 break;
Geoff Langb1196682014-07-23 13:47:29 -04006874
Geoff Langbfdea662014-07-23 14:16:32 -04006875 case GL_DEPTH:
6876 if (drawbuffer != 0)
6877 {
Geoff Langb1196682014-07-23 13:47:29 -04006878 context->recordError(gl::Error(GL_INVALID_VALUE));
6879 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006880 }
6881 break;
Geoff Langb1196682014-07-23 13:47:29 -04006882
Geoff Langbfdea662014-07-23 14:16:32 -04006883 default:
Geoff Langb1196682014-07-23 13:47:29 -04006884 context->recordError(gl::Error(GL_INVALID_ENUM));
6885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006886 }
6887
Geoff Langcc79b8c2014-07-25 13:48:02 -04006888 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6889 if (error.isError())
6890 {
6891 context->recordError(error);
6892 return;
6893 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006894 }
6895}
6896
Kenneth Russell67ea1902014-10-06 16:44:50 -07006897void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006898{
6899 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6900 buffer, drawbuffer, depth, stencil);
6901
Geoff Langbfdea662014-07-23 14:16:32 -04006902 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006903 if (context)
6904 {
6905 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006906 {
Geoff Langbfdea662014-07-23 14:16:32 -04006907 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006908 }
Geoff Langbfdea662014-07-23 14:16:32 -04006909
6910 switch (buffer)
6911 {
6912 case GL_DEPTH_STENCIL:
6913 if (drawbuffer != 0)
6914 {
Geoff Langb1196682014-07-23 13:47:29 -04006915 context->recordError(gl::Error(GL_INVALID_VALUE));
6916 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006917 }
6918 break;
Geoff Langb1196682014-07-23 13:47:29 -04006919
Geoff Langbfdea662014-07-23 14:16:32 -04006920 default:
Geoff Langb1196682014-07-23 13:47:29 -04006921 context->recordError(gl::Error(GL_INVALID_ENUM));
6922 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006923 }
6924
Geoff Langcc79b8c2014-07-25 13:48:02 -04006925 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6926 if (error.isError())
6927 {
6928 context->recordError(error);
6929 return;
6930 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006931 }
6932}
6933
Kenneth Russell67ea1902014-10-06 16:44:50 -07006934const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006935{
6936 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6937
Geoff Langbfdea662014-07-23 14:16:32 -04006938 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006939 if (context)
6940 {
6941 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006942 {
Geoff Langb1196682014-07-23 13:47:29 -04006943 context->recordError(gl::Error(GL_INVALID_OPERATION));
6944 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006945 }
Geoff Langbfdea662014-07-23 14:16:32 -04006946
6947 if (name != GL_EXTENSIONS)
6948 {
Geoff Langb1196682014-07-23 13:47:29 -04006949 context->recordError(gl::Error(GL_INVALID_ENUM));
6950 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006951 }
6952
6953 if (index >= context->getExtensionStringCount())
6954 {
Geoff Langb1196682014-07-23 13:47:29 -04006955 context->recordError(gl::Error(GL_INVALID_VALUE));
6956 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006957 }
6958
6959 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006960 }
6961
6962 return NULL;
6963}
6964
Kenneth Russell67ea1902014-10-06 16:44:50 -07006965void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006966{
6967 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6968 readTarget, writeTarget, readOffset, writeOffset, size);
6969
Geoff Langbfdea662014-07-23 14:16:32 -04006970 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006971 if (context)
6972 {
6973 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006974 {
Geoff Langb1196682014-07-23 13:47:29 -04006975 context->recordError(gl::Error(GL_INVALID_OPERATION));
6976 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006977 }
Geoff Langbfdea662014-07-23 14:16:32 -04006978
6979 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
6980 {
Geoff Langb1196682014-07-23 13:47:29 -04006981 context->recordError(gl::Error(GL_INVALID_ENUM));
6982 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006983 }
6984
6985 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
6986 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
6987
6988 if (!readBuffer || !writeBuffer)
6989 {
Geoff Langb1196682014-07-23 13:47:29 -04006990 context->recordError(gl::Error(GL_INVALID_OPERATION));
6991 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006992 }
6993
Jamie Madillcfaaf722014-07-31 10:47:54 -04006994 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04006995 if (readBuffer->isMapped() || writeBuffer->isMapped())
6996 {
Geoff Langb1196682014-07-23 13:47:29 -04006997 context->recordError(gl::Error(GL_INVALID_OPERATION));
6998 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006999 }
7000
7001 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7002 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7003 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7004 {
Geoff Langb1196682014-07-23 13:47:29 -04007005 context->recordError(gl::Error(GL_INVALID_VALUE));
7006 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007007 }
7008
Kenneth Russell67ea1902014-10-06 16:44:50 -07007009 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007010 {
Geoff Langb1196682014-07-23 13:47:29 -04007011 context->recordError(gl::Error(GL_INVALID_VALUE));
7012 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007013 }
7014
Geoff Langbfdea662014-07-23 14:16:32 -04007015 // if size is zero, the copy is a successful no-op
7016 if (size > 0)
7017 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007018 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7019 if (error.isError())
7020 {
7021 context->recordError(error);
7022 return;
7023 }
Geoff Langbfdea662014-07-23 14:16:32 -04007024 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007025 }
7026}
7027
Kenneth Russell67ea1902014-10-06 16:44:50 -07007028void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007029{
7030 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7031 program, uniformCount, uniformNames, uniformIndices);
7032
Geoff Langbfdea662014-07-23 14:16:32 -04007033 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007034 if (context)
7035 {
7036 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007037 {
Geoff Langb1196682014-07-23 13:47:29 -04007038 context->recordError(gl::Error(GL_INVALID_OPERATION));
7039 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007040 }
7041
7042 if (uniformCount < 0)
7043 {
Geoff Langb1196682014-07-23 13:47:29 -04007044 context->recordError(gl::Error(GL_INVALID_VALUE));
7045 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007046 }
7047
7048 gl::Program *programObject = context->getProgram(program);
7049
7050 if (!programObject)
7051 {
7052 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007053 {
Geoff Langb1196682014-07-23 13:47:29 -04007054 context->recordError(gl::Error(GL_INVALID_OPERATION));
7055 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007056 }
Geoff Langbfdea662014-07-23 14:16:32 -04007057 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007058 {
Geoff Langb1196682014-07-23 13:47:29 -04007059 context->recordError(gl::Error(GL_INVALID_VALUE));
7060 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007061 }
Geoff Langbfdea662014-07-23 14:16:32 -04007062 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007063
Geoff Langbfdea662014-07-23 14:16:32 -04007064 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7065 if (!programObject->isLinked() || !programBinary)
7066 {
7067 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007068 {
Geoff Langbfdea662014-07-23 14:16:32 -04007069 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007070 }
7071 }
Geoff Langbfdea662014-07-23 14:16:32 -04007072 else
7073 {
7074 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7075 {
7076 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7077 }
7078 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007079 }
7080}
7081
Kenneth Russell67ea1902014-10-06 16:44:50 -07007082void 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 +00007083{
7084 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7085 program, uniformCount, uniformIndices, pname, params);
7086
Geoff Langbfdea662014-07-23 14:16:32 -04007087 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007088 if (context)
7089 {
7090 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007091 {
Geoff Langb1196682014-07-23 13:47:29 -04007092 context->recordError(gl::Error(GL_INVALID_OPERATION));
7093 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007094 }
7095
7096 if (uniformCount < 0)
7097 {
Geoff Langb1196682014-07-23 13:47:29 -04007098 context->recordError(gl::Error(GL_INVALID_VALUE));
7099 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007100 }
7101
7102 gl::Program *programObject = context->getProgram(program);
7103
7104 if (!programObject)
7105 {
7106 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007107 {
Geoff Langb1196682014-07-23 13:47:29 -04007108 context->recordError(gl::Error(GL_INVALID_OPERATION));
7109 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007110 }
Geoff Langbfdea662014-07-23 14:16:32 -04007111 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007112 {
Geoff Langb1196682014-07-23 13:47:29 -04007113 context->recordError(gl::Error(GL_INVALID_VALUE));
7114 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007115 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007116 }
Geoff Langbfdea662014-07-23 14:16:32 -04007117
7118 switch (pname)
7119 {
7120 case GL_UNIFORM_TYPE:
7121 case GL_UNIFORM_SIZE:
7122 case GL_UNIFORM_NAME_LENGTH:
7123 case GL_UNIFORM_BLOCK_INDEX:
7124 case GL_UNIFORM_OFFSET:
7125 case GL_UNIFORM_ARRAY_STRIDE:
7126 case GL_UNIFORM_MATRIX_STRIDE:
7127 case GL_UNIFORM_IS_ROW_MAJOR:
7128 break;
Geoff Langb1196682014-07-23 13:47:29 -04007129
Geoff Langbfdea662014-07-23 14:16:32 -04007130 default:
Geoff Langb1196682014-07-23 13:47:29 -04007131 context->recordError(gl::Error(GL_INVALID_ENUM));
7132 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007133 }
7134
7135 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7136
7137 if (!programBinary && uniformCount > 0)
7138 {
Geoff Langb1196682014-07-23 13:47:29 -04007139 context->recordError(gl::Error(GL_INVALID_VALUE));
7140 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007141 }
7142
7143 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7144 {
7145 const GLuint index = uniformIndices[uniformId];
7146
7147 if (index >= (GLuint)programBinary->getActiveUniformCount())
7148 {
Geoff Langb1196682014-07-23 13:47:29 -04007149 context->recordError(gl::Error(GL_INVALID_VALUE));
7150 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007151 }
7152 }
7153
7154 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7155 {
7156 const GLuint index = uniformIndices[uniformId];
7157 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7158 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007159 }
7160}
7161
Kenneth Russell67ea1902014-10-06 16:44:50 -07007162GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007163{
7164 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7165
Geoff Langbfdea662014-07-23 14:16:32 -04007166 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007167 if (context)
7168 {
7169 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007170 {
Geoff Langb1196682014-07-23 13:47:29 -04007171 context->recordError(gl::Error(GL_INVALID_OPERATION));
7172 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007173 }
7174
7175 gl::Program *programObject = context->getProgram(program);
7176
7177 if (!programObject)
7178 {
7179 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007180 {
Geoff Langb1196682014-07-23 13:47:29 -04007181 context->recordError(gl::Error(GL_INVALID_OPERATION));
7182 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007183 }
Geoff Langbfdea662014-07-23 14:16:32 -04007184 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007185 {
Geoff Langb1196682014-07-23 13:47:29 -04007186 context->recordError(gl::Error(GL_INVALID_VALUE));
7187 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007188 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007189 }
Geoff Langbfdea662014-07-23 14:16:32 -04007190
7191 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7192 if (!programBinary)
7193 {
7194 return GL_INVALID_INDEX;
7195 }
7196
7197 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007198 }
7199
7200 return 0;
7201}
7202
Kenneth Russell67ea1902014-10-06 16:44:50 -07007203void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007204{
7205 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7206 program, uniformBlockIndex, pname, params);
7207
Geoff Langbfdea662014-07-23 14:16:32 -04007208 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007209 if (context)
7210 {
7211 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007212 {
Geoff Langb1196682014-07-23 13:47:29 -04007213 context->recordError(gl::Error(GL_INVALID_OPERATION));
7214 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007215 }
7216 gl::Program *programObject = context->getProgram(program);
7217
7218 if (!programObject)
7219 {
7220 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007221 {
Geoff Langb1196682014-07-23 13:47:29 -04007222 context->recordError(gl::Error(GL_INVALID_OPERATION));
7223 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007224 }
Geoff Langbfdea662014-07-23 14:16:32 -04007225 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007226 {
Geoff Langb1196682014-07-23 13:47:29 -04007227 context->recordError(gl::Error(GL_INVALID_VALUE));
7228 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007229 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007230 }
Geoff Langbfdea662014-07-23 14:16:32 -04007231
7232 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7233
7234 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7235 {
Geoff Langb1196682014-07-23 13:47:29 -04007236 context->recordError(gl::Error(GL_INVALID_VALUE));
7237 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007238 }
7239
7240 switch (pname)
7241 {
7242 case GL_UNIFORM_BLOCK_BINDING:
7243 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7244 break;
7245
7246 case GL_UNIFORM_BLOCK_DATA_SIZE:
7247 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7248 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7249 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7250 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7251 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7252 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7253 break;
7254
7255 default:
Geoff Langb1196682014-07-23 13:47:29 -04007256 context->recordError(gl::Error(GL_INVALID_ENUM));
7257 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007258 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007259 }
7260}
7261
Kenneth Russell67ea1902014-10-06 16:44:50 -07007262void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007263{
7264 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7265 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7266
Geoff Langbfdea662014-07-23 14:16:32 -04007267 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007268 if (context)
7269 {
7270 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007271 {
Geoff Langb1196682014-07-23 13:47:29 -04007272 context->recordError(gl::Error(GL_INVALID_OPERATION));
7273 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007274 }
7275
7276 gl::Program *programObject = context->getProgram(program);
7277
7278 if (!programObject)
7279 {
7280 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007281 {
Geoff Langb1196682014-07-23 13:47:29 -04007282 context->recordError(gl::Error(GL_INVALID_OPERATION));
7283 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007284 }
Geoff Langbfdea662014-07-23 14:16:32 -04007285 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007286 {
Geoff Langb1196682014-07-23 13:47:29 -04007287 context->recordError(gl::Error(GL_INVALID_VALUE));
7288 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007289 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007290 }
Geoff Langbfdea662014-07-23 14:16:32 -04007291
7292 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7293
7294 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7295 {
Geoff Langb1196682014-07-23 13:47:29 -04007296 context->recordError(gl::Error(GL_INVALID_VALUE));
7297 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007298 }
7299
7300 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007301 }
7302}
7303
Kenneth Russell67ea1902014-10-06 16:44:50 -07007304void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007305{
7306 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7307 program, uniformBlockIndex, uniformBlockBinding);
7308
Geoff Langbfdea662014-07-23 14:16:32 -04007309 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007310 if (context)
7311 {
7312 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007313 {
Geoff Langb1196682014-07-23 13:47:29 -04007314 context->recordError(gl::Error(GL_INVALID_OPERATION));
7315 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007316 }
7317
Geoff Lang3a61c322014-07-10 13:01:54 -04007318 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007319 {
Geoff Langb1196682014-07-23 13:47:29 -04007320 context->recordError(gl::Error(GL_INVALID_VALUE));
7321 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007322 }
7323
7324 gl::Program *programObject = context->getProgram(program);
7325
7326 if (!programObject)
7327 {
7328 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007329 {
Geoff Langb1196682014-07-23 13:47:29 -04007330 context->recordError(gl::Error(GL_INVALID_OPERATION));
7331 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007332 }
Geoff Langbfdea662014-07-23 14:16:32 -04007333 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007334 {
Geoff Langb1196682014-07-23 13:47:29 -04007335 context->recordError(gl::Error(GL_INVALID_VALUE));
7336 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007337 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007338 }
Geoff Langbfdea662014-07-23 14:16:32 -04007339
7340 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7341
7342 // if never linked, there won't be any uniform blocks
7343 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7344 {
Geoff Langb1196682014-07-23 13:47:29 -04007345 context->recordError(gl::Error(GL_INVALID_VALUE));
7346 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007347 }
7348
7349 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007350 }
7351}
7352
Kenneth Russell67ea1902014-10-06 16:44:50 -07007353void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007354{
7355 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7356 mode, first, count, instanceCount);
7357
Geoff Langbfdea662014-07-23 14:16:32 -04007358 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007359 if (context)
7360 {
7361 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007362 {
Geoff Langb1196682014-07-23 13:47:29 -04007363 context->recordError(gl::Error(GL_INVALID_OPERATION));
7364 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007365 }
Geoff Langbfdea662014-07-23 14:16:32 -04007366
7367 // glDrawArraysInstanced
7368 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007369 }
7370}
7371
Kenneth Russell67ea1902014-10-06 16:44:50 -07007372void 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 +00007373{
7374 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7375 mode, count, type, indices, instanceCount);
7376
Geoff Langbfdea662014-07-23 14:16:32 -04007377 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007378 if (context)
7379 {
7380 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007381 {
Geoff Langb1196682014-07-23 13:47:29 -04007382 context->recordError(gl::Error(GL_INVALID_OPERATION));
7383 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007384 }
Geoff Langbfdea662014-07-23 14:16:32 -04007385
7386 // glDrawElementsInstanced
7387 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007388 }
7389}
7390
Kenneth Russell67ea1902014-10-06 16:44:50 -07007391GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007392{
7393 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7394
Geoff Langbfdea662014-07-23 14:16:32 -04007395 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007396 if (context)
7397 {
7398 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007399 {
Geoff Langb1196682014-07-23 13:47:29 -04007400 context->recordError(gl::Error(GL_INVALID_OPERATION));
7401 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007402 }
Geoff Langbfdea662014-07-23 14:16:32 -04007403
7404 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7405 {
Geoff Langb1196682014-07-23 13:47:29 -04007406 context->recordError(gl::Error(GL_INVALID_ENUM));
7407 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007408 }
7409
7410 if (flags != 0)
7411 {
Geoff Langb1196682014-07-23 13:47:29 -04007412 context->recordError(gl::Error(GL_INVALID_VALUE));
7413 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007414 }
7415
Geoff Lang882033e2014-09-30 11:26:07 -04007416 GLsync fenceSync = context->createFenceSync();
7417
7418 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7419 gl::Error error = fenceSyncObject->set(condition);
7420 if (error.isError())
7421 {
7422 context->deleteFenceSync(fenceSync);
7423 context->recordError(error);
7424 return NULL;
7425 }
7426
7427 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007428 }
7429
7430 return NULL;
7431}
7432
Kenneth Russell67ea1902014-10-06 16:44:50 -07007433GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007434{
7435 EVENT("(GLsync sync = 0x%0.8p)", sync);
7436
Geoff Langbfdea662014-07-23 14:16:32 -04007437 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007438 if (context)
7439 {
7440 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007441 {
Geoff Langb1196682014-07-23 13:47:29 -04007442 context->recordError(gl::Error(GL_INVALID_OPERATION));
7443 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007444 }
Geoff Langbfdea662014-07-23 14:16:32 -04007445
7446 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007447 }
7448
7449 return GL_FALSE;
7450}
7451
Kenneth Russell67ea1902014-10-06 16:44:50 -07007452void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007453{
7454 EVENT("(GLsync sync = 0x%0.8p)", sync);
7455
Geoff Langbfdea662014-07-23 14:16:32 -04007456 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007457 if (context)
7458 {
7459 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007460 {
Geoff Langb1196682014-07-23 13:47:29 -04007461 context->recordError(gl::Error(GL_INVALID_OPERATION));
7462 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007463 }
Geoff Langbfdea662014-07-23 14:16:32 -04007464
7465 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7466 {
Geoff Langb1196682014-07-23 13:47:29 -04007467 context->recordError(gl::Error(GL_INVALID_VALUE));
7468 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007469 }
7470
7471 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007472 }
7473}
7474
Kenneth Russell67ea1902014-10-06 16:44:50 -07007475GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007476{
7477 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7478 sync, flags, timeout);
7479
Geoff Langbfdea662014-07-23 14:16:32 -04007480 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007481 if (context)
7482 {
7483 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007484 {
Geoff Langb1196682014-07-23 13:47:29 -04007485 context->recordError(gl::Error(GL_INVALID_OPERATION));
7486 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007487 }
Geoff Langbfdea662014-07-23 14:16:32 -04007488
7489 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7490 {
Geoff Langb1196682014-07-23 13:47:29 -04007491 context->recordError(gl::Error(GL_INVALID_VALUE));
7492 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007493 }
7494
7495 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7496
7497 if (!fenceSync)
7498 {
Geoff Langb1196682014-07-23 13:47:29 -04007499 context->recordError(gl::Error(GL_INVALID_VALUE));
7500 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007501 }
7502
Geoff Lang882033e2014-09-30 11:26:07 -04007503 GLenum result = GL_WAIT_FAILED;
7504 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7505 if (error.isError())
7506 {
7507 context->recordError(error);
7508 return GL_WAIT_FAILED;
7509 }
7510
7511 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007512 }
7513
7514 return GL_FALSE;
7515}
7516
Kenneth Russell67ea1902014-10-06 16:44:50 -07007517void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007518{
7519 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7520 sync, flags, timeout);
7521
Geoff Langbfdea662014-07-23 14:16:32 -04007522 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007523 if (context)
7524 {
7525 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007526 {
Geoff Langb1196682014-07-23 13:47:29 -04007527 context->recordError(gl::Error(GL_INVALID_OPERATION));
7528 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007529 }
Geoff Langbfdea662014-07-23 14:16:32 -04007530
7531 if (flags != 0)
7532 {
Geoff Langb1196682014-07-23 13:47:29 -04007533 context->recordError(gl::Error(GL_INVALID_VALUE));
7534 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007535 }
7536
7537 if (timeout != GL_TIMEOUT_IGNORED)
7538 {
Geoff Langb1196682014-07-23 13:47:29 -04007539 context->recordError(gl::Error(GL_INVALID_VALUE));
7540 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007541 }
7542
7543 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7544
7545 if (!fenceSync)
7546 {
Geoff Langb1196682014-07-23 13:47:29 -04007547 context->recordError(gl::Error(GL_INVALID_VALUE));
7548 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007549 }
7550
Geoff Lang882033e2014-09-30 11:26:07 -04007551 gl::Error error = fenceSync->serverWait();
7552 if (error.isError())
7553 {
7554 context->recordError(error);
7555 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007556 }
7557}
7558
Kenneth Russell67ea1902014-10-06 16:44:50 -07007559void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007560{
7561 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7562 pname, params);
7563
Geoff Langbfdea662014-07-23 14:16:32 -04007564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007565 if (context)
7566 {
7567 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007568 {
Geoff Langb1196682014-07-23 13:47:29 -04007569 context->recordError(gl::Error(GL_INVALID_OPERATION));
7570 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007571 }
Geoff Langbfdea662014-07-23 14:16:32 -04007572
7573 GLenum nativeType;
7574 unsigned int numParams = 0;
7575 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7576 {
7577 return;
7578 }
7579
7580 if (nativeType == GL_INT_64_ANGLEX)
7581 {
7582 context->getInteger64v(pname, params);
7583 }
7584 else
7585 {
7586 CastStateValues(context, nativeType, pname, numParams, params);
7587 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007588 }
7589}
7590
Kenneth Russell67ea1902014-10-06 16:44:50 -07007591void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007592{
7593 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7594 sync, pname, bufSize, length, values);
7595
Geoff Langbfdea662014-07-23 14:16:32 -04007596 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007597 if (context)
7598 {
7599 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007600 {
Geoff Langb1196682014-07-23 13:47:29 -04007601 context->recordError(gl::Error(GL_INVALID_OPERATION));
7602 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007603 }
Geoff Langbfdea662014-07-23 14:16:32 -04007604
7605 if (bufSize < 0)
7606 {
Geoff Langb1196682014-07-23 13:47:29 -04007607 context->recordError(gl::Error(GL_INVALID_VALUE));
7608 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007609 }
7610
7611 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7612
7613 if (!fenceSync)
7614 {
Geoff Langb1196682014-07-23 13:47:29 -04007615 context->recordError(gl::Error(GL_INVALID_VALUE));
7616 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007617 }
7618
7619 switch (pname)
7620 {
7621 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007622 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7623 case GL_SYNC_FLAGS: values[0] = 0; break;
7624
Geoff Lang882033e2014-09-30 11:26:07 -04007625 case GL_SYNC_STATUS:
7626 {
7627 gl::Error error = fenceSync->getStatus(values);
7628 if (error.isError())
7629 {
7630 context->recordError(error);
7631 return;
7632 }
7633 break;
7634 }
7635
Geoff Langbfdea662014-07-23 14:16:32 -04007636 default:
Geoff Langb1196682014-07-23 13:47:29 -04007637 context->recordError(gl::Error(GL_INVALID_ENUM));
7638 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007639 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007640 }
7641}
7642
Kenneth Russell67ea1902014-10-06 16:44:50 -07007643void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007644{
7645 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7646 target, index, data);
7647
Geoff Langbfdea662014-07-23 14:16:32 -04007648 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007649 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007650 {
Geoff Langbfdea662014-07-23 14:16:32 -04007651 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007652 {
Geoff Langb1196682014-07-23 13:47:29 -04007653 context->recordError(gl::Error(GL_INVALID_OPERATION));
7654 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007655 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007656
Geoff Lang3a61c322014-07-10 13:01:54 -04007657 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007658 switch (target)
7659 {
7660 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7661 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7662 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007663 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7664 {
Geoff Langb1196682014-07-23 13:47:29 -04007665 context->recordError(gl::Error(GL_INVALID_VALUE));
7666 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007667 }
Geoff Langbfdea662014-07-23 14:16:32 -04007668 break;
Geoff Langb1196682014-07-23 13:47:29 -04007669
Geoff Langbfdea662014-07-23 14:16:32 -04007670 case GL_UNIFORM_BUFFER_START:
7671 case GL_UNIFORM_BUFFER_SIZE:
7672 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007673 if (index >= caps.maxUniformBufferBindings)
7674 {
Geoff Langb1196682014-07-23 13:47:29 -04007675 context->recordError(gl::Error(GL_INVALID_VALUE));
7676 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007677 }
Geoff Langbfdea662014-07-23 14:16:32 -04007678 break;
Geoff Langb1196682014-07-23 13:47:29 -04007679
Geoff Langbfdea662014-07-23 14:16:32 -04007680 default:
Geoff Langb1196682014-07-23 13:47:29 -04007681 context->recordError(gl::Error(GL_INVALID_ENUM));
7682 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007683 }
7684
7685 if (!(context->getIndexedInteger64v(target, index, data)))
7686 {
7687 GLenum nativeType;
7688 unsigned int numParams = 0;
7689 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007690 {
7691 context->recordError(gl::Error(GL_INVALID_ENUM));
7692 return;
7693 }
Shannon Woods15934d52013-08-19 14:28:49 -04007694
Geoff Langbfdea662014-07-23 14:16:32 -04007695 if (numParams == 0)
7696 return; // it is known that pname is valid, but there are no parameters to return
7697
7698 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007699 {
Geoff Langbfdea662014-07-23 14:16:32 -04007700 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007701
Geoff Langbfdea662014-07-23 14:16:32 -04007702 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007703
Geoff Langbfdea662014-07-23 14:16:32 -04007704 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007705 {
Geoff Langbfdea662014-07-23 14:16:32 -04007706 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007707 }
Geoff Langbfdea662014-07-23 14:16:32 -04007708
7709 delete [] intParams;
7710 }
7711 else
7712 {
7713 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007714 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007715 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007716 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007717}
7718
Kenneth Russell67ea1902014-10-06 16:44:50 -07007719void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007720{
7721 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7722 target, pname, params);
7723
Geoff Langbfdea662014-07-23 14:16:32 -04007724 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007725 if (context)
7726 {
7727 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007728 {
Geoff Langb1196682014-07-23 13:47:29 -04007729 context->recordError(gl::Error(GL_INVALID_OPERATION));
7730 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007731 }
Geoff Langbfdea662014-07-23 14:16:32 -04007732
7733 if (!gl::ValidBufferTarget(context, target))
7734 {
Geoff Langb1196682014-07-23 13:47:29 -04007735 context->recordError(gl::Error(GL_INVALID_ENUM));
7736 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007737 }
7738
7739 if (!gl::ValidBufferParameter(context, pname))
7740 {
Geoff Langb1196682014-07-23 13:47:29 -04007741 context->recordError(gl::Error(GL_INVALID_ENUM));
7742 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007743 }
7744
7745 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7746
7747 if (!buffer)
7748 {
7749 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007750 context->recordError(gl::Error(GL_INVALID_OPERATION));
7751 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007752 }
7753
7754 switch (pname)
7755 {
7756 case GL_BUFFER_USAGE:
7757 *params = static_cast<GLint64>(buffer->getUsage());
7758 break;
7759 case GL_BUFFER_SIZE:
7760 *params = buffer->getSize();
7761 break;
7762 case GL_BUFFER_ACCESS_FLAGS:
7763 *params = static_cast<GLint64>(buffer->getAccessFlags());
7764 break;
7765 case GL_BUFFER_MAPPED:
7766 *params = static_cast<GLint64>(buffer->isMapped());
7767 break;
7768 case GL_BUFFER_MAP_OFFSET:
7769 *params = buffer->getMapOffset();
7770 break;
7771 case GL_BUFFER_MAP_LENGTH:
7772 *params = buffer->getMapLength();
7773 break;
7774 default: UNREACHABLE(); break;
7775 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007776 }
7777}
7778
Kenneth Russell67ea1902014-10-06 16:44:50 -07007779void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007780{
7781 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7782
Geoff Langbfdea662014-07-23 14:16:32 -04007783 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007784 if (context)
7785 {
7786 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007787 {
Geoff Langb1196682014-07-23 13:47:29 -04007788 context->recordError(gl::Error(GL_INVALID_OPERATION));
7789 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007790 }
Geoff Langbfdea662014-07-23 14:16:32 -04007791
7792 if (count < 0)
7793 {
Geoff Langb1196682014-07-23 13:47:29 -04007794 context->recordError(gl::Error(GL_INVALID_VALUE));
7795 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007796 }
7797
7798 for (int i = 0; i < count; i++)
7799 {
7800 samplers[i] = context->createSampler();
7801 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007802 }
7803}
7804
Kenneth Russell67ea1902014-10-06 16:44:50 -07007805void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007806{
7807 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7808
Geoff Langbfdea662014-07-23 14:16:32 -04007809 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007810 if (context)
7811 {
7812 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007813 {
Geoff Langb1196682014-07-23 13:47:29 -04007814 context->recordError(gl::Error(GL_INVALID_OPERATION));
7815 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007816 }
Geoff Langbfdea662014-07-23 14:16:32 -04007817
7818 if (count < 0)
7819 {
Geoff Langb1196682014-07-23 13:47:29 -04007820 context->recordError(gl::Error(GL_INVALID_VALUE));
7821 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007822 }
7823
7824 for (int i = 0; i < count; i++)
7825 {
7826 context->deleteSampler(samplers[i]);
7827 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007828 }
7829}
7830
Kenneth Russell67ea1902014-10-06 16:44:50 -07007831GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007832{
7833 EVENT("(GLuint sampler = %u)", sampler);
7834
Geoff Langbfdea662014-07-23 14:16:32 -04007835 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007836 if (context)
7837 {
7838 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007839 {
Geoff Langb1196682014-07-23 13:47:29 -04007840 context->recordError(gl::Error(GL_INVALID_OPERATION));
7841 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007842 }
Geoff Langbfdea662014-07-23 14:16:32 -04007843
7844 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007845 }
7846
7847 return GL_FALSE;
7848}
7849
Kenneth Russell67ea1902014-10-06 16:44:50 -07007850void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007851{
7852 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7853
Geoff Langbfdea662014-07-23 14:16:32 -04007854 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007855 if (context)
7856 {
7857 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007858 {
Geoff Langb1196682014-07-23 13:47:29 -04007859 context->recordError(gl::Error(GL_INVALID_OPERATION));
7860 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007861 }
Geoff Langbfdea662014-07-23 14:16:32 -04007862
7863 if (sampler != 0 && !context->isSampler(sampler))
7864 {
Geoff Langb1196682014-07-23 13:47:29 -04007865 context->recordError(gl::Error(GL_INVALID_OPERATION));
7866 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007867 }
7868
Geoff Lang3a61c322014-07-10 13:01:54 -04007869 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007870 {
Geoff Langb1196682014-07-23 13:47:29 -04007871 context->recordError(gl::Error(GL_INVALID_VALUE));
7872 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007873 }
7874
7875 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007876 }
7877}
7878
Kenneth Russell67ea1902014-10-06 16:44:50 -07007879void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007880{
7881 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7882
Geoff Langbfdea662014-07-23 14:16:32 -04007883 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007884 if (context)
7885 {
7886 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007887 {
Geoff Langb1196682014-07-23 13:47:29 -04007888 context->recordError(gl::Error(GL_INVALID_OPERATION));
7889 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007890 }
Geoff Langbfdea662014-07-23 14:16:32 -04007891
Geoff Langb1196682014-07-23 13:47:29 -04007892 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007893 {
7894 return;
7895 }
7896
7897 if (!gl::ValidateTexParamParameters(context, pname, param))
7898 {
7899 return;
7900 }
7901
7902 if (!context->isSampler(sampler))
7903 {
Geoff Langb1196682014-07-23 13:47:29 -04007904 context->recordError(gl::Error(GL_INVALID_OPERATION));
7905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007906 }
7907
7908 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007909 }
7910}
7911
Kenneth Russell67ea1902014-10-06 16:44:50 -07007912void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007913{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007914 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007915}
7916
Kenneth Russell67ea1902014-10-06 16:44:50 -07007917void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007918{
7919 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7920
Geoff Langbfdea662014-07-23 14:16:32 -04007921 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007922 if (context)
7923 {
7924 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007925 {
Geoff Langb1196682014-07-23 13:47:29 -04007926 context->recordError(gl::Error(GL_INVALID_OPERATION));
7927 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007928 }
Geoff Langbfdea662014-07-23 14:16:32 -04007929
Geoff Langb1196682014-07-23 13:47:29 -04007930 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007931 {
7932 return;
7933 }
7934
7935 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7936 {
7937 return;
7938 }
7939
7940 if (!context->isSampler(sampler))
7941 {
Geoff Langb1196682014-07-23 13:47:29 -04007942 context->recordError(gl::Error(GL_INVALID_OPERATION));
7943 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007944 }
7945
7946 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007947 }
7948}
7949
Kenneth Russell67ea1902014-10-06 16:44:50 -07007950void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007951{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007952 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953}
7954
Kenneth Russell67ea1902014-10-06 16:44:50 -07007955void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007956{
7957 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7958
Geoff Langbfdea662014-07-23 14:16:32 -04007959 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007960 if (context)
7961 {
7962 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007963 {
Geoff Langb1196682014-07-23 13:47:29 -04007964 context->recordError(gl::Error(GL_INVALID_OPERATION));
7965 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007966 }
Geoff Langbfdea662014-07-23 14:16:32 -04007967
Geoff Langb1196682014-07-23 13:47:29 -04007968 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007969 {
7970 return;
7971 }
7972
7973 if (!context->isSampler(sampler))
7974 {
Geoff Langb1196682014-07-23 13:47:29 -04007975 context->recordError(gl::Error(GL_INVALID_OPERATION));
7976 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007977 }
7978
7979 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980 }
7981}
7982
Kenneth Russell67ea1902014-10-06 16:44:50 -07007983void GL_APIENTRY glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007984{
7985 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
7986
Geoff Langbfdea662014-07-23 14:16:32 -04007987 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007988 if (context)
7989 {
7990 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007991 {
Geoff Langb1196682014-07-23 13:47:29 -04007992 context->recordError(gl::Error(GL_INVALID_OPERATION));
7993 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007994 }
Geoff Langbfdea662014-07-23 14:16:32 -04007995
Geoff Langb1196682014-07-23 13:47:29 -04007996 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007997 {
7998 return;
7999 }
8000
8001 if (!context->isSampler(sampler))
8002 {
Geoff Langb1196682014-07-23 13:47:29 -04008003 context->recordError(gl::Error(GL_INVALID_OPERATION));
8004 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008005 }
8006
8007 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008008 }
8009}
8010
Kenneth Russell67ea1902014-10-06 16:44:50 -07008011void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008012{
8013 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8014
Geoff Langbfdea662014-07-23 14:16:32 -04008015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008016 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008017 {
Geoff Langbfdea662014-07-23 14:16:32 -04008018 if (context->getClientVersion() < 3)
8019 {
Geoff Langb1196682014-07-23 13:47:29 -04008020 context->recordError(gl::Error(GL_INVALID_OPERATION));
8021 return;
8022 }
8023
8024 if (index >= gl::MAX_VERTEX_ATTRIBS)
8025 {
8026 context->recordError(gl::Error(GL_INVALID_VALUE));
8027 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008028 }
8029
8030 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008031 }
8032}
8033
Kenneth Russell67ea1902014-10-06 16:44:50 -07008034void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008035{
8036 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8037
Geoff Langbfdea662014-07-23 14:16:32 -04008038 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008039 if (context)
8040 {
8041 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008042 {
Geoff Langb1196682014-07-23 13:47:29 -04008043 context->recordError(gl::Error(GL_INVALID_OPERATION));
8044 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008045 }
Geoff Langbfdea662014-07-23 14:16:32 -04008046
8047 switch (target)
8048 {
8049 case GL_TRANSFORM_FEEDBACK:
8050 {
8051 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8052 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8053 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8054 {
Geoff Langb1196682014-07-23 13:47:29 -04008055 context->recordError(gl::Error(GL_INVALID_OPERATION));
8056 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008057 }
8058
8059 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8060 if (context->getTransformFeedback(id) == NULL)
8061 {
Geoff Langb1196682014-07-23 13:47:29 -04008062 context->recordError(gl::Error(GL_INVALID_OPERATION));
8063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008064 }
8065
8066 context->bindTransformFeedback(id);
8067 }
8068 break;
8069
8070 default:
Geoff Langb1196682014-07-23 13:47:29 -04008071 context->recordError(gl::Error(GL_INVALID_ENUM));
8072 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008073 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008074 }
8075}
8076
Kenneth Russell67ea1902014-10-06 16:44:50 -07008077void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008078{
8079 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8080
Geoff Langbfdea662014-07-23 14:16:32 -04008081 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008082 if (context)
8083 {
8084 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008085 {
Geoff Langb1196682014-07-23 13:47:29 -04008086 context->recordError(gl::Error(GL_INVALID_OPERATION));
8087 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008088 }
Geoff Langbfdea662014-07-23 14:16:32 -04008089
8090 for (int i = 0; i < n; i++)
8091 {
8092 context->deleteTransformFeedback(ids[i]);
8093 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008094 }
8095}
8096
Kenneth Russell67ea1902014-10-06 16:44:50 -07008097void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008098{
8099 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8100
Geoff Langbfdea662014-07-23 14:16:32 -04008101 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008102 if (context)
8103 {
8104 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008105 {
Geoff Langb1196682014-07-23 13:47:29 -04008106 context->recordError(gl::Error(GL_INVALID_OPERATION));
8107 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008108 }
Geoff Langbfdea662014-07-23 14:16:32 -04008109
8110 for (int i = 0; i < n; i++)
8111 {
8112 ids[i] = context->createTransformFeedback();
8113 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008114 }
8115}
8116
Kenneth Russell67ea1902014-10-06 16:44:50 -07008117GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008118{
8119 EVENT("(GLuint id = %u)", id);
8120
Geoff Langbfdea662014-07-23 14:16:32 -04008121 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008122 if (context)
8123 {
8124 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008125 {
Geoff Langb1196682014-07-23 13:47:29 -04008126 context->recordError(gl::Error(GL_INVALID_OPERATION));
8127 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008128 }
Geoff Langbfdea662014-07-23 14:16:32 -04008129
8130 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008131 }
8132
8133 return GL_FALSE;
8134}
8135
Kenneth Russell67ea1902014-10-06 16:44:50 -07008136void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008137{
8138 EVENT("(void)");
8139
Geoff Langbfdea662014-07-23 14:16:32 -04008140 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008141 if (context)
8142 {
8143 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008144 {
Geoff Langb1196682014-07-23 13:47:29 -04008145 context->recordError(gl::Error(GL_INVALID_OPERATION));
8146 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008147 }
Geoff Langbfdea662014-07-23 14:16:32 -04008148
8149 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8150 ASSERT(transformFeedback != NULL);
8151
8152 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8153 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8154 {
Geoff Langb1196682014-07-23 13:47:29 -04008155 context->recordError(gl::Error(GL_INVALID_OPERATION));
8156 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008157 }
8158
8159 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008160 }
8161}
8162
Kenneth Russell67ea1902014-10-06 16:44:50 -07008163void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008164{
8165 EVENT("(void)");
8166
Geoff Langbfdea662014-07-23 14:16:32 -04008167 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008168 if (context)
8169 {
8170 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008171 {
Geoff Langb1196682014-07-23 13:47:29 -04008172 context->recordError(gl::Error(GL_INVALID_OPERATION));
8173 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008174 }
Geoff Langbfdea662014-07-23 14:16:32 -04008175
8176 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8177 ASSERT(transformFeedback != NULL);
8178
8179 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8180 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8181 {
Geoff Langb1196682014-07-23 13:47:29 -04008182 context->recordError(gl::Error(GL_INVALID_OPERATION));
8183 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008184 }
8185
8186 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008187 }
8188}
8189
Kenneth Russell67ea1902014-10-06 16:44:50 -07008190void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008191{
8192 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8193 program, bufSize, length, binaryFormat, binary);
8194
Geoff Langbfdea662014-07-23 14:16:32 -04008195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008196 if (context)
8197 {
8198 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008199 {
Geoff Langb1196682014-07-23 13:47:29 -04008200 context->recordError(gl::Error(GL_INVALID_OPERATION));
8201 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008202 }
Geoff Langbfdea662014-07-23 14:16:32 -04008203
8204 // glGetProgramBinary
8205 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008206 }
8207}
8208
Kenneth Russell67ea1902014-10-06 16:44:50 -07008209void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008210{
8211 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8212 program, binaryFormat, binary, length);
8213
Geoff Langbfdea662014-07-23 14:16:32 -04008214 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008215 if (context)
8216 {
8217 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008218 {
Geoff Langb1196682014-07-23 13:47:29 -04008219 context->recordError(gl::Error(GL_INVALID_OPERATION));
8220 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008221 }
Geoff Langbfdea662014-07-23 14:16:32 -04008222
8223 // glProgramBinary
8224 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008225 }
8226}
8227
Kenneth Russell67ea1902014-10-06 16:44:50 -07008228void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008229{
8230 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8231 program, pname, value);
8232
Geoff Langbfdea662014-07-23 14:16:32 -04008233 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008234 if (context)
8235 {
8236 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008237 {
Geoff Langb1196682014-07-23 13:47:29 -04008238 context->recordError(gl::Error(GL_INVALID_OPERATION));
8239 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008240 }
Geoff Langbfdea662014-07-23 14:16:32 -04008241
8242 // glProgramParameteri
8243 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008244 }
8245}
8246
Kenneth Russell67ea1902014-10-06 16:44:50 -07008247void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008248{
8249 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8250 target, numAttachments, attachments);
8251
Geoff Langbfdea662014-07-23 14:16:32 -04008252 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008253 if (context)
8254 {
8255 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008256 {
Geoff Langb1196682014-07-23 13:47:29 -04008257 context->recordError(gl::Error(GL_INVALID_OPERATION));
8258 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008259 }
Geoff Langbfdea662014-07-23 14:16:32 -04008260
8261 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8262 {
8263 return;
8264 }
8265
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008266 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8267 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8268 {
8269 framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8270 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008271 }
8272}
8273
Kenneth Russell67ea1902014-10-06 16:44:50 -07008274void 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 +00008275{
8276 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8277 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8278 target, numAttachments, attachments, x, y, width, height);
8279
Geoff Langbfdea662014-07-23 14:16:32 -04008280 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008281 if (context)
8282 {
8283 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008284 {
Geoff Langb1196682014-07-23 13:47:29 -04008285 context->recordError(gl::Error(GL_INVALID_OPERATION));
8286 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008287 }
Geoff Langbfdea662014-07-23 14:16:32 -04008288
8289 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8290 {
8291 return;
8292 }
8293
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008294 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8295 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8296 {
8297 framebuffer->invalidateSub(context->getCaps(), numAttachments, attachments, x, y, width, height);
8298 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008299 }
8300}
8301
Kenneth Russell67ea1902014-10-06 16:44:50 -07008302void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008303{
8304 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8305 target, levels, internalformat, width, height);
8306
Geoff Langbfdea662014-07-23 14:16:32 -04008307 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008308 if (context)
8309 {
8310 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008311 {
Geoff Langb1196682014-07-23 13:47:29 -04008312 context->recordError(gl::Error(GL_INVALID_OPERATION));
8313 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008314 }
Geoff Langbfdea662014-07-23 14:16:32 -04008315
8316 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8317 {
8318 return;
8319 }
8320
8321 switch (target)
8322 {
8323 case GL_TEXTURE_2D:
8324 {
8325 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008326 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8327 if (error.isError())
8328 {
8329 context->recordError(error);
8330 return;
8331 }
Geoff Langbfdea662014-07-23 14:16:32 -04008332 }
8333 break;
8334
8335 case GL_TEXTURE_CUBE_MAP:
8336 {
8337 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008338 gl::Error error = textureCube->storage(levels, internalformat, width);
8339 if (error.isError())
8340 {
8341 context->recordError(error);
8342 return;
8343 }
Geoff Langbfdea662014-07-23 14:16:32 -04008344 }
8345 break;
8346
8347 default:
Geoff Langb1196682014-07-23 13:47:29 -04008348 context->recordError(gl::Error(GL_INVALID_ENUM));
8349 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008350 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008351 }
8352}
8353
Kenneth Russell67ea1902014-10-06 16:44:50 -07008354void 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 +00008355{
8356 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8357 "GLsizei height = %d, GLsizei depth = %d)",
8358 target, levels, internalformat, width, height, depth);
8359
Geoff Langbfdea662014-07-23 14:16:32 -04008360 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008361 if (context)
8362 {
8363 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008364 {
Geoff Langb1196682014-07-23 13:47:29 -04008365 context->recordError(gl::Error(GL_INVALID_OPERATION));
8366 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008367 }
Geoff Langbfdea662014-07-23 14:16:32 -04008368
8369 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8370 {
8371 return;
8372 }
8373
8374 switch (target)
8375 {
8376 case GL_TEXTURE_3D:
8377 {
8378 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008379 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8380 if (error.isError())
8381 {
8382 context->recordError(error);
8383 return;
8384 }
Geoff Langbfdea662014-07-23 14:16:32 -04008385 }
8386 break;
8387
8388 case GL_TEXTURE_2D_ARRAY:
8389 {
8390 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008391 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8392 if (error.isError())
8393 {
8394 context->recordError(error);
8395 return;
8396 }
Geoff Langbfdea662014-07-23 14:16:32 -04008397 }
8398 break;
8399
8400 default:
8401 UNREACHABLE();
8402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008403 }
8404}
8405
Kenneth Russell67ea1902014-10-06 16:44:50 -07008406void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008407{
8408 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8409 "GLint* params = 0x%0.8p)",
8410 target, internalformat, pname, bufSize, params);
8411
Geoff Langbfdea662014-07-23 14:16:32 -04008412 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008413 if (context)
8414 {
8415 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008416 {
Geoff Langb1196682014-07-23 13:47:29 -04008417 context->recordError(gl::Error(GL_INVALID_OPERATION));
8418 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008419 }
Geoff Langbfdea662014-07-23 14:16:32 -04008420
8421 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8422 if (!formatCaps.renderable)
8423 {
Geoff Langb1196682014-07-23 13:47:29 -04008424 context->recordError(gl::Error(GL_INVALID_ENUM));
8425 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008426 }
8427
8428 if (target != GL_RENDERBUFFER)
8429 {
Geoff Langb1196682014-07-23 13:47:29 -04008430 context->recordError(gl::Error(GL_INVALID_ENUM));
8431 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008432 }
8433
8434 if (bufSize < 0)
8435 {
Geoff Langb1196682014-07-23 13:47:29 -04008436 context->recordError(gl::Error(GL_INVALID_VALUE));
8437 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008438 }
8439
8440 switch (pname)
8441 {
8442 case GL_NUM_SAMPLE_COUNTS:
8443 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008444 {
8445 *params = formatCaps.sampleCounts.size();
8446 }
Geoff Langbfdea662014-07-23 14:16:32 -04008447 break;
Geoff Langb1196682014-07-23 13:47:29 -04008448
Geoff Langbfdea662014-07-23 14:16:32 -04008449 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008450 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008451 break;
Geoff Langb1196682014-07-23 13:47:29 -04008452
Geoff Langbfdea662014-07-23 14:16:32 -04008453 default:
Geoff Langb1196682014-07-23 13:47:29 -04008454 context->recordError(gl::Error(GL_INVALID_ENUM));
8455 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008456 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008457 }
8458}
8459
8460// Extension functions
8461
Kenneth Russell67ea1902014-10-06 16:44:50 -07008462void 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 +00008463 GLbitfield mask, GLenum filter)
8464{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008465 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008466 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8467 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8468 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8469
Geoff Langbfdea662014-07-23 14:16:32 -04008470 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008471 if (context)
8472 {
8473 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8474 dstX0, dstY0, dstX1, dstY1, mask, filter,
8475 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008476 {
Geoff Langbfdea662014-07-23 14:16:32 -04008477 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008478 }
Geoff Langbfdea662014-07-23 14:16:32 -04008479
Geoff Lang64839152014-08-26 16:23:25 -04008480 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8481 mask, filter);
8482 if (error.isError())
8483 {
8484 context->recordError(error);
8485 return;
8486 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008487 }
8488}
8489
Kenneth Russell67ea1902014-10-06 16:44:50 -07008490void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008491 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008492{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008493 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008494 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008495 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008496 target, level, internalformat, width, height, depth, border, format, type, pixels);
8497
Geoff Langbfdea662014-07-23 14:16:32 -04008498 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008499}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008500
Kenneth Russell67ea1902014-10-06 16:44:50 -07008501void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008502 GLenum *binaryFormat, void *binary)
8503{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008504 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 +00008505 program, bufSize, length, binaryFormat, binary);
8506
Geoff Langbfdea662014-07-23 14:16:32 -04008507 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008508 if (context)
8509 {
8510 gl::Program *programObject = context->getProgram(program);
8511
8512 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008513 {
Geoff Langb1196682014-07-23 13:47:29 -04008514 context->recordError(gl::Error(GL_INVALID_OPERATION));
8515 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008516 }
Geoff Langbfdea662014-07-23 14:16:32 -04008517
8518 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8519
8520 if (!programBinary)
8521 {
Geoff Langb1196682014-07-23 13:47:29 -04008522 context->recordError(gl::Error(GL_INVALID_OPERATION));
8523 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008524 }
8525
Geoff Langb543aff2014-09-30 14:52:54 -04008526 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8527 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008528 {
Geoff Langb543aff2014-09-30 14:52:54 -04008529 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008530 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008531 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008532 }
8533}
8534
Kenneth Russell67ea1902014-10-06 16:44:50 -07008535void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008536 const void *binary, GLint length)
8537{
8538 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8539 program, binaryFormat, binary, length);
8540
Geoff Langbfdea662014-07-23 14:16:32 -04008541 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008542 if (context)
8543 {
Geoff Lang900013c2014-07-07 11:32:19 -04008544 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8545 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008546 {
Geoff Langb1196682014-07-23 13:47:29 -04008547 context->recordError(gl::Error(GL_INVALID_ENUM));
8548 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008549 }
Geoff Langbfdea662014-07-23 14:16:32 -04008550
8551 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008552 if (!programObject)
8553 {
Geoff Langb1196682014-07-23 13:47:29 -04008554 context->recordError(gl::Error(GL_INVALID_OPERATION));
8555 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008556 }
8557
Geoff Langb543aff2014-09-30 14:52:54 -04008558 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8559 if (error.isError())
8560 {
8561 context->recordError(error);
8562 return;
8563 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008564 }
8565}
8566
Kenneth Russell67ea1902014-10-06 16:44:50 -07008567void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008568{
8569 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8570
Geoff Langbfdea662014-07-23 14:16:32 -04008571 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008572 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008573 {
Geoff Langbfdea662014-07-23 14:16:32 -04008574 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008575 {
Geoff Langb1196682014-07-23 13:47:29 -04008576 context->recordError(gl::Error(GL_INVALID_VALUE));
8577 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008578 }
8579
8580 if (context->getState().getDrawFramebuffer()->id() == 0)
8581 {
8582 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008583 {
Geoff Langb1196682014-07-23 13:47:29 -04008584 context->recordError(gl::Error(GL_INVALID_OPERATION));
8585 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008586 }
8587
Geoff Langbfdea662014-07-23 14:16:32 -04008588 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008589 {
Geoff Langb1196682014-07-23 13:47:29 -04008590 context->recordError(gl::Error(GL_INVALID_OPERATION));
8591 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008592 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008593 }
Geoff Langbfdea662014-07-23 14:16:32 -04008594 else
8595 {
8596 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8597 {
8598 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8599 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8600 {
Geoff Langb1196682014-07-23 13:47:29 -04008601 context->recordError(gl::Error(GL_INVALID_OPERATION));
8602 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008603 }
8604 }
8605 }
8606
8607 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
8608
8609 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8610 {
8611 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8612 }
8613
8614 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8615 {
8616 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8617 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008618 }
8619}
8620
Kenneth Russell67ea1902014-10-06 16:44:50 -07008621void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008622{
8623 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8624
Geoff Langbfdea662014-07-23 14:16:32 -04008625 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008626 if (context)
8627 {
8628 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008629 {
Geoff Langb1196682014-07-23 13:47:29 -04008630 context->recordError(gl::Error(GL_INVALID_ENUM));
8631 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008632 }
Geoff Langbfdea662014-07-23 14:16:32 -04008633
8634 if (pname != GL_BUFFER_MAP_POINTER)
8635 {
Geoff Langb1196682014-07-23 13:47:29 -04008636 context->recordError(gl::Error(GL_INVALID_ENUM));
8637 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008638 }
8639
8640 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8641
8642 if (!buffer || !buffer->isMapped())
8643 {
8644 *params = NULL;
8645 }
8646 else
8647 {
8648 *params = buffer->getMapPointer();
8649 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008650 }
8651}
8652
Kenneth Russell67ea1902014-10-06 16:44:50 -07008653void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008654{
8655 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8656
Geoff Langbfdea662014-07-23 14:16:32 -04008657 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008658 if (context)
8659 {
8660 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008661 {
Geoff Langb1196682014-07-23 13:47:29 -04008662 context->recordError(gl::Error(GL_INVALID_ENUM));
8663 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008664 }
Geoff Langbfdea662014-07-23 14:16:32 -04008665
8666 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8667
8668 if (buffer == NULL)
8669 {
Geoff Langb1196682014-07-23 13:47:29 -04008670 context->recordError(gl::Error(GL_INVALID_OPERATION));
8671 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008672 }
8673
8674 if (access != GL_WRITE_ONLY_OES)
8675 {
Geoff Langb1196682014-07-23 13:47:29 -04008676 context->recordError(gl::Error(GL_INVALID_ENUM));
8677 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008678 }
8679
8680 if (buffer->isMapped())
8681 {
Geoff Langb1196682014-07-23 13:47:29 -04008682 context->recordError(gl::Error(GL_INVALID_OPERATION));
8683 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008684 }
8685
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008686 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8687 if (error.isError())
8688 {
8689 context->recordError(error);
8690 return NULL;
8691 }
8692
8693 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008694 }
8695
8696 return NULL;
8697}
8698
Kenneth Russell67ea1902014-10-06 16:44:50 -07008699GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008700{
8701 EVENT("(GLenum target = 0x%X)", target);
8702
Geoff Langbfdea662014-07-23 14:16:32 -04008703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008704 if (context)
8705 {
8706 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008707 {
Geoff Langb1196682014-07-23 13:47:29 -04008708 context->recordError(gl::Error(GL_INVALID_ENUM));
8709 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008710 }
Geoff Langbfdea662014-07-23 14:16:32 -04008711
8712 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8713
8714 if (buffer == NULL || !buffer->isMapped())
8715 {
Geoff Langb1196682014-07-23 13:47:29 -04008716 context->recordError(gl::Error(GL_INVALID_OPERATION));
8717 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008718 }
8719
8720 // TODO: detect if we had corruption. if so, throw an error and return false.
8721
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008722 gl::Error error = buffer->unmap();
8723 if (error.isError())
8724 {
8725 context->recordError(error);
8726 return GL_FALSE;
8727 }
Geoff Langbfdea662014-07-23 14:16:32 -04008728
8729 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008730 }
8731
8732 return GL_FALSE;
8733}
8734
Kenneth Russell67ea1902014-10-06 16:44:50 -07008735void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008736{
8737 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8738 target, offset, length, access);
8739
Geoff Langbfdea662014-07-23 14:16:32 -04008740 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008741 if (context)
8742 {
8743 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008744 {
Geoff Langb1196682014-07-23 13:47:29 -04008745 context->recordError(gl::Error(GL_INVALID_ENUM));
8746 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008747 }
Geoff Langbfdea662014-07-23 14:16:32 -04008748
8749 if (offset < 0 || length < 0)
8750 {
Geoff Langb1196682014-07-23 13:47:29 -04008751 context->recordError(gl::Error(GL_INVALID_VALUE));
8752 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008753 }
8754
8755 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8756
8757 if (buffer == NULL)
8758 {
Geoff Langb1196682014-07-23 13:47:29 -04008759 context->recordError(gl::Error(GL_INVALID_OPERATION));
8760 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008761 }
8762
8763 // Check for buffer overflow
8764 size_t offsetSize = static_cast<size_t>(offset);
8765 size_t lengthSize = static_cast<size_t>(length);
8766
8767 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8768 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8769 {
Geoff Langb1196682014-07-23 13:47:29 -04008770 context->recordError(gl::Error(GL_INVALID_VALUE));
8771 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008772 }
8773
8774 // Check for invalid bits in the mask
8775 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8776 GL_MAP_WRITE_BIT |
8777 GL_MAP_INVALIDATE_RANGE_BIT |
8778 GL_MAP_INVALIDATE_BUFFER_BIT |
8779 GL_MAP_FLUSH_EXPLICIT_BIT |
8780 GL_MAP_UNSYNCHRONIZED_BIT;
8781
8782 if (access & ~(allAccessBits))
8783 {
Geoff Langb1196682014-07-23 13:47:29 -04008784 context->recordError(gl::Error(GL_INVALID_VALUE));
8785 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008786 }
8787
8788 if (length == 0 || buffer->isMapped())
8789 {
Geoff Langb1196682014-07-23 13:47:29 -04008790 context->recordError(gl::Error(GL_INVALID_OPERATION));
8791 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008792 }
8793
8794 // Check for invalid bit combinations
8795 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8796 {
Geoff Langb1196682014-07-23 13:47:29 -04008797 context->recordError(gl::Error(GL_INVALID_OPERATION));
8798 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008799 }
8800
8801 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8802 GL_MAP_INVALIDATE_BUFFER_BIT |
8803 GL_MAP_UNSYNCHRONIZED_BIT;
8804
8805 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8806 {
Geoff Langb1196682014-07-23 13:47:29 -04008807 context->recordError(gl::Error(GL_INVALID_OPERATION));
8808 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008809 }
8810
8811 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8812 {
Geoff Langb1196682014-07-23 13:47:29 -04008813 context->recordError(gl::Error(GL_INVALID_OPERATION));
8814 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008815 }
8816
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008817 gl::Error error = buffer->mapRange(offset, length, access);
8818 if (error.isError())
8819 {
8820 context->recordError(error);
8821 return NULL;
8822 }
8823
8824 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008825 }
8826
8827 return NULL;
8828}
8829
Kenneth Russell67ea1902014-10-06 16:44:50 -07008830void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008831{
8832 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8833
Geoff Langbfdea662014-07-23 14:16:32 -04008834 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008835 if (context)
8836 {
8837 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008838 {
Geoff Langb1196682014-07-23 13:47:29 -04008839 context->recordError(gl::Error(GL_INVALID_VALUE));
8840 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008841 }
Geoff Langbfdea662014-07-23 14:16:32 -04008842
8843 if (!gl::ValidBufferTarget(context, target))
8844 {
Geoff Langb1196682014-07-23 13:47:29 -04008845 context->recordError(gl::Error(GL_INVALID_ENUM));
8846 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008847 }
8848
8849 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8850
8851 if (buffer == NULL)
8852 {
Geoff Langb1196682014-07-23 13:47:29 -04008853 context->recordError(gl::Error(GL_INVALID_OPERATION));
8854 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008855 }
8856
8857 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8858 {
Geoff Langb1196682014-07-23 13:47:29 -04008859 context->recordError(gl::Error(GL_INVALID_OPERATION));
8860 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008861 }
8862
8863 // Check for buffer overflow
8864 size_t offsetSize = static_cast<size_t>(offset);
8865 size_t lengthSize = static_cast<size_t>(length);
8866
8867 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8868 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8869 {
Geoff Langb1196682014-07-23 13:47:29 -04008870 context->recordError(gl::Error(GL_INVALID_VALUE));
8871 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008872 }
8873
8874 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008875 }
8876}
8877
Kenneth Russell67ea1902014-10-06 16:44:50 -07008878__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008879{
8880 struct Extension
8881 {
8882 const char *name;
8883 __eglMustCastToProperFunctionPointerType address;
8884 };
8885
8886 static const Extension glExtensions[] =
8887 {
8888 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008889 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008890 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008891 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8892 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8893 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8894 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8895 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8896 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8897 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008898 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008899 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008900 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8901 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8902 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8903 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008904 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8905 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8906 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8907 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8908 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8909 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8910 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008911 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008912 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8913 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8914 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008915 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008916 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8917 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8918 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008919 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8920 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8921 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008922
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008923 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008924 {
8925 if (strcmp(procname, glExtensions[ext].name) == 0)
8926 {
8927 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8928 }
8929 }
8930
8931 return NULL;
8932}
8933
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008934// Non-public functions used by EGL
8935
Kenneth Russell67ea1902014-10-06 16:44:50 -07008936bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008937{
8938 EVENT("(egl::Surface* surface = 0x%0.8p)",
8939 surface);
8940
Geoff Langbfdea662014-07-23 14:16:32 -04008941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008942 if (context)
8943 {
8944 gl::Texture2D *textureObject = context->getTexture2D();
8945 ASSERT(textureObject != NULL);
8946
8947 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008948 {
Geoff Langbfdea662014-07-23 14:16:32 -04008949 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008950 }
Geoff Langbfdea662014-07-23 14:16:32 -04008951
8952 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008953 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008954
8955 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008956}
8957
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008958}