blob: d49a9a95e6e267e8152b7d0148c6ffa54c88efbb [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Geoff Lang48dcae72014-02-05 16:28:24 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
8
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00009#include "common/version.h"
Geoff Lang0b7eef72014-06-12 14:10:47 -040010#include "common/utilities.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000013#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000015#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000016#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000017#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000019#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000021#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000022#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040023#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070024#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050025#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040026#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027
Geoff Lange8ebe7f2013-08-05 15:03:13 -040028#include "libGLESv2/validationES.h"
29#include "libGLESv2/validationES2.h"
30#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050031#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040032
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033extern "C"
34{
35
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000036// OpenGL ES 2.0 functions
37
Kenneth Russell67ea1902014-10-06 16:44:50 -070038void GL_APIENTRY glActiveTexture(GLenum texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000040 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041
Geoff Langbfdea662014-07-23 14:16:32 -040042 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040043 if (context)
44 {
Geoff Lang3a61c322014-07-10 13:01:54 -040045 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046 {
Geoff Langb1196682014-07-23 13:47:29 -040047 context->recordError(gl::Error(GL_INVALID_ENUM));
48 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000049 }
Geoff Langbfdea662014-07-23 14:16:32 -040050
51 context->getState().setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052 }
53}
54
Kenneth Russell67ea1902014-10-06 16:44:50 -070055void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000056{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000057 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058
Geoff Langbfdea662014-07-23 14:16:32 -040059 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -040060 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 {
Geoff Langbfdea662014-07-23 14:16:32 -040062 gl::Program *programObject = context->getProgram(program);
63 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
Geoff Langbfdea662014-07-23 14:16:32 -040065 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066 {
Geoff Langbfdea662014-07-23 14:16:32 -040067 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
Geoff Langb1196682014-07-23 13:47:29 -040069 context->recordError(gl::Error(GL_INVALID_OPERATION));
70 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 }
Geoff Langbfdea662014-07-23 14:16:32 -040072 else
73 {
Geoff Langb1196682014-07-23 13:47:29 -040074 context->recordError(gl::Error(GL_INVALID_VALUE));
75 return;
Geoff Langbfdea662014-07-23 14:16:32 -040076 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 }
Geoff Langbfdea662014-07-23 14:16:32 -040078
79 if (!shaderObject)
80 {
81 if (context->getProgram(shader))
82 {
Geoff Langb1196682014-07-23 13:47:29 -040083 context->recordError(gl::Error(GL_INVALID_OPERATION));
84 return;
Geoff Langbfdea662014-07-23 14:16:32 -040085 }
86 else
87 {
Geoff Langb1196682014-07-23 13:47:29 -040088 context->recordError(gl::Error(GL_INVALID_VALUE));
89 return;
Geoff Langbfdea662014-07-23 14:16:32 -040090 }
91 }
92
93 if (!programObject->attachShader(shaderObject))
94 {
Geoff Langb1196682014-07-23 13:47:29 -040095 context->recordError(gl::Error(GL_INVALID_OPERATION));
96 return;
Geoff Langbfdea662014-07-23 14:16:32 -040097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99}
100
Kenneth Russell67ea1902014-10-06 16:44:50 -0700101void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000102{
103 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
104
Geoff Langbfdea662014-07-23 14:16:32 -0400105 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400106 if (context)
107 {
108 if (!ValidateBeginQuery(context, target, id))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000109 {
Geoff Langbfdea662014-07-23 14:16:32 -0400110 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000111 }
Geoff Langbfdea662014-07-23 14:16:32 -0400112
Geoff Lang5aad9672014-09-08 11:10:42 -0400113 gl::Error error = context->beginQuery(target, id);
114 if (error.isError())
115 {
116 context->recordError(error);
117 return;
118 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000119 }
120}
121
Kenneth Russell67ea1902014-10-06 16:44:50 -0700122void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000124 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Geoff Langbfdea662014-07-23 14:16:32 -0400126 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400127 if (context)
128 {
Geoff Langb1196682014-07-23 13:47:29 -0400129 if (index >= gl::MAX_VERTEX_ATTRIBS)
130 {
131 context->recordError(gl::Error(GL_INVALID_VALUE));
132 return;
133 }
134
Geoff Langbfdea662014-07-23 14:16:32 -0400135 gl::Program *programObject = context->getProgram(program);
136
137 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 {
Geoff Langbfdea662014-07-23 14:16:32 -0400139 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_OPERATION));
142 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143 }
Geoff Langbfdea662014-07-23 14:16:32 -0400144 else
145 {
Geoff Langb1196682014-07-23 13:47:29 -0400146 context->recordError(gl::Error(GL_INVALID_VALUE));
147 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400148 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000149 }
Geoff Langbfdea662014-07-23 14:16:32 -0400150
151 if (strncmp(name, "gl_", 3) == 0)
152 {
Geoff Langb1196682014-07-23 13:47:29 -0400153 context->recordError(gl::Error(GL_INVALID_OPERATION));
154 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400155 }
156
157 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158 }
159}
160
Kenneth Russell67ea1902014-10-06 16:44:50 -0700161void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000162{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000163 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164
Geoff Langbfdea662014-07-23 14:16:32 -0400165 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400166 if (context)
167 {
168 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000169 {
Geoff Langb1196682014-07-23 13:47:29 -0400170 context->recordError(gl::Error(GL_INVALID_ENUM));
171 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000172 }
Geoff Langbfdea662014-07-23 14:16:32 -0400173
174 switch (target)
175 {
176 case GL_ARRAY_BUFFER:
177 context->bindArrayBuffer(buffer);
178 return;
179 case GL_ELEMENT_ARRAY_BUFFER:
180 context->bindElementArrayBuffer(buffer);
181 return;
182 case GL_COPY_READ_BUFFER:
183 context->bindCopyReadBuffer(buffer);
184 return;
185 case GL_COPY_WRITE_BUFFER:
186 context->bindCopyWriteBuffer(buffer);
187 return;
188 case GL_PIXEL_PACK_BUFFER:
189 context->bindPixelPackBuffer(buffer);
190 return;
191 case GL_PIXEL_UNPACK_BUFFER:
192 context->bindPixelUnpackBuffer(buffer);
193 return;
194 case GL_UNIFORM_BUFFER:
195 context->bindGenericUniformBuffer(buffer);
196 return;
197 case GL_TRANSFORM_FEEDBACK_BUFFER:
198 context->bindGenericTransformFeedbackBuffer(buffer);
199 return;
Geoff Langb1196682014-07-23 13:47:29 -0400200
Geoff Langbfdea662014-07-23 14:16:32 -0400201 default:
Geoff Langb1196682014-07-23 13:47:29 -0400202 context->recordError(gl::Error(GL_INVALID_ENUM));
203 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205 }
206}
207
Kenneth Russell67ea1902014-10-06 16:44:50 -0700208void GL_APIENTRY glBindFramebuffer(GLenum target, GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000210 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000211
Geoff Langbfdea662014-07-23 14:16:32 -0400212 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400213 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000214 {
Geoff Langb1196682014-07-23 13:47:29 -0400215 if (!gl::ValidFramebufferTarget(target))
216 {
217 context->recordError(gl::Error(GL_INVALID_ENUM));
218 return;
219 }
220
Geoff Langbfdea662014-07-23 14:16:32 -0400221 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindReadFramebuffer(framebuffer);
224 }
225
226 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
227 {
228 context->bindDrawFramebuffer(framebuffer);
229 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000230 }
231}
232
Kenneth Russell67ea1902014-10-06 16:44:50 -0700233void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000235 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236
Geoff Langbfdea662014-07-23 14:16:32 -0400237 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400238 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000239 {
Geoff Langb1196682014-07-23 13:47:29 -0400240 if (target != GL_RENDERBUFFER)
241 {
242 context->recordError(gl::Error(GL_INVALID_ENUM));
243 return;
244 }
245
Geoff Langbfdea662014-07-23 14:16:32 -0400246 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000247 }
248}
249
Kenneth Russell67ea1902014-10-06 16:44:50 -0700250void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000252 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400255 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000256 {
Geoff Langbfdea662014-07-23 14:16:32 -0400257 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258
Geoff Langbfdea662014-07-23 14:16:32 -0400259 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 {
Geoff Langb1196682014-07-23 13:47:29 -0400261 context->recordError(gl::Error(GL_INVALID_OPERATION));
262 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400263 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264
Geoff Langbfdea662014-07-23 14:16:32 -0400265 switch (target)
266 {
267 case GL_TEXTURE_2D:
Geoff Langbfdea662014-07-23 14:16:32 -0400268 case GL_TEXTURE_CUBE_MAP:
Geoff Lang76b10c92014-09-05 16:28:14 -0400269 break;
Geoff Langb1196682014-07-23 13:47:29 -0400270
Geoff Langbfdea662014-07-23 14:16:32 -0400271 case GL_TEXTURE_3D:
Geoff Langbfdea662014-07-23 14:16:32 -0400272 case GL_TEXTURE_2D_ARRAY:
273 if (context->getClientVersion() < 3)
274 {
Geoff Langb1196682014-07-23 13:47:29 -0400275 context->recordError(gl::Error(GL_INVALID_ENUM));
276 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400277 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400278 break;
Geoff Langb1196682014-07-23 13:47:29 -0400279
Geoff Langbfdea662014-07-23 14:16:32 -0400280 default:
Geoff Langb1196682014-07-23 13:47:29 -0400281 context->recordError(gl::Error(GL_INVALID_ENUM));
282 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000283 }
Geoff Lang76b10c92014-09-05 16:28:14 -0400284
285 context->bindTexture(target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000287}
288
Kenneth Russell67ea1902014-10-06 16:44:50 -0700289void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000291 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000292 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Geoff Langbfdea662014-07-23 14:16:32 -0400294 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295
Geoff Langbfdea662014-07-23 14:16:32 -0400296 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297 {
Geoff Langbfdea662014-07-23 14:16:32 -0400298 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299 }
300}
301
Kenneth Russell67ea1902014-10-06 16:44:50 -0700302void GL_APIENTRY glBlendEquation(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303{
304 glBlendEquationSeparate(mode, mode);
305}
306
Kenneth Russell67ea1902014-10-06 16:44:50 -0700307void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000309 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000310
Geoff Langbfdea662014-07-23 14:16:32 -0400311 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400312 if (context)
313 {
Geoff Langb1196682014-07-23 13:47:29 -0400314 switch (modeRGB)
315 {
316 case GL_FUNC_ADD:
317 case GL_FUNC_SUBTRACT:
318 case GL_FUNC_REVERSE_SUBTRACT:
319 case GL_MIN:
320 case GL_MAX:
321 break;
322
323 default:
324 context->recordError(gl::Error(GL_INVALID_ENUM));
325 return;
326 }
327
328 switch (modeAlpha)
329 {
330 case GL_FUNC_ADD:
331 case GL_FUNC_SUBTRACT:
332 case GL_FUNC_REVERSE_SUBTRACT:
333 case GL_MIN:
334 case GL_MAX:
335 break;
336
337 default:
338 context->recordError(gl::Error(GL_INVALID_ENUM));
339 return;
340 }
341
Geoff Langbfdea662014-07-23 14:16:32 -0400342 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 }
344}
345
Kenneth Russell67ea1902014-10-06 16:44:50 -0700346void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347{
348 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
349}
350
Kenneth Russell67ea1902014-10-06 16:44:50 -0700351void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000353 EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000354 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000355
Geoff Langbfdea662014-07-23 14:16:32 -0400356 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400357 if (context)
358 {
Geoff Langb1196682014-07-23 13:47:29 -0400359 switch (srcRGB)
360 {
361 case GL_ZERO:
362 case GL_ONE:
363 case GL_SRC_COLOR:
364 case GL_ONE_MINUS_SRC_COLOR:
365 case GL_DST_COLOR:
366 case GL_ONE_MINUS_DST_COLOR:
367 case GL_SRC_ALPHA:
368 case GL_ONE_MINUS_SRC_ALPHA:
369 case GL_DST_ALPHA:
370 case GL_ONE_MINUS_DST_ALPHA:
371 case GL_CONSTANT_COLOR:
372 case GL_ONE_MINUS_CONSTANT_COLOR:
373 case GL_CONSTANT_ALPHA:
374 case GL_ONE_MINUS_CONSTANT_ALPHA:
375 case GL_SRC_ALPHA_SATURATE:
376 break;
377
378 default:
379 context->recordError(gl::Error(GL_INVALID_ENUM));
380 return;
381 }
382
383 switch (dstRGB)
384 {
385 case GL_ZERO:
386 case GL_ONE:
387 case GL_SRC_COLOR:
388 case GL_ONE_MINUS_SRC_COLOR:
389 case GL_DST_COLOR:
390 case GL_ONE_MINUS_DST_COLOR:
391 case GL_SRC_ALPHA:
392 case GL_ONE_MINUS_SRC_ALPHA:
393 case GL_DST_ALPHA:
394 case GL_ONE_MINUS_DST_ALPHA:
395 case GL_CONSTANT_COLOR:
396 case GL_ONE_MINUS_CONSTANT_COLOR:
397 case GL_CONSTANT_ALPHA:
398 case GL_ONE_MINUS_CONSTANT_ALPHA:
399 break;
400
401 case GL_SRC_ALPHA_SATURATE:
402 if (context->getClientVersion() < 3)
403 {
404 context->recordError(gl::Error(GL_INVALID_ENUM));
405 return;
406 }
407 break;
408
409 default:
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413
414 switch (srcAlpha)
415 {
416 case GL_ZERO:
417 case GL_ONE:
418 case GL_SRC_COLOR:
419 case GL_ONE_MINUS_SRC_COLOR:
420 case GL_DST_COLOR:
421 case GL_ONE_MINUS_DST_COLOR:
422 case GL_SRC_ALPHA:
423 case GL_ONE_MINUS_SRC_ALPHA:
424 case GL_DST_ALPHA:
425 case GL_ONE_MINUS_DST_ALPHA:
426 case GL_CONSTANT_COLOR:
427 case GL_ONE_MINUS_CONSTANT_COLOR:
428 case GL_CONSTANT_ALPHA:
429 case GL_ONE_MINUS_CONSTANT_ALPHA:
430 case GL_SRC_ALPHA_SATURATE:
431 break;
432
433 default:
434 context->recordError(gl::Error(GL_INVALID_ENUM));
435 return;
436 }
437
438 switch (dstAlpha)
439 {
440 case GL_ZERO:
441 case GL_ONE:
442 case GL_SRC_COLOR:
443 case GL_ONE_MINUS_SRC_COLOR:
444 case GL_DST_COLOR:
445 case GL_ONE_MINUS_DST_COLOR:
446 case GL_SRC_ALPHA:
447 case GL_ONE_MINUS_SRC_ALPHA:
448 case GL_DST_ALPHA:
449 case GL_ONE_MINUS_DST_ALPHA:
450 case GL_CONSTANT_COLOR:
451 case GL_ONE_MINUS_CONSTANT_COLOR:
452 case GL_CONSTANT_ALPHA:
453 case GL_ONE_MINUS_CONSTANT_ALPHA:
454 break;
455
456 case GL_SRC_ALPHA_SATURATE:
457 if (context->getClientVersion() < 3)
458 {
459 context->recordError(gl::Error(GL_INVALID_ENUM));
460 return;
461 }
462 break;
463
464 default:
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468
469 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
470 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
471
472 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
473 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
474
475 if (constantColorUsed && constantAlphaUsed)
476 {
477 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
478 context->recordError(gl::Error(GL_INVALID_OPERATION));
479 return;
480 }
481
Geoff Langbfdea662014-07-23 14:16:32 -0400482 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483 }
484}
485
Kenneth Russell67ea1902014-10-06 16:44:50 -0700486void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000487{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000488 EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000489 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000490
Geoff Langbfdea662014-07-23 14:16:32 -0400491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400492 if (context)
493 {
Geoff Langb1196682014-07-23 13:47:29 -0400494 if (size < 0)
495 {
496 context->recordError(gl::Error(GL_INVALID_VALUE));
497 return;
498 }
499
500 switch (usage)
501 {
502 case GL_STREAM_DRAW:
503 case GL_STATIC_DRAW:
504 case GL_DYNAMIC_DRAW:
505 break;
506
507 case GL_STREAM_READ:
508 case GL_STREAM_COPY:
509 case GL_STATIC_READ:
510 case GL_STATIC_COPY:
511 case GL_DYNAMIC_READ:
512 case GL_DYNAMIC_COPY:
513 if (context->getClientVersion() < 3)
514 {
515 context->recordError(gl::Error(GL_INVALID_ENUM));
516 return;
517 }
518 break;
519
520 default:
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524
Geoff Langbfdea662014-07-23 14:16:32 -0400525 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000526 {
Geoff Langb1196682014-07-23 13:47:29 -0400527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
532
533 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000534 {
Geoff Langb1196682014-07-23 13:47:29 -0400535 context->recordError(gl::Error(GL_INVALID_OPERATION));
536 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000537 }
Geoff Langbfdea662014-07-23 14:16:32 -0400538
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400539 gl::Error error = buffer->bufferData(data, size, usage);
540 if (error.isError())
541 {
542 context->recordError(error);
543 return;
544 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000545 }
546}
547
Kenneth Russell67ea1902014-10-06 16:44:50 -0700548void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000549{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000550 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000551 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552
Geoff Langbfdea662014-07-23 14:16:32 -0400553 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400554 if (context)
555 {
Geoff Langb1196682014-07-23 13:47:29 -0400556 if (size < 0 || offset < 0)
557 {
558 context->recordError(gl::Error(GL_INVALID_VALUE));
559 return;
560 }
561
562 if (data == NULL)
563 {
564 return;
565 }
566
Geoff Langbfdea662014-07-23 14:16:32 -0400567 if (!gl::ValidBufferTarget(context, target))
568 {
Geoff Langb1196682014-07-23 13:47:29 -0400569 context->recordError(gl::Error(GL_INVALID_ENUM));
570 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400571 }
572
573 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
574
575 if (!buffer)
576 {
Geoff Langb1196682014-07-23 13:47:29 -0400577 context->recordError(gl::Error(GL_INVALID_OPERATION));
578 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400579 }
580
581 if (buffer->isMapped())
582 {
Geoff Langb1196682014-07-23 13:47:29 -0400583 context->recordError(gl::Error(GL_INVALID_OPERATION));
584 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400585 }
586
587 // Check for possible overflow of size + offset
588 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
589 {
Geoff Langb1196682014-07-23 13:47:29 -0400590 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
591 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400592 }
593
594 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 {
Geoff Langb1196682014-07-23 13:47:29 -0400596 context->recordError(gl::Error(GL_INVALID_VALUE));
597 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599
Geoff Lang2a1c15a2014-07-25 11:43:00 -0400600 gl::Error error = buffer->bufferSubData(data, size, offset);
601 if (error.isError())
602 {
603 context->recordError(error);
604 return;
605 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000606 }
607}
608
Kenneth Russell67ea1902014-10-06 16:44:50 -0700609GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000611 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612
Geoff Langbfdea662014-07-23 14:16:32 -0400613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400614 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000615 {
Geoff Langb1196682014-07-23 13:47:29 -0400616 if (!gl::ValidFramebufferTarget(target))
617 {
618 context->recordError(gl::Error(GL_INVALID_ENUM));
619 return 0;
620 }
621
Geoff Langbfdea662014-07-23 14:16:32 -0400622 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
623 ASSERT(framebuffer);
Jamie Madill48faf802014-11-06 15:27:22 -0500624
625 return framebuffer->completeness(context->getData());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000626 }
627
628 return 0;
629}
630
Kenneth Russell67ea1902014-10-06 16:44:50 -0700631void GL_APIENTRY glClear(GLbitfield mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000632{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000633 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000634
Geoff Langbfdea662014-07-23 14:16:32 -0400635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400636 if (context)
637 {
638 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -0500639 ASSERT(framebufferObject);
Geoff Langbfdea662014-07-23 14:16:32 -0400640
Jamie Madill48faf802014-11-06 15:27:22 -0500641 if (framebufferObject->completeness(context->getData()) != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000642 {
Geoff Langb1196682014-07-23 13:47:29 -0400643 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
644 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000645 }
Geoff Langbfdea662014-07-23 14:16:32 -0400646
647 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
648 {
Geoff Langb1196682014-07-23 13:47:29 -0400649 context->recordError(gl::Error(GL_INVALID_VALUE));
650 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400651 }
652
Geoff Langcc79b8c2014-07-25 13:48:02 -0400653 gl::Error error = context->clear(mask);
654 if (error.isError())
655 {
656 context->recordError(error);
657 return;
658 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000659 }
660}
661
Kenneth Russell67ea1902014-10-06 16:44:50 -0700662void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000664 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000665 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000666
Geoff Langbfdea662014-07-23 14:16:32 -0400667 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400668 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 {
Geoff Langbfdea662014-07-23 14:16:32 -0400670 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 }
672}
673
Kenneth Russell67ea1902014-10-06 16:44:50 -0700674void GL_APIENTRY glClearDepthf(GLclampf depth)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000676 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000677
Geoff Langbfdea662014-07-23 14:16:32 -0400678 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400679 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000680 {
Geoff Langbfdea662014-07-23 14:16:32 -0400681 context->getState().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000682 }
683}
684
Kenneth Russell67ea1902014-10-06 16:44:50 -0700685void GL_APIENTRY glClearStencil(GLint s)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000687 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000688
Geoff Langbfdea662014-07-23 14:16:32 -0400689 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400690 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000691 {
Geoff Langbfdea662014-07-23 14:16:32 -0400692 context->getState().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000693 }
694}
695
Kenneth Russell67ea1902014-10-06 16:44:50 -0700696void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000697{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000698 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000699 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000700
Geoff Langbfdea662014-07-23 14:16:32 -0400701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400702 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000703 {
Geoff Langbfdea662014-07-23 14:16:32 -0400704 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000705 }
706}
707
Kenneth Russell67ea1902014-10-06 16:44:50 -0700708void GL_APIENTRY glCompileShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000710 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000711
Geoff Langbfdea662014-07-23 14:16:32 -0400712 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400713 if (context)
714 {
715 gl::Shader *shaderObject = context->getShader(shader);
716
717 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
Geoff Langbfdea662014-07-23 14:16:32 -0400719 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000720 {
Geoff Langb1196682014-07-23 13:47:29 -0400721 context->recordError(gl::Error(GL_INVALID_OPERATION));
722 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000723 }
Geoff Langbfdea662014-07-23 14:16:32 -0400724 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000725 {
Geoff Langb1196682014-07-23 13:47:29 -0400726 context->recordError(gl::Error(GL_INVALID_VALUE));
727 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000728 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000729 }
Geoff Langbfdea662014-07-23 14:16:32 -0400730
731 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000732 }
Geoff Langbfdea662014-07-23 14:16:32 -0400733}
734
Kenneth Russell67ea1902014-10-06 16:44:50 -0700735void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
Geoff Langbfdea662014-07-23 14:16:32 -0400736 GLint border, GLsizei imageSize, const GLvoid* data)
737{
738 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
739 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
740 target, level, internalformat, width, height, border, imageSize, data);
741
742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400743 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000744 {
Geoff Langbfdea662014-07-23 14:16:32 -0400745 if (context->getClientVersion() < 3 &&
746 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
747 0, 0, width, height, border, GL_NONE, GL_NONE, data))
748 {
749 return;
750 }
751
752 if (context->getClientVersion() >= 3 &&
753 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
754 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
755 {
756 return;
757 }
758
Geoff Lang5d601382014-07-22 15:14:06 -0400759 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
760 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400761 {
Geoff Langb1196682014-07-23 13:47:29 -0400762 context->recordError(gl::Error(GL_INVALID_VALUE));
763 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400764 }
765
766 switch (target)
767 {
768 case GL_TEXTURE_2D:
769 {
770 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400771 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400772 if (error.isError())
773 {
774 context->recordError(error);
775 return;
776 }
Geoff Langbfdea662014-07-23 14:16:32 -0400777 }
778 break;
779
780 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
781 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
782 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
783 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
784 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
785 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
786 {
787 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400788 gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400789 if (error.isError())
790 {
791 context->recordError(error);
792 return;
793 }
Geoff Langbfdea662014-07-23 14:16:32 -0400794 }
795 break;
796
797 default:
Geoff Langb1196682014-07-23 13:47:29 -0400798 context->recordError(gl::Error(GL_INVALID_ENUM));
799 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400800 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000801 }
802}
803
Kenneth Russell67ea1902014-10-06 16:44:50 -0700804void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000805 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000806{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000807 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000808 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000809 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000810 target, level, xoffset, yoffset, width, height, format, imageSize, data);
811
Geoff Langbfdea662014-07-23 14:16:32 -0400812 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400813 if (context)
814 {
815 if (context->getClientVersion() < 3 &&
816 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
817 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000818 {
Geoff Langbfdea662014-07-23 14:16:32 -0400819 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000820 }
Geoff Langbfdea662014-07-23 14:16:32 -0400821
822 if (context->getClientVersion() >= 3 &&
823 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
824 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
825 {
826 return;
827 }
828
Geoff Lang5d601382014-07-22 15:14:06 -0400829 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
830 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400831 {
Geoff Langb1196682014-07-23 13:47:29 -0400832 context->recordError(gl::Error(GL_INVALID_VALUE));
833 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400834 }
835
836 switch (target)
837 {
838 case GL_TEXTURE_2D:
839 {
840 gl::Texture2D *texture = context->getTexture2D();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400841 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400842 if (error.isError())
843 {
844 context->recordError(error);
845 return;
846 }
Geoff Langbfdea662014-07-23 14:16:32 -0400847 }
848 break;
849
850 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
851 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
852 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
853 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
854 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
855 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
856 {
857 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madillc751d1e2014-10-21 17:46:29 -0400858 gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -0400859 if (error.isError())
860 {
861 context->recordError(error);
862 return;
863 }
Geoff Langbfdea662014-07-23 14:16:32 -0400864 }
865 break;
866
867 default:
Geoff Langb1196682014-07-23 13:47:29 -0400868 context->recordError(gl::Error(GL_INVALID_ENUM));
869 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400870 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000871 }
872}
873
Kenneth Russell67ea1902014-10-06 16:44:50 -0700874void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000876 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000877 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000878 target, level, internalformat, x, y, width, height, border);
879
Geoff Langbfdea662014-07-23 14:16:32 -0400880 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400881 if (context)
882 {
883 if (context->getClientVersion() < 3 &&
884 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
885 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000886 {
Geoff Langbfdea662014-07-23 14:16:32 -0400887 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000888 }
Geoff Langbfdea662014-07-23 14:16:32 -0400889
890 if (context->getClientVersion() >= 3 &&
891 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
892 0, 0, 0, x, y, width, height, border))
893 {
894 return;
895 }
896
897 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
898
899 switch (target)
900 {
901 case GL_TEXTURE_2D:
902 {
903 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400904 gl::Error error = texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
905 if (error.isError())
906 {
907 context->recordError(error);
908 return;
909 }
Geoff Langbfdea662014-07-23 14:16:32 -0400910 }
911 break;
912
913 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
914 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
915 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
916 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
917 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
918 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
919 {
920 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400921 gl::Error error = texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
922 if (error.isError())
923 {
924 context->recordError(error);
925 return;
926 }
Geoff Langbfdea662014-07-23 14:16:32 -0400927 }
928 break;
929
Geoff Langb1196682014-07-23 13:47:29 -0400930 default:
931 context->recordError(gl::Error(GL_INVALID_ENUM));
932 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400933 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000934 }
935}
936
Kenneth Russell67ea1902014-10-06 16:44:50 -0700937void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000938{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000939 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000940 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000941 target, level, xoffset, yoffset, x, y, width, height);
942
Geoff Langbfdea662014-07-23 14:16:32 -0400943 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400944 if (context)
945 {
946 if (context->getClientVersion() < 3 &&
947 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
948 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000949 {
Geoff Langbfdea662014-07-23 14:16:32 -0400950 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000951 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000952
Geoff Langbfdea662014-07-23 14:16:32 -0400953 if (context->getClientVersion() >= 3 &&
954 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
955 xoffset, yoffset, 0, x, y, width, height, 0))
956 {
957 return;
958 }
959
960 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
961
962 switch (target)
963 {
964 case GL_TEXTURE_2D:
965 {
966 gl::Texture2D *texture = context->getTexture2D();
Geoff Langef7b0162014-09-04 13:29:23 -0400967 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
968 if (error.isError())
969 {
970 context->recordError(error);
971 return;
972 }
Geoff Langbfdea662014-07-23 14:16:32 -0400973 }
974 break;
975
976 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
977 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
978 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
979 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
980 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
981 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
982 {
983 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Langef7b0162014-09-04 13:29:23 -0400984 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
985 if (error.isError())
986 {
987 context->recordError(error);
988 return;
989 }
Geoff Langbfdea662014-07-23 14:16:32 -0400990 }
991 break;
992
993 default:
Geoff Langb1196682014-07-23 13:47:29 -0400994 context->recordError(gl::Error(GL_INVALID_ENUM));
995 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400996 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000997 }
998}
999
Kenneth Russell67ea1902014-10-06 16:44:50 -07001000GLuint GL_APIENTRY glCreateProgram(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001002 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001003
Geoff Langbfdea662014-07-23 14:16:32 -04001004 gl::Context *context = gl::getNonLostContext();
1005 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001006 {
Geoff Langbfdea662014-07-23 14:16:32 -04001007 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001008 }
1009
1010 return 0;
1011}
1012
Kenneth Russell67ea1902014-10-06 16:44:50 -07001013GLuint GL_APIENTRY glCreateShader(GLenum type)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001014{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001015 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001016
Geoff Langbfdea662014-07-23 14:16:32 -04001017 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001018 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001019 {
Geoff Langbfdea662014-07-23 14:16:32 -04001020 switch (type)
1021 {
1022 case GL_FRAGMENT_SHADER:
1023 case GL_VERTEX_SHADER:
1024 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -04001025
Geoff Langbfdea662014-07-23 14:16:32 -04001026 default:
Geoff Langb1196682014-07-23 13:47:29 -04001027 context->recordError(gl::Error(GL_INVALID_ENUM));
1028 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04001029 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001030 }
1031
1032 return 0;
1033}
1034
Kenneth Russell67ea1902014-10-06 16:44:50 -07001035void GL_APIENTRY glCullFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001036{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001037 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001038
Geoff Langb1196682014-07-23 13:47:29 -04001039 gl::Context *context = gl::getNonLostContext();
1040 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001041 {
Geoff Langb1196682014-07-23 13:47:29 -04001042 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001043 {
Geoff Langb1196682014-07-23 13:47:29 -04001044 case GL_FRONT:
1045 case GL_BACK:
1046 case GL_FRONT_AND_BACK:
1047 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001048
Geoff Langb1196682014-07-23 13:47:29 -04001049 default:
1050 context->recordError(gl::Error(GL_INVALID_ENUM));
1051 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001052 }
Geoff Langb1196682014-07-23 13:47:29 -04001053
1054 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001055 }
1056}
1057
Kenneth Russell67ea1902014-10-06 16:44:50 -07001058void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001059{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001060 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001061
Geoff Langbfdea662014-07-23 14:16:32 -04001062 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001063 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001064 {
Geoff Langb1196682014-07-23 13:47:29 -04001065 if (n < 0)
1066 {
1067 context->recordError(gl::Error(GL_INVALID_VALUE));
1068 return;
1069 }
1070
Geoff Langbfdea662014-07-23 14:16:32 -04001071 for (int i = 0; i < n; i++)
1072 {
1073 context->deleteBuffer(buffers[i]);
1074 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001075 }
1076}
1077
Kenneth Russell67ea1902014-10-06 16:44:50 -07001078void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001079{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001080 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001081
Geoff Langbfdea662014-07-23 14:16:32 -04001082 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001083 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001084 {
Geoff Langb1196682014-07-23 13:47:29 -04001085 if (n < 0)
1086 {
1087 context->recordError(gl::Error(GL_INVALID_VALUE));
1088 return;
1089 }
1090
Geoff Langbfdea662014-07-23 14:16:32 -04001091 for (int i = 0; i < n; i++)
1092 {
1093 context->deleteFenceNV(fences[i]);
1094 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001095 }
1096}
1097
Kenneth Russell67ea1902014-10-06 16:44:50 -07001098void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001100 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001101
Geoff Langbfdea662014-07-23 14:16:32 -04001102 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001103 if (context)
1104 {
Geoff Langb1196682014-07-23 13:47:29 -04001105 if (n < 0)
1106 {
1107 context->recordError(gl::Error(GL_INVALID_VALUE));
1108 return;
1109 }
1110
Geoff Langbfdea662014-07-23 14:16:32 -04001111 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112 {
Geoff Langbfdea662014-07-23 14:16:32 -04001113 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001114 {
Geoff Langbfdea662014-07-23 14:16:32 -04001115 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001116 }
1117 }
1118 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001119}
1120
Kenneth Russell67ea1902014-10-06 16:44:50 -07001121void GL_APIENTRY glDeleteProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001123 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001124
Geoff Langbfdea662014-07-23 14:16:32 -04001125 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001126 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001127 {
Geoff Langb1196682014-07-23 13:47:29 -04001128 if (program == 0)
1129 {
1130 return;
1131 }
1132
Geoff Langbfdea662014-07-23 14:16:32 -04001133 if (!context->getProgram(program))
1134 {
1135 if(context->getShader(program))
1136 {
Geoff Langb1196682014-07-23 13:47:29 -04001137 context->recordError(gl::Error(GL_INVALID_OPERATION));
1138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001139 }
1140 else
1141 {
Geoff Langb1196682014-07-23 13:47:29 -04001142 context->recordError(gl::Error(GL_INVALID_VALUE));
1143 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001144 }
1145 }
1146
1147 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001148 }
1149}
1150
Kenneth Russell67ea1902014-10-06 16:44:50 -07001151void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001152{
1153 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1154
Geoff Langbfdea662014-07-23 14:16:32 -04001155 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001156 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001157 {
Geoff Langb1196682014-07-23 13:47:29 -04001158 if (n < 0)
1159 {
1160 context->recordError(gl::Error(GL_INVALID_VALUE));
1161 return;
1162 }
1163
Geoff Langbfdea662014-07-23 14:16:32 -04001164 for (int i = 0; i < n; i++)
1165 {
1166 context->deleteQuery(ids[i]);
1167 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001168 }
1169}
1170
Kenneth Russell67ea1902014-10-06 16:44:50 -07001171void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001173 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001174
Geoff Langbfdea662014-07-23 14:16:32 -04001175 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001176 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001177 {
Geoff Langb1196682014-07-23 13:47:29 -04001178 if (n < 0)
1179 {
1180 context->recordError(gl::Error(GL_INVALID_VALUE));
1181 return;
1182 }
1183
Geoff Langbfdea662014-07-23 14:16:32 -04001184 for (int i = 0; i < n; i++)
1185 {
1186 context->deleteRenderbuffer(renderbuffers[i]);
1187 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001188 }
1189}
1190
Kenneth Russell67ea1902014-10-06 16:44:50 -07001191void GL_APIENTRY glDeleteShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001193 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001194
Geoff Langbfdea662014-07-23 14:16:32 -04001195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001196 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001197 {
Geoff Langb1196682014-07-23 13:47:29 -04001198 if (shader == 0)
1199 {
1200 return;
1201 }
1202
Geoff Langbfdea662014-07-23 14:16:32 -04001203 if (!context->getShader(shader))
1204 {
1205 if(context->getProgram(shader))
1206 {
Geoff Langb1196682014-07-23 13:47:29 -04001207 context->recordError(gl::Error(GL_INVALID_OPERATION));
1208 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001209 }
1210 else
1211 {
Geoff Langb1196682014-07-23 13:47:29 -04001212 context->recordError(gl::Error(GL_INVALID_VALUE));
1213 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001214 }
1215 }
1216
1217 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001218 }
1219}
1220
Kenneth Russell67ea1902014-10-06 16:44:50 -07001221void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001223 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001224
Geoff Langbfdea662014-07-23 14:16:32 -04001225 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001226 if (context)
1227 {
Geoff Langb1196682014-07-23 13:47:29 -04001228 if (n < 0)
1229 {
1230 context->recordError(gl::Error(GL_INVALID_VALUE));
1231 return;
1232 }
1233
Geoff Langbfdea662014-07-23 14:16:32 -04001234 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001235 {
Geoff Langbfdea662014-07-23 14:16:32 -04001236 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 {
Geoff Langbfdea662014-07-23 14:16:32 -04001238 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001239 }
1240 }
1241 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001242}
1243
Kenneth Russell67ea1902014-10-06 16:44:50 -07001244void GL_APIENTRY glDepthFunc(GLenum func)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001246 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001247
Geoff Langbfdea662014-07-23 14:16:32 -04001248 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001249 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001250 {
Geoff Langb1196682014-07-23 13:47:29 -04001251 switch (func)
1252 {
1253 case GL_NEVER:
1254 case GL_ALWAYS:
1255 case GL_LESS:
1256 case GL_LEQUAL:
1257 case GL_EQUAL:
1258 case GL_GREATER:
1259 case GL_GEQUAL:
1260 case GL_NOTEQUAL:
1261 context->getState().setDepthFunc(func);
1262 break;
1263
1264 default:
1265 context->recordError(gl::Error(GL_INVALID_ENUM));
1266 return;
1267 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001268 }
1269}
1270
Kenneth Russell67ea1902014-10-06 16:44:50 -07001271void GL_APIENTRY glDepthMask(GLboolean flag)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001272{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001273 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001274
Geoff Langbfdea662014-07-23 14:16:32 -04001275 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001276 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001277 {
Geoff Langbfdea662014-07-23 14:16:32 -04001278 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001279 }
1280}
1281
Kenneth Russell67ea1902014-10-06 16:44:50 -07001282void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001283{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001284 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001285
Geoff Langbfdea662014-07-23 14:16:32 -04001286 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001287 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 {
Geoff Langbfdea662014-07-23 14:16:32 -04001289 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001290 }
1291}
1292
Kenneth Russell67ea1902014-10-06 16:44:50 -07001293void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001295 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001296
Geoff Langbfdea662014-07-23 14:16:32 -04001297 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001298 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001299 {
Geoff Langbfdea662014-07-23 14:16:32 -04001300 gl::Program *programObject = context->getProgram(program);
1301 gl::Shader *shaderObject = context->getShader(shader);
1302
1303 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001304 {
Geoff Langbfdea662014-07-23 14:16:32 -04001305 gl::Shader *shaderByProgramHandle;
1306 shaderByProgramHandle = context->getShader(program);
1307 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001308 {
Geoff Langb1196682014-07-23 13:47:29 -04001309 context->recordError(gl::Error(GL_INVALID_VALUE));
1310 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001311 }
Geoff Langbfdea662014-07-23 14:16:32 -04001312 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001313 {
Geoff Langb1196682014-07-23 13:47:29 -04001314 context->recordError(gl::Error(GL_INVALID_OPERATION));
1315 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001316 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001317 }
Geoff Langbfdea662014-07-23 14:16:32 -04001318
1319 if (!shaderObject)
1320 {
1321 gl::Program *programByShaderHandle = context->getProgram(shader);
1322 if (!programByShaderHandle)
1323 {
Geoff Langb1196682014-07-23 13:47:29 -04001324 context->recordError(gl::Error(GL_INVALID_VALUE));
1325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001326 }
1327 else
1328 {
Geoff Langb1196682014-07-23 13:47:29 -04001329 context->recordError(gl::Error(GL_INVALID_OPERATION));
1330 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001331 }
1332 }
1333
1334 if (!programObject->detachShader(shaderObject))
1335 {
Geoff Langb1196682014-07-23 13:47:29 -04001336 context->recordError(gl::Error(GL_INVALID_OPERATION));
1337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001338 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001339 }
1340}
1341
Kenneth Russell67ea1902014-10-06 16:44:50 -07001342void GL_APIENTRY glDisable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001344 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001345
Geoff Langbfdea662014-07-23 14:16:32 -04001346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001347 if (context)
1348 {
1349 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001350 {
Geoff Langb1196682014-07-23 13:47:29 -04001351 context->recordError(gl::Error(GL_INVALID_ENUM));
1352 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001353 }
Geoff Langbfdea662014-07-23 14:16:32 -04001354
1355 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001356 }
1357}
1358
Kenneth Russell67ea1902014-10-06 16:44:50 -07001359void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001360{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001361 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001362
Geoff Langbfdea662014-07-23 14:16:32 -04001363 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001364 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001365 {
Geoff Langb1196682014-07-23 13:47:29 -04001366 if (index >= gl::MAX_VERTEX_ATTRIBS)
1367 {
1368 context->recordError(gl::Error(GL_INVALID_VALUE));
1369 return;
1370 }
1371
Geoff Langbfdea662014-07-23 14:16:32 -04001372 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001373 }
1374}
1375
Kenneth Russell67ea1902014-10-06 16:44:50 -07001376void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001377{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001378 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001379
Geoff Langbfdea662014-07-23 14:16:32 -04001380 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001381 if (context)
1382 {
Jamie Madill2b976812014-08-25 15:47:49 -04001383 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001384 {
Geoff Langbfdea662014-07-23 14:16:32 -04001385 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001386 }
Geoff Langbfdea662014-07-23 14:16:32 -04001387
Geoff Langc77e8c32014-09-08 16:28:24 -04001388 gl::Error error = context->drawArrays(mode, first, count, 0);
1389 if (error.isError())
1390 {
1391 context->recordError(error);
1392 return;
1393 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001394 }
1395}
1396
Kenneth Russell67ea1902014-10-06 16:44:50 -07001397void GL_APIENTRY glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001398{
1399 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1400
Geoff Langbfdea662014-07-23 14:16:32 -04001401 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001402 if (context)
1403 {
Geoff Lang87a93302014-09-16 13:29:43 -04001404 if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001405 {
Geoff Langbfdea662014-07-23 14:16:32 -04001406 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001407 }
Geoff Langbfdea662014-07-23 14:16:32 -04001408
Geoff Langc77e8c32014-09-08 16:28:24 -04001409 gl::Error error = context->drawArrays(mode, first, count, primcount);
1410 if (error.isError())
1411 {
1412 context->recordError(error);
1413 return;
1414 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001415 }
1416}
1417
Kenneth Russell67ea1902014-10-06 16:44:50 -07001418void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001419{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001420 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001421 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001422
Geoff Langbfdea662014-07-23 14:16:32 -04001423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001424 if (context)
1425 {
Jamie Madill2b976812014-08-25 15:47:49 -04001426 rx::RangeUI indexRange;
1427 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001428 {
Geoff Langbfdea662014-07-23 14:16:32 -04001429 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001430 }
Geoff Langbfdea662014-07-23 14:16:32 -04001431
Geoff Langc77e8c32014-09-08 16:28:24 -04001432 gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange);
1433 if (error.isError())
1434 {
1435 context->recordError(error);
1436 return;
1437 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001438 }
1439}
1440
Kenneth Russell67ea1902014-10-06 16:44:50 -07001441void GL_APIENTRY glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001442{
1443 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1444 mode, count, type, indices, primcount);
1445
Geoff Langbfdea662014-07-23 14:16:32 -04001446 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001447 if (context)
1448 {
Jamie Madill2b976812014-08-25 15:47:49 -04001449 rx::RangeUI indexRange;
Geoff Lang87a93302014-09-16 13:29:43 -04001450 if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001451 {
Geoff Langbfdea662014-07-23 14:16:32 -04001452 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001453 }
Geoff Langbfdea662014-07-23 14:16:32 -04001454
Geoff Langc77e8c32014-09-08 16:28:24 -04001455 gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange);
1456 if (error.isError())
1457 {
1458 context->recordError(error);
1459 return;
1460 }
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001461 }
1462}
1463
Kenneth Russell67ea1902014-10-06 16:44:50 -07001464void GL_APIENTRY glEnable(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001465{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001466 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001467
Geoff Langbfdea662014-07-23 14:16:32 -04001468 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001469 if (context)
1470 {
1471 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001472 {
Geoff Langb1196682014-07-23 13:47:29 -04001473 context->recordError(gl::Error(GL_INVALID_ENUM));
1474 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001475 }
Geoff Langbfdea662014-07-23 14:16:32 -04001476
1477 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001478 }
1479}
1480
Kenneth Russell67ea1902014-10-06 16:44:50 -07001481void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001483 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001484
Geoff Langbfdea662014-07-23 14:16:32 -04001485 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001486 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001487 {
Geoff Langb1196682014-07-23 13:47:29 -04001488 if (index >= gl::MAX_VERTEX_ATTRIBS)
1489 {
1490 context->recordError(gl::Error(GL_INVALID_VALUE));
1491 return;
1492 }
1493
Geoff Langbfdea662014-07-23 14:16:32 -04001494 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001495 }
1496}
1497
Kenneth Russell67ea1902014-10-06 16:44:50 -07001498void GL_APIENTRY glEndQueryEXT(GLenum target)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001499{
1500 EVENT("GLenum target = 0x%X)", target);
1501
Geoff Langbfdea662014-07-23 14:16:32 -04001502 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001503 if (context)
1504 {
1505 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001506 {
Geoff Langbfdea662014-07-23 14:16:32 -04001507 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001508 }
Geoff Langbfdea662014-07-23 14:16:32 -04001509
Geoff Lang5aad9672014-09-08 11:10:42 -04001510 gl::Error error = context->endQuery(target);
1511 if (error.isError())
1512 {
1513 context->recordError(error);
1514 return;
1515 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001516 }
1517}
1518
Kenneth Russell67ea1902014-10-06 16:44:50 -07001519void GL_APIENTRY glFinishFenceNV(GLuint fence)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001520{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001521 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001522
Geoff Langbfdea662014-07-23 14:16:32 -04001523 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001524 if (context)
1525 {
1526 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1527
1528 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001529 {
Geoff Langb1196682014-07-23 13:47:29 -04001530 context->recordError(gl::Error(GL_INVALID_OPERATION));
1531 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001532 }
Geoff Langbfdea662014-07-23 14:16:32 -04001533
1534 if (fenceObject->isFence() != GL_TRUE)
1535 {
Geoff Langb1196682014-07-23 13:47:29 -04001536 context->recordError(gl::Error(GL_INVALID_OPERATION));
1537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001538 }
1539
1540 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001541 }
1542}
1543
Kenneth Russell67ea1902014-10-06 16:44:50 -07001544void GL_APIENTRY glFinish(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001546 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547
Geoff Langbfdea662014-07-23 14:16:32 -04001548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001549 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001550 {
Geoff Lang26298562014-10-01 10:49:03 -04001551 gl::Error error = context->sync(true);
1552 if (error.isError())
1553 {
1554 context->recordError(error);
1555 return;
1556 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557 }
1558}
1559
Kenneth Russell67ea1902014-10-06 16:44:50 -07001560void GL_APIENTRY glFlush(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001562 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001563
Geoff Langbfdea662014-07-23 14:16:32 -04001564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001565 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001566 {
Geoff Lang26298562014-10-01 10:49:03 -04001567 gl::Error error = context->sync(false);
1568 if (error.isError())
1569 {
1570 context->recordError(error);
1571 return;
1572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573 }
1574}
1575
Kenneth Russell67ea1902014-10-06 16:44:50 -07001576void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001578 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001579 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001580
Geoff Langbfdea662014-07-23 14:16:32 -04001581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001582 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583 {
Geoff Langb1196682014-07-23 13:47:29 -04001584 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1585 {
1586 context->recordError(gl::Error(GL_INVALID_ENUM));
1587 return;
1588 }
1589
Geoff Langbfdea662014-07-23 14:16:32 -04001590 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1591 {
1592 return;
1593 }
1594
1595 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1596 ASSERT(framebuffer);
1597
1598 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1599 {
1600 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1601 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1602 }
1603 else
1604 {
1605 switch (attachment)
1606 {
1607 case GL_DEPTH_ATTACHMENT:
1608 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1609 break;
1610 case GL_STENCIL_ATTACHMENT:
1611 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1612 break;
1613 case GL_DEPTH_STENCIL_ATTACHMENT:
1614 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1615 break;
1616 default:
1617 UNREACHABLE();
1618 break;
1619 }
1620 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001621 }
1622}
1623
Kenneth Russell67ea1902014-10-06 16:44:50 -07001624void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001626 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001627 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001628
Geoff Langbfdea662014-07-23 14:16:32 -04001629 gl::Context *context = gl::getNonLostContext();
1630 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001631 {
Geoff Langbfdea662014-07-23 14:16:32 -04001632 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001633 {
Geoff Langbfdea662014-07-23 14:16:32 -04001634 return;
1635 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001636
Geoff Langbfdea662014-07-23 14:16:32 -04001637 if (texture == 0)
1638 {
1639 textarget = GL_NONE;
1640 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641
Geoff Langbfdea662014-07-23 14:16:32 -04001642 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05001643 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001644
Geoff Langbfdea662014-07-23 14:16:32 -04001645 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1646 {
1647 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1648 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1649 }
1650 else
1651 {
1652 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001653 {
Geoff Langbfdea662014-07-23 14:16:32 -04001654 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1655 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1656 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001657 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001658 }
1659 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001660}
1661
Kenneth Russell67ea1902014-10-06 16:44:50 -07001662void GL_APIENTRY glFrontFace(GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001663{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001664 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001665
Geoff Langb1196682014-07-23 13:47:29 -04001666 gl::Context *context = gl::getNonLostContext();
1667 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001668 {
Geoff Langb1196682014-07-23 13:47:29 -04001669 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001670 {
Geoff Langb1196682014-07-23 13:47:29 -04001671 case GL_CW:
1672 case GL_CCW:
1673 context->getState().setFrontFace(mode);
1674 break;
1675 default:
1676 context->recordError(gl::Error(GL_INVALID_ENUM));
1677 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001678 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001679 }
1680}
1681
Kenneth Russell67ea1902014-10-06 16:44:50 -07001682void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001683{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001684 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685
Geoff Langbfdea662014-07-23 14:16:32 -04001686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001687 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001688 {
Geoff Langb1196682014-07-23 13:47:29 -04001689 if (n < 0)
1690 {
1691 context->recordError(gl::Error(GL_INVALID_VALUE));
1692 return;
1693 }
1694
Geoff Langbfdea662014-07-23 14:16:32 -04001695 for (int i = 0; i < n; i++)
1696 {
1697 buffers[i] = context->createBuffer();
1698 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001699 }
1700}
1701
Kenneth Russell67ea1902014-10-06 16:44:50 -07001702void GL_APIENTRY glGenerateMipmap(GLenum target)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001703{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001704 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001705
Geoff Langbfdea662014-07-23 14:16:32 -04001706 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001707 if (context)
1708 {
1709 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001710 {
Geoff Langb1196682014-07-23 13:47:29 -04001711 context->recordError(gl::Error(GL_INVALID_ENUM));
1712 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001713 }
Geoff Langbfdea662014-07-23 14:16:32 -04001714
1715 gl::Texture *texture = context->getTargetTexture(target);
1716
1717 if (texture == NULL)
1718 {
Geoff Langb1196682014-07-23 13:47:29 -04001719 context->recordError(gl::Error(GL_INVALID_OPERATION));
1720 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001721 }
1722
1723 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1724 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001725 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001726
1727 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1728 // unsized formats or that are color renderable and filterable. Since we do not track if
1729 // the texture was created with sized or unsized format (only sized formats are stored),
1730 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1731 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1732 // textures since they're the only texture format that can be created with unsized formats
1733 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1734 // was the last version to use add them.
1735 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1736 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1737 internalFormat == GL_ALPHA8_EXT;
1738
Geoff Lang5d601382014-07-22 15:14:06 -04001739 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1740 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001741 {
Geoff Langb1196682014-07-23 13:47:29 -04001742 context->recordError(gl::Error(GL_INVALID_OPERATION));
1743 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001744 }
1745
1746 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001747 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001748 {
Geoff Langb1196682014-07-23 13:47:29 -04001749 context->recordError(gl::Error(GL_INVALID_OPERATION));
1750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001751 }
1752
1753 // Non-power of 2 ES2 check
1754 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1755 {
1756 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001757 context->recordError(gl::Error(GL_INVALID_OPERATION));
1758 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001759 }
1760
1761 // Cube completeness check
1762 if (target == GL_TEXTURE_CUBE_MAP)
1763 {
1764 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1765 if (!textureCube->isCubeComplete())
1766 {
Geoff Langb1196682014-07-23 13:47:29 -04001767 context->recordError(gl::Error(GL_INVALID_OPERATION));
1768 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001769 }
1770 }
1771
Geoff Lang06ecf3d2014-09-23 16:39:50 -04001772 gl::Error error = texture->generateMipmaps();
1773 if (error.isError())
1774 {
1775 context->recordError(error);
1776 return;
1777 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001778 }
1779}
1780
Kenneth Russell67ea1902014-10-06 16:44:50 -07001781void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001782{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001783 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001784
Geoff Langbfdea662014-07-23 14:16:32 -04001785 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001786 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001787 {
Geoff Langb1196682014-07-23 13:47:29 -04001788 if (n < 0)
1789 {
1790 context->recordError(gl::Error(GL_INVALID_VALUE));
1791 return;
1792 }
1793
Geoff Langbfdea662014-07-23 14:16:32 -04001794 for (int i = 0; i < n; i++)
1795 {
1796 fences[i] = context->createFenceNV();
1797 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001798 }
1799}
1800
Kenneth Russell67ea1902014-10-06 16:44:50 -07001801void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001802{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001803 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001804
Geoff Langbfdea662014-07-23 14:16:32 -04001805 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001806 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001807 {
Geoff Langb1196682014-07-23 13:47:29 -04001808 if (n < 0)
1809 {
1810 context->recordError(gl::Error(GL_INVALID_VALUE));
1811 return;
1812 }
1813
Geoff Langbfdea662014-07-23 14:16:32 -04001814 for (int i = 0; i < n; i++)
1815 {
1816 framebuffers[i] = context->createFramebuffer();
1817 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001818 }
1819}
1820
Kenneth Russell67ea1902014-10-06 16:44:50 -07001821void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001822{
1823 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1824
Geoff Langbfdea662014-07-23 14:16:32 -04001825 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001826 if (context)
1827 {
1828 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001829 {
Geoff Langb1196682014-07-23 13:47:29 -04001830 context->recordError(gl::Error(GL_INVALID_VALUE));
1831 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001832 }
Geoff Langbfdea662014-07-23 14:16:32 -04001833
1834 for (GLsizei i = 0; i < n; i++)
1835 {
1836 ids[i] = context->createQuery();
1837 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001838 }
1839}
1840
Kenneth Russell67ea1902014-10-06 16:44:50 -07001841void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001842{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001843 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001844
Geoff Langbfdea662014-07-23 14:16:32 -04001845 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001846 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001847 {
Geoff Langb1196682014-07-23 13:47:29 -04001848 if (n < 0)
1849 {
1850 context->recordError(gl::Error(GL_INVALID_VALUE));
1851 return;
1852 }
1853
Geoff Langbfdea662014-07-23 14:16:32 -04001854 for (int i = 0; i < n; i++)
1855 {
1856 renderbuffers[i] = context->createRenderbuffer();
1857 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001858 }
1859}
1860
Kenneth Russell67ea1902014-10-06 16:44:50 -07001861void GL_APIENTRY glGenTextures(GLsizei n, GLuint* textures)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001862{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001863 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001864
Geoff Langbfdea662014-07-23 14:16:32 -04001865 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001866 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001867 {
Geoff Langb1196682014-07-23 13:47:29 -04001868 if (n < 0)
1869 {
1870 context->recordError(gl::Error(GL_INVALID_VALUE));
1871 return;
1872 }
1873
Geoff Langbfdea662014-07-23 14:16:32 -04001874 for (int i = 0; i < n; i++)
1875 {
1876 textures[i] = context->createTexture();
1877 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001878 }
1879}
1880
Kenneth Russell67ea1902014-10-06 16:44:50 -07001881void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001882{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001883 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001884 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001885 program, index, bufsize, length, size, type, name);
1886
Geoff Langbfdea662014-07-23 14:16:32 -04001887 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001888 if (context)
1889 {
Geoff Langb1196682014-07-23 13:47:29 -04001890 if (bufsize < 0)
1891 {
1892 context->recordError(gl::Error(GL_INVALID_VALUE));
1893 return;
1894 }
1895
Geoff Langbfdea662014-07-23 14:16:32 -04001896 gl::Program *programObject = context->getProgram(program);
1897
1898 if (!programObject)
1899 {
1900 if (context->getShader(program))
1901 {
Geoff Langb1196682014-07-23 13:47:29 -04001902 context->recordError(gl::Error(GL_INVALID_OPERATION));
1903 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001904 }
1905 else
1906 {
Geoff Langb1196682014-07-23 13:47:29 -04001907 context->recordError(gl::Error(GL_INVALID_VALUE));
1908 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001909 }
1910 }
1911
1912 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001913 {
Geoff Langb1196682014-07-23 13:47:29 -04001914 context->recordError(gl::Error(GL_INVALID_VALUE));
1915 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001916 }
1917
Geoff Langbfdea662014-07-23 14:16:32 -04001918 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001919 }
1920}
1921
Kenneth Russell67ea1902014-10-06 16:44:50 -07001922void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001923{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001924 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001925 "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001926 program, index, bufsize, length, size, type, name);
1927
Geoff Langbfdea662014-07-23 14:16:32 -04001928
1929 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001930 if (context)
1931 {
Geoff Langb1196682014-07-23 13:47:29 -04001932 if (bufsize < 0)
1933 {
1934 context->recordError(gl::Error(GL_INVALID_VALUE));
1935 return;
1936 }
1937
Geoff Langbfdea662014-07-23 14:16:32 -04001938 gl::Program *programObject = context->getProgram(program);
1939
1940 if (!programObject)
1941 {
1942 if (context->getShader(program))
1943 {
Geoff Langb1196682014-07-23 13:47:29 -04001944 context->recordError(gl::Error(GL_INVALID_OPERATION));
1945 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001946 }
1947 else
1948 {
Geoff Langb1196682014-07-23 13:47:29 -04001949 context->recordError(gl::Error(GL_INVALID_VALUE));
1950 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001951 }
1952 }
1953
1954 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001955 {
Geoff Langb1196682014-07-23 13:47:29 -04001956 context->recordError(gl::Error(GL_INVALID_VALUE));
1957 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001958 }
1959
Geoff Langbfdea662014-07-23 14:16:32 -04001960 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001961 }
1962}
1963
Kenneth Russell67ea1902014-10-06 16:44:50 -07001964void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001966 EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001967 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001968
Geoff Langbfdea662014-07-23 14:16:32 -04001969 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001970 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001971 {
Geoff Langb1196682014-07-23 13:47:29 -04001972 if (maxcount < 0)
1973 {
1974 context->recordError(gl::Error(GL_INVALID_VALUE));
1975 return;
1976 }
1977
Geoff Langbfdea662014-07-23 14:16:32 -04001978 gl::Program *programObject = context->getProgram(program);
1979
1980 if (!programObject)
1981 {
1982 if (context->getShader(program))
1983 {
Geoff Langb1196682014-07-23 13:47:29 -04001984 context->recordError(gl::Error(GL_INVALID_OPERATION));
1985 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001986 }
1987 else
1988 {
Geoff Langb1196682014-07-23 13:47:29 -04001989 context->recordError(gl::Error(GL_INVALID_VALUE));
1990 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001991 }
1992 }
1993
1994 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001995 }
1996}
1997
Kenneth Russell67ea1902014-10-06 16:44:50 -07001998GLint GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002000 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002001
Geoff Langbfdea662014-07-23 14:16:32 -04002002 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002003 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002004 {
Geoff Langbfdea662014-07-23 14:16:32 -04002005 gl::Program *programObject = context->getProgram(program);
2006
2007 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002008 {
Geoff Langbfdea662014-07-23 14:16:32 -04002009 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002010 {
Geoff Langb1196682014-07-23 13:47:29 -04002011 context->recordError(gl::Error(GL_INVALID_OPERATION));
2012 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002013 }
Geoff Langbfdea662014-07-23 14:16:32 -04002014 else
2015 {
Geoff Langb1196682014-07-23 13:47:29 -04002016 context->recordError(gl::Error(GL_INVALID_VALUE));
2017 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002018 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002019 }
Geoff Langbfdea662014-07-23 14:16:32 -04002020
2021 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
2022 if (!programObject->isLinked() || !programBinary)
2023 {
Geoff Langb1196682014-07-23 13:47:29 -04002024 context->recordError(gl::Error(GL_INVALID_OPERATION));
2025 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04002026 }
2027
2028 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029 }
2030
2031 return -1;
2032}
2033
Kenneth Russell67ea1902014-10-06 16:44:50 -07002034void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002035{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002036 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002037
Geoff Langbfdea662014-07-23 14:16:32 -04002038 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002039 if (context)
2040 {
2041 GLenum nativeType;
2042 unsigned int numParams = 0;
2043 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002044 {
Geoff Langbfdea662014-07-23 14:16:32 -04002045 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002046 }
Geoff Langbfdea662014-07-23 14:16:32 -04002047
2048 if (nativeType == GL_BOOL)
2049 {
2050 context->getBooleanv(pname, params);
2051 }
2052 else
2053 {
2054 CastStateValues(context, nativeType, pname, numParams, params);
2055 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002056 }
2057}
2058
Kenneth Russell67ea1902014-10-06 16:44:50 -07002059void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002060{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002061 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002062
Geoff Langbfdea662014-07-23 14:16:32 -04002063 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002064 if (context)
2065 {
2066 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002067 {
Geoff Langb1196682014-07-23 13:47:29 -04002068 context->recordError(gl::Error(GL_INVALID_ENUM));
2069 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002070 }
Geoff Langbfdea662014-07-23 14:16:32 -04002071
2072 if (!gl::ValidBufferParameter(context, pname))
2073 {
Geoff Langb1196682014-07-23 13:47:29 -04002074 context->recordError(gl::Error(GL_INVALID_ENUM));
2075 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002076 }
2077
2078 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
2079
2080 if (!buffer)
2081 {
2082 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04002083 context->recordError(gl::Error(GL_INVALID_OPERATION));
2084 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002085 }
2086
2087 switch (pname)
2088 {
2089 case GL_BUFFER_USAGE:
2090 *params = static_cast<GLint>(buffer->getUsage());
2091 break;
2092 case GL_BUFFER_SIZE:
2093 *params = gl::clampCast<GLint>(buffer->getSize());
2094 break;
2095 case GL_BUFFER_ACCESS_FLAGS:
2096 *params = buffer->getAccessFlags();
2097 break;
2098 case GL_BUFFER_MAPPED:
2099 *params = static_cast<GLint>(buffer->isMapped());
2100 break;
2101 case GL_BUFFER_MAP_OFFSET:
2102 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2103 break;
2104 case GL_BUFFER_MAP_LENGTH:
2105 *params = gl::clampCast<GLint>(buffer->getMapLength());
2106 break;
2107 default: UNREACHABLE(); break;
2108 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002109 }
2110}
2111
Kenneth Russell67ea1902014-10-06 16:44:50 -07002112GLenum GL_APIENTRY glGetError(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002113{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002114 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002115
2116 gl::Context *context = gl::getContext();
2117
2118 if (context)
2119 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002120 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002121 }
2122
2123 return GL_NO_ERROR;
2124}
2125
Kenneth Russell67ea1902014-10-06 16:44:50 -07002126void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002127{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002128 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002129
Geoff Langbfdea662014-07-23 14:16:32 -04002130 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002131 if (context)
2132 {
2133 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2134
2135 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002136 {
Geoff Langb1196682014-07-23 13:47:29 -04002137 context->recordError(gl::Error(GL_INVALID_OPERATION));
2138 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002139 }
Geoff Langbfdea662014-07-23 14:16:32 -04002140
2141 if (fenceObject->isFence() != GL_TRUE)
2142 {
Geoff Langb1196682014-07-23 13:47:29 -04002143 context->recordError(gl::Error(GL_INVALID_OPERATION));
2144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002145 }
2146
2147 switch (pname)
2148 {
2149 case GL_FENCE_STATUS_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002150 {
2151 // GL_NV_fence spec:
2152 // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
2153 // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
2154 GLboolean status = GL_TRUE;
2155 if (fenceObject->getStatus() != GL_TRUE)
2156 {
2157 gl::Error error = fenceObject->testFence(&status);
2158 if (error.isError())
2159 {
2160 context->recordError(error);
2161 return;
2162 }
2163 }
2164 *params = status;
2165 break;
2166 }
2167
Geoff Langbfdea662014-07-23 14:16:32 -04002168 case GL_FENCE_CONDITION_NV:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002169 {
2170 *params = fenceObject->getCondition();
2171 break;
2172 }
Geoff Langbfdea662014-07-23 14:16:32 -04002173
Geoff Langb1196682014-07-23 13:47:29 -04002174 default:
Kenneth Russellcaa549c2014-10-10 17:52:59 -07002175 {
2176 context->recordError(gl::Error(GL_INVALID_ENUM));
2177 return;
2178 }
Geoff Lang882033e2014-09-30 11:26:07 -04002179 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002180 }
2181}
2182
Kenneth Russell67ea1902014-10-06 16:44:50 -07002183void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002184{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002185 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002186
Geoff Langbfdea662014-07-23 14:16:32 -04002187 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002188 if (context)
2189 {
2190 GLenum nativeType;
2191 unsigned int numParams = 0;
2192 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002193 {
Geoff Langbfdea662014-07-23 14:16:32 -04002194 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002195 }
Geoff Langbfdea662014-07-23 14:16:32 -04002196
2197 if (nativeType == GL_FLOAT)
2198 {
2199 context->getFloatv(pname, params);
2200 }
2201 else
2202 {
2203 CastStateValues(context, nativeType, pname, numParams, params);
2204 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002205 }
2206}
2207
Kenneth Russell67ea1902014-10-06 16:44:50 -07002208void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002209{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002210 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002211 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002212
Geoff Langbfdea662014-07-23 14:16:32 -04002213 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002214 if (context)
2215 {
2216 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002217 {
Geoff Langb1196682014-07-23 13:47:29 -04002218 context->recordError(gl::Error(GL_INVALID_ENUM));
2219 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002220 }
2221
2222 int clientVersion = context->getClientVersion();
2223
2224 switch (pname)
2225 {
2226 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2227 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2228 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2229 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2230 break;
Geoff Langb1196682014-07-23 13:47:29 -04002231
Geoff Langbfdea662014-07-23 14:16:32 -04002232 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2233 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002234 {
Geoff Langb1196682014-07-23 13:47:29 -04002235 context->recordError(gl::Error(GL_INVALID_ENUM));
2236 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002237 }
Geoff Langbfdea662014-07-23 14:16:32 -04002238 break;
Geoff Langb1196682014-07-23 13:47:29 -04002239
Geoff Langbfdea662014-07-23 14:16:32 -04002240 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2241 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2242 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2243 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2244 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2245 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2246 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2247 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2248 if (clientVersion < 3)
2249 {
Geoff Langb1196682014-07-23 13:47:29 -04002250 context->recordError(gl::Error(GL_INVALID_ENUM));
2251 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002252 }
2253 break;
Geoff Langb1196682014-07-23 13:47:29 -04002254
Geoff Langbfdea662014-07-23 14:16:32 -04002255 default:
Geoff Langb1196682014-07-23 13:47:29 -04002256 context->recordError(gl::Error(GL_INVALID_ENUM));
2257 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002258 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002259
Geoff Langbfdea662014-07-23 14:16:32 -04002260 // Determine if the attachment is a valid enum
2261 switch (attachment)
2262 {
2263 case GL_BACK:
2264 case GL_FRONT:
2265 case GL_DEPTH:
2266 case GL_STENCIL:
2267 case GL_DEPTH_STENCIL_ATTACHMENT:
2268 if (clientVersion < 3)
2269 {
Geoff Langb1196682014-07-23 13:47:29 -04002270 context->recordError(gl::Error(GL_INVALID_ENUM));
2271 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002272 }
2273 break;
2274
2275 case GL_DEPTH_ATTACHMENT:
2276 case GL_STENCIL_ATTACHMENT:
2277 break;
2278
2279 default:
2280 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2281 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2282 {
Geoff Langb1196682014-07-23 13:47:29 -04002283 context->recordError(gl::Error(GL_INVALID_ENUM));
2284 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002285 }
2286 break;
2287 }
2288
2289 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2290 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
Jamie Madill48faf802014-11-06 15:27:22 -05002291 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04002292
2293 if (framebufferHandle == 0)
2294 {
2295 if (clientVersion < 3)
2296 {
Geoff Langb1196682014-07-23 13:47:29 -04002297 context->recordError(gl::Error(GL_INVALID_OPERATION));
2298 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002299 }
2300
2301 switch (attachment)
2302 {
2303 case GL_BACK:
2304 case GL_DEPTH:
2305 case GL_STENCIL:
2306 break;
Geoff Langb1196682014-07-23 13:47:29 -04002307
Geoff Langbfdea662014-07-23 14:16:32 -04002308 default:
Geoff Langb1196682014-07-23 13:47:29 -04002309 context->recordError(gl::Error(GL_INVALID_OPERATION));
2310 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002311 }
2312 }
2313 else
2314 {
2315 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2316 {
2317 // Valid attachment query
2318 }
2319 else
2320 {
2321 switch (attachment)
2322 {
2323 case GL_DEPTH_ATTACHMENT:
2324 case GL_STENCIL_ATTACHMENT:
2325 break;
Geoff Langb1196682014-07-23 13:47:29 -04002326
Geoff Langbfdea662014-07-23 14:16:32 -04002327 case GL_DEPTH_STENCIL_ATTACHMENT:
2328 if (framebuffer->hasValidDepthStencil())
2329 {
Geoff Langb1196682014-07-23 13:47:29 -04002330 context->recordError(gl::Error(GL_INVALID_OPERATION));
2331 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002332 }
2333 break;
Geoff Langb1196682014-07-23 13:47:29 -04002334
Geoff Langbfdea662014-07-23 14:16:32 -04002335 default:
Geoff Langb1196682014-07-23 13:47:29 -04002336 context->recordError(gl::Error(GL_INVALID_OPERATION));
2337 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002338 }
2339 }
2340 }
2341
2342 GLenum attachmentType = GL_NONE;
2343 GLuint attachmentHandle = 0;
2344 GLuint attachmentLevel = 0;
2345 GLuint attachmentLayer = 0;
2346
2347 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2348
2349 if (attachmentObject)
2350 {
2351 attachmentType = attachmentObject->type();
2352 attachmentHandle = attachmentObject->id();
2353 attachmentLevel = attachmentObject->mipLevel();
2354 attachmentLayer = attachmentObject->layer();
2355 }
2356
2357 GLenum attachmentObjectType; // Type category
2358 if (framebufferHandle == 0)
2359 {
2360 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2361 }
2362 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2363 {
2364 attachmentObjectType = attachmentType;
2365 }
2366 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2367 {
2368 attachmentObjectType = GL_TEXTURE;
2369 }
2370 else
2371 {
2372 UNREACHABLE();
2373 return;
2374 }
2375
2376 if (attachmentObjectType == GL_NONE)
2377 {
2378 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2379 // is NONE, then querying any other pname will generate INVALID_ENUM.
2380
2381 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2382 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2383 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002384
Geoff Lang646559f2013-08-15 11:08:15 -04002385 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002386 {
Geoff Lang646559f2013-08-15 11:08:15 -04002387 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002388 *params = attachmentObjectType;
2389 break;
2390
Geoff Lang646559f2013-08-15 11:08:15 -04002391 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002392 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002393 {
Geoff Langb1196682014-07-23 13:47:29 -04002394 context->recordError(gl::Error(GL_INVALID_ENUM));
2395 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002396 }
Geoff Langbfdea662014-07-23 14:16:32 -04002397 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002398 break;
2399
2400 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002401 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002402 {
Geoff Langb1196682014-07-23 13:47:29 -04002403 context->recordError(gl::Error(GL_INVALID_ENUM));
2404 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002405 }
2406 else
2407 {
Geoff Langb1196682014-07-23 13:47:29 -04002408 context->recordError(gl::Error(GL_INVALID_OPERATION));
2409 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002410 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002411 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002412 }
Geoff Langbfdea662014-07-23 14:16:32 -04002413 else
2414 {
2415 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2416 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2417 ASSERT(attachmentObject != NULL);
2418
2419 switch (pname)
2420 {
2421 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2422 *params = attachmentObjectType;
2423 break;
2424
2425 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2426 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2427 {
Geoff Langb1196682014-07-23 13:47:29 -04002428 context->recordError(gl::Error(GL_INVALID_ENUM));
2429 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002430 }
2431 *params = attachmentHandle;
2432 break;
2433
2434 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2435 if (attachmentObjectType != GL_TEXTURE)
2436 {
Geoff Langb1196682014-07-23 13:47:29 -04002437 context->recordError(gl::Error(GL_INVALID_ENUM));
2438 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002439 }
2440 *params = attachmentLevel;
2441 break;
2442
2443 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2444 if (attachmentObjectType != GL_TEXTURE)
2445 {
Geoff Langb1196682014-07-23 13:47:29 -04002446 context->recordError(gl::Error(GL_INVALID_ENUM));
2447 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002448 }
2449 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2450 break;
2451
2452 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2453 *params = attachmentObject->getRedSize();
2454 break;
2455
2456 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2457 *params = attachmentObject->getGreenSize();
2458 break;
2459
2460 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2461 *params = attachmentObject->getBlueSize();
2462 break;
2463
2464 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2465 *params = attachmentObject->getAlphaSize();
2466 break;
2467
2468 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2469 *params = attachmentObject->getDepthSize();
2470 break;
2471
2472 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2473 *params = attachmentObject->getStencilSize();
2474 break;
2475
2476 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Jamie Madillee85d1b2014-09-17 10:35:23 -04002477 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
Geoff Langbfdea662014-07-23 14:16:32 -04002478 {
Geoff Langb1196682014-07-23 13:47:29 -04002479 context->recordError(gl::Error(GL_INVALID_OPERATION));
2480 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002481 }
2482 *params = attachmentObject->getComponentType();
2483 break;
2484
2485 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2486 *params = attachmentObject->getColorEncoding();
2487 break;
2488
2489 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2490 if (attachmentObjectType != GL_TEXTURE)
2491 {
Geoff Langb1196682014-07-23 13:47:29 -04002492 context->recordError(gl::Error(GL_INVALID_ENUM));
2493 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002494 }
2495 *params = attachmentLayer;
2496 break;
2497
2498 default:
2499 UNREACHABLE();
2500 break;
2501 }
2502 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002503 }
2504}
2505
Kenneth Russell67ea1902014-10-06 16:44:50 -07002506GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002507{
2508 EVENT("()");
2509
Geoff Langbfdea662014-07-23 14:16:32 -04002510 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002511
Geoff Langbfdea662014-07-23 14:16:32 -04002512 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002513 {
Geoff Langbfdea662014-07-23 14:16:32 -04002514 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002515 }
Geoff Langbfdea662014-07-23 14:16:32 -04002516
2517 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002518}
2519
Kenneth Russell67ea1902014-10-06 16:44:50 -07002520void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002521{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002522 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002523
Geoff Langbfdea662014-07-23 14:16:32 -04002524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002525 if (context)
2526 {
2527 GLenum nativeType;
2528 unsigned int numParams = 0;
2529
2530 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002531 {
Geoff Langbfdea662014-07-23 14:16:32 -04002532 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 }
Geoff Langbfdea662014-07-23 14:16:32 -04002534
2535 if (nativeType == GL_INT)
2536 {
2537 context->getIntegerv(pname, params);
2538 }
2539 else
2540 {
2541 CastStateValues(context, nativeType, pname, numParams, params);
2542 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002543 }
2544}
2545
Kenneth Russell67ea1902014-10-06 16:44:50 -07002546void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002548 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002549
Geoff Langbfdea662014-07-23 14:16:32 -04002550 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002551 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002552 {
Geoff Langbfdea662014-07-23 14:16:32 -04002553 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002554
Geoff Langbfdea662014-07-23 14:16:32 -04002555 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002556 {
Geoff Langb1196682014-07-23 13:47:29 -04002557 context->recordError(gl::Error(GL_INVALID_VALUE));
2558 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002559 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002560
Geoff Langbfdea662014-07-23 14:16:32 -04002561 if (context->getClientVersion() < 3)
2562 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002563 switch (pname)
2564 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002565 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002566 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002567 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002568 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002569 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002570 context->recordError(gl::Error(GL_INVALID_ENUM));
2571 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002572 }
2573 }
Geoff Langbfdea662014-07-23 14:16:32 -04002574
2575 switch (pname)
2576 {
2577 case GL_DELETE_STATUS:
2578 *params = programObject->isFlaggedForDeletion();
2579 return;
2580 case GL_LINK_STATUS:
2581 *params = programObject->isLinked();
2582 return;
2583 case GL_VALIDATE_STATUS:
2584 *params = programObject->isValidated();
2585 return;
2586 case GL_INFO_LOG_LENGTH:
2587 *params = programObject->getInfoLogLength();
2588 return;
2589 case GL_ATTACHED_SHADERS:
2590 *params = programObject->getAttachedShadersCount();
2591 return;
2592 case GL_ACTIVE_ATTRIBUTES:
2593 *params = programObject->getActiveAttributeCount();
2594 return;
2595 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2596 *params = programObject->getActiveAttributeMaxLength();
2597 return;
2598 case GL_ACTIVE_UNIFORMS:
2599 *params = programObject->getActiveUniformCount();
2600 return;
2601 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2602 *params = programObject->getActiveUniformMaxLength();
2603 return;
2604 case GL_PROGRAM_BINARY_LENGTH_OES:
2605 *params = programObject->getProgramBinaryLength();
2606 return;
2607 case GL_ACTIVE_UNIFORM_BLOCKS:
2608 *params = programObject->getActiveUniformBlockCount();
2609 return;
2610 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2611 *params = programObject->getActiveUniformBlockMaxLength();
2612 break;
2613 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2614 *params = programObject->getTransformFeedbackBufferMode();
2615 break;
2616 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2617 *params = programObject->getTransformFeedbackVaryingCount();
2618 break;
2619 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2620 *params = programObject->getTransformFeedbackVaryingMaxLength();
2621 break;
Geoff Langb1196682014-07-23 13:47:29 -04002622
Geoff Langbfdea662014-07-23 14:16:32 -04002623 default:
Geoff Langb1196682014-07-23 13:47:29 -04002624 context->recordError(gl::Error(GL_INVALID_ENUM));
2625 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002626 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002627 }
2628}
2629
Kenneth Russell67ea1902014-10-06 16:44:50 -07002630void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002631{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002632 EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002633 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002634
Geoff Langbfdea662014-07-23 14:16:32 -04002635 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002636 if (context)
2637 {
Geoff Langb1196682014-07-23 13:47:29 -04002638 if (bufsize < 0)
2639 {
2640 context->recordError(gl::Error(GL_INVALID_VALUE));
2641 return;
2642 }
2643
Geoff Langbfdea662014-07-23 14:16:32 -04002644 gl::Program *programObject = context->getProgram(program);
2645
2646 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002647 {
Geoff Langb1196682014-07-23 13:47:29 -04002648 context->recordError(gl::Error(GL_INVALID_VALUE));
2649 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002650 }
2651
Geoff Langbfdea662014-07-23 14:16:32 -04002652 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002653 }
2654}
2655
Kenneth Russell67ea1902014-10-06 16:44:50 -07002656void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002657{
2658 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2659
Geoff Langbfdea662014-07-23 14:16:32 -04002660 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002661 if (context)
2662 {
2663 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002664 {
Geoff Langb1196682014-07-23 13:47:29 -04002665 context->recordError(gl::Error(GL_INVALID_ENUM));
2666 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002667 }
Geoff Langbfdea662014-07-23 14:16:32 -04002668
2669 switch (pname)
2670 {
2671 case GL_CURRENT_QUERY_EXT:
2672 params[0] = context->getState().getActiveQueryId(target);
2673 break;
2674
2675 default:
Geoff Langb1196682014-07-23 13:47:29 -04002676 context->recordError(gl::Error(GL_INVALID_ENUM));
2677 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002678 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002679 }
2680}
2681
Kenneth Russell67ea1902014-10-06 16:44:50 -07002682void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002683{
2684 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2685
Geoff Langbfdea662014-07-23 14:16:32 -04002686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002687 if (context)
2688 {
2689 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2690
2691 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002692 {
Geoff Langb1196682014-07-23 13:47:29 -04002693 context->recordError(gl::Error(GL_INVALID_OPERATION));
2694 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002695 }
Geoff Langbfdea662014-07-23 14:16:32 -04002696
2697 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2698 {
Geoff Langb1196682014-07-23 13:47:29 -04002699 context->recordError(gl::Error(GL_INVALID_OPERATION));
2700 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002701 }
2702
2703 switch(pname)
2704 {
2705 case GL_QUERY_RESULT_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002706 {
2707 gl::Error error = queryObject->getResult(params);
2708 if (error.isError())
2709 {
2710 context->recordError(error);
2711 return;
2712 }
2713 }
Geoff Langbfdea662014-07-23 14:16:32 -04002714 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002715
Geoff Langbfdea662014-07-23 14:16:32 -04002716 case GL_QUERY_RESULT_AVAILABLE_EXT:
Geoff Lang5aad9672014-09-08 11:10:42 -04002717 {
2718 gl::Error error = queryObject->isResultAvailable(params);
2719 if (error.isError())
2720 {
2721 context->recordError(error);
2722 return;
2723 }
2724 }
Geoff Langbfdea662014-07-23 14:16:32 -04002725 break;
Geoff Lang5aad9672014-09-08 11:10:42 -04002726
Geoff Langbfdea662014-07-23 14:16:32 -04002727 default:
Geoff Langb1196682014-07-23 13:47:29 -04002728 context->recordError(gl::Error(GL_INVALID_ENUM));
2729 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002730 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002731 }
2732}
2733
Kenneth Russell67ea1902014-10-06 16:44:50 -07002734void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002735{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002736 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002737
Geoff Langbfdea662014-07-23 14:16:32 -04002738 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002739 if (context)
2740 {
2741 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002742 {
Geoff Langb1196682014-07-23 13:47:29 -04002743 context->recordError(gl::Error(GL_INVALID_ENUM));
2744 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002745 }
Geoff Langbfdea662014-07-23 14:16:32 -04002746
2747 if (context->getState().getRenderbufferId() == 0)
2748 {
Geoff Langb1196682014-07-23 13:47:29 -04002749 context->recordError(gl::Error(GL_INVALID_OPERATION));
2750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002751 }
2752
2753 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2754
2755 switch (pname)
2756 {
2757 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2758 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2759 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2760 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2761 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2762 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2763 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2764 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2765 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002766
Geoff Langbfdea662014-07-23 14:16:32 -04002767 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2768 if (!context->getExtensions().framebufferMultisample)
2769 {
Geoff Langb1196682014-07-23 13:47:29 -04002770 context->recordError(gl::Error(GL_INVALID_ENUM));
2771 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002772 }
2773 *params = renderbuffer->getSamples();
2774 break;
Geoff Langb1196682014-07-23 13:47:29 -04002775
Geoff Langbfdea662014-07-23 14:16:32 -04002776 default:
Geoff Langb1196682014-07-23 13:47:29 -04002777 context->recordError(gl::Error(GL_INVALID_ENUM));
2778 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002779 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002780 }
2781}
2782
Kenneth Russell67ea1902014-10-06 16:44:50 -07002783void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002785 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002786
Geoff Langbfdea662014-07-23 14:16:32 -04002787 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002788 if (context)
2789 {
2790 gl::Shader *shaderObject = context->getShader(shader);
2791
2792 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002793 {
Geoff Langb1196682014-07-23 13:47:29 -04002794 context->recordError(gl::Error(GL_INVALID_VALUE));
2795 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002796 }
Geoff Langbfdea662014-07-23 14:16:32 -04002797
2798 switch (pname)
2799 {
2800 case GL_SHADER_TYPE:
2801 *params = shaderObject->getType();
2802 return;
2803 case GL_DELETE_STATUS:
2804 *params = shaderObject->isFlaggedForDeletion();
2805 return;
2806 case GL_COMPILE_STATUS:
2807 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2808 return;
2809 case GL_INFO_LOG_LENGTH:
2810 *params = shaderObject->getInfoLogLength();
2811 return;
2812 case GL_SHADER_SOURCE_LENGTH:
2813 *params = shaderObject->getSourceLength();
2814 return;
2815 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2816 *params = shaderObject->getTranslatedSourceLength();
2817 return;
Geoff Langb1196682014-07-23 13:47:29 -04002818
Geoff Langbfdea662014-07-23 14:16:32 -04002819 default:
Geoff Langb1196682014-07-23 13:47:29 -04002820 context->recordError(gl::Error(GL_INVALID_ENUM));
2821 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002822 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002823 }
2824}
2825
Kenneth Russell67ea1902014-10-06 16:44:50 -07002826void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002827{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002828 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002829 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002830
Geoff Langbfdea662014-07-23 14:16:32 -04002831 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002832 if (context)
2833 {
Geoff Langb1196682014-07-23 13:47:29 -04002834 if (bufsize < 0)
2835 {
2836 context->recordError(gl::Error(GL_INVALID_VALUE));
2837 return;
2838 }
2839
Geoff Langbfdea662014-07-23 14:16:32 -04002840 gl::Shader *shaderObject = context->getShader(shader);
2841
2842 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002843 {
Geoff Langb1196682014-07-23 13:47:29 -04002844 context->recordError(gl::Error(GL_INVALID_VALUE));
2845 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002846 }
2847
Geoff Langbfdea662014-07-23 14:16:32 -04002848 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002849 }
2850}
2851
Kenneth Russell67ea1902014-10-06 16:44:50 -07002852void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002853{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002854 EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002855 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002856
Geoff Langb1196682014-07-23 13:47:29 -04002857 gl::Context *context = gl::getNonLostContext();
2858 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002859 {
Geoff Langb1196682014-07-23 13:47:29 -04002860 switch (shadertype)
2861 {
2862 case GL_VERTEX_SHADER:
2863 case GL_FRAGMENT_SHADER:
2864 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002865
Geoff Langb1196682014-07-23 13:47:29 -04002866 default:
2867 context->recordError(gl::Error(GL_INVALID_ENUM));
2868 return;
2869 }
2870
2871 switch (precisiontype)
2872 {
2873 case GL_LOW_FLOAT:
2874 case GL_MEDIUM_FLOAT:
2875 case GL_HIGH_FLOAT:
2876 // Assume IEEE 754 precision
2877 range[0] = 127;
2878 range[1] = 127;
2879 *precision = 23;
2880 break;
2881
2882 case GL_LOW_INT:
2883 case GL_MEDIUM_INT:
2884 case GL_HIGH_INT:
2885 // Some (most) hardware only supports single-precision floating-point numbers,
2886 // which can accurately represent integers up to +/-16777216
2887 range[0] = 24;
2888 range[1] = 24;
2889 *precision = 0;
2890 break;
2891
2892 default:
2893 context->recordError(gl::Error(GL_INVALID_ENUM));
2894 return;
2895 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002896 }
2897}
2898
Kenneth Russell67ea1902014-10-06 16:44:50 -07002899void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002901 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00002902 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002903
Geoff Langbfdea662014-07-23 14:16:32 -04002904 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002905 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002906 {
Geoff Langb1196682014-07-23 13:47:29 -04002907 if (bufsize < 0)
2908 {
2909 context->recordError(gl::Error(GL_INVALID_VALUE));
2910 return;
2911 }
2912
Geoff Langbfdea662014-07-23 14:16:32 -04002913 gl::Shader *shaderObject = context->getShader(shader);
2914
2915 if (!shaderObject)
2916 {
Geoff Langb1196682014-07-23 13:47:29 -04002917 context->recordError(gl::Error(GL_INVALID_OPERATION));
2918 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002919 }
2920
2921 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002922 }
2923}
2924
Kenneth Russell67ea1902014-10-06 16:44:50 -07002925void GL_APIENTRY glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
zmo@google.coma574f782011-10-03 21:45:23 +00002926{
2927 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2928 shader, bufsize, length, source);
2929
Geoff Langbfdea662014-07-23 14:16:32 -04002930 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002931 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002932 {
Geoff Langb1196682014-07-23 13:47:29 -04002933 if (bufsize < 0)
2934 {
2935 context->recordError(gl::Error(GL_INVALID_VALUE));
2936 return;
2937 }
2938
Geoff Langbfdea662014-07-23 14:16:32 -04002939 gl::Shader *shaderObject = context->getShader(shader);
2940
2941 if (!shaderObject)
2942 {
Geoff Langb1196682014-07-23 13:47:29 -04002943 context->recordError(gl::Error(GL_INVALID_OPERATION));
2944 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002945 }
2946
Tibor den Ouden97049c62014-10-06 21:39:16 +02002947 // Only returns extra info if ANGLE_GENERATE_SHADER_DEBUG_INFO is defined
2948 shaderObject->getTranslatedSourceWithDebugInfo(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002949 }
2950}
2951
Kenneth Russell67ea1902014-10-06 16:44:50 -07002952const GLubyte* GL_APIENTRY glGetString(GLenum name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002953{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002954 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002955
Geoff Langbfdea662014-07-23 14:16:32 -04002956 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002957
Geoff Langbfdea662014-07-23 14:16:32 -04002958 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002959 {
Geoff Langbfdea662014-07-23 14:16:32 -04002960 case GL_VENDOR:
2961 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002962
Geoff Langbfdea662014-07-23 14:16:32 -04002963 case GL_RENDERER:
2964 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002965
Geoff Langbfdea662014-07-23 14:16:32 -04002966 case GL_VERSION:
2967 if (context->getClientVersion() == 2)
2968 {
2969 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2970 }
2971 else
2972 {
2973 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2974 }
Geoff Langb1196682014-07-23 13:47:29 -04002975
Geoff Langbfdea662014-07-23 14:16:32 -04002976 case GL_SHADING_LANGUAGE_VERSION:
2977 if (context->getClientVersion() == 2)
2978 {
2979 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2980 }
2981 else
2982 {
2983 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2984 }
Geoff Langb1196682014-07-23 13:47:29 -04002985
Geoff Langbfdea662014-07-23 14:16:32 -04002986 case GL_EXTENSIONS:
2987 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002988
Geoff Langbfdea662014-07-23 14:16:32 -04002989 default:
Geoff Langb1196682014-07-23 13:47:29 -04002990 if (context)
2991 {
2992 context->recordError(gl::Error(GL_INVALID_ENUM));
2993 }
2994 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002996}
2997
Kenneth Russell67ea1902014-10-06 16:44:50 -07002998void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002999{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003000 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003001
Geoff Langbfdea662014-07-23 14:16:32 -04003002 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003003 if (context)
3004 {
3005 gl::Texture *texture = context->getTargetTexture(target);
3006
3007 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003008 {
Geoff Langb1196682014-07-23 13:47:29 -04003009 context->recordError(gl::Error(GL_INVALID_ENUM));
3010 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003011 }
Geoff Langbfdea662014-07-23 14:16:32 -04003012
3013 switch (pname)
3014 {
3015 case GL_TEXTURE_MAG_FILTER:
3016 *params = (GLfloat)texture->getSamplerState().magFilter;
3017 break;
3018 case GL_TEXTURE_MIN_FILTER:
3019 *params = (GLfloat)texture->getSamplerState().minFilter;
3020 break;
3021 case GL_TEXTURE_WRAP_S:
3022 *params = (GLfloat)texture->getSamplerState().wrapS;
3023 break;
3024 case GL_TEXTURE_WRAP_T:
3025 *params = (GLfloat)texture->getSamplerState().wrapT;
3026 break;
3027 case GL_TEXTURE_WRAP_R:
3028 if (context->getClientVersion() < 3)
3029 {
Geoff Langb1196682014-07-23 13:47:29 -04003030 context->recordError(gl::Error(GL_INVALID_ENUM));
3031 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003032 }
3033 *params = (GLfloat)texture->getSamplerState().wrapR;
3034 break;
3035 case GL_TEXTURE_IMMUTABLE_FORMAT:
3036 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3037 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3038 break;
3039 case GL_TEXTURE_IMMUTABLE_LEVELS:
3040 if (context->getClientVersion() < 3)
3041 {
Geoff Langb1196682014-07-23 13:47:29 -04003042 context->recordError(gl::Error(GL_INVALID_ENUM));
3043 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003044 }
3045 *params = (GLfloat)texture->immutableLevelCount();
3046 break;
3047 case GL_TEXTURE_USAGE_ANGLE:
3048 *params = (GLfloat)texture->getUsage();
3049 break;
3050 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3051 if (!context->getExtensions().textureFilterAnisotropic)
3052 {
Geoff Langb1196682014-07-23 13:47:29 -04003053 context->recordError(gl::Error(GL_INVALID_ENUM));
3054 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003055 }
3056 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
3057 break;
3058 case GL_TEXTURE_SWIZZLE_R:
3059 if (context->getClientVersion() < 3)
3060 {
Geoff Langb1196682014-07-23 13:47:29 -04003061 context->recordError(gl::Error(GL_INVALID_ENUM));
3062 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003063 }
3064 *params = (GLfloat)texture->getSamplerState().swizzleRed;
3065 break;
3066 case GL_TEXTURE_SWIZZLE_G:
3067 if (context->getClientVersion() < 3)
3068 {
Geoff Langb1196682014-07-23 13:47:29 -04003069 context->recordError(gl::Error(GL_INVALID_ENUM));
3070 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003071 }
3072 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
3073 break;
3074 case GL_TEXTURE_SWIZZLE_B:
3075 if (context->getClientVersion() < 3)
3076 {
Geoff Langb1196682014-07-23 13:47:29 -04003077 context->recordError(gl::Error(GL_INVALID_ENUM));
3078 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003079 }
3080 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
3081 break;
3082 case GL_TEXTURE_SWIZZLE_A:
3083 if (context->getClientVersion() < 3)
3084 {
Geoff Langb1196682014-07-23 13:47:29 -04003085 context->recordError(gl::Error(GL_INVALID_ENUM));
3086 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003087 }
3088 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
3089 break;
3090 case GL_TEXTURE_BASE_LEVEL:
3091 if (context->getClientVersion() < 3)
3092 {
Geoff Langb1196682014-07-23 13:47:29 -04003093 context->recordError(gl::Error(GL_INVALID_ENUM));
3094 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003095 }
3096 *params = (GLfloat)texture->getSamplerState().baseLevel;
3097 break;
3098 case GL_TEXTURE_MAX_LEVEL:
3099 if (context->getClientVersion() < 3)
3100 {
Geoff Langb1196682014-07-23 13:47:29 -04003101 context->recordError(gl::Error(GL_INVALID_ENUM));
3102 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003103 }
3104 *params = (GLfloat)texture->getSamplerState().maxLevel;
3105 break;
3106 case GL_TEXTURE_MIN_LOD:
3107 if (context->getClientVersion() < 3)
3108 {
Geoff Langb1196682014-07-23 13:47:29 -04003109 context->recordError(gl::Error(GL_INVALID_ENUM));
3110 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003111 }
3112 *params = texture->getSamplerState().minLod;
3113 break;
3114 case GL_TEXTURE_MAX_LOD:
3115 if (context->getClientVersion() < 3)
3116 {
Geoff Langb1196682014-07-23 13:47:29 -04003117 context->recordError(gl::Error(GL_INVALID_ENUM));
3118 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003119 }
3120 *params = texture->getSamplerState().maxLod;
3121 break;
Geoff Langb1196682014-07-23 13:47:29 -04003122
Geoff Langbfdea662014-07-23 14:16:32 -04003123 default:
Geoff Langb1196682014-07-23 13:47:29 -04003124 context->recordError(gl::Error(GL_INVALID_ENUM));
3125 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003126 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003127 }
3128}
3129
Kenneth Russell67ea1902014-10-06 16:44:50 -07003130void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003131{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003132 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003133
Geoff Langbfdea662014-07-23 14:16:32 -04003134 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003135 if (context)
3136 {
3137 gl::Texture *texture = context->getTargetTexture(target);
3138
3139 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003140 {
Geoff Langb1196682014-07-23 13:47:29 -04003141 context->recordError(gl::Error(GL_INVALID_ENUM));
3142 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003143 }
Geoff Langbfdea662014-07-23 14:16:32 -04003144
3145 switch (pname)
3146 {
3147 case GL_TEXTURE_MAG_FILTER:
3148 *params = texture->getSamplerState().magFilter;
3149 break;
3150 case GL_TEXTURE_MIN_FILTER:
3151 *params = texture->getSamplerState().minFilter;
3152 break;
3153 case GL_TEXTURE_WRAP_S:
3154 *params = texture->getSamplerState().wrapS;
3155 break;
3156 case GL_TEXTURE_WRAP_T:
3157 *params = texture->getSamplerState().wrapT;
3158 break;
3159 case GL_TEXTURE_WRAP_R:
3160 if (context->getClientVersion() < 3)
3161 {
Geoff Langb1196682014-07-23 13:47:29 -04003162 context->recordError(gl::Error(GL_INVALID_ENUM));
3163 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003164 }
3165 *params = texture->getSamplerState().wrapR;
3166 break;
3167 case GL_TEXTURE_IMMUTABLE_FORMAT:
3168 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3169 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3170 break;
3171 case GL_TEXTURE_IMMUTABLE_LEVELS:
3172 if (context->getClientVersion() < 3)
3173 {
Geoff Langb1196682014-07-23 13:47:29 -04003174 context->recordError(gl::Error(GL_INVALID_ENUM));
3175 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003176 }
Jamie Madill6948e302014-10-20 17:04:33 -04003177 *params = static_cast<GLint>(texture->immutableLevelCount());
Geoff Langbfdea662014-07-23 14:16:32 -04003178 break;
3179 case GL_TEXTURE_USAGE_ANGLE:
3180 *params = texture->getUsage();
3181 break;
3182 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3183 if (!context->getExtensions().textureFilterAnisotropic)
3184 {
Geoff Langb1196682014-07-23 13:47:29 -04003185 context->recordError(gl::Error(GL_INVALID_ENUM));
3186 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003187 }
3188 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3189 break;
3190 case GL_TEXTURE_SWIZZLE_R:
3191 if (context->getClientVersion() < 3)
3192 {
Geoff Langb1196682014-07-23 13:47:29 -04003193 context->recordError(gl::Error(GL_INVALID_ENUM));
3194 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003195 }
3196 *params = texture->getSamplerState().swizzleRed;
3197 break;
3198 case GL_TEXTURE_SWIZZLE_G:
3199 if (context->getClientVersion() < 3)
3200 {
Geoff Langb1196682014-07-23 13:47:29 -04003201 context->recordError(gl::Error(GL_INVALID_ENUM));
3202 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003203 }
3204 *params = texture->getSamplerState().swizzleGreen;
3205 break;
3206 case GL_TEXTURE_SWIZZLE_B:
3207 if (context->getClientVersion() < 3)
3208 {
Geoff Langb1196682014-07-23 13:47:29 -04003209 context->recordError(gl::Error(GL_INVALID_ENUM));
3210 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003211 }
3212 *params = texture->getSamplerState().swizzleBlue;
3213 break;
3214 case GL_TEXTURE_SWIZZLE_A:
3215 if (context->getClientVersion() < 3)
3216 {
Geoff Langb1196682014-07-23 13:47:29 -04003217 context->recordError(gl::Error(GL_INVALID_ENUM));
3218 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003219 }
3220 *params = texture->getSamplerState().swizzleAlpha;
3221 break;
3222 case GL_TEXTURE_BASE_LEVEL:
3223 if (context->getClientVersion() < 3)
3224 {
Geoff Langb1196682014-07-23 13:47:29 -04003225 context->recordError(gl::Error(GL_INVALID_ENUM));
3226 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003227 }
3228 *params = texture->getSamplerState().baseLevel;
3229 break;
3230 case GL_TEXTURE_MAX_LEVEL:
3231 if (context->getClientVersion() < 3)
3232 {
Geoff Langb1196682014-07-23 13:47:29 -04003233 context->recordError(gl::Error(GL_INVALID_ENUM));
3234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003235 }
3236 *params = texture->getSamplerState().maxLevel;
3237 break;
3238 case GL_TEXTURE_MIN_LOD:
3239 if (context->getClientVersion() < 3)
3240 {
Geoff Langb1196682014-07-23 13:47:29 -04003241 context->recordError(gl::Error(GL_INVALID_ENUM));
3242 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003243 }
3244 *params = (GLint)texture->getSamplerState().minLod;
3245 break;
3246 case GL_TEXTURE_MAX_LOD:
3247 if (context->getClientVersion() < 3)
3248 {
Geoff Langb1196682014-07-23 13:47:29 -04003249 context->recordError(gl::Error(GL_INVALID_ENUM));
3250 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003251 }
3252 *params = (GLint)texture->getSamplerState().maxLod;
3253 break;
Geoff Langb1196682014-07-23 13:47:29 -04003254
Geoff Langbfdea662014-07-23 14:16:32 -04003255 default:
Geoff Langb1196682014-07-23 13:47:29 -04003256 context->recordError(gl::Error(GL_INVALID_ENUM));
3257 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003258 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003259 }
3260}
3261
Kenneth Russell67ea1902014-10-06 16:44:50 -07003262void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003263{
3264 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3265 program, location, bufSize, params);
3266
Geoff Langbfdea662014-07-23 14:16:32 -04003267 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003268 if (context)
3269 {
Jamie Madill0063c512014-08-25 15:47:53 -04003270 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003271 {
Jamie Madill0063c512014-08-25 15:47:53 -04003272 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003273 }
3274
Jamie Madilla502c742014-08-28 17:19:13 -04003275 gl::Program *programObject = context->getProgram(program);
3276 ASSERT(programObject);
3277 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003278 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003279
Jamie Madill99a1e982014-08-25 15:47:54 -04003280 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003281 }
3282}
3283
Kenneth Russell67ea1902014-10-06 16:44:50 -07003284void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003285{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003286 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003287
Geoff Langbfdea662014-07-23 14:16:32 -04003288 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003289 if (context)
3290 {
Jamie Madill0063c512014-08-25 15:47:53 -04003291 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003292 {
Jamie Madill0063c512014-08-25 15:47:53 -04003293 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003294 }
Geoff Langbfdea662014-07-23 14:16:32 -04003295
Jamie Madilla502c742014-08-28 17:19:13 -04003296 gl::Program *programObject = context->getProgram(program);
3297 ASSERT(programObject);
3298 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003299 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003300
Jamie Madill99a1e982014-08-25 15:47:54 -04003301 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003302 }
3303}
3304
Kenneth Russell67ea1902014-10-06 16:44:50 -07003305void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003306{
Geoff Langbfdea662014-07-23 14:16:32 -04003307 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003308 program, location, bufSize, params);
3309
Geoff Langbfdea662014-07-23 14:16:32 -04003310 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003311 if (context)
3312 {
Jamie Madill0063c512014-08-25 15:47:53 -04003313 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003314 {
Jamie Madill0063c512014-08-25 15:47:53 -04003315 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003316 }
3317
Jamie Madilla502c742014-08-28 17:19:13 -04003318 gl::Program *programObject = context->getProgram(program);
3319 ASSERT(programObject);
3320 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003321 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003322
Jamie Madill99a1e982014-08-25 15:47:54 -04003323 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003324 }
3325}
3326
Kenneth Russell67ea1902014-10-06 16:44:50 -07003327void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003328{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003329 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003330
Geoff Langbfdea662014-07-23 14:16:32 -04003331 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003332 if (context)
3333 {
Jamie Madill0063c512014-08-25 15:47:53 -04003334 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003335 {
Jamie Madill0063c512014-08-25 15:47:53 -04003336 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003337 }
Geoff Langbfdea662014-07-23 14:16:32 -04003338
Jamie Madilla502c742014-08-28 17:19:13 -04003339 gl::Program *programObject = context->getProgram(program);
3340 ASSERT(programObject);
3341 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003342 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003343
Jamie Madill99a1e982014-08-25 15:47:54 -04003344 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003345 }
3346}
3347
Kenneth Russell67ea1902014-10-06 16:44:50 -07003348GLint GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003349{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003350 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003351
Geoff Langbfdea662014-07-23 14:16:32 -04003352 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003353 if (context)
3354 {
Geoff Langb1196682014-07-23 13:47:29 -04003355 if (strstr(name, "gl_") == name)
3356 {
3357 return -1;
3358 }
3359
Geoff Langbfdea662014-07-23 14:16:32 -04003360 gl::Program *programObject = context->getProgram(program);
3361
3362 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003363 {
Geoff Langbfdea662014-07-23 14:16:32 -04003364 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003365 {
Geoff Langb1196682014-07-23 13:47:29 -04003366 context->recordError(gl::Error(GL_INVALID_OPERATION));
3367 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003368 }
Geoff Langbfdea662014-07-23 14:16:32 -04003369 else
3370 {
Geoff Langb1196682014-07-23 13:47:29 -04003371 context->recordError(gl::Error(GL_INVALID_VALUE));
3372 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003373 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003374 }
Geoff Langbfdea662014-07-23 14:16:32 -04003375
3376 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3377 if (!programObject->isLinked() || !programBinary)
3378 {
Geoff Langb1196682014-07-23 13:47:29 -04003379 context->recordError(gl::Error(GL_INVALID_OPERATION));
3380 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003381 }
3382
3383 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003384 }
3385
3386 return -1;
3387}
3388
Kenneth Russell67ea1902014-10-06 16:44:50 -07003389void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003390{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003391 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003392
Geoff Langbfdea662014-07-23 14:16:32 -04003393 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003394 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003395 {
Geoff Langbfdea662014-07-23 14:16:32 -04003396 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003397 {
Geoff Langb1196682014-07-23 13:47:29 -04003398 context->recordError(gl::Error(GL_INVALID_VALUE));
3399 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003400 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003401
Geoff Langbfdea662014-07-23 14:16:32 -04003402 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003403 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003404 {
3405 return;
3406 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003407
Geoff Langbfdea662014-07-23 14:16:32 -04003408 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3409 {
3410 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3411 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003412 {
Geoff Langbfdea662014-07-23 14:16:32 -04003413 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003414 }
3415 }
Geoff Langbfdea662014-07-23 14:16:32 -04003416 else
3417 {
3418 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3419 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003420 }
3421}
3422
Kenneth Russell67ea1902014-10-06 16:44:50 -07003423void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003424{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003425 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003426
Geoff Langbfdea662014-07-23 14:16:32 -04003427 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003428 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003429 {
Geoff Langbfdea662014-07-23 14:16:32 -04003430 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003431 {
Geoff Langb1196682014-07-23 13:47:29 -04003432 context->recordError(gl::Error(GL_INVALID_VALUE));
3433 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003434 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003435
Geoff Langbfdea662014-07-23 14:16:32 -04003436 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003437
Geoff Langb1196682014-07-23 13:47:29 -04003438 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003439 {
3440 return;
3441 }
Jamie Madillaff71502013-07-02 11:57:05 -04003442
Geoff Langbfdea662014-07-23 14:16:32 -04003443 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3444 {
3445 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3446 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003447 {
Geoff Langbfdea662014-07-23 14:16:32 -04003448 float currentValue = currentValueData.FloatValues[i];
3449 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003450 }
3451 }
Geoff Langbfdea662014-07-23 14:16:32 -04003452 else
3453 {
3454 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3455 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456 }
3457}
3458
Kenneth Russell67ea1902014-10-06 16:44:50 -07003459void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003460{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003461 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003462
Geoff Langbfdea662014-07-23 14:16:32 -04003463 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003464 if (context)
3465 {
3466 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003467 {
Geoff Langb1196682014-07-23 13:47:29 -04003468 context->recordError(gl::Error(GL_INVALID_VALUE));
3469 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003470 }
Geoff Langbfdea662014-07-23 14:16:32 -04003471
3472 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3473 {
Geoff Langb1196682014-07-23 13:47:29 -04003474 context->recordError(gl::Error(GL_INVALID_ENUM));
3475 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003476 }
3477
3478 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003479 }
3480}
3481
Kenneth Russell67ea1902014-10-06 16:44:50 -07003482void GL_APIENTRY glHint(GLenum target, GLenum mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003483{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003484 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003485
Geoff Langbfdea662014-07-23 14:16:32 -04003486 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003487 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003488 {
Geoff Langb1196682014-07-23 13:47:29 -04003489 switch (mode)
3490 {
3491 case GL_FASTEST:
3492 case GL_NICEST:
3493 case GL_DONT_CARE:
3494 break;
3495
3496 default:
3497 context->recordError(gl::Error(GL_INVALID_ENUM));
3498 return;
3499 }
3500
3501 switch (target)
3502 {
3503 case GL_GENERATE_MIPMAP_HINT:
3504 context->getState().setGenerateMipmapHint(mode);
3505 break;
3506
3507 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3508 context->getState().setFragmentShaderDerivativeHint(mode);
3509 break;
3510
3511 default:
3512 context->recordError(gl::Error(GL_INVALID_ENUM));
3513 return;
3514 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003515 }
3516}
3517
Kenneth Russell67ea1902014-10-06 16:44:50 -07003518GLboolean GL_APIENTRY glIsBuffer(GLuint buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003519{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003520 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521
Geoff Langbfdea662014-07-23 14:16:32 -04003522 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003523 if (context && buffer)
3524 {
3525 gl::Buffer *bufferObject = context->getBuffer(buffer);
3526
3527 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003528 {
Geoff Langbfdea662014-07-23 14:16:32 -04003529 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003530 }
3531 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003532
3533 return GL_FALSE;
3534}
3535
Kenneth Russell67ea1902014-10-06 16:44:50 -07003536GLboolean GL_APIENTRY glIsEnabled(GLenum cap)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003538 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003539
Geoff Langbfdea662014-07-23 14:16:32 -04003540 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003541 if (context)
3542 {
3543 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003544 {
Geoff Langb1196682014-07-23 13:47:29 -04003545 context->recordError(gl::Error(GL_INVALID_ENUM));
3546 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003547 }
Geoff Langbfdea662014-07-23 14:16:32 -04003548
3549 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550 }
3551
3552 return false;
3553}
3554
Kenneth Russell67ea1902014-10-06 16:44:50 -07003555GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003556{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003557 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003558
Geoff Langbfdea662014-07-23 14:16:32 -04003559 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003560 if (context)
3561 {
3562 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3563
3564 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003565 {
Geoff Langbfdea662014-07-23 14:16:32 -04003566 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003567 }
Geoff Langbfdea662014-07-23 14:16:32 -04003568
3569 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003570 }
3571
3572 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003573}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003574
Kenneth Russell67ea1902014-10-06 16:44:50 -07003575GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003576{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003577 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003578
Geoff Langbfdea662014-07-23 14:16:32 -04003579 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003580 if (context && framebuffer)
3581 {
3582 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3583
3584 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585 {
Geoff Langbfdea662014-07-23 14:16:32 -04003586 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003587 }
3588 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003589
3590 return GL_FALSE;
3591}
3592
Kenneth Russell67ea1902014-10-06 16:44:50 -07003593GLboolean GL_APIENTRY glIsProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003595 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003596
Geoff Langbfdea662014-07-23 14:16:32 -04003597 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003598 if (context && program)
3599 {
3600 gl::Program *programObject = context->getProgram(program);
3601
3602 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003603 {
Geoff Langbfdea662014-07-23 14:16:32 -04003604 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003605 }
3606 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003607
3608 return GL_FALSE;
3609}
3610
Kenneth Russell67ea1902014-10-06 16:44:50 -07003611GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003612{
3613 EVENT("(GLuint id = %d)", id);
3614
Geoff Langbfdea662014-07-23 14:16:32 -04003615 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003616 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003617 {
Geoff Langbfdea662014-07-23 14:16:32 -04003618 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003619 }
3620
3621 return GL_FALSE;
3622}
3623
Kenneth Russell67ea1902014-10-06 16:44:50 -07003624GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003626 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003627
Geoff Langbfdea662014-07-23 14:16:32 -04003628 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003629 if (context && renderbuffer)
3630 {
3631 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3632
3633 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003634 {
Geoff Langbfdea662014-07-23 14:16:32 -04003635 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003636 }
3637 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003638
3639 return GL_FALSE;
3640}
3641
Kenneth Russell67ea1902014-10-06 16:44:50 -07003642GLboolean GL_APIENTRY glIsShader(GLuint shader)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003643{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003644 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645
Geoff Langbfdea662014-07-23 14:16:32 -04003646 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003647 if (context && shader)
3648 {
3649 gl::Shader *shaderObject = context->getShader(shader);
3650
3651 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003652 {
Geoff Langbfdea662014-07-23 14:16:32 -04003653 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003654 }
3655 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003656
3657 return GL_FALSE;
3658}
3659
Kenneth Russell67ea1902014-10-06 16:44:50 -07003660GLboolean GL_APIENTRY glIsTexture(GLuint texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003661{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003662 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003663
Geoff Langbfdea662014-07-23 14:16:32 -04003664 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003665 if (context && texture)
3666 {
3667 gl::Texture *textureObject = context->getTexture(texture);
3668
3669 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003670 {
Geoff Langbfdea662014-07-23 14:16:32 -04003671 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003672 }
3673 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003674
3675 return GL_FALSE;
3676}
3677
Kenneth Russell67ea1902014-10-06 16:44:50 -07003678void GL_APIENTRY glLineWidth(GLfloat width)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003679{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003680 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003681
Geoff Langbfdea662014-07-23 14:16:32 -04003682 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003683 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003684 {
Geoff Langb1196682014-07-23 13:47:29 -04003685 if (width <= 0.0f)
3686 {
3687 context->recordError(gl::Error(GL_INVALID_VALUE));
3688 return;
3689 }
3690
Geoff Langbfdea662014-07-23 14:16:32 -04003691 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003692 }
3693}
3694
Kenneth Russell67ea1902014-10-06 16:44:50 -07003695void GL_APIENTRY glLinkProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003696{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003697 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003698
Geoff Langbfdea662014-07-23 14:16:32 -04003699 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003700 if (context)
3701 {
3702 gl::Program *programObject = context->getProgram(program);
3703
3704 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003705 {
Geoff Langbfdea662014-07-23 14:16:32 -04003706 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003707 {
Geoff Langb1196682014-07-23 13:47:29 -04003708 context->recordError(gl::Error(GL_INVALID_OPERATION));
3709 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003710 }
Geoff Langbfdea662014-07-23 14:16:32 -04003711 else
3712 {
Geoff Langb1196682014-07-23 13:47:29 -04003713 context->recordError(gl::Error(GL_INVALID_VALUE));
3714 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003715 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003716 }
Geoff Langbfdea662014-07-23 14:16:32 -04003717
Geoff Langb543aff2014-09-30 14:52:54 -04003718 gl::Error error = context->linkProgram(program);
3719 if (error.isError())
3720 {
3721 context->recordError(error);
3722 return;
3723 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724 }
3725}
3726
Kenneth Russell67ea1902014-10-06 16:44:50 -07003727void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003728{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003729 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003730
Geoff Langbfdea662014-07-23 14:16:32 -04003731 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003732 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 {
Geoff Langbfdea662014-07-23 14:16:32 -04003734 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003735 {
Geoff Langbfdea662014-07-23 14:16:32 -04003736 case GL_UNPACK_ALIGNMENT:
3737 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003738 {
Geoff Langb1196682014-07-23 13:47:29 -04003739 context->recordError(gl::Error(GL_INVALID_VALUE));
3740 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003741 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003742
Geoff Langbfdea662014-07-23 14:16:32 -04003743 context->getState().setUnpackAlignment(param);
3744 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003745
Geoff Langbfdea662014-07-23 14:16:32 -04003746 case GL_PACK_ALIGNMENT:
3747 if (param != 1 && param != 2 && param != 4 && param != 8)
3748 {
Geoff Langb1196682014-07-23 13:47:29 -04003749 context->recordError(gl::Error(GL_INVALID_VALUE));
3750 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003751 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003752
Geoff Langbfdea662014-07-23 14:16:32 -04003753 context->getState().setPackAlignment(param);
3754 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003755
Geoff Langbfdea662014-07-23 14:16:32 -04003756 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3757 context->getState().setPackReverseRowOrder(param != 0);
3758 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003759
Geoff Langbfdea662014-07-23 14:16:32 -04003760 case GL_UNPACK_IMAGE_HEIGHT:
3761 case GL_UNPACK_SKIP_IMAGES:
3762 case GL_UNPACK_ROW_LENGTH:
3763 case GL_UNPACK_SKIP_ROWS:
3764 case GL_UNPACK_SKIP_PIXELS:
3765 case GL_PACK_ROW_LENGTH:
3766 case GL_PACK_SKIP_ROWS:
3767 case GL_PACK_SKIP_PIXELS:
3768 if (context->getClientVersion() < 3)
3769 {
Geoff Langb1196682014-07-23 13:47:29 -04003770 context->recordError(gl::Error(GL_INVALID_ENUM));
3771 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003772 }
Geoff Langbfdea662014-07-23 14:16:32 -04003773 UNIMPLEMENTED();
3774 break;
3775
3776 default:
Geoff Langb1196682014-07-23 13:47:29 -04003777 context->recordError(gl::Error(GL_INVALID_ENUM));
3778 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003779 }
3780 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003781}
3782
Kenneth Russell67ea1902014-10-06 16:44:50 -07003783void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003785 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003786
Geoff Langbfdea662014-07-23 14:16:32 -04003787 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003788 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003789 {
Geoff Langbfdea662014-07-23 14:16:32 -04003790 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003791 }
3792}
3793
Kenneth Russell67ea1902014-10-06 16:44:50 -07003794void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003795 GLenum format, GLenum type, GLsizei bufSize,
3796 GLvoid *data)
3797{
3798 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3799 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3800 x, y, width, height, format, type, bufSize, data);
3801
Geoff Langbfdea662014-07-23 14:16:32 -04003802 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003803 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003804 {
Geoff Langb1196682014-07-23 13:47:29 -04003805 if (width < 0 || height < 0 || bufSize < 0)
3806 {
3807 context->recordError(gl::Error(GL_INVALID_VALUE));
3808 return;
3809 }
3810
Geoff Langbfdea662014-07-23 14:16:32 -04003811 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3812 format, type, &bufSize, data))
3813 {
3814 return;
3815 }
3816
Geoff Lang63d2fc72014-07-25 14:51:41 -04003817 gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data);
3818 if (error.isError())
3819 {
3820 context->recordError(error);
3821 return;
3822 }
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003823 }
3824}
3825
Kenneth Russell67ea1902014-10-06 16:44:50 -07003826void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003827 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003829 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003830 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003831 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003832
Geoff Langbfdea662014-07-23 14:16:32 -04003833 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003834 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003835 {
Geoff Langb1196682014-07-23 13:47:29 -04003836 if (width < 0 || height < 0)
3837 {
3838 context->recordError(gl::Error(GL_INVALID_VALUE));
3839 return;
3840 }
3841
Geoff Langbfdea662014-07-23 14:16:32 -04003842 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3843 format, type, NULL, pixels))
3844 {
3845 return;
3846 }
3847
Geoff Lang63d2fc72014-07-25 14:51:41 -04003848 gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels);
3849 if (error.isError())
3850 {
3851 context->recordError(error);
3852 return;
3853 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003854 }
3855}
3856
Kenneth Russell67ea1902014-10-06 16:44:50 -07003857void GL_APIENTRY glReleaseShaderCompiler(void)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003859 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003860
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003861 gl::Context *context = gl::getNonLostContext();
3862
3863 if (context)
3864 {
3865 context->releaseShaderCompiler();
3866 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003867}
3868
Kenneth Russell67ea1902014-10-06 16:44:50 -07003869void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003870{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003871 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003872 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003873
Geoff Langbfdea662014-07-23 14:16:32 -04003874 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003875 if (context)
3876 {
3877 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3878 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003879 {
Geoff Langbfdea662014-07-23 14:16:32 -04003880 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003881 }
Geoff Langbfdea662014-07-23 14:16:32 -04003882
Shannon Woodse2632d22014-10-17 13:08:51 -04003883 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
3884 renderbuffer->setStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003885 }
3886}
3887
Kenneth Russell67ea1902014-10-06 16:44:50 -07003888void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003889{
3890 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3891}
3892
Kenneth Russell67ea1902014-10-06 16:44:50 -07003893void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003894{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003895 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003896
Geoff Langbfdea662014-07-23 14:16:32 -04003897 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003898
Geoff Langbfdea662014-07-23 14:16:32 -04003899 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003900 {
Geoff Langbfdea662014-07-23 14:16:32 -04003901 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003902 }
3903}
3904
Kenneth Russell67ea1902014-10-06 16:44:50 -07003905void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003906{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003907 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003908
Geoff Langbfdea662014-07-23 14:16:32 -04003909 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003910 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003911 {
Geoff Langb1196682014-07-23 13:47:29 -04003912 if (condition != GL_ALL_COMPLETED_NV)
3913 {
3914 context->recordError(gl::Error(GL_INVALID_ENUM));
3915 return;
3916 }
3917
Geoff Langbfdea662014-07-23 14:16:32 -04003918 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3919
3920 if (fenceObject == NULL)
3921 {
Geoff Langb1196682014-07-23 13:47:29 -04003922 context->recordError(gl::Error(GL_INVALID_OPERATION));
3923 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003924 }
3925
Geoff Lang882033e2014-09-30 11:26:07 -04003926 gl::Error error = fenceObject->setFence(condition);
3927 if (error.isError())
3928 {
3929 context->recordError(error);
3930 return;
3931 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003932 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003933}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003934
Kenneth Russell67ea1902014-10-06 16:44:50 -07003935void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003936{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003937 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 +00003938
Geoff Langbfdea662014-07-23 14:16:32 -04003939 gl::Context* context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003940 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003941 {
Geoff Langb1196682014-07-23 13:47:29 -04003942 if (width < 0 || height < 0)
3943 {
3944 context->recordError(gl::Error(GL_INVALID_VALUE));
3945 return;
3946 }
3947
Geoff Langbfdea662014-07-23 14:16:32 -04003948 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003949 }
3950}
3951
Kenneth Russell67ea1902014-10-06 16:44:50 -07003952void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003954 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003955 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003956 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003957
Geoff Lang900013c2014-07-07 11:32:19 -04003958 gl::Context* context = gl::getNonLostContext();
3959 if (context)
3960 {
3961 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3962 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3963 {
Geoff Langb1196682014-07-23 13:47:29 -04003964 context->recordError(gl::Error(GL_INVALID_ENUM));
3965 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003966 }
3967
3968 // No binary shader formats are supported.
3969 UNIMPLEMENTED();
3970 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003971}
3972
Kenneth Russell67ea1902014-10-06 16:44:50 -07003973void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003974{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003975 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 +00003976 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003977
Geoff Langbfdea662014-07-23 14:16:32 -04003978 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003979 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003980 {
Geoff Langb1196682014-07-23 13:47:29 -04003981 if (count < 0)
3982 {
3983 context->recordError(gl::Error(GL_INVALID_VALUE));
3984 return;
3985 }
3986
Geoff Langbfdea662014-07-23 14:16:32 -04003987 gl::Shader *shaderObject = context->getShader(shader);
3988
3989 if (!shaderObject)
3990 {
3991 if (context->getProgram(shader))
3992 {
Geoff Langb1196682014-07-23 13:47:29 -04003993 context->recordError(gl::Error(GL_INVALID_OPERATION));
3994 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003995 }
3996 else
3997 {
Geoff Langb1196682014-07-23 13:47:29 -04003998 context->recordError(gl::Error(GL_INVALID_VALUE));
3999 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004000 }
4001 }
4002
4003 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004004 }
4005}
4006
Kenneth Russell67ea1902014-10-06 16:44:50 -07004007void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004008{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004009 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004010}
4011
Kenneth Russell67ea1902014-10-06 16:44:50 -07004012void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004013{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004014 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 +00004015
Geoff Langbfdea662014-07-23 14:16:32 -04004016 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004017 if (context)
4018 {
Geoff Langb1196682014-07-23 13:47:29 -04004019 switch (face)
4020 {
4021 case GL_FRONT:
4022 case GL_BACK:
4023 case GL_FRONT_AND_BACK:
4024 break;
4025
4026 default:
4027 context->recordError(gl::Error(GL_INVALID_ENUM));
4028 return;
4029 }
4030
4031 switch (func)
4032 {
4033 case GL_NEVER:
4034 case GL_ALWAYS:
4035 case GL_LESS:
4036 case GL_LEQUAL:
4037 case GL_EQUAL:
4038 case GL_GEQUAL:
4039 case GL_GREATER:
4040 case GL_NOTEQUAL:
4041 break;
4042
4043 default:
4044 context->recordError(gl::Error(GL_INVALID_ENUM));
4045 return;
4046 }
4047
Geoff Langbfdea662014-07-23 14:16:32 -04004048 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4049 {
4050 context->getState().setStencilParams(func, ref, mask);
4051 }
4052
4053 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4054 {
4055 context->getState().setStencilBackParams(func, ref, mask);
4056 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004057 }
4058}
4059
Kenneth Russell67ea1902014-10-06 16:44:50 -07004060void GL_APIENTRY glStencilMask(GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004061{
4062 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4063}
4064
Kenneth Russell67ea1902014-10-06 16:44:50 -07004065void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004066{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004067 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004068
Geoff Langbfdea662014-07-23 14:16:32 -04004069 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004070 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004071 {
Geoff Langb1196682014-07-23 13:47:29 -04004072 switch (face)
4073 {
4074 case GL_FRONT:
4075 case GL_BACK:
4076 case GL_FRONT_AND_BACK:
4077 break;
4078
4079 default:
4080 context->recordError(gl::Error(GL_INVALID_ENUM));
4081 return;
4082 }
4083
Geoff Langbfdea662014-07-23 14:16:32 -04004084 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4085 {
4086 context->getState().setStencilWritemask(mask);
4087 }
4088
4089 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4090 {
4091 context->getState().setStencilBackWritemask(mask);
4092 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004093 }
4094}
4095
Kenneth Russell67ea1902014-10-06 16:44:50 -07004096void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004097{
4098 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4099}
4100
Kenneth Russell67ea1902014-10-06 16:44:50 -07004101void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004102{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004103 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 +00004104 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004105
Geoff Langbfdea662014-07-23 14:16:32 -04004106 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004107 if (context)
4108 {
Geoff Langb1196682014-07-23 13:47:29 -04004109 switch (face)
4110 {
4111 case GL_FRONT:
4112 case GL_BACK:
4113 case GL_FRONT_AND_BACK:
4114 break;
4115
4116 default:
4117 context->recordError(gl::Error(GL_INVALID_ENUM));
4118 return;
4119 }
4120
4121 switch (fail)
4122 {
4123 case GL_ZERO:
4124 case GL_KEEP:
4125 case GL_REPLACE:
4126 case GL_INCR:
4127 case GL_DECR:
4128 case GL_INVERT:
4129 case GL_INCR_WRAP:
4130 case GL_DECR_WRAP:
4131 break;
4132
4133 default:
4134 context->recordError(gl::Error(GL_INVALID_ENUM));
4135 return;
4136 }
4137
4138 switch (zfail)
4139 {
4140 case GL_ZERO:
4141 case GL_KEEP:
4142 case GL_REPLACE:
4143 case GL_INCR:
4144 case GL_DECR:
4145 case GL_INVERT:
4146 case GL_INCR_WRAP:
4147 case GL_DECR_WRAP:
4148 break;
4149
4150 default:
4151 context->recordError(gl::Error(GL_INVALID_ENUM));
4152 return;
4153 }
4154
4155 switch (zpass)
4156 {
4157 case GL_ZERO:
4158 case GL_KEEP:
4159 case GL_REPLACE:
4160 case GL_INCR:
4161 case GL_DECR:
4162 case GL_INVERT:
4163 case GL_INCR_WRAP:
4164 case GL_DECR_WRAP:
4165 break;
4166
4167 default:
4168 context->recordError(gl::Error(GL_INVALID_ENUM));
4169 return;
4170 }
4171
Geoff Langbfdea662014-07-23 14:16:32 -04004172 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4173 {
4174 context->getState().setStencilOperations(fail, zfail, zpass);
4175 }
4176
4177 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4178 {
4179 context->getState().setStencilBackOperations(fail, zfail, zpass);
4180 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004181 }
4182}
4183
Kenneth Russell67ea1902014-10-06 16:44:50 -07004184GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004185{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004186 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004187
Geoff Langbfdea662014-07-23 14:16:32 -04004188 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004189 if (context)
4190 {
4191 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4192
4193 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004194 {
Geoff Langb1196682014-07-23 13:47:29 -04004195 context->recordError(gl::Error(GL_INVALID_OPERATION));
4196 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004197 }
Geoff Langbfdea662014-07-23 14:16:32 -04004198
4199 if (fenceObject->isFence() != GL_TRUE)
4200 {
Geoff Langb1196682014-07-23 13:47:29 -04004201 context->recordError(gl::Error(GL_INVALID_OPERATION));
4202 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004203 }
4204
Geoff Lang882033e2014-09-30 11:26:07 -04004205 GLboolean result;
4206 gl::Error error = fenceObject->testFence(&result);
4207 if (error.isError())
4208 {
4209 context->recordError(error);
4210 return GL_TRUE;
4211 }
4212
4213 return result;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004214 }
Geoff Langbfdea662014-07-23 14:16:32 -04004215
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004216 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004217}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004218
Kenneth Russell67ea1902014-10-06 16:44:50 -07004219void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004220 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004221{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004222 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004223 "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 +00004224 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004225
Geoff Langbfdea662014-07-23 14:16:32 -04004226 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004227 if (context)
4228 {
4229 if (context->getClientVersion() < 3 &&
4230 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4231 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004232 {
Geoff Langbfdea662014-07-23 14:16:32 -04004233 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004234 }
Geoff Langbfdea662014-07-23 14:16:32 -04004235
4236 if (context->getClientVersion() >= 3 &&
4237 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4238 0, 0, 0, width, height, 1, border, format, type, pixels))
4239 {
4240 return;
4241 }
4242
4243 switch (target)
4244 {
4245 case GL_TEXTURE_2D:
4246 {
4247 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004248 gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4249 if (error.isError())
4250 {
4251 context->recordError(error);
4252 return;
4253 }
Geoff Langbfdea662014-07-23 14:16:32 -04004254 }
4255 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004256
Geoff Langbfdea662014-07-23 14:16:32 -04004257 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004258 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
Geoff Langbfdea662014-07-23 14:16:32 -04004259 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004260 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
Geoff Langbfdea662014-07-23 14:16:32 -04004261 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
Geoff Langbfdea662014-07-23 14:16:32 -04004262 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4263 {
4264 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang8376cea2014-09-02 11:47:07 -04004265 gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004266 if (error.isError())
4267 {
4268 context->recordError(error);
4269 return;
4270 }
Geoff Langbfdea662014-07-23 14:16:32 -04004271 }
4272 break;
Geoff Lang8376cea2014-09-02 11:47:07 -04004273
Geoff Langbfdea662014-07-23 14:16:32 -04004274 default: UNREACHABLE();
4275 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004276 }
4277}
4278
Kenneth Russell67ea1902014-10-06 16:44:50 -07004279void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004280{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004281 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4282
Geoff Langbfdea662014-07-23 14:16:32 -04004283 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004284 if (context)
4285 {
4286 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004287 {
Geoff Langbfdea662014-07-23 14:16:32 -04004288 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004289 }
Geoff Langbfdea662014-07-23 14:16:32 -04004290
4291 gl::Texture *texture = context->getTargetTexture(target);
4292
4293 if (!texture)
4294 {
Geoff Langb1196682014-07-23 13:47:29 -04004295 context->recordError(gl::Error(GL_INVALID_ENUM));
4296 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004297 }
4298
4299 switch (pname)
4300 {
4301 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4302 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4303 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4304 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4305 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4306 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4307 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4308 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4309 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4310 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4311 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4312 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4313 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4314 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4315 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4316 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4317 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4318 default: UNREACHABLE(); break;
4319 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004320 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004321}
4322
Kenneth Russell67ea1902014-10-06 16:44:50 -07004323void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004324{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004325 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004326}
4327
Kenneth Russell67ea1902014-10-06 16:44:50 -07004328void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004329{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004330 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004331
Geoff Langbfdea662014-07-23 14:16:32 -04004332 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004333 if (context)
4334 {
4335 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004336 {
Geoff Langbfdea662014-07-23 14:16:32 -04004337 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004338 }
Geoff Langbfdea662014-07-23 14:16:32 -04004339
4340 gl::Texture *texture = context->getTargetTexture(target);
4341
4342 if (!texture)
4343 {
Geoff Langb1196682014-07-23 13:47:29 -04004344 context->recordError(gl::Error(GL_INVALID_ENUM));
4345 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004346 }
4347
4348 switch (pname)
4349 {
4350 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4351 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4352 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4353 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4354 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4355 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4356 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4357 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4358 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4359 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4360 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4361 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4362 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4363 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4364 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4365 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4366 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4367 default: UNREACHABLE(); break;
4368 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004369 }
4370}
4371
Kenneth Russell67ea1902014-10-06 16:44:50 -07004372void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004373{
4374 glTexParameteri(target, pname, *params);
4375}
4376
Kenneth Russell67ea1902014-10-06 16:44:50 -07004377void GL_APIENTRY glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004378{
4379 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4380 target, levels, internalformat, width, height);
4381
Geoff Langbfdea662014-07-23 14:16:32 -04004382 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004383 if (context)
4384 {
4385 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004386 {
Geoff Langb1196682014-07-23 13:47:29 -04004387 context->recordError(gl::Error(GL_INVALID_OPERATION));
4388 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004389 }
Geoff Langbfdea662014-07-23 14:16:32 -04004390
4391 if (context->getClientVersion() < 3 &&
4392 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4393 {
4394 return;
4395 }
4396
4397 if (context->getClientVersion() >= 3 &&
4398 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4399 {
4400 return;
4401 }
4402
4403 switch (target)
4404 {
4405 case GL_TEXTURE_2D:
4406 {
4407 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004408 gl::Error error = texture2d->storage(levels, internalformat, width, height);
4409 if (error.isError())
4410 {
4411 context->recordError(error);
4412 return;
4413 }
Geoff Langbfdea662014-07-23 14:16:32 -04004414 }
4415 break;
4416
4417 case GL_TEXTURE_CUBE_MAP:
4418 {
4419 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04004420 gl::Error error = textureCube->storage(levels, internalformat, width);
4421 if (error.isError())
4422 {
4423 context->recordError(error);
4424 return;
4425 }
Geoff Langbfdea662014-07-23 14:16:32 -04004426 }
4427 break;
4428
4429 default:
Geoff Langb1196682014-07-23 13:47:29 -04004430 context->recordError(gl::Error(GL_INVALID_ENUM));
4431 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004432 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004433 }
4434}
4435
Kenneth Russell67ea1902014-10-06 16:44:50 -07004436void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004437 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004438{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004439 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004440 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004441 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004442 target, level, xoffset, yoffset, width, height, format, type, pixels);
4443
Geoff Langbfdea662014-07-23 14:16:32 -04004444 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004445 if (context)
4446 {
4447 if (context->getClientVersion() < 3 &&
4448 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4449 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004450 {
Geoff Langbfdea662014-07-23 14:16:32 -04004451 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004452 }
Geoff Langbfdea662014-07-23 14:16:32 -04004453
4454 if (context->getClientVersion() >= 3 &&
4455 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4456 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4457 {
4458 return;
4459 }
4460
4461 // Zero sized uploads are valid but no-ops
4462 if (width == 0 || height == 0)
4463 {
4464 return;
4465 }
4466
4467 switch (target)
4468 {
4469 case GL_TEXTURE_2D:
4470 {
4471 gl::Texture2D *texture = context->getTexture2D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004472 gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4473 if (error.isError())
4474 {
4475 context->recordError(error);
4476 return;
4477 }
Geoff Langbfdea662014-07-23 14:16:32 -04004478 }
4479 break;
4480
4481 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4482 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4483 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4484 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4485 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4486 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4487 {
4488 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04004489 gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4490 if (error.isError())
4491 {
4492 context->recordError(error);
4493 return;
4494 }
Geoff Langbfdea662014-07-23 14:16:32 -04004495 }
4496 break;
4497
4498 default:
4499 UNREACHABLE();
4500 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501 }
4502}
4503
Kenneth Russell67ea1902014-10-06 16:44:50 -07004504void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505{
4506 glUniform1fv(location, 1, &x);
4507}
4508
Kenneth Russell67ea1902014-10-06 16:44:50 -07004509void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004510{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004511 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004512
Geoff Langbfdea662014-07-23 14:16:32 -04004513 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004514 if (context)
4515 {
4516 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004517 {
Geoff Langbfdea662014-07-23 14:16:32 -04004518 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004519 }
Geoff Langbfdea662014-07-23 14:16:32 -04004520
4521 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4522 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523 }
4524}
4525
Kenneth Russell67ea1902014-10-06 16:44:50 -07004526void GL_APIENTRY glUniform1i(GLint location, GLint x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004527{
4528 glUniform1iv(location, 1, &x);
4529}
4530
Kenneth Russell67ea1902014-10-06 16:44:50 -07004531void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004532{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004533 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004534
Geoff Langbfdea662014-07-23 14:16:32 -04004535 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004536 if (context)
4537 {
4538 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004539 {
Geoff Langbfdea662014-07-23 14:16:32 -04004540 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004541 }
Geoff Langbfdea662014-07-23 14:16:32 -04004542
4543 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4544 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004545 }
4546}
4547
Kenneth Russell67ea1902014-10-06 16:44:50 -07004548void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004549{
4550 GLfloat xy[2] = {x, y};
4551
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004552 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004553}
4554
Kenneth Russell67ea1902014-10-06 16:44:50 -07004555void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004556{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004557 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004558
Geoff Langbfdea662014-07-23 14:16:32 -04004559 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004560 if (context)
4561 {
4562 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004563 {
Geoff Langbfdea662014-07-23 14:16:32 -04004564 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004565 }
Geoff Langbfdea662014-07-23 14:16:32 -04004566
4567 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4568 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004569 }
4570}
4571
Kenneth Russell67ea1902014-10-06 16:44:50 -07004572void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004573{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004574 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004575
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004576 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004577}
4578
Kenneth Russell67ea1902014-10-06 16:44:50 -07004579void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004580{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004581 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004582
Geoff Langbfdea662014-07-23 14:16:32 -04004583 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004584 if (context)
4585 {
4586 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004587 {
Geoff Langbfdea662014-07-23 14:16:32 -04004588 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004589 }
Geoff Langbfdea662014-07-23 14:16:32 -04004590
4591 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4592 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004593 }
4594}
4595
Kenneth Russell67ea1902014-10-06 16:44:50 -07004596void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004597{
4598 GLfloat xyz[3] = {x, y, z};
4599
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004600 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004601}
4602
Kenneth Russell67ea1902014-10-06 16:44:50 -07004603void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004604{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004605 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004606
Geoff Langbfdea662014-07-23 14:16:32 -04004607 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004608 if (context)
4609 {
4610 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004611 {
Geoff Langbfdea662014-07-23 14:16:32 -04004612 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004613 }
Geoff Langbfdea662014-07-23 14:16:32 -04004614
4615 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4616 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004617 }
4618}
4619
Kenneth Russell67ea1902014-10-06 16:44:50 -07004620void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004621{
4622 GLint xyz[3] = {x, y, z};
4623
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004624 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004625}
4626
Kenneth Russell67ea1902014-10-06 16:44:50 -07004627void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004628{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004629 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004630
Geoff Langbfdea662014-07-23 14:16:32 -04004631 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004632 if (context)
4633 {
4634 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004635 {
Geoff Langbfdea662014-07-23 14:16:32 -04004636 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004637 }
Geoff Langbfdea662014-07-23 14:16:32 -04004638
4639 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4640 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004641 }
4642}
4643
Kenneth Russell67ea1902014-10-06 16:44:50 -07004644void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004645{
4646 GLfloat xyzw[4] = {x, y, z, w};
4647
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004648 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004649}
4650
Kenneth Russell67ea1902014-10-06 16:44:50 -07004651void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004652{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004653 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004654
Geoff Langbfdea662014-07-23 14:16:32 -04004655 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004656 if (context)
4657 {
4658 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004659 {
Geoff Langbfdea662014-07-23 14:16:32 -04004660 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004661 }
Geoff Langbfdea662014-07-23 14:16:32 -04004662
4663 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4664 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004665 }
4666}
4667
Kenneth Russell67ea1902014-10-06 16:44:50 -07004668void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004669{
4670 GLint xyzw[4] = {x, y, z, w};
4671
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004672 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004673}
4674
Kenneth Russell67ea1902014-10-06 16:44:50 -07004675void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004676{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004677 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004678
Geoff Langbfdea662014-07-23 14:16:32 -04004679 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004680 if (context)
4681 {
4682 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004683 {
Geoff Langbfdea662014-07-23 14:16:32 -04004684 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004685 }
Geoff Langbfdea662014-07-23 14:16:32 -04004686
4687 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4688 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004689 }
4690}
4691
Kenneth Russell67ea1902014-10-06 16:44:50 -07004692void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004693{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004694 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004695 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004696
Geoff Langbfdea662014-07-23 14:16:32 -04004697 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004698 if (context)
4699 {
4700 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004701 {
Geoff Langbfdea662014-07-23 14:16:32 -04004702 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703 }
Geoff Langbfdea662014-07-23 14:16:32 -04004704
4705 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4706 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004707 }
4708}
4709
Kenneth Russell67ea1902014-10-06 16:44:50 -07004710void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004712 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004713 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004714
Geoff Langbfdea662014-07-23 14:16:32 -04004715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004716 if (context)
4717 {
4718 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004719 {
Geoff Langbfdea662014-07-23 14:16:32 -04004720 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721 }
Geoff Langbfdea662014-07-23 14:16:32 -04004722
4723 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4724 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004725 }
4726}
4727
Kenneth Russell67ea1902014-10-06 16:44:50 -07004728void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004729{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004730 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004731 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004732
Geoff Langbfdea662014-07-23 14:16:32 -04004733 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004734 if (context)
4735 {
4736 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004737 {
Geoff Langbfdea662014-07-23 14:16:32 -04004738 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004739 }
Geoff Langbfdea662014-07-23 14:16:32 -04004740
4741 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4742 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004743 }
4744}
4745
Kenneth Russell67ea1902014-10-06 16:44:50 -07004746void GL_APIENTRY glUseProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004747{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004748 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004749
Geoff Langbfdea662014-07-23 14:16:32 -04004750 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004751 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004752 {
Geoff Langbfdea662014-07-23 14:16:32 -04004753 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754
Geoff Langbfdea662014-07-23 14:16:32 -04004755 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004756 {
Geoff Langbfdea662014-07-23 14:16:32 -04004757 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004758 {
Geoff Langb1196682014-07-23 13:47:29 -04004759 context->recordError(gl::Error(GL_INVALID_OPERATION));
4760 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004761 }
Geoff Langbfdea662014-07-23 14:16:32 -04004762 else
4763 {
Geoff Langb1196682014-07-23 13:47:29 -04004764 context->recordError(gl::Error(GL_INVALID_VALUE));
4765 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004766 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004767 }
Geoff Langbfdea662014-07-23 14:16:32 -04004768
4769 if (program != 0 && !programObject->isLinked())
4770 {
Geoff Langb1196682014-07-23 13:47:29 -04004771 context->recordError(gl::Error(GL_INVALID_OPERATION));
4772 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004773 }
4774
4775 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004776 }
4777}
4778
Kenneth Russell67ea1902014-10-06 16:44:50 -07004779void GL_APIENTRY glValidateProgram(GLuint program)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004780{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004781 EVENT("(GLuint program = %d)", program);
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)
4785 {
4786 gl::Program *programObject = context->getProgram(program);
4787
4788 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004789 {
Geoff Langbfdea662014-07-23 14:16:32 -04004790 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004791 {
Geoff Langb1196682014-07-23 13:47:29 -04004792 context->recordError(gl::Error(GL_INVALID_OPERATION));
4793 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004794 }
Geoff Langbfdea662014-07-23 14:16:32 -04004795 else
4796 {
Geoff Langb1196682014-07-23 13:47:29 -04004797 context->recordError(gl::Error(GL_INVALID_VALUE));
4798 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004799 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004800 }
Geoff Langbfdea662014-07-23 14:16:32 -04004801
Brandon Jones43a53e22014-08-28 16:23:22 -07004802 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004803 }
4804}
4805
Kenneth Russell67ea1902014-10-06 16:44:50 -07004806void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004807{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004808 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004809
Geoff Langbfdea662014-07-23 14:16:32 -04004810 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004811 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004812 {
Geoff Langb1196682014-07-23 13:47:29 -04004813 if (index >= gl::MAX_VERTEX_ATTRIBS)
4814 {
4815 context->recordError(gl::Error(GL_INVALID_VALUE));
4816 return;
4817 }
4818
Geoff Langbfdea662014-07-23 14:16:32 -04004819 GLfloat vals[4] = { x, 0, 0, 1 };
4820 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004821 }
4822}
4823
Kenneth Russell67ea1902014-10-06 16:44:50 -07004824void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004825{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004826 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004827
Geoff Langbfdea662014-07-23 14:16:32 -04004828 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004829 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004830 {
Geoff Langb1196682014-07-23 13:47:29 -04004831 if (index >= gl::MAX_VERTEX_ATTRIBS)
4832 {
4833 context->recordError(gl::Error(GL_INVALID_VALUE));
4834 return;
4835 }
4836
Geoff Langbfdea662014-07-23 14:16:32 -04004837 GLfloat vals[4] = { values[0], 0, 0, 1 };
4838 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004839 }
4840}
4841
Kenneth Russell67ea1902014-10-06 16:44:50 -07004842void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004843{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004844 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004845
Geoff Langbfdea662014-07-23 14:16:32 -04004846 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004847 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004848 {
Geoff Langb1196682014-07-23 13:47:29 -04004849 if (index >= gl::MAX_VERTEX_ATTRIBS)
4850 {
4851 context->recordError(gl::Error(GL_INVALID_VALUE));
4852 return;
4853 }
4854
Geoff Langbfdea662014-07-23 14:16:32 -04004855 GLfloat vals[4] = { x, y, 0, 1 };
4856 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004857 }
4858}
4859
Kenneth Russell67ea1902014-10-06 16:44:50 -07004860void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004862 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004863
Geoff Langbfdea662014-07-23 14:16:32 -04004864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004865 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004866 {
Geoff Langb1196682014-07-23 13:47:29 -04004867 if (index >= gl::MAX_VERTEX_ATTRIBS)
4868 {
4869 context->recordError(gl::Error(GL_INVALID_VALUE));
4870 return;
4871 }
4872
Geoff Langbfdea662014-07-23 14:16:32 -04004873 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4874 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004875 }
4876}
4877
Kenneth Russell67ea1902014-10-06 16:44:50 -07004878void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004879{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004880 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 +00004881
Geoff Langbfdea662014-07-23 14:16:32 -04004882 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004883 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004884 {
Geoff Langb1196682014-07-23 13:47:29 -04004885 if (index >= gl::MAX_VERTEX_ATTRIBS)
4886 {
4887 context->recordError(gl::Error(GL_INVALID_VALUE));
4888 return;
4889 }
4890
Geoff Langbfdea662014-07-23 14:16:32 -04004891 GLfloat vals[4] = { x, y, z, 1 };
4892 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 }
4894}
4895
Kenneth Russell67ea1902014-10-06 16:44:50 -07004896void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004898 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004899
Geoff Langbfdea662014-07-23 14:16:32 -04004900 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004901 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004902 {
Geoff Langb1196682014-07-23 13:47:29 -04004903 if (index >= gl::MAX_VERTEX_ATTRIBS)
4904 {
4905 context->recordError(gl::Error(GL_INVALID_VALUE));
4906 return;
4907 }
4908
Geoff Langbfdea662014-07-23 14:16:32 -04004909 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4910 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004911 }
4912}
4913
Kenneth Russell67ea1902014-10-06 16:44:50 -07004914void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004916 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 +00004917
Geoff Langbfdea662014-07-23 14:16:32 -04004918 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004919 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004920 {
Geoff Langb1196682014-07-23 13:47:29 -04004921 if (index >= gl::MAX_VERTEX_ATTRIBS)
4922 {
4923 context->recordError(gl::Error(GL_INVALID_VALUE));
4924 return;
4925 }
4926
Geoff Langbfdea662014-07-23 14:16:32 -04004927 GLfloat vals[4] = { x, y, z, w };
4928 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004929 }
4930}
4931
Kenneth Russell67ea1902014-10-06 16:44:50 -07004932void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004933{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004934 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004935
Geoff Langbfdea662014-07-23 14:16:32 -04004936 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004937 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004938 {
Geoff Langb1196682014-07-23 13:47:29 -04004939 if (index >= gl::MAX_VERTEX_ATTRIBS)
4940 {
4941 context->recordError(gl::Error(GL_INVALID_VALUE));
4942 return;
4943 }
4944
Geoff Langbfdea662014-07-23 14:16:32 -04004945 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004946 }
4947}
4948
Kenneth Russell67ea1902014-10-06 16:44:50 -07004949void GL_APIENTRY glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004950{
4951 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4952
Geoff Langbfdea662014-07-23 14:16:32 -04004953 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004954 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004955 {
Geoff Langb1196682014-07-23 13:47:29 -04004956 if (index >= gl::MAX_VERTEX_ATTRIBS)
4957 {
4958 context->recordError(gl::Error(GL_INVALID_VALUE));
4959 return;
4960 }
4961
Geoff Langbfdea662014-07-23 14:16:32 -04004962 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004963 }
4964}
4965
Kenneth Russell67ea1902014-10-06 16:44:50 -07004966void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004967{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004968 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004969 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004970 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004971
Geoff Langbfdea662014-07-23 14:16:32 -04004972 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004973 if (context)
4974 {
Geoff Langb1196682014-07-23 13:47:29 -04004975 if (index >= gl::MAX_VERTEX_ATTRIBS)
4976 {
4977 context->recordError(gl::Error(GL_INVALID_VALUE));
4978 return;
4979 }
4980
4981 if (size < 1 || size > 4)
4982 {
4983 context->recordError(gl::Error(GL_INVALID_VALUE));
4984 return;
4985 }
4986
4987 switch (type)
4988 {
4989 case GL_BYTE:
4990 case GL_UNSIGNED_BYTE:
4991 case GL_SHORT:
4992 case GL_UNSIGNED_SHORT:
4993 case GL_FIXED:
4994 case GL_FLOAT:
4995 break;
4996
4997 case GL_HALF_FLOAT:
4998 case GL_INT:
4999 case GL_UNSIGNED_INT:
5000 case GL_INT_2_10_10_10_REV:
5001 case GL_UNSIGNED_INT_2_10_10_10_REV:
5002 if (context->getClientVersion() < 3)
5003 {
5004 context->recordError(gl::Error(GL_INVALID_ENUM));
5005 return;
5006 }
5007 break;
5008
5009 default:
5010 context->recordError(gl::Error(GL_INVALID_ENUM));
5011 return;
5012 }
5013
5014 if (stride < 0)
5015 {
5016 context->recordError(gl::Error(GL_INVALID_VALUE));
5017 return;
5018 }
5019
5020 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5021 {
5022 context->recordError(gl::Error(GL_INVALID_OPERATION));
5023 return;
5024 }
5025
Geoff Langbfdea662014-07-23 14:16:32 -04005026 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5027 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5028 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5029 // and the pointer argument is not NULL.
5030 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005031 {
Geoff Langb1196682014-07-23 13:47:29 -04005032 context->recordError(gl::Error(GL_INVALID_OPERATION));
5033 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005034 }
5035
Geoff Langbfdea662014-07-23 14:16:32 -04005036 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
5037 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005038 }
5039}
5040
Kenneth Russell67ea1902014-10-06 16:44:50 -07005041void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005042{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005043 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 +00005044
Geoff Langbfdea662014-07-23 14:16:32 -04005045 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005046 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005047 {
Geoff Langb1196682014-07-23 13:47:29 -04005048 if (width < 0 || height < 0)
5049 {
5050 context->recordError(gl::Error(GL_INVALID_VALUE));
5051 return;
5052 }
5053
Geoff Langbfdea662014-07-23 14:16:32 -04005054 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005055 }
5056}
5057
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005058// OpenGL ES 3.0 functions
5059
Kenneth Russell67ea1902014-10-06 16:44:50 -07005060void GL_APIENTRY glReadBuffer(GLenum mode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005061{
5062 EVENT("(GLenum mode = 0x%X)", mode);
5063
Geoff Langbfdea662014-07-23 14:16:32 -04005064 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005065 if (context)
5066 {
5067 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005068 {
Geoff Langb1196682014-07-23 13:47:29 -04005069 context->recordError(gl::Error(GL_INVALID_OPERATION));
5070 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005071 }
Geoff Langbfdea662014-07-23 14:16:32 -04005072
5073 // glReadBuffer
5074 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005075 }
5076}
5077
Kenneth Russell67ea1902014-10-06 16:44:50 -07005078void 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 +00005079{
5080 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5081 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5082
Geoff Langbfdea662014-07-23 14:16:32 -04005083 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005084 if (context)
5085 {
5086 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005087 {
Geoff Langb1196682014-07-23 13:47:29 -04005088 context->recordError(gl::Error(GL_INVALID_OPERATION));
5089 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005090 }
Geoff Langbfdea662014-07-23 14:16:32 -04005091
5092 // glDrawRangeElements
5093 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005094 }
5095}
5096
Kenneth Russell67ea1902014-10-06 16:44:50 -07005097void 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 +00005098{
5099 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5100 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5101 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5102 target, level, internalformat, width, height, depth, border, format, type, pixels);
5103
Geoff Langbfdea662014-07-23 14:16:32 -04005104 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005105 if (context)
5106 {
5107 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005108 {
Geoff Langb1196682014-07-23 13:47:29 -04005109 context->recordError(gl::Error(GL_INVALID_OPERATION));
5110 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005111 }
Geoff Langbfdea662014-07-23 14:16:32 -04005112
5113 // validateES3TexImageFormat sets the error code if there is an error
5114 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
5115 0, 0, 0, width, height, depth, border, format, type, pixels))
5116 {
5117 return;
5118 }
5119
5120 switch(target)
5121 {
5122 case GL_TEXTURE_3D:
5123 {
5124 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005125 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5126 if (error.isError())
5127 {
5128 context->recordError(error);
5129 return;
5130 }
Geoff Langbfdea662014-07-23 14:16:32 -04005131 }
5132 break;
5133
5134 case GL_TEXTURE_2D_ARRAY:
5135 {
5136 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005137 gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
5138 if (error.isError())
5139 {
5140 context->recordError(error);
5141 return;
5142 }
Geoff Langbfdea662014-07-23 14:16:32 -04005143 }
5144 break;
5145
5146 default:
Geoff Langb1196682014-07-23 13:47:29 -04005147 context->recordError(gl::Error(GL_INVALID_ENUM));
5148 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005149 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005150 }
5151}
5152
Kenneth Russell67ea1902014-10-06 16:44:50 -07005153void 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 +00005154{
5155 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5156 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5157 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5158 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5159
Geoff Langbfdea662014-07-23 14:16:32 -04005160 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005161 if (context)
5162 {
5163 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005164 {
Geoff Langb1196682014-07-23 13:47:29 -04005165 context->recordError(gl::Error(GL_INVALID_OPERATION));
5166 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005167 }
Geoff Langbfdea662014-07-23 14:16:32 -04005168
5169 // validateES3TexImageFormat sets the error code if there is an error
5170 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
5171 xoffset, yoffset, zoffset, width, height, depth, 0,
5172 format, type, pixels))
5173 {
5174 return;
5175 }
5176
5177 // Zero sized uploads are valid but no-ops
5178 if (width == 0 || height == 0 || depth == 0)
5179 {
5180 return;
5181 }
5182
5183 switch(target)
5184 {
5185 case GL_TEXTURE_3D:
5186 {
5187 gl::Texture3D *texture = context->getTexture3D();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005188 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5189 if (error.isError())
5190 {
5191 context->recordError(error);
5192 return;
5193 }
Geoff Langbfdea662014-07-23 14:16:32 -04005194 }
5195 break;
5196
5197 case GL_TEXTURE_2D_ARRAY:
5198 {
5199 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Lang1ba6b8d2014-08-28 10:57:31 -04005200 gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5201 if (error.isError())
5202 {
5203 context->recordError(error);
5204 return;
5205 }
Geoff Langbfdea662014-07-23 14:16:32 -04005206 }
5207 break;
5208
5209 default:
Geoff Langb1196682014-07-23 13:47:29 -04005210 context->recordError(gl::Error(GL_INVALID_ENUM));
5211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005212 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005213 }
5214}
5215
Kenneth Russell67ea1902014-10-06 16:44:50 -07005216void 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 +00005217{
5218 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5219 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5220 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5221
Geoff Langbfdea662014-07-23 14:16:32 -04005222 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005223 if (context)
5224 {
5225 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005226 {
Geoff Langb1196682014-07-23 13:47:29 -04005227 context->recordError(gl::Error(GL_INVALID_OPERATION));
5228 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005229 }
Geoff Langbfdea662014-07-23 14:16:32 -04005230
5231 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5232 x, y, width, height, 0))
5233 {
5234 return;
5235 }
5236
5237 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5238 gl::Texture *texture = NULL;
5239 switch (target)
5240 {
5241 case GL_TEXTURE_3D:
5242 texture = context->getTexture3D();
5243 break;
5244
5245 case GL_TEXTURE_2D_ARRAY:
5246 texture = context->getTexture2DArray();
5247 break;
5248
5249 default:
Geoff Langb1196682014-07-23 13:47:29 -04005250 context->recordError(gl::Error(GL_INVALID_ENUM));
5251 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005252 }
5253
Geoff Langef7b0162014-09-04 13:29:23 -04005254 gl::Error error = texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
5255 if (error.isError())
5256 {
5257 context->recordError(error);
5258 return;
5259 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005260 }
5261}
5262
Kenneth Russell67ea1902014-10-06 16:44:50 -07005263void 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 +00005264{
Geoff Langeef52cc2013-10-16 15:07:39 -04005265 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 +00005266 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5267 "const GLvoid* data = 0x%0.8p)",
5268 target, level, internalformat, width, height, depth, border, imageSize, data);
5269
Geoff Langbfdea662014-07-23 14:16:32 -04005270 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005271 if (context)
5272 {
5273 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005274 {
Geoff Langb1196682014-07-23 13:47:29 -04005275 context->recordError(gl::Error(GL_INVALID_OPERATION));
5276 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005277 }
Geoff Langbfdea662014-07-23 14:16:32 -04005278
Geoff Lang5d601382014-07-22 15:14:06 -04005279 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5280 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005281 {
Geoff Langb1196682014-07-23 13:47:29 -04005282 context->recordError(gl::Error(GL_INVALID_VALUE));
5283 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005284 }
5285
5286 // validateES3TexImageFormat sets the error code if there is an error
5287 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5288 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5289 {
5290 return;
5291 }
5292
5293 switch(target)
5294 {
5295 case GL_TEXTURE_3D:
5296 {
5297 gl::Texture3D *texture = context->getTexture3D();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005298 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005299 if (error.isError())
5300 {
5301 context->recordError(error);
5302 return;
5303 }
Geoff Langbfdea662014-07-23 14:16:32 -04005304 }
5305 break;
5306
5307 case GL_TEXTURE_2D_ARRAY:
5308 {
5309 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madillc751d1e2014-10-21 17:46:29 -04005310 gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005311 if (error.isError())
5312 {
5313 context->recordError(error);
5314 return;
5315 }
Geoff Langbfdea662014-07-23 14:16:32 -04005316 }
5317 break;
5318
5319 default:
Geoff Langb1196682014-07-23 13:47:29 -04005320 context->recordError(gl::Error(GL_INVALID_ENUM));
5321 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005322 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005323 }
5324}
5325
Kenneth Russell67ea1902014-10-06 16:44:50 -07005326void 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 +00005327{
5328 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5329 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5330 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5331 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5332
Geoff Langbfdea662014-07-23 14:16:32 -04005333 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005334 if (context)
5335 {
5336 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005337 {
Geoff Langb1196682014-07-23 13:47:29 -04005338 context->recordError(gl::Error(GL_INVALID_OPERATION));
5339 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005340 }
Geoff Langbfdea662014-07-23 14:16:32 -04005341
Geoff Lang5d601382014-07-22 15:14:06 -04005342 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5343 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005344 {
Geoff Langb1196682014-07-23 13:47:29 -04005345 context->recordError(gl::Error(GL_INVALID_VALUE));
5346 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005347 }
5348
5349 if (!data)
5350 {
Geoff Langb1196682014-07-23 13:47:29 -04005351 context->recordError(gl::Error(GL_INVALID_VALUE));
5352 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005353 }
5354
5355 // validateES3TexImageFormat sets the error code if there is an error
5356 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5357 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5358 {
5359 return;
5360 }
5361
5362 // Zero sized uploads are valid but no-ops
5363 if (width == 0 || height == 0)
5364 {
5365 return;
5366 }
5367
5368 switch(target)
5369 {
5370 case GL_TEXTURE_3D:
5371 {
5372 gl::Texture3D *texture = context->getTexture3D();
Geoff Langb5348332014-09-02 13:16:34 -04005373 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005374 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005375 if (error.isError())
5376 {
5377 context->recordError(error);
5378 return;
5379 }
Geoff Langbfdea662014-07-23 14:16:32 -04005380 }
5381 break;
5382
5383 case GL_TEXTURE_2D_ARRAY:
5384 {
5385 gl::Texture2DArray *texture = context->getTexture2DArray();
Geoff Langb5348332014-09-02 13:16:34 -04005386 gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
Jamie Madillc751d1e2014-10-21 17:46:29 -04005387 format, imageSize, context->getState().getUnpackState(), data);
Geoff Langb5348332014-09-02 13:16:34 -04005388 if (error.isError())
5389 {
5390 context->recordError(error);
5391 return;
5392 }
Geoff Langbfdea662014-07-23 14:16:32 -04005393 }
5394 break;
5395
Geoff Langb1196682014-07-23 13:47:29 -04005396 default:
5397 context->recordError(gl::Error(GL_INVALID_ENUM));
5398 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005399 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005400 }
5401}
5402
Kenneth Russell67ea1902014-10-06 16:44:50 -07005403void GL_APIENTRY glGenQueries(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005404{
5405 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5406
Geoff Langbfdea662014-07-23 14:16:32 -04005407 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005408 if (context)
5409 {
5410 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005411 {
Geoff Langb1196682014-07-23 13:47:29 -04005412 context->recordError(gl::Error(GL_INVALID_OPERATION));
5413 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005414 }
Geoff Langbfdea662014-07-23 14:16:32 -04005415
5416 if (n < 0)
5417 {
Geoff Langb1196682014-07-23 13:47:29 -04005418 context->recordError(gl::Error(GL_INVALID_VALUE));
5419 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005420 }
5421
5422 for (GLsizei i = 0; i < n; i++)
5423 {
5424 ids[i] = context->createQuery();
5425 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005426 }
5427}
5428
Kenneth Russell67ea1902014-10-06 16:44:50 -07005429void GL_APIENTRY glDeleteQueries(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005430{
5431 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5432
Geoff Langbfdea662014-07-23 14:16:32 -04005433 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005434 if (context)
5435 {
5436 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005437 {
Geoff Langb1196682014-07-23 13:47:29 -04005438 context->recordError(gl::Error(GL_INVALID_OPERATION));
5439 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005440 }
Geoff Langbfdea662014-07-23 14:16:32 -04005441
5442 if (n < 0)
5443 {
Geoff Langb1196682014-07-23 13:47:29 -04005444 context->recordError(gl::Error(GL_INVALID_VALUE));
5445 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005446 }
5447
5448 for (GLsizei i = 0; i < n; i++)
5449 {
5450 context->deleteQuery(ids[i]);
5451 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005452 }
5453}
5454
Kenneth Russell67ea1902014-10-06 16:44:50 -07005455GLboolean GL_APIENTRY glIsQuery(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005456{
5457 EVENT("(GLuint id = %u)", id);
5458
Geoff Langbfdea662014-07-23 14:16:32 -04005459 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005460 if (context)
5461 {
5462 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005463 {
Geoff Langb1196682014-07-23 13:47:29 -04005464 context->recordError(gl::Error(GL_INVALID_OPERATION));
5465 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005466 }
Geoff Langbfdea662014-07-23 14:16:32 -04005467
5468 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005469 }
5470
5471 return GL_FALSE;
5472}
5473
Kenneth Russell67ea1902014-10-06 16:44:50 -07005474void GL_APIENTRY glBeginQuery(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005475{
5476 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
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 (!ValidateBeginQuery(context, target, id))
5488 {
5489 return;
5490 }
Geoff Lang5aad9672014-09-08 11:10:42 -04005491
5492 gl::Error error = context->beginQuery(target, id);
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 glEndQuery(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005502{
5503 EVENT("(GLenum target = 0x%X)", target);
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 (!ValidateEndQuery(context, target))
5515 {
5516 return;
5517 }
5518
Geoff Lang5aad9672014-09-08 11:10:42 -04005519 gl::Error error = context->endQuery(target);
5520 if (error.isError())
5521 {
5522 context->recordError(error);
5523 return;
5524 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005525 }
5526}
5527
Kenneth Russell67ea1902014-10-06 16:44:50 -07005528void GL_APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005529{
5530 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5531
Geoff Langbfdea662014-07-23 14:16:32 -04005532 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005533 if (context)
5534 {
5535 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005536 {
Geoff Langb1196682014-07-23 13:47:29 -04005537 context->recordError(gl::Error(GL_INVALID_OPERATION));
5538 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005539 }
Geoff Langbfdea662014-07-23 14:16:32 -04005540
5541 if (!ValidQueryType(context, target))
5542 {
Geoff Langb1196682014-07-23 13:47:29 -04005543 context->recordError(gl::Error(GL_INVALID_ENUM));
5544 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005545 }
5546
5547 switch (pname)
5548 {
5549 case GL_CURRENT_QUERY:
5550 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5551 break;
5552
5553 default:
Geoff Langb1196682014-07-23 13:47:29 -04005554 context->recordError(gl::Error(GL_INVALID_ENUM));
5555 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005556 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005557 }
5558}
5559
Kenneth Russell67ea1902014-10-06 16:44:50 -07005560void GL_APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005561{
5562 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5563
Geoff Langbfdea662014-07-23 14:16:32 -04005564 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005565 if (context)
5566 {
5567 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005568 {
Geoff Langb1196682014-07-23 13:47:29 -04005569 context->recordError(gl::Error(GL_INVALID_OPERATION));
5570 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005571 }
Geoff Langbfdea662014-07-23 14:16:32 -04005572
5573 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5574
5575 if (!queryObject)
5576 {
Geoff Langb1196682014-07-23 13:47:29 -04005577 context->recordError(gl::Error(GL_INVALID_OPERATION));
5578 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005579 }
5580
5581 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5582 {
Geoff Langb1196682014-07-23 13:47:29 -04005583 context->recordError(gl::Error(GL_INVALID_OPERATION));
5584 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005585 }
5586
5587 switch(pname)
5588 {
Geoff Lang5aad9672014-09-08 11:10:42 -04005589 case GL_QUERY_RESULT_EXT:
5590 {
5591 gl::Error error = queryObject->getResult(params);
5592 if (error.isError())
5593 {
5594 context->recordError(error);
5595 return;
5596 }
5597 }
Geoff Langbfdea662014-07-23 14:16:32 -04005598 break;
Geoff Langb1196682014-07-23 13:47:29 -04005599
Geoff Lang5aad9672014-09-08 11:10:42 -04005600 case GL_QUERY_RESULT_AVAILABLE_EXT:
5601 {
5602 gl::Error error = queryObject->isResultAvailable(params);
5603 if (error.isError())
5604 {
5605 context->recordError(error);
5606 return;
5607 }
5608 }
Geoff Langbfdea662014-07-23 14:16:32 -04005609 break;
Geoff Langb1196682014-07-23 13:47:29 -04005610
Geoff Langbfdea662014-07-23 14:16:32 -04005611 default:
Geoff Langb1196682014-07-23 13:47:29 -04005612 context->recordError(gl::Error(GL_INVALID_ENUM));
5613 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005614 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005615 }
5616}
5617
Kenneth Russell67ea1902014-10-06 16:44:50 -07005618GLboolean GL_APIENTRY glUnmapBuffer(GLenum target)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005619{
5620 EVENT("(GLenum target = 0x%X)", target);
5621
Geoff Langbfdea662014-07-23 14:16:32 -04005622 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005623 if (context)
5624 {
5625 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005626 {
Geoff Langb1196682014-07-23 13:47:29 -04005627 context->recordError(gl::Error(GL_INVALID_OPERATION));
5628 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005629 }
Geoff Langbfdea662014-07-23 14:16:32 -04005630
5631 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005632 }
5633
5634 return GL_FALSE;
5635}
5636
Kenneth Russell67ea1902014-10-06 16:44:50 -07005637void GL_APIENTRY glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005638{
5639 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5640
Geoff Langbfdea662014-07-23 14:16:32 -04005641 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005642 if (context)
5643 {
5644 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005645 {
Geoff Langb1196682014-07-23 13:47:29 -04005646 context->recordError(gl::Error(GL_INVALID_OPERATION));
5647 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005648 }
Geoff Langbfdea662014-07-23 14:16:32 -04005649
5650 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005651 }
5652}
5653
Kenneth Russell67ea1902014-10-06 16:44:50 -07005654void GL_APIENTRY glDrawBuffers(GLsizei n, const GLenum* bufs)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005655{
Geoff Langbfdea662014-07-23 14:16:32 -04005656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005657 if (context)
5658 {
5659 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005660 {
Geoff Langb1196682014-07-23 13:47:29 -04005661 context->recordError(gl::Error(GL_INVALID_OPERATION));
5662 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005663 }
Geoff Langbfdea662014-07-23 14:16:32 -04005664
5665 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005666 }
5667}
5668
Kenneth Russell67ea1902014-10-06 16:44:50 -07005669void GL_APIENTRY glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005670{
5671 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5672 location, count, transpose, value);
5673
Geoff Langbfdea662014-07-23 14:16:32 -04005674 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005675 if (context)
5676 {
5677 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005678 {
Geoff Langbfdea662014-07-23 14:16:32 -04005679 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005680 }
Geoff Langbfdea662014-07-23 14:16:32 -04005681
5682 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5683 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005684 }
5685}
5686
Kenneth Russell67ea1902014-10-06 16:44:50 -07005687void GL_APIENTRY glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005688{
5689 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5690 location, count, transpose, value);
5691
Geoff Langbfdea662014-07-23 14:16:32 -04005692 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005693 if (context)
5694 {
5695 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005696 {
Geoff Langbfdea662014-07-23 14:16:32 -04005697 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005698 }
Geoff Langbfdea662014-07-23 14:16:32 -04005699
5700 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5701 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005702 }
5703}
5704
Kenneth Russell67ea1902014-10-06 16:44:50 -07005705void GL_APIENTRY glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005706{
5707 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5708 location, count, transpose, value);
5709
Geoff Langbfdea662014-07-23 14:16:32 -04005710 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005711 if (context)
5712 {
5713 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005714 {
Geoff Langbfdea662014-07-23 14:16:32 -04005715 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005716 }
Geoff Langbfdea662014-07-23 14:16:32 -04005717
5718 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5719 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005720 }
5721}
5722
Kenneth Russell67ea1902014-10-06 16:44:50 -07005723void GL_APIENTRY glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005724{
5725 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5726 location, count, transpose, value);
5727
Geoff Langbfdea662014-07-23 14:16:32 -04005728 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005729 if (context)
5730 {
5731 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005732 {
Geoff Langbfdea662014-07-23 14:16:32 -04005733 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005734 }
Geoff Langbfdea662014-07-23 14:16:32 -04005735
5736 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5737 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005738 }
5739}
5740
Kenneth Russell67ea1902014-10-06 16:44:50 -07005741void GL_APIENTRY glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005742{
5743 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5744 location, count, transpose, value);
5745
Geoff Langbfdea662014-07-23 14:16:32 -04005746 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005747 if (context)
5748 {
5749 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005750 {
Geoff Langbfdea662014-07-23 14:16:32 -04005751 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005752 }
Geoff Langbfdea662014-07-23 14:16:32 -04005753
5754 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5755 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005756 }
5757}
5758
Kenneth Russell67ea1902014-10-06 16:44:50 -07005759void GL_APIENTRY glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005760{
5761 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5762 location, count, transpose, value);
5763
Geoff Langbfdea662014-07-23 14:16:32 -04005764 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005765 if (context)
5766 {
5767 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005768 {
Geoff Langbfdea662014-07-23 14:16:32 -04005769 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005770 }
Geoff Langbfdea662014-07-23 14:16:32 -04005771
5772 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5773 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005774 }
5775}
5776
Kenneth Russell67ea1902014-10-06 16:44:50 -07005777void 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 +00005778{
5779 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5780 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5781 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5782
Geoff Langbfdea662014-07-23 14:16:32 -04005783 gl::Context *context = gl::getNonLostContext();
5784 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005785 {
Geoff Langbfdea662014-07-23 14:16:32 -04005786 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005787 {
Geoff Langb1196682014-07-23 13:47:29 -04005788 context->recordError(gl::Error(GL_INVALID_OPERATION));
5789 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005790 }
Geoff Langbfdea662014-07-23 14:16:32 -04005791
5792 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5793 dstX0, dstY0, dstX1, dstY1, mask, filter,
5794 false))
5795 {
5796 return;
5797 }
5798
Geoff Lang64839152014-08-26 16:23:25 -04005799 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5800 mask, filter);
5801 if (error.isError())
5802 {
5803 context->recordError(error);
5804 return;
5805 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005806 }
5807}
5808
Kenneth Russell67ea1902014-10-06 16:44:50 -07005809void GL_APIENTRY glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005810{
5811 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5812 target, samples, internalformat, width, height);
5813
Geoff Langbfdea662014-07-23 14:16:32 -04005814 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005815 if (context)
5816 {
5817 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005818 {
Geoff Langb1196682014-07-23 13:47:29 -04005819 context->recordError(gl::Error(GL_INVALID_OPERATION));
5820 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005821 }
Geoff Langbfdea662014-07-23 14:16:32 -04005822
5823 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5824 width, height, false))
5825 {
5826 return;
5827 }
5828
Shannon Woodse2632d22014-10-17 13:08:51 -04005829 gl::Renderbuffer *renderbuffer = context->getState().getCurrentRenderbuffer();
5830 renderbuffer->setStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005831 }
5832}
5833
Kenneth Russell67ea1902014-10-06 16:44:50 -07005834void GL_APIENTRY glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005835{
5836 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5837 target, attachment, texture, level, layer);
5838
Geoff Langbfdea662014-07-23 14:16:32 -04005839 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005840 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005841 {
Geoff Langbfdea662014-07-23 14:16:32 -04005842 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5843 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005844 {
Geoff Langbfdea662014-07-23 14:16:32 -04005845 return;
5846 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005847
Geoff Langbfdea662014-07-23 14:16:32 -04005848 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5849 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005850
Geoff Langbfdea662014-07-23 14:16:32 -04005851 gl::Texture *textureObject = context->getTexture(texture);
5852 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005853
Geoff Langbfdea662014-07-23 14:16:32 -04005854 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5855 {
5856 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5857 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5858 }
5859 else
5860 {
5861 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005862 {
Geoff Langbfdea662014-07-23 14:16:32 -04005863 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5864 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5865 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005866 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005867 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005868 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005869}
5870
Kenneth Russell67ea1902014-10-06 16:44:50 -07005871GLvoid* GL_APIENTRY glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005872{
5873 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5874 target, offset, length, access);
5875
Geoff Langbfdea662014-07-23 14:16:32 -04005876 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005877 if (context)
5878 {
5879 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005880 {
Geoff Langb1196682014-07-23 13:47:29 -04005881 context->recordError(gl::Error(GL_INVALID_OPERATION));
5882 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005883 }
Geoff Langbfdea662014-07-23 14:16:32 -04005884
5885 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005886 }
5887
5888 return NULL;
5889}
5890
Kenneth Russell67ea1902014-10-06 16:44:50 -07005891void GL_APIENTRY glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005892{
5893 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5894
Geoff Langbfdea662014-07-23 14:16:32 -04005895 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005896 if (context)
5897 {
5898 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005899 {
Geoff Langb1196682014-07-23 13:47:29 -04005900 context->recordError(gl::Error(GL_INVALID_OPERATION));
5901 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005902 }
Geoff Langbfdea662014-07-23 14:16:32 -04005903
5904 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005905 }
5906}
5907
Kenneth Russell67ea1902014-10-06 16:44:50 -07005908void GL_APIENTRY glBindVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005909{
5910 EVENT("(GLuint array = %u)", array);
5911
Geoff Langbfdea662014-07-23 14:16:32 -04005912 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005913 if (context)
5914 {
5915 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005916 {
Geoff Langb1196682014-07-23 13:47:29 -04005917 context->recordError(gl::Error(GL_INVALID_OPERATION));
5918 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005919 }
Geoff Langbfdea662014-07-23 14:16:32 -04005920
5921 gl::VertexArray *vao = context->getVertexArray(array);
5922
5923 if (!vao)
5924 {
5925 // The default VAO should always exist
5926 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005927 context->recordError(gl::Error(GL_INVALID_OPERATION));
5928 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005929 }
5930
5931 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005932 }
5933}
5934
Kenneth Russell67ea1902014-10-06 16:44:50 -07005935void GL_APIENTRY glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005936{
5937 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5938
Geoff Langbfdea662014-07-23 14:16:32 -04005939 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005940 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005941 {
Geoff Langbfdea662014-07-23 14:16:32 -04005942 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005943 {
Geoff Langb1196682014-07-23 13:47:29 -04005944 context->recordError(gl::Error(GL_INVALID_OPERATION));
5945 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005946 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005947
Geoff Langbfdea662014-07-23 14:16:32 -04005948 if (n < 0)
5949 {
Geoff Langb1196682014-07-23 13:47:29 -04005950 context->recordError(gl::Error(GL_INVALID_VALUE));
5951 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005952 }
Jamie Madilld1028542013-07-02 11:57:04 -04005953
Geoff Langbfdea662014-07-23 14:16:32 -04005954 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5955 {
5956 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005957 {
Geoff Langbfdea662014-07-23 14:16:32 -04005958 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005959 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005960 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005961 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005962}
5963
Kenneth Russell67ea1902014-10-06 16:44:50 -07005964void GL_APIENTRY glGenVertexArrays(GLsizei n, GLuint* arrays)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005965{
5966 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5967
Geoff Langbfdea662014-07-23 14:16:32 -04005968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005969 if (context)
5970 {
5971 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005972 {
Geoff Langb1196682014-07-23 13:47:29 -04005973 context->recordError(gl::Error(GL_INVALID_OPERATION));
5974 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005975 }
Geoff Langbfdea662014-07-23 14:16:32 -04005976
5977 if (n < 0)
5978 {
Geoff Langb1196682014-07-23 13:47:29 -04005979 context->recordError(gl::Error(GL_INVALID_VALUE));
5980 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005981 }
5982
5983 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5984 {
5985 arrays[arrayIndex] = context->createVertexArray();
5986 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005987 }
5988}
5989
Kenneth Russell67ea1902014-10-06 16:44:50 -07005990GLboolean GL_APIENTRY glIsVertexArray(GLuint array)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005991{
5992 EVENT("(GLuint array = %u)", array);
5993
Geoff Langbfdea662014-07-23 14:16:32 -04005994 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005995 if (context)
5996 {
5997 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005998 {
Geoff Langb1196682014-07-23 13:47:29 -04005999 context->recordError(gl::Error(GL_INVALID_OPERATION));
6000 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006001 }
Geoff Langbfdea662014-07-23 14:16:32 -04006002
6003 if (array == 0)
6004 {
6005 return GL_FALSE;
6006 }
6007
6008 gl::VertexArray *vao = context->getVertexArray(array);
6009
6010 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006011 }
6012
6013 return GL_FALSE;
6014}
6015
Kenneth Russell67ea1902014-10-06 16:44:50 -07006016void GL_APIENTRY glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006017{
6018 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6019 target, index, data);
6020
Geoff Langbfdea662014-07-23 14:16:32 -04006021 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006022 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006023 {
Geoff Langbfdea662014-07-23 14:16:32 -04006024 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006025 {
Geoff Langb1196682014-07-23 13:47:29 -04006026 context->recordError(gl::Error(GL_INVALID_OPERATION));
6027 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006028 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006029
Geoff Lang3a61c322014-07-10 13:01:54 -04006030 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006031 switch (target)
6032 {
6033 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6034 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6035 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04006036 if (index >= caps.maxTransformFeedbackSeparateAttributes)
6037 {
Geoff Langb1196682014-07-23 13:47:29 -04006038 context->recordError(gl::Error(GL_INVALID_VALUE));
6039 return;
Geoff Lang05881a02014-07-10 14:05:30 -04006040 }
Geoff Langbfdea662014-07-23 14:16:32 -04006041 break;
Geoff Langb1196682014-07-23 13:47:29 -04006042
Geoff Langbfdea662014-07-23 14:16:32 -04006043 case GL_UNIFORM_BUFFER_START:
6044 case GL_UNIFORM_BUFFER_SIZE:
6045 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04006046 if (index >= caps.maxCombinedUniformBlocks)
6047 {
Geoff Langb1196682014-07-23 13:47:29 -04006048 context->recordError(gl::Error(GL_INVALID_VALUE));
6049 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04006050 }
Geoff Langbfdea662014-07-23 14:16:32 -04006051 break;
Geoff Langb1196682014-07-23 13:47:29 -04006052
Geoff Langbfdea662014-07-23 14:16:32 -04006053 default:
Geoff Langb1196682014-07-23 13:47:29 -04006054 context->recordError(gl::Error(GL_INVALID_ENUM));
6055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006056 }
6057
6058 if (!(context->getIndexedIntegerv(target, index, data)))
6059 {
6060 GLenum nativeType;
6061 unsigned int numParams = 0;
6062 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04006063 {
6064 context->recordError(gl::Error(GL_INVALID_ENUM));
6065 return;
6066 }
Shannon Woods15934d52013-08-19 14:28:49 -04006067
Geoff Langbfdea662014-07-23 14:16:32 -04006068 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04006069 {
Geoff Langbfdea662014-07-23 14:16:32 -04006070 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04006071 }
Geoff Langbfdea662014-07-23 14:16:32 -04006072
6073 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04006074 {
Geoff Langbfdea662014-07-23 14:16:32 -04006075 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6076 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6077 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04006078
Geoff Langbfdea662014-07-23 14:16:32 -04006079 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04006080
Geoff Langbfdea662014-07-23 14:16:32 -04006081 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04006082 {
Geoff Langbfdea662014-07-23 14:16:32 -04006083 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6084 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04006085 }
Geoff Langbfdea662014-07-23 14:16:32 -04006086
6087 delete [] int64Params;
6088 }
6089 else
6090 {
6091 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04006092 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006093 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006094 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006095}
6096
Kenneth Russell67ea1902014-10-06 16:44:50 -07006097void GL_APIENTRY glBeginTransformFeedback(GLenum primitiveMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006098{
6099 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6100
Geoff Langbfdea662014-07-23 14:16:32 -04006101 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006102 if (context)
6103 {
6104 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006105 {
Geoff Langb1196682014-07-23 13:47:29 -04006106 context->recordError(gl::Error(GL_INVALID_OPERATION));
6107 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006108 }
Geoff Langbfdea662014-07-23 14:16:32 -04006109
6110 switch (primitiveMode)
6111 {
6112 case GL_TRIANGLES:
6113 case GL_LINES:
6114 case GL_POINTS:
6115 break;
Geoff Langb1196682014-07-23 13:47:29 -04006116
Geoff Langbfdea662014-07-23 14:16:32 -04006117 default:
Geoff Langb1196682014-07-23 13:47:29 -04006118 context->recordError(gl::Error(GL_INVALID_ENUM));
6119 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006120 }
6121
6122 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6123 ASSERT(transformFeedback != NULL);
6124
6125 if (transformFeedback->isStarted())
6126 {
Geoff Langb1196682014-07-23 13:47:29 -04006127 context->recordError(gl::Error(GL_INVALID_OPERATION));
6128 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006129 }
6130
6131 if (transformFeedback->isPaused())
6132 {
6133 transformFeedback->resume();
6134 }
6135 else
6136 {
6137 transformFeedback->start(primitiveMode);
6138 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006139 }
6140}
6141
Kenneth Russell67ea1902014-10-06 16:44:50 -07006142void GL_APIENTRY glEndTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006143{
6144 EVENT("(void)");
6145
Geoff Langbfdea662014-07-23 14:16:32 -04006146 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006147 if (context)
6148 {
6149 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006150 {
Geoff Langb1196682014-07-23 13:47:29 -04006151 context->recordError(gl::Error(GL_INVALID_OPERATION));
6152 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006153 }
Geoff Langbfdea662014-07-23 14:16:32 -04006154
6155 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
6156 ASSERT(transformFeedback != NULL);
6157
6158 if (!transformFeedback->isStarted())
6159 {
Geoff Langb1196682014-07-23 13:47:29 -04006160 context->recordError(gl::Error(GL_INVALID_OPERATION));
6161 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006162 }
6163
6164 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006165 }
6166}
6167
Kenneth Russell67ea1902014-10-06 16:44:50 -07006168void GL_APIENTRY glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006169{
6170 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
6171 target, index, buffer, offset, size);
6172
Geoff Langbfdea662014-07-23 14:16:32 -04006173 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006174 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006175 {
Geoff Langbfdea662014-07-23 14:16:32 -04006176 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006177 {
Geoff Langb1196682014-07-23 13:47:29 -04006178 context->recordError(gl::Error(GL_INVALID_OPERATION));
6179 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006180 }
6181
Geoff Lang3a61c322014-07-10 13:01:54 -04006182 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006183 switch (target)
6184 {
6185 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006186 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006187 {
Geoff Langb1196682014-07-23 13:47:29 -04006188 context->recordError(gl::Error(GL_INVALID_VALUE));
6189 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006190 }
Geoff Langbfdea662014-07-23 14:16:32 -04006191 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006192
Geoff Langbfdea662014-07-23 14:16:32 -04006193 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006194 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006195 {
Geoff Langb1196682014-07-23 13:47:29 -04006196 context->recordError(gl::Error(GL_INVALID_VALUE));
6197 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006198 }
Geoff Langbfdea662014-07-23 14:16:32 -04006199 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006200
Geoff Langbfdea662014-07-23 14:16:32 -04006201 default:
Geoff Langb1196682014-07-23 13:47:29 -04006202 context->recordError(gl::Error(GL_INVALID_ENUM));
6203 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006204 }
6205
6206 if (buffer != 0 && size <= 0)
6207 {
Geoff Langb1196682014-07-23 13:47:29 -04006208 context->recordError(gl::Error(GL_INVALID_VALUE));
6209 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006210 }
6211
6212 switch (target)
6213 {
6214 case GL_TRANSFORM_FEEDBACK_BUFFER:
6215
6216 // size and offset must be a multiple of 4
6217 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006218 {
Geoff Langb1196682014-07-23 13:47:29 -04006219 context->recordError(gl::Error(GL_INVALID_VALUE));
6220 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006221 }
6222
Geoff Langbfdea662014-07-23 14:16:32 -04006223 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
6224 context->bindGenericTransformFeedbackBuffer(buffer);
6225 break;
6226
6227 case GL_UNIFORM_BUFFER:
6228
6229 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04006230 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006231 {
Geoff Langb1196682014-07-23 13:47:29 -04006232 context->recordError(gl::Error(GL_INVALID_VALUE));
6233 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006234 }
Geoff Langbfdea662014-07-23 14:16:32 -04006235
6236 context->bindIndexedUniformBuffer(buffer, index, offset, size);
6237 context->bindGenericUniformBuffer(buffer);
6238 break;
6239
6240 default:
6241 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006242 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006243 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006244}
6245
Kenneth Russell67ea1902014-10-06 16:44:50 -07006246void GL_APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006247{
6248 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6249 target, index, buffer);
6250
Geoff Langbfdea662014-07-23 14:16:32 -04006251 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006252 if (context)
6253 {
6254 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006255 {
Geoff Langb1196682014-07-23 13:47:29 -04006256 context->recordError(gl::Error(GL_INVALID_OPERATION));
6257 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006258 }
Geoff Langbfdea662014-07-23 14:16:32 -04006259
Geoff Lang3a61c322014-07-10 13:01:54 -04006260 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006261 switch (target)
6262 {
6263 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006264 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006265 {
Geoff Langb1196682014-07-23 13:47:29 -04006266 context->recordError(gl::Error(GL_INVALID_VALUE));
6267 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006268 }
6269 break;
6270
6271 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006272 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006273 {
Geoff Langb1196682014-07-23 13:47:29 -04006274 context->recordError(gl::Error(GL_INVALID_VALUE));
6275 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006276 }
6277 break;
6278
6279 default:
Geoff Langb1196682014-07-23 13:47:29 -04006280 context->recordError(gl::Error(GL_INVALID_ENUM));
6281 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006282 }
6283
6284 switch (target)
6285 {
6286 case GL_TRANSFORM_FEEDBACK_BUFFER:
6287 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6288 context->bindGenericTransformFeedbackBuffer(buffer);
6289 break;
6290
6291 case GL_UNIFORM_BUFFER:
6292 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6293 context->bindGenericUniformBuffer(buffer);
6294 break;
6295
6296 default:
6297 UNREACHABLE();
6298 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006299 }
6300}
6301
Kenneth Russell67ea1902014-10-06 16:44:50 -07006302void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006303{
6304 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6305 program, count, varyings, bufferMode);
6306
Geoff Langbfdea662014-07-23 14:16:32 -04006307 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006308 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006309 {
Geoff Langbfdea662014-07-23 14:16:32 -04006310 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006311 {
Geoff Langb1196682014-07-23 13:47:29 -04006312 context->recordError(gl::Error(GL_INVALID_OPERATION));
6313 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006314 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006315
Geoff Langbfdea662014-07-23 14:16:32 -04006316 if (count < 0)
6317 {
Geoff Langb1196682014-07-23 13:47:29 -04006318 context->recordError(gl::Error(GL_INVALID_VALUE));
6319 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006320 }
6321
Geoff Lang05881a02014-07-10 14:05:30 -04006322 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006323 switch (bufferMode)
6324 {
6325 case GL_INTERLEAVED_ATTRIBS:
6326 break;
6327 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006328 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006329 {
Geoff Langb1196682014-07-23 13:47:29 -04006330 context->recordError(gl::Error(GL_INVALID_VALUE));
6331 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006332 }
Geoff Langbfdea662014-07-23 14:16:32 -04006333 break;
6334 default:
Geoff Langb1196682014-07-23 13:47:29 -04006335 context->recordError(gl::Error(GL_INVALID_ENUM));
6336 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006337 }
Geoff Langbfdea662014-07-23 14:16:32 -04006338
6339 if (!gl::ValidProgram(context, program))
6340 {
6341 return;
6342 }
6343
6344 gl::Program *programObject = context->getProgram(program);
6345 ASSERT(programObject);
6346
6347 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006348 }
6349}
6350
Kenneth Russell67ea1902014-10-06 16:44:50 -07006351void 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 +00006352{
6353 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6354 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6355 program, index, bufSize, length, size, type, name);
6356
Geoff Langbfdea662014-07-23 14:16:32 -04006357 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006358 if (context)
6359 {
6360 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006361 {
Geoff Langb1196682014-07-23 13:47:29 -04006362 context->recordError(gl::Error(GL_INVALID_OPERATION));
6363 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006364 }
Geoff Langbfdea662014-07-23 14:16:32 -04006365
6366 if (bufSize < 0)
6367 {
Geoff Langb1196682014-07-23 13:47:29 -04006368 context->recordError(gl::Error(GL_INVALID_VALUE));
6369 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006370 }
6371
6372 if (!gl::ValidProgram(context, program))
6373 {
6374 return;
6375 }
6376
6377 gl::Program *programObject = context->getProgram(program);
6378 ASSERT(programObject);
6379
6380 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6381 {
Geoff Langb1196682014-07-23 13:47:29 -04006382 context->recordError(gl::Error(GL_INVALID_VALUE));
6383 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006384 }
6385
6386 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006387 }
6388}
6389
Kenneth Russell67ea1902014-10-06 16:44:50 -07006390void 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 +00006391{
6392 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6393 index, size, type, stride, pointer);
6394
Geoff Langbfdea662014-07-23 14:16:32 -04006395 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006396 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006397 {
Geoff Langbfdea662014-07-23 14:16:32 -04006398 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006399 {
Geoff Langb1196682014-07-23 13:47:29 -04006400 context->recordError(gl::Error(GL_INVALID_OPERATION));
6401 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006402 }
6403
Geoff Langb1196682014-07-23 13:47:29 -04006404 if (index >= gl::MAX_VERTEX_ATTRIBS)
6405 {
6406 context->recordError(gl::Error(GL_INVALID_VALUE));
6407 return;
6408 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006409
Geoff Langb1196682014-07-23 13:47:29 -04006410 if (size < 1 || size > 4)
6411 {
6412 context->recordError(gl::Error(GL_INVALID_VALUE));
6413 return;
6414 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006415
Geoff Langb1196682014-07-23 13:47:29 -04006416 switch (type)
6417 {
6418 case GL_BYTE:
6419 case GL_UNSIGNED_BYTE:
6420 case GL_SHORT:
6421 case GL_UNSIGNED_SHORT:
6422 case GL_INT:
6423 case GL_UNSIGNED_INT:
6424 case GL_INT_2_10_10_10_REV:
6425 case GL_UNSIGNED_INT_2_10_10_10_REV:
6426 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006427
Geoff Langb1196682014-07-23 13:47:29 -04006428 default:
6429 context->recordError(gl::Error(GL_INVALID_ENUM));
6430 return;
6431 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006432
Geoff Langb1196682014-07-23 13:47:29 -04006433 if (stride < 0)
6434 {
6435 context->recordError(gl::Error(GL_INVALID_VALUE));
6436 return;
6437 }
Geoff Langbfdea662014-07-23 14:16:32 -04006438
Geoff Langb1196682014-07-23 13:47:29 -04006439 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6440 {
6441 context->recordError(gl::Error(GL_INVALID_OPERATION));
6442 return;
6443 }
6444
Geoff Langbfdea662014-07-23 14:16:32 -04006445 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6446 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6447 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6448 // and the pointer argument is not NULL.
6449 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006450 {
Geoff Langb1196682014-07-23 13:47:29 -04006451 context->recordError(gl::Error(GL_INVALID_OPERATION));
6452 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006453 }
6454
Geoff Langbfdea662014-07-23 14:16:32 -04006455 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6456 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006457 }
6458}
6459
Kenneth Russell67ea1902014-10-06 16:44:50 -07006460void GL_APIENTRY glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006461{
6462 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6463 index, pname, params);
6464
Geoff Langbfdea662014-07-23 14:16:32 -04006465 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006466 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006467 {
Geoff Langbfdea662014-07-23 14:16:32 -04006468 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006469 {
Geoff Langb1196682014-07-23 13:47:29 -04006470 context->recordError(gl::Error(GL_INVALID_OPERATION));
6471 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006473
Geoff Langbfdea662014-07-23 14:16:32 -04006474 if (index >= gl::MAX_VERTEX_ATTRIBS)
6475 {
Geoff Langb1196682014-07-23 13:47:29 -04006476 context->recordError(gl::Error(GL_INVALID_VALUE));
6477 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006478 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006479
Geoff Langbfdea662014-07-23 14:16:32 -04006480 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006481
Geoff Langb1196682014-07-23 13:47:29 -04006482 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006483 {
6484 return;
6485 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006486
Geoff Langbfdea662014-07-23 14:16:32 -04006487 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6488 {
6489 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6490 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006491 {
Geoff Langbfdea662014-07-23 14:16:32 -04006492 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006493 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006494 }
Geoff Langbfdea662014-07-23 14:16:32 -04006495 else
6496 {
6497 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006499 }
6500}
6501
Kenneth Russell67ea1902014-10-06 16:44:50 -07006502void GL_APIENTRY glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006503{
6504 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6505 index, pname, params);
6506
Geoff Langbfdea662014-07-23 14:16:32 -04006507 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006508 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006509 {
Geoff Langbfdea662014-07-23 14:16:32 -04006510 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006511 {
Geoff Langb1196682014-07-23 13:47:29 -04006512 context->recordError(gl::Error(GL_INVALID_OPERATION));
6513 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006514 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006515
Geoff Langbfdea662014-07-23 14:16:32 -04006516 if (index >= gl::MAX_VERTEX_ATTRIBS)
6517 {
Geoff Langb1196682014-07-23 13:47:29 -04006518 context->recordError(gl::Error(GL_INVALID_VALUE));
6519 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006520 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006521
Geoff Langbfdea662014-07-23 14:16:32 -04006522 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006523
Geoff Langb1196682014-07-23 13:47:29 -04006524 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006525 {
6526 return;
6527 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006528
Geoff Langbfdea662014-07-23 14:16:32 -04006529 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6530 {
6531 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6532 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006533 {
Geoff Langbfdea662014-07-23 14:16:32 -04006534 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006535 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006536 }
Geoff Langbfdea662014-07-23 14:16:32 -04006537 else
6538 {
6539 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6540 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541 }
6542}
6543
Kenneth Russell67ea1902014-10-06 16:44:50 -07006544void GL_APIENTRY glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006545{
6546 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6547 index, x, y, z, w);
6548
Geoff Langbfdea662014-07-23 14:16:32 -04006549 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006550 if (context)
6551 {
6552 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006553 {
Geoff Langb1196682014-07-23 13:47:29 -04006554 context->recordError(gl::Error(GL_INVALID_OPERATION));
6555 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006556 }
Geoff Langbfdea662014-07-23 14:16:32 -04006557
6558 if (index >= gl::MAX_VERTEX_ATTRIBS)
6559 {
Geoff Langb1196682014-07-23 13:47:29 -04006560 context->recordError(gl::Error(GL_INVALID_VALUE));
6561 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006562 }
6563
6564 GLint vals[4] = { x, y, z, w };
6565 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006566 }
6567}
6568
Kenneth Russell67ea1902014-10-06 16:44:50 -07006569void GL_APIENTRY glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006570{
6571 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6572 index, x, y, z, w);
6573
Geoff Langbfdea662014-07-23 14:16:32 -04006574 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006575 if (context)
6576 {
6577 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006578 {
Geoff Langb1196682014-07-23 13:47:29 -04006579 context->recordError(gl::Error(GL_INVALID_OPERATION));
6580 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006581 }
Geoff Langbfdea662014-07-23 14:16:32 -04006582
6583 if (index >= gl::MAX_VERTEX_ATTRIBS)
6584 {
Geoff Langb1196682014-07-23 13:47:29 -04006585 context->recordError(gl::Error(GL_INVALID_VALUE));
6586 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006587 }
6588
6589 GLuint vals[4] = { x, y, z, w };
6590 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006591 }
6592}
6593
Kenneth Russell67ea1902014-10-06 16:44:50 -07006594void GL_APIENTRY glVertexAttribI4iv(GLuint index, const GLint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006595{
6596 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6597
Geoff Langbfdea662014-07-23 14:16:32 -04006598 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006599 if (context)
6600 {
6601 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006602 {
Geoff Langb1196682014-07-23 13:47:29 -04006603 context->recordError(gl::Error(GL_INVALID_OPERATION));
6604 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006605 }
Geoff Langbfdea662014-07-23 14:16:32 -04006606
6607 if (index >= gl::MAX_VERTEX_ATTRIBS)
6608 {
Geoff Langb1196682014-07-23 13:47:29 -04006609 context->recordError(gl::Error(GL_INVALID_VALUE));
6610 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006611 }
6612
6613 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006614 }
6615}
6616
Kenneth Russell67ea1902014-10-06 16:44:50 -07006617void GL_APIENTRY glVertexAttribI4uiv(GLuint index, const GLuint* v)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006618{
6619 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6620
Geoff Langbfdea662014-07-23 14:16:32 -04006621 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006622 if (context)
6623 {
6624 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006625 {
Geoff Langb1196682014-07-23 13:47:29 -04006626 context->recordError(gl::Error(GL_INVALID_OPERATION));
6627 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006628 }
Geoff Langbfdea662014-07-23 14:16:32 -04006629
6630 if (index >= gl::MAX_VERTEX_ATTRIBS)
6631 {
Geoff Langb1196682014-07-23 13:47:29 -04006632 context->recordError(gl::Error(GL_INVALID_VALUE));
6633 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006634 }
6635
6636 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637 }
6638}
6639
Kenneth Russell67ea1902014-10-06 16:44:50 -07006640void GL_APIENTRY glGetUniformuiv(GLuint program, GLint location, GLuint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006641{
6642 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6643 program, location, params);
6644
Geoff Langbfdea662014-07-23 14:16:32 -04006645 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006646 if (context)
6647 {
Jamie Madill0063c512014-08-25 15:47:53 -04006648 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006649 {
Jamie Madill0063c512014-08-25 15:47:53 -04006650 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006651 }
Geoff Langbfdea662014-07-23 14:16:32 -04006652
Jamie Madilla502c742014-08-28 17:19:13 -04006653 gl::Program *programObject = context->getProgram(program);
6654 ASSERT(programObject);
6655 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006656 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006657
Jamie Madill99a1e982014-08-25 15:47:54 -04006658 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006659 }
6660}
6661
Kenneth Russell67ea1902014-10-06 16:44:50 -07006662GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar *name)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006663{
6664 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6665 program, name);
6666
Geoff Langbfdea662014-07-23 14:16:32 -04006667 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006668 if (context)
6669 {
6670 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006671 {
Geoff Langb1196682014-07-23 13:47:29 -04006672 context->recordError(gl::Error(GL_INVALID_OPERATION));
6673 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006674 }
Geoff Langbfdea662014-07-23 14:16:32 -04006675
6676 if (program == 0)
6677 {
Geoff Langb1196682014-07-23 13:47:29 -04006678 context->recordError(gl::Error(GL_INVALID_VALUE));
6679 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006680 }
6681
6682 gl::Program *programObject = context->getProgram(program);
6683
6684 if (!programObject || !programObject->isLinked())
6685 {
Geoff Langb1196682014-07-23 13:47:29 -04006686 context->recordError(gl::Error(GL_INVALID_OPERATION));
6687 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006688 }
6689
6690 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6691 if (!programBinary)
6692 {
Geoff Langb1196682014-07-23 13:47:29 -04006693 context->recordError(gl::Error(GL_INVALID_OPERATION));
6694 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006695 }
6696
6697 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006698 }
6699
6700 return 0;
6701}
6702
Kenneth Russell67ea1902014-10-06 16:44:50 -07006703void GL_APIENTRY glUniform1ui(GLint location, GLuint v0)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006704{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006705 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006706}
6707
Kenneth Russell67ea1902014-10-06 16:44:50 -07006708void GL_APIENTRY glUniform2ui(GLint location, GLuint v0, GLuint v1)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006709{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006710 const GLuint xy[] = { v0, v1 };
6711 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006712}
6713
Kenneth Russell67ea1902014-10-06 16:44:50 -07006714void GL_APIENTRY glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006715{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006716 const GLuint xyz[] = { v0, v1, v2 };
6717 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006718}
6719
Kenneth Russell67ea1902014-10-06 16:44:50 -07006720void GL_APIENTRY glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006721{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006722 const GLuint xyzw[] = { v0, v1, v2, v3 };
6723 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006724}
6725
Kenneth Russell67ea1902014-10-06 16:44:50 -07006726void GL_APIENTRY glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006727{
6728 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6729 location, count, value);
6730
Geoff Langbfdea662014-07-23 14:16:32 -04006731 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006732 if (context)
6733 {
6734 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006735 {
Geoff Langbfdea662014-07-23 14:16:32 -04006736 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006737 }
Geoff Langbfdea662014-07-23 14:16:32 -04006738
6739 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6740 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006741 }
6742}
6743
Kenneth Russell67ea1902014-10-06 16:44:50 -07006744void GL_APIENTRY glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006745{
6746 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6747 location, count, value);
6748
Geoff Langbfdea662014-07-23 14:16:32 -04006749 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006750 if (context)
6751 {
6752 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006753 {
Geoff Langbfdea662014-07-23 14:16:32 -04006754 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006755 }
Geoff Langbfdea662014-07-23 14:16:32 -04006756
6757 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6758 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006759 }
6760}
6761
Kenneth Russell67ea1902014-10-06 16:44:50 -07006762void GL_APIENTRY glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006763{
6764 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6765 location, count, value);
6766
Geoff Langbfdea662014-07-23 14:16:32 -04006767 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006768 if (context)
6769 {
6770 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006771 {
Geoff Langbfdea662014-07-23 14:16:32 -04006772 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006773 }
Geoff Langbfdea662014-07-23 14:16:32 -04006774
6775 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6776 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006777 }
6778}
6779
Kenneth Russell67ea1902014-10-06 16:44:50 -07006780void GL_APIENTRY glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006781{
6782 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6783 location, count, value);
6784
Geoff Langbfdea662014-07-23 14:16:32 -04006785 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006786 if (context)
6787 {
6788 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006789 {
Geoff Langbfdea662014-07-23 14:16:32 -04006790 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006791 }
Geoff Langbfdea662014-07-23 14:16:32 -04006792
6793 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6794 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006795 }
6796}
6797
Kenneth Russell67ea1902014-10-06 16:44:50 -07006798void GL_APIENTRY glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006799{
6800 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6801 buffer, drawbuffer, value);
6802
Geoff Langbfdea662014-07-23 14:16:32 -04006803 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006804 if (context)
6805 {
6806 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006807 {
Geoff Langbfdea662014-07-23 14:16:32 -04006808 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006809 }
Geoff Langbfdea662014-07-23 14:16:32 -04006810
6811 switch (buffer)
6812 {
6813 case GL_COLOR:
6814 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6815 {
Geoff Langb1196682014-07-23 13:47:29 -04006816 context->recordError(gl::Error(GL_INVALID_VALUE));
6817 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006818 }
6819 break;
Geoff Langb1196682014-07-23 13:47:29 -04006820
Geoff Langbfdea662014-07-23 14:16:32 -04006821 case GL_STENCIL:
6822 if (drawbuffer != 0)
6823 {
Geoff Langb1196682014-07-23 13:47:29 -04006824 context->recordError(gl::Error(GL_INVALID_VALUE));
6825 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006826 }
6827 break;
Geoff Langb1196682014-07-23 13:47:29 -04006828
Geoff Langbfdea662014-07-23 14:16:32 -04006829 default:
Geoff Langb1196682014-07-23 13:47:29 -04006830 context->recordError(gl::Error(GL_INVALID_ENUM));
6831 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006832 }
6833
Geoff Langcc79b8c2014-07-25 13:48:02 -04006834 gl::Error error = context->clearBufferiv(buffer, drawbuffer, value);
6835 if (error.isError())
6836 {
6837 context->recordError(error);
6838 return;
6839 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006840 }
6841}
6842
Kenneth Russell67ea1902014-10-06 16:44:50 -07006843void GL_APIENTRY glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006844{
6845 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6846 buffer, drawbuffer, value);
6847
Geoff Langbfdea662014-07-23 14:16:32 -04006848 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006849 if (context)
6850 {
6851 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006852 {
Geoff Langbfdea662014-07-23 14:16:32 -04006853 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006854 }
Geoff Langbfdea662014-07-23 14:16:32 -04006855
6856 switch (buffer)
6857 {
6858 case GL_COLOR:
6859 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6860 {
Geoff Langb1196682014-07-23 13:47:29 -04006861 context->recordError(gl::Error(GL_INVALID_VALUE));
6862 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006863 }
6864 break;
Geoff Langb1196682014-07-23 13:47:29 -04006865
Geoff Langbfdea662014-07-23 14:16:32 -04006866 default:
Geoff Langb1196682014-07-23 13:47:29 -04006867 context->recordError(gl::Error(GL_INVALID_ENUM));
6868 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006869 }
6870
Geoff Langcc79b8c2014-07-25 13:48:02 -04006871 gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value);
6872 if (error.isError())
6873 {
6874 context->recordError(error);
6875 return;
6876 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006877 }
6878}
6879
Kenneth Russell67ea1902014-10-06 16:44:50 -07006880void GL_APIENTRY glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006881{
6882 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6883 buffer, drawbuffer, value);
6884
Geoff Langbfdea662014-07-23 14:16:32 -04006885 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006886 if (context)
6887 {
6888 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006889 {
Geoff Langbfdea662014-07-23 14:16:32 -04006890 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006891 }
Geoff Langbfdea662014-07-23 14:16:32 -04006892
6893 switch (buffer)
6894 {
6895 case GL_COLOR:
6896 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6897 {
Geoff Langb1196682014-07-23 13:47:29 -04006898 context->recordError(gl::Error(GL_INVALID_VALUE));
6899 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006900 }
6901 break;
Geoff Langb1196682014-07-23 13:47:29 -04006902
Geoff Langbfdea662014-07-23 14:16:32 -04006903 case GL_DEPTH:
6904 if (drawbuffer != 0)
6905 {
Geoff Langb1196682014-07-23 13:47:29 -04006906 context->recordError(gl::Error(GL_INVALID_VALUE));
6907 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006908 }
6909 break;
Geoff Langb1196682014-07-23 13:47:29 -04006910
Geoff Langbfdea662014-07-23 14:16:32 -04006911 default:
Geoff Langb1196682014-07-23 13:47:29 -04006912 context->recordError(gl::Error(GL_INVALID_ENUM));
6913 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006914 }
6915
Geoff Langcc79b8c2014-07-25 13:48:02 -04006916 gl::Error error = context->clearBufferfv(buffer, drawbuffer, value);
6917 if (error.isError())
6918 {
6919 context->recordError(error);
6920 return;
6921 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006922 }
6923}
6924
Kenneth Russell67ea1902014-10-06 16:44:50 -07006925void GL_APIENTRY glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006926{
6927 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6928 buffer, drawbuffer, depth, stencil);
6929
Geoff Langbfdea662014-07-23 14:16:32 -04006930 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006931 if (context)
6932 {
6933 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006934 {
Geoff Langbfdea662014-07-23 14:16:32 -04006935 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006936 }
Geoff Langbfdea662014-07-23 14:16:32 -04006937
6938 switch (buffer)
6939 {
6940 case GL_DEPTH_STENCIL:
6941 if (drawbuffer != 0)
6942 {
Geoff Langb1196682014-07-23 13:47:29 -04006943 context->recordError(gl::Error(GL_INVALID_VALUE));
6944 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006945 }
6946 break;
Geoff Langb1196682014-07-23 13:47:29 -04006947
Geoff Langbfdea662014-07-23 14:16:32 -04006948 default:
Geoff Langb1196682014-07-23 13:47:29 -04006949 context->recordError(gl::Error(GL_INVALID_ENUM));
6950 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006951 }
6952
Geoff Langcc79b8c2014-07-25 13:48:02 -04006953 gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil);
6954 if (error.isError())
6955 {
6956 context->recordError(error);
6957 return;
6958 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006959 }
6960}
6961
Kenneth Russell67ea1902014-10-06 16:44:50 -07006962const GLubyte* GL_APIENTRY glGetStringi(GLenum name, GLuint index)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006963{
6964 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6965
Geoff Langbfdea662014-07-23 14:16:32 -04006966 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006967 if (context)
6968 {
6969 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006970 {
Geoff Langb1196682014-07-23 13:47:29 -04006971 context->recordError(gl::Error(GL_INVALID_OPERATION));
6972 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006973 }
Geoff Langbfdea662014-07-23 14:16:32 -04006974
6975 if (name != GL_EXTENSIONS)
6976 {
Geoff Langb1196682014-07-23 13:47:29 -04006977 context->recordError(gl::Error(GL_INVALID_ENUM));
6978 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006979 }
6980
6981 if (index >= context->getExtensionStringCount())
6982 {
Geoff Langb1196682014-07-23 13:47:29 -04006983 context->recordError(gl::Error(GL_INVALID_VALUE));
6984 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006985 }
6986
6987 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006988 }
6989
6990 return NULL;
6991}
6992
Kenneth Russell67ea1902014-10-06 16:44:50 -07006993void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006994{
6995 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6996 readTarget, writeTarget, readOffset, writeOffset, size);
6997
Geoff Langbfdea662014-07-23 14:16:32 -04006998 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006999 if (context)
7000 {
7001 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007002 {
Geoff Langb1196682014-07-23 13:47:29 -04007003 context->recordError(gl::Error(GL_INVALID_OPERATION));
7004 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00007005 }
Geoff Langbfdea662014-07-23 14:16:32 -04007006
Jamie Madill24e83192014-10-20 11:00:53 -04007007 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, writeTarget))
Geoff Langbfdea662014-07-23 14:16:32 -04007008 {
Geoff Langb1196682014-07-23 13:47:29 -04007009 context->recordError(gl::Error(GL_INVALID_ENUM));
7010 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007011 }
7012
7013 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
7014 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
7015
7016 if (!readBuffer || !writeBuffer)
7017 {
Geoff Langb1196682014-07-23 13:47:29 -04007018 context->recordError(gl::Error(GL_INVALID_OPERATION));
7019 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007020 }
7021
Jamie Madillcfaaf722014-07-31 10:47:54 -04007022 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04007023 if (readBuffer->isMapped() || writeBuffer->isMapped())
7024 {
Geoff Langb1196682014-07-23 13:47:29 -04007025 context->recordError(gl::Error(GL_INVALID_OPERATION));
7026 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007027 }
7028
7029 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
7030 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
7031 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
7032 {
Geoff Langb1196682014-07-23 13:47:29 -04007033 context->recordError(gl::Error(GL_INVALID_VALUE));
7034 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007035 }
7036
Kenneth Russell67ea1902014-10-06 16:44:50 -07007037 if (readBuffer == writeBuffer && std::abs(readOffset - writeOffset) < size)
Geoff Langbfdea662014-07-23 14:16:32 -04007038 {
Geoff Langb1196682014-07-23 13:47:29 -04007039 context->recordError(gl::Error(GL_INVALID_VALUE));
7040 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007041 }
7042
Geoff Langbfdea662014-07-23 14:16:32 -04007043 // if size is zero, the copy is a successful no-op
7044 if (size > 0)
7045 {
Geoff Lang2a1c15a2014-07-25 11:43:00 -04007046 gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
7047 if (error.isError())
7048 {
7049 context->recordError(error);
7050 return;
7051 }
Geoff Langbfdea662014-07-23 14:16:32 -04007052 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007053 }
7054}
7055
Kenneth Russell67ea1902014-10-06 16:44:50 -07007056void GL_APIENTRY glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007057{
7058 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
7059 program, uniformCount, uniformNames, uniformIndices);
7060
Geoff Langbfdea662014-07-23 14:16:32 -04007061 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007062 if (context)
7063 {
7064 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007065 {
Geoff Langb1196682014-07-23 13:47:29 -04007066 context->recordError(gl::Error(GL_INVALID_OPERATION));
7067 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007068 }
7069
7070 if (uniformCount < 0)
7071 {
Geoff Langb1196682014-07-23 13:47:29 -04007072 context->recordError(gl::Error(GL_INVALID_VALUE));
7073 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007074 }
7075
7076 gl::Program *programObject = context->getProgram(program);
7077
7078 if (!programObject)
7079 {
7080 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007081 {
Geoff Langb1196682014-07-23 13:47:29 -04007082 context->recordError(gl::Error(GL_INVALID_OPERATION));
7083 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007084 }
Geoff Langbfdea662014-07-23 14:16:32 -04007085 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007086 {
Geoff Langb1196682014-07-23 13:47:29 -04007087 context->recordError(gl::Error(GL_INVALID_VALUE));
7088 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007089 }
Geoff Langbfdea662014-07-23 14:16:32 -04007090 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007091
Geoff Langbfdea662014-07-23 14:16:32 -04007092 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7093 if (!programObject->isLinked() || !programBinary)
7094 {
7095 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007096 {
Geoff Langbfdea662014-07-23 14:16:32 -04007097 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00007098 }
7099 }
Geoff Langbfdea662014-07-23 14:16:32 -04007100 else
7101 {
7102 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7103 {
7104 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
7105 }
7106 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007107 }
7108}
7109
Kenneth Russell67ea1902014-10-06 16:44:50 -07007110void 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 +00007111{
7112 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7113 program, uniformCount, uniformIndices, pname, params);
7114
Geoff Langbfdea662014-07-23 14:16:32 -04007115 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007116 if (context)
7117 {
7118 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007119 {
Geoff Langb1196682014-07-23 13:47:29 -04007120 context->recordError(gl::Error(GL_INVALID_OPERATION));
7121 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007122 }
7123
7124 if (uniformCount < 0)
7125 {
Geoff Langb1196682014-07-23 13:47:29 -04007126 context->recordError(gl::Error(GL_INVALID_VALUE));
7127 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007128 }
7129
7130 gl::Program *programObject = context->getProgram(program);
7131
7132 if (!programObject)
7133 {
7134 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007135 {
Geoff Langb1196682014-07-23 13:47:29 -04007136 context->recordError(gl::Error(GL_INVALID_OPERATION));
7137 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007138 }
Geoff Langbfdea662014-07-23 14:16:32 -04007139 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007140 {
Geoff Langb1196682014-07-23 13:47:29 -04007141 context->recordError(gl::Error(GL_INVALID_VALUE));
7142 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007143 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00007144 }
Geoff Langbfdea662014-07-23 14:16:32 -04007145
7146 switch (pname)
7147 {
7148 case GL_UNIFORM_TYPE:
7149 case GL_UNIFORM_SIZE:
7150 case GL_UNIFORM_NAME_LENGTH:
7151 case GL_UNIFORM_BLOCK_INDEX:
7152 case GL_UNIFORM_OFFSET:
7153 case GL_UNIFORM_ARRAY_STRIDE:
7154 case GL_UNIFORM_MATRIX_STRIDE:
7155 case GL_UNIFORM_IS_ROW_MAJOR:
7156 break;
Geoff Langb1196682014-07-23 13:47:29 -04007157
Geoff Langbfdea662014-07-23 14:16:32 -04007158 default:
Geoff Langb1196682014-07-23 13:47:29 -04007159 context->recordError(gl::Error(GL_INVALID_ENUM));
7160 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007161 }
7162
7163 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7164
7165 if (!programBinary && uniformCount > 0)
7166 {
Geoff Langb1196682014-07-23 13:47:29 -04007167 context->recordError(gl::Error(GL_INVALID_VALUE));
7168 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007169 }
7170
7171 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7172 {
7173 const GLuint index = uniformIndices[uniformId];
7174
7175 if (index >= (GLuint)programBinary->getActiveUniformCount())
7176 {
Geoff Langb1196682014-07-23 13:47:29 -04007177 context->recordError(gl::Error(GL_INVALID_VALUE));
7178 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007179 }
7180 }
7181
7182 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
7183 {
7184 const GLuint index = uniformIndices[uniformId];
7185 params[uniformId] = programBinary->getActiveUniformi(index, pname);
7186 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007187 }
7188}
7189
Kenneth Russell67ea1902014-10-06 16:44:50 -07007190GLuint GL_APIENTRY glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007191{
7192 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
7193
Geoff Langbfdea662014-07-23 14:16:32 -04007194 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007195 if (context)
7196 {
7197 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007198 {
Geoff Langb1196682014-07-23 13:47:29 -04007199 context->recordError(gl::Error(GL_INVALID_OPERATION));
7200 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04007201 }
7202
7203 gl::Program *programObject = context->getProgram(program);
7204
7205 if (!programObject)
7206 {
7207 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007208 {
Geoff Langb1196682014-07-23 13:47:29 -04007209 context->recordError(gl::Error(GL_INVALID_OPERATION));
7210 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007211 }
Geoff Langbfdea662014-07-23 14:16:32 -04007212 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007213 {
Geoff Langb1196682014-07-23 13:47:29 -04007214 context->recordError(gl::Error(GL_INVALID_VALUE));
7215 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007216 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00007217 }
Geoff Langbfdea662014-07-23 14:16:32 -04007218
7219 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7220 if (!programBinary)
7221 {
7222 return GL_INVALID_INDEX;
7223 }
7224
7225 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007226 }
7227
7228 return 0;
7229}
7230
Kenneth Russell67ea1902014-10-06 16:44:50 -07007231void GL_APIENTRY glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007232{
7233 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7234 program, uniformBlockIndex, pname, params);
7235
Geoff Langbfdea662014-07-23 14:16:32 -04007236 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007237 if (context)
7238 {
7239 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007240 {
Geoff Langb1196682014-07-23 13:47:29 -04007241 context->recordError(gl::Error(GL_INVALID_OPERATION));
7242 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007243 }
7244 gl::Program *programObject = context->getProgram(program);
7245
7246 if (!programObject)
7247 {
7248 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007249 {
Geoff Langb1196682014-07-23 13:47:29 -04007250 context->recordError(gl::Error(GL_INVALID_OPERATION));
7251 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007252 }
Geoff Langbfdea662014-07-23 14:16:32 -04007253 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007254 {
Geoff Langb1196682014-07-23 13:47:29 -04007255 context->recordError(gl::Error(GL_INVALID_VALUE));
7256 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007257 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00007258 }
Geoff Langbfdea662014-07-23 14:16:32 -04007259
7260 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7261
7262 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7263 {
Geoff Langb1196682014-07-23 13:47:29 -04007264 context->recordError(gl::Error(GL_INVALID_VALUE));
7265 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007266 }
7267
7268 switch (pname)
7269 {
7270 case GL_UNIFORM_BLOCK_BINDING:
7271 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7272 break;
7273
7274 case GL_UNIFORM_BLOCK_DATA_SIZE:
7275 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7276 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7277 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7278 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7279 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7280 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7281 break;
7282
7283 default:
Geoff Langb1196682014-07-23 13:47:29 -04007284 context->recordError(gl::Error(GL_INVALID_ENUM));
7285 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007286 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007287 }
7288}
7289
Kenneth Russell67ea1902014-10-06 16:44:50 -07007290void GL_APIENTRY glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007291{
7292 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7293 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7294
Geoff Langbfdea662014-07-23 14:16:32 -04007295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007296 if (context)
7297 {
7298 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007299 {
Geoff Langb1196682014-07-23 13:47:29 -04007300 context->recordError(gl::Error(GL_INVALID_OPERATION));
7301 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007302 }
7303
7304 gl::Program *programObject = context->getProgram(program);
7305
7306 if (!programObject)
7307 {
7308 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007309 {
Geoff Langb1196682014-07-23 13:47:29 -04007310 context->recordError(gl::Error(GL_INVALID_OPERATION));
7311 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007312 }
Geoff Langbfdea662014-07-23 14:16:32 -04007313 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007314 {
Geoff Langb1196682014-07-23 13:47:29 -04007315 context->recordError(gl::Error(GL_INVALID_VALUE));
7316 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007317 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007318 }
Geoff Langbfdea662014-07-23 14:16:32 -04007319
7320 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7321
7322 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7323 {
Geoff Langb1196682014-07-23 13:47:29 -04007324 context->recordError(gl::Error(GL_INVALID_VALUE));
7325 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007326 }
7327
7328 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007329 }
7330}
7331
Kenneth Russell67ea1902014-10-06 16:44:50 -07007332void GL_APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007333{
7334 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7335 program, uniformBlockIndex, uniformBlockBinding);
7336
Geoff Langbfdea662014-07-23 14:16:32 -04007337 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007338 if (context)
7339 {
7340 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007341 {
Geoff Langb1196682014-07-23 13:47:29 -04007342 context->recordError(gl::Error(GL_INVALID_OPERATION));
7343 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007344 }
7345
Geoff Lang3a61c322014-07-10 13:01:54 -04007346 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007347 {
Geoff Langb1196682014-07-23 13:47:29 -04007348 context->recordError(gl::Error(GL_INVALID_VALUE));
7349 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007350 }
7351
7352 gl::Program *programObject = context->getProgram(program);
7353
7354 if (!programObject)
7355 {
7356 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007357 {
Geoff Langb1196682014-07-23 13:47:29 -04007358 context->recordError(gl::Error(GL_INVALID_OPERATION));
7359 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007360 }
Geoff Langbfdea662014-07-23 14:16:32 -04007361 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007362 {
Geoff Langb1196682014-07-23 13:47:29 -04007363 context->recordError(gl::Error(GL_INVALID_VALUE));
7364 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007365 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007366 }
Geoff Langbfdea662014-07-23 14:16:32 -04007367
7368 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7369
7370 // if never linked, there won't be any uniform blocks
7371 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7372 {
Geoff Langb1196682014-07-23 13:47:29 -04007373 context->recordError(gl::Error(GL_INVALID_VALUE));
7374 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007375 }
7376
7377 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007378 }
7379}
7380
Kenneth Russell67ea1902014-10-06 16:44:50 -07007381void GL_APIENTRY glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007382{
7383 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7384 mode, first, count, instanceCount);
7385
Geoff Langbfdea662014-07-23 14:16:32 -04007386 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007387 if (context)
7388 {
7389 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007390 {
Geoff Langb1196682014-07-23 13:47:29 -04007391 context->recordError(gl::Error(GL_INVALID_OPERATION));
7392 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007393 }
Geoff Langbfdea662014-07-23 14:16:32 -04007394
7395 // glDrawArraysInstanced
7396 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007397 }
7398}
7399
Kenneth Russell67ea1902014-10-06 16:44:50 -07007400void 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 +00007401{
7402 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7403 mode, count, type, indices, instanceCount);
7404
Geoff Langbfdea662014-07-23 14:16:32 -04007405 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007406 if (context)
7407 {
7408 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007409 {
Geoff Langb1196682014-07-23 13:47:29 -04007410 context->recordError(gl::Error(GL_INVALID_OPERATION));
7411 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007412 }
Geoff Langbfdea662014-07-23 14:16:32 -04007413
7414 // glDrawElementsInstanced
7415 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007416 }
7417}
7418
Kenneth Russell67ea1902014-10-06 16:44:50 -07007419GLsync GL_APIENTRY glFenceSync(GLenum condition, GLbitfield flags)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007420{
7421 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7422
Geoff Langbfdea662014-07-23 14:16:32 -04007423 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007424 if (context)
7425 {
7426 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007427 {
Geoff Langb1196682014-07-23 13:47:29 -04007428 context->recordError(gl::Error(GL_INVALID_OPERATION));
7429 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007430 }
Geoff Langbfdea662014-07-23 14:16:32 -04007431
7432 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7433 {
Geoff Langb1196682014-07-23 13:47:29 -04007434 context->recordError(gl::Error(GL_INVALID_ENUM));
7435 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007436 }
7437
7438 if (flags != 0)
7439 {
Geoff Langb1196682014-07-23 13:47:29 -04007440 context->recordError(gl::Error(GL_INVALID_VALUE));
7441 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007442 }
7443
Geoff Lang882033e2014-09-30 11:26:07 -04007444 GLsync fenceSync = context->createFenceSync();
7445
7446 gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
7447 gl::Error error = fenceSyncObject->set(condition);
7448 if (error.isError())
7449 {
7450 context->deleteFenceSync(fenceSync);
7451 context->recordError(error);
7452 return NULL;
7453 }
7454
7455 return fenceSync;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007456 }
7457
7458 return NULL;
7459}
7460
Kenneth Russell67ea1902014-10-06 16:44:50 -07007461GLboolean GL_APIENTRY glIsSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007462{
7463 EVENT("(GLsync sync = 0x%0.8p)", sync);
7464
Geoff Langbfdea662014-07-23 14:16:32 -04007465 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007466 if (context)
7467 {
7468 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007469 {
Geoff Langb1196682014-07-23 13:47:29 -04007470 context->recordError(gl::Error(GL_INVALID_OPERATION));
7471 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007472 }
Geoff Langbfdea662014-07-23 14:16:32 -04007473
7474 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007475 }
7476
7477 return GL_FALSE;
7478}
7479
Kenneth Russell67ea1902014-10-06 16:44:50 -07007480void GL_APIENTRY glDeleteSync(GLsync sync)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007481{
7482 EVENT("(GLsync sync = 0x%0.8p)", sync);
7483
Geoff Langbfdea662014-07-23 14:16:32 -04007484 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007485 if (context)
7486 {
7487 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007488 {
Geoff Langb1196682014-07-23 13:47:29 -04007489 context->recordError(gl::Error(GL_INVALID_OPERATION));
7490 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007491 }
Geoff Langbfdea662014-07-23 14:16:32 -04007492
7493 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7494 {
Geoff Langb1196682014-07-23 13:47:29 -04007495 context->recordError(gl::Error(GL_INVALID_VALUE));
7496 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007497 }
7498
7499 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007500 }
7501}
7502
Kenneth Russell67ea1902014-10-06 16:44:50 -07007503GLenum GL_APIENTRY glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007504{
7505 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7506 sync, flags, timeout);
7507
Geoff Langbfdea662014-07-23 14:16:32 -04007508 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007509 if (context)
7510 {
7511 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007512 {
Geoff Langb1196682014-07-23 13:47:29 -04007513 context->recordError(gl::Error(GL_INVALID_OPERATION));
7514 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007515 }
Geoff Langbfdea662014-07-23 14:16:32 -04007516
7517 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7518 {
Geoff Langb1196682014-07-23 13:47:29 -04007519 context->recordError(gl::Error(GL_INVALID_VALUE));
7520 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007521 }
7522
7523 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7524
7525 if (!fenceSync)
7526 {
Geoff Langb1196682014-07-23 13:47:29 -04007527 context->recordError(gl::Error(GL_INVALID_VALUE));
7528 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007529 }
7530
Geoff Lang882033e2014-09-30 11:26:07 -04007531 GLenum result = GL_WAIT_FAILED;
7532 gl::Error error = fenceSync->clientWait(flags, timeout, &result);
7533 if (error.isError())
7534 {
7535 context->recordError(error);
7536 return GL_WAIT_FAILED;
7537 }
7538
7539 return result;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007540 }
7541
7542 return GL_FALSE;
7543}
7544
Kenneth Russell67ea1902014-10-06 16:44:50 -07007545void GL_APIENTRY glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007546{
7547 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7548 sync, flags, timeout);
7549
Geoff Langbfdea662014-07-23 14:16:32 -04007550 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007551 if (context)
7552 {
7553 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007554 {
Geoff Langb1196682014-07-23 13:47:29 -04007555 context->recordError(gl::Error(GL_INVALID_OPERATION));
7556 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007557 }
Geoff Langbfdea662014-07-23 14:16:32 -04007558
7559 if (flags != 0)
7560 {
Geoff Langb1196682014-07-23 13:47:29 -04007561 context->recordError(gl::Error(GL_INVALID_VALUE));
7562 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007563 }
7564
7565 if (timeout != GL_TIMEOUT_IGNORED)
7566 {
Geoff Langb1196682014-07-23 13:47:29 -04007567 context->recordError(gl::Error(GL_INVALID_VALUE));
7568 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007569 }
7570
7571 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7572
7573 if (!fenceSync)
7574 {
Geoff Langb1196682014-07-23 13:47:29 -04007575 context->recordError(gl::Error(GL_INVALID_VALUE));
7576 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007577 }
7578
Kenneth Russellcaa549c2014-10-10 17:52:59 -07007579 gl::Error error = fenceSync->serverWait(flags, timeout);
Geoff Lang882033e2014-09-30 11:26:07 -04007580 if (error.isError())
7581 {
7582 context->recordError(error);
7583 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007584 }
7585}
7586
Kenneth Russell67ea1902014-10-06 16:44:50 -07007587void GL_APIENTRY glGetInteger64v(GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007588{
7589 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7590 pname, params);
7591
Geoff Langbfdea662014-07-23 14:16:32 -04007592 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007593 if (context)
7594 {
7595 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007596 {
Geoff Langb1196682014-07-23 13:47:29 -04007597 context->recordError(gl::Error(GL_INVALID_OPERATION));
7598 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007599 }
Geoff Langbfdea662014-07-23 14:16:32 -04007600
7601 GLenum nativeType;
7602 unsigned int numParams = 0;
7603 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7604 {
7605 return;
7606 }
7607
7608 if (nativeType == GL_INT_64_ANGLEX)
7609 {
7610 context->getInteger64v(pname, params);
7611 }
7612 else
7613 {
7614 CastStateValues(context, nativeType, pname, numParams, params);
7615 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007616 }
7617}
7618
Kenneth Russell67ea1902014-10-06 16:44:50 -07007619void GL_APIENTRY glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007620{
7621 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7622 sync, pname, bufSize, length, values);
7623
Geoff Langbfdea662014-07-23 14:16:32 -04007624 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007625 if (context)
7626 {
7627 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007628 {
Geoff Langb1196682014-07-23 13:47:29 -04007629 context->recordError(gl::Error(GL_INVALID_OPERATION));
7630 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007631 }
Geoff Langbfdea662014-07-23 14:16:32 -04007632
7633 if (bufSize < 0)
7634 {
Geoff Langb1196682014-07-23 13:47:29 -04007635 context->recordError(gl::Error(GL_INVALID_VALUE));
7636 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007637 }
7638
7639 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7640
7641 if (!fenceSync)
7642 {
Geoff Langb1196682014-07-23 13:47:29 -04007643 context->recordError(gl::Error(GL_INVALID_VALUE));
7644 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007645 }
7646
7647 switch (pname)
7648 {
7649 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
Geoff Langbfdea662014-07-23 14:16:32 -04007650 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7651 case GL_SYNC_FLAGS: values[0] = 0; break;
7652
Geoff Lang882033e2014-09-30 11:26:07 -04007653 case GL_SYNC_STATUS:
7654 {
7655 gl::Error error = fenceSync->getStatus(values);
7656 if (error.isError())
7657 {
7658 context->recordError(error);
7659 return;
7660 }
7661 break;
7662 }
7663
Geoff Langbfdea662014-07-23 14:16:32 -04007664 default:
Geoff Langb1196682014-07-23 13:47:29 -04007665 context->recordError(gl::Error(GL_INVALID_ENUM));
7666 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007667 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007668 }
7669}
7670
Kenneth Russell67ea1902014-10-06 16:44:50 -07007671void GL_APIENTRY glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007672{
7673 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7674 target, index, data);
7675
Geoff Langbfdea662014-07-23 14:16:32 -04007676 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007677 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007678 {
Geoff Langbfdea662014-07-23 14:16:32 -04007679 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007680 {
Geoff Langb1196682014-07-23 13:47:29 -04007681 context->recordError(gl::Error(GL_INVALID_OPERATION));
7682 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007683 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007684
Geoff Lang3a61c322014-07-10 13:01:54 -04007685 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007686 switch (target)
7687 {
7688 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7689 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7690 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007691 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7692 {
Geoff Langb1196682014-07-23 13:47:29 -04007693 context->recordError(gl::Error(GL_INVALID_VALUE));
7694 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007695 }
Geoff Langbfdea662014-07-23 14:16:32 -04007696 break;
Geoff Langb1196682014-07-23 13:47:29 -04007697
Geoff Langbfdea662014-07-23 14:16:32 -04007698 case GL_UNIFORM_BUFFER_START:
7699 case GL_UNIFORM_BUFFER_SIZE:
7700 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007701 if (index >= caps.maxUniformBufferBindings)
7702 {
Geoff Langb1196682014-07-23 13:47:29 -04007703 context->recordError(gl::Error(GL_INVALID_VALUE));
7704 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007705 }
Geoff Langbfdea662014-07-23 14:16:32 -04007706 break;
Geoff Langb1196682014-07-23 13:47:29 -04007707
Geoff Langbfdea662014-07-23 14:16:32 -04007708 default:
Geoff Langb1196682014-07-23 13:47:29 -04007709 context->recordError(gl::Error(GL_INVALID_ENUM));
7710 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007711 }
7712
7713 if (!(context->getIndexedInteger64v(target, index, data)))
7714 {
7715 GLenum nativeType;
7716 unsigned int numParams = 0;
7717 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007718 {
7719 context->recordError(gl::Error(GL_INVALID_ENUM));
7720 return;
7721 }
Shannon Woods15934d52013-08-19 14:28:49 -04007722
Geoff Langbfdea662014-07-23 14:16:32 -04007723 if (numParams == 0)
7724 return; // it is known that pname is valid, but there are no parameters to return
7725
7726 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007727 {
Geoff Langbfdea662014-07-23 14:16:32 -04007728 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007729
Geoff Langbfdea662014-07-23 14:16:32 -04007730 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007731
Geoff Langbfdea662014-07-23 14:16:32 -04007732 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007733 {
Geoff Langbfdea662014-07-23 14:16:32 -04007734 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007735 }
Geoff Langbfdea662014-07-23 14:16:32 -04007736
7737 delete [] intParams;
7738 }
7739 else
7740 {
7741 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007742 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007743 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007744 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007745}
7746
Kenneth Russell67ea1902014-10-06 16:44:50 -07007747void GL_APIENTRY glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007748{
7749 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7750 target, pname, params);
7751
Geoff Langbfdea662014-07-23 14:16:32 -04007752 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007753 if (context)
7754 {
7755 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007756 {
Geoff Langb1196682014-07-23 13:47:29 -04007757 context->recordError(gl::Error(GL_INVALID_OPERATION));
7758 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007759 }
Geoff Langbfdea662014-07-23 14:16:32 -04007760
7761 if (!gl::ValidBufferTarget(context, target))
7762 {
Geoff Langb1196682014-07-23 13:47:29 -04007763 context->recordError(gl::Error(GL_INVALID_ENUM));
7764 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007765 }
7766
7767 if (!gl::ValidBufferParameter(context, pname))
7768 {
Geoff Langb1196682014-07-23 13:47:29 -04007769 context->recordError(gl::Error(GL_INVALID_ENUM));
7770 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007771 }
7772
7773 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7774
7775 if (!buffer)
7776 {
7777 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007778 context->recordError(gl::Error(GL_INVALID_OPERATION));
7779 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007780 }
7781
7782 switch (pname)
7783 {
7784 case GL_BUFFER_USAGE:
7785 *params = static_cast<GLint64>(buffer->getUsage());
7786 break;
7787 case GL_BUFFER_SIZE:
7788 *params = buffer->getSize();
7789 break;
7790 case GL_BUFFER_ACCESS_FLAGS:
7791 *params = static_cast<GLint64>(buffer->getAccessFlags());
7792 break;
7793 case GL_BUFFER_MAPPED:
7794 *params = static_cast<GLint64>(buffer->isMapped());
7795 break;
7796 case GL_BUFFER_MAP_OFFSET:
7797 *params = buffer->getMapOffset();
7798 break;
7799 case GL_BUFFER_MAP_LENGTH:
7800 *params = buffer->getMapLength();
7801 break;
7802 default: UNREACHABLE(); break;
7803 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804 }
7805}
7806
Kenneth Russell67ea1902014-10-06 16:44:50 -07007807void GL_APIENTRY glGenSamplers(GLsizei count, GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007808{
7809 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7810
Geoff Langbfdea662014-07-23 14:16:32 -04007811 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007812 if (context)
7813 {
7814 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007815 {
Geoff Langb1196682014-07-23 13:47:29 -04007816 context->recordError(gl::Error(GL_INVALID_OPERATION));
7817 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007818 }
Geoff Langbfdea662014-07-23 14:16:32 -04007819
7820 if (count < 0)
7821 {
Geoff Langb1196682014-07-23 13:47:29 -04007822 context->recordError(gl::Error(GL_INVALID_VALUE));
7823 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007824 }
7825
7826 for (int i = 0; i < count; i++)
7827 {
7828 samplers[i] = context->createSampler();
7829 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830 }
7831}
7832
Kenneth Russell67ea1902014-10-06 16:44:50 -07007833void GL_APIENTRY glDeleteSamplers(GLsizei count, const GLuint* samplers)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007834{
7835 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7836
Geoff Langbfdea662014-07-23 14:16:32 -04007837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007838 if (context)
7839 {
7840 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007841 {
Geoff Langb1196682014-07-23 13:47:29 -04007842 context->recordError(gl::Error(GL_INVALID_OPERATION));
7843 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007844 }
Geoff Langbfdea662014-07-23 14:16:32 -04007845
7846 if (count < 0)
7847 {
Geoff Langb1196682014-07-23 13:47:29 -04007848 context->recordError(gl::Error(GL_INVALID_VALUE));
7849 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007850 }
7851
7852 for (int i = 0; i < count; i++)
7853 {
7854 context->deleteSampler(samplers[i]);
7855 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007856 }
7857}
7858
Kenneth Russell67ea1902014-10-06 16:44:50 -07007859GLboolean GL_APIENTRY glIsSampler(GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007860{
7861 EVENT("(GLuint sampler = %u)", sampler);
7862
Geoff Langbfdea662014-07-23 14:16:32 -04007863 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007864 if (context)
7865 {
7866 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007867 {
Geoff Langb1196682014-07-23 13:47:29 -04007868 context->recordError(gl::Error(GL_INVALID_OPERATION));
7869 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007870 }
Geoff Langbfdea662014-07-23 14:16:32 -04007871
7872 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007873 }
7874
7875 return GL_FALSE;
7876}
7877
Kenneth Russell67ea1902014-10-06 16:44:50 -07007878void GL_APIENTRY glBindSampler(GLuint unit, GLuint sampler)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007879{
7880 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7881
Geoff Langbfdea662014-07-23 14:16:32 -04007882 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007883 if (context)
7884 {
7885 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007886 {
Geoff Langb1196682014-07-23 13:47:29 -04007887 context->recordError(gl::Error(GL_INVALID_OPERATION));
7888 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007889 }
Geoff Langbfdea662014-07-23 14:16:32 -04007890
7891 if (sampler != 0 && !context->isSampler(sampler))
7892 {
Geoff Langb1196682014-07-23 13:47:29 -04007893 context->recordError(gl::Error(GL_INVALID_OPERATION));
7894 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007895 }
7896
Geoff Lang3a61c322014-07-10 13:01:54 -04007897 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007898 {
Geoff Langb1196682014-07-23 13:47:29 -04007899 context->recordError(gl::Error(GL_INVALID_VALUE));
7900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007901 }
7902
7903 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007904 }
7905}
7906
Kenneth Russell67ea1902014-10-06 16:44:50 -07007907void GL_APIENTRY glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007908{
7909 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7910
Geoff Langbfdea662014-07-23 14:16:32 -04007911 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007912 if (context)
7913 {
7914 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007915 {
Geoff Langb1196682014-07-23 13:47:29 -04007916 context->recordError(gl::Error(GL_INVALID_OPERATION));
7917 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007918 }
Geoff Langbfdea662014-07-23 14:16:32 -04007919
Geoff Langb1196682014-07-23 13:47:29 -04007920 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007921 {
7922 return;
7923 }
7924
7925 if (!gl::ValidateTexParamParameters(context, pname, param))
7926 {
7927 return;
7928 }
7929
7930 if (!context->isSampler(sampler))
7931 {
Geoff Langb1196682014-07-23 13:47:29 -04007932 context->recordError(gl::Error(GL_INVALID_OPERATION));
7933 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007934 }
7935
7936 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007937 }
7938}
7939
Kenneth Russell67ea1902014-10-06 16:44:50 -07007940void GL_APIENTRY glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007941{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007942 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007943}
7944
Kenneth Russell67ea1902014-10-06 16:44:50 -07007945void GL_APIENTRY glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007946{
7947 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7948
Geoff Langbfdea662014-07-23 14:16:32 -04007949 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007950 if (context)
7951 {
7952 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953 {
Geoff Langb1196682014-07-23 13:47:29 -04007954 context->recordError(gl::Error(GL_INVALID_OPERATION));
7955 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007956 }
Geoff Langbfdea662014-07-23 14:16:32 -04007957
Geoff Langb1196682014-07-23 13:47:29 -04007958 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007959 {
7960 return;
7961 }
7962
7963 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7964 {
7965 return;
7966 }
7967
7968 if (!context->isSampler(sampler))
7969 {
Geoff Langb1196682014-07-23 13:47:29 -04007970 context->recordError(gl::Error(GL_INVALID_OPERATION));
7971 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007972 }
7973
7974 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007975 }
7976}
7977
Kenneth Russell67ea1902014-10-06 16:44:50 -07007978void GL_APIENTRY glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007979{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007980 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007981}
7982
Kenneth Russell67ea1902014-10-06 16:44:50 -07007983void GL_APIENTRY glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007984{
7985 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* 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->getSamplerParameteri(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 glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008012{
8013 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
8014
Geoff Langbfdea662014-07-23 14:16:32 -04008015 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008016 if (context)
8017 {
8018 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008019 {
Geoff Langb1196682014-07-23 13:47:29 -04008020 context->recordError(gl::Error(GL_INVALID_OPERATION));
8021 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008022 }
Geoff Langbfdea662014-07-23 14:16:32 -04008023
Geoff Langb1196682014-07-23 13:47:29 -04008024 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04008025 {
8026 return;
8027 }
8028
8029 if (!context->isSampler(sampler))
8030 {
Geoff Langb1196682014-07-23 13:47:29 -04008031 context->recordError(gl::Error(GL_INVALID_OPERATION));
8032 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008033 }
8034
8035 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008036 }
8037}
8038
Kenneth Russell67ea1902014-10-06 16:44:50 -07008039void GL_APIENTRY glVertexAttribDivisor(GLuint index, GLuint divisor)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008040{
8041 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
8042
Geoff Langbfdea662014-07-23 14:16:32 -04008043 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008044 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008045 {
Geoff Langbfdea662014-07-23 14:16:32 -04008046 if (context->getClientVersion() < 3)
8047 {
Geoff Langb1196682014-07-23 13:47:29 -04008048 context->recordError(gl::Error(GL_INVALID_OPERATION));
8049 return;
8050 }
8051
8052 if (index >= gl::MAX_VERTEX_ATTRIBS)
8053 {
8054 context->recordError(gl::Error(GL_INVALID_VALUE));
8055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008056 }
8057
8058 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008059 }
8060}
8061
Kenneth Russell67ea1902014-10-06 16:44:50 -07008062void GL_APIENTRY glBindTransformFeedback(GLenum target, GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008063{
8064 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
8065
Geoff Langbfdea662014-07-23 14:16:32 -04008066 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008067 if (context)
8068 {
8069 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008070 {
Geoff Langb1196682014-07-23 13:47:29 -04008071 context->recordError(gl::Error(GL_INVALID_OPERATION));
8072 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008073 }
Geoff Langbfdea662014-07-23 14:16:32 -04008074
8075 switch (target)
8076 {
8077 case GL_TRANSFORM_FEEDBACK:
8078 {
8079 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
8080 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
8081 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
8082 {
Geoff Langb1196682014-07-23 13:47:29 -04008083 context->recordError(gl::Error(GL_INVALID_OPERATION));
8084 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008085 }
8086
8087 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
8088 if (context->getTransformFeedback(id) == NULL)
8089 {
Geoff Langb1196682014-07-23 13:47:29 -04008090 context->recordError(gl::Error(GL_INVALID_OPERATION));
8091 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008092 }
8093
8094 context->bindTransformFeedback(id);
8095 }
8096 break;
8097
8098 default:
Geoff Langb1196682014-07-23 13:47:29 -04008099 context->recordError(gl::Error(GL_INVALID_ENUM));
8100 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008101 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008102 }
8103}
8104
Kenneth Russell67ea1902014-10-06 16:44:50 -07008105void GL_APIENTRY glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008106{
8107 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
8108
Geoff Langbfdea662014-07-23 14:16:32 -04008109 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008110 if (context)
8111 {
8112 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008113 {
Geoff Langb1196682014-07-23 13:47:29 -04008114 context->recordError(gl::Error(GL_INVALID_OPERATION));
8115 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008116 }
Geoff Langbfdea662014-07-23 14:16:32 -04008117
8118 for (int i = 0; i < n; i++)
8119 {
8120 context->deleteTransformFeedback(ids[i]);
8121 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008122 }
8123}
8124
Kenneth Russell67ea1902014-10-06 16:44:50 -07008125void GL_APIENTRY glGenTransformFeedbacks(GLsizei n, GLuint* ids)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008126{
8127 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
8128
Geoff Langbfdea662014-07-23 14:16:32 -04008129 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008130 if (context)
8131 {
8132 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008133 {
Geoff Langb1196682014-07-23 13:47:29 -04008134 context->recordError(gl::Error(GL_INVALID_OPERATION));
8135 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008136 }
Geoff Langbfdea662014-07-23 14:16:32 -04008137
8138 for (int i = 0; i < n; i++)
8139 {
8140 ids[i] = context->createTransformFeedback();
8141 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008142 }
8143}
8144
Kenneth Russell67ea1902014-10-06 16:44:50 -07008145GLboolean GL_APIENTRY glIsTransformFeedback(GLuint id)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008146{
8147 EVENT("(GLuint id = %u)", id);
8148
Geoff Langbfdea662014-07-23 14:16:32 -04008149 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008150 if (context)
8151 {
8152 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008153 {
Geoff Langb1196682014-07-23 13:47:29 -04008154 context->recordError(gl::Error(GL_INVALID_OPERATION));
8155 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008156 }
Geoff Langbfdea662014-07-23 14:16:32 -04008157
8158 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008159 }
8160
8161 return GL_FALSE;
8162}
8163
Kenneth Russell67ea1902014-10-06 16:44:50 -07008164void GL_APIENTRY glPauseTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008165{
8166 EVENT("(void)");
8167
Geoff Langbfdea662014-07-23 14:16:32 -04008168 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008169 if (context)
8170 {
8171 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008172 {
Geoff Langb1196682014-07-23 13:47:29 -04008173 context->recordError(gl::Error(GL_INVALID_OPERATION));
8174 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008175 }
Geoff Langbfdea662014-07-23 14:16:32 -04008176
8177 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8178 ASSERT(transformFeedback != NULL);
8179
8180 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
8181 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
8182 {
Geoff Langb1196682014-07-23 13:47:29 -04008183 context->recordError(gl::Error(GL_INVALID_OPERATION));
8184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008185 }
8186
8187 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008188 }
8189}
8190
Kenneth Russell67ea1902014-10-06 16:44:50 -07008191void GL_APIENTRY glResumeTransformFeedback(void)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008192{
8193 EVENT("(void)");
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 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
8205 ASSERT(transformFeedback != NULL);
8206
8207 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
8208 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
8209 {
Geoff Langb1196682014-07-23 13:47:29 -04008210 context->recordError(gl::Error(GL_INVALID_OPERATION));
8211 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008212 }
8213
8214 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008215 }
8216}
8217
Kenneth Russell67ea1902014-10-06 16:44:50 -07008218void GL_APIENTRY glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008219{
8220 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
8221 program, bufSize, length, binaryFormat, binary);
8222
Geoff Langbfdea662014-07-23 14:16:32 -04008223 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008224 if (context)
8225 {
8226 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008227 {
Geoff Langb1196682014-07-23 13:47:29 -04008228 context->recordError(gl::Error(GL_INVALID_OPERATION));
8229 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008230 }
Geoff Langbfdea662014-07-23 14:16:32 -04008231
8232 // glGetProgramBinary
8233 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008234 }
8235}
8236
Kenneth Russell67ea1902014-10-06 16:44:50 -07008237void GL_APIENTRY glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008238{
8239 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
8240 program, binaryFormat, binary, length);
8241
Geoff Langbfdea662014-07-23 14:16:32 -04008242 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008243 if (context)
8244 {
8245 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008246 {
Geoff Langb1196682014-07-23 13:47:29 -04008247 context->recordError(gl::Error(GL_INVALID_OPERATION));
8248 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008249 }
Geoff Langbfdea662014-07-23 14:16:32 -04008250
8251 // glProgramBinary
8252 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008253 }
8254}
8255
Kenneth Russell67ea1902014-10-06 16:44:50 -07008256void GL_APIENTRY glProgramParameteri(GLuint program, GLenum pname, GLint value)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008257{
8258 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
8259 program, pname, value);
8260
Geoff Langbfdea662014-07-23 14:16:32 -04008261 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008262 if (context)
8263 {
8264 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008265 {
Geoff Langb1196682014-07-23 13:47:29 -04008266 context->recordError(gl::Error(GL_INVALID_OPERATION));
8267 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008268 }
Geoff Langbfdea662014-07-23 14:16:32 -04008269
8270 // glProgramParameteri
8271 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008272 }
8273}
8274
Kenneth Russell67ea1902014-10-06 16:44:50 -07008275void GL_APIENTRY glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008276{
8277 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
8278 target, numAttachments, attachments);
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);
Jamie Madill48faf802014-11-06 15:27:22 -05008295 ASSERT(framebuffer);
8296
8297 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008298 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008299 gl::Error error = framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
8300 if (error.isError())
8301 {
8302 context->recordError(error);
8303 return;
8304 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008305 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008306 }
8307}
8308
Kenneth Russell67ea1902014-10-06 16:44:50 -07008309void 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 +00008310{
8311 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8312 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8313 target, numAttachments, attachments, x, y, width, height);
8314
Geoff Langbfdea662014-07-23 14:16:32 -04008315 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008316 if (context)
8317 {
8318 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008319 {
Geoff Langb1196682014-07-23 13:47:29 -04008320 context->recordError(gl::Error(GL_INVALID_OPERATION));
8321 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008322 }
Geoff Langbfdea662014-07-23 14:16:32 -04008323
8324 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8325 {
8326 return;
8327 }
8328
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008329 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
Jamie Madill48faf802014-11-06 15:27:22 -05008330 ASSERT(framebuffer);
8331
8332 if (framebuffer->completeness(context->getData()) == GL_FRAMEBUFFER_COMPLETE)
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008333 {
Geoff Lang64f23f62014-09-10 14:40:12 -04008334 gl::Error error = framebuffer->invalidateSub(numAttachments, attachments, x, y, width, height);
8335 if (error.isError())
8336 {
8337 context->recordError(error);
8338 return;
8339 }
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008340 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008341 }
8342}
8343
Kenneth Russell67ea1902014-10-06 16:44:50 -07008344void GL_APIENTRY glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008345{
8346 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8347 target, levels, internalformat, width, height);
8348
Geoff Langbfdea662014-07-23 14:16:32 -04008349 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008350 if (context)
8351 {
8352 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008353 {
Geoff Langb1196682014-07-23 13:47:29 -04008354 context->recordError(gl::Error(GL_INVALID_OPERATION));
8355 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008356 }
Geoff Langbfdea662014-07-23 14:16:32 -04008357
8358 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8359 {
8360 return;
8361 }
8362
8363 switch (target)
8364 {
8365 case GL_TEXTURE_2D:
8366 {
8367 gl::Texture2D *texture2d = context->getTexture2D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008368 gl::Error error = texture2d->storage(levels, internalformat, width, height);
8369 if (error.isError())
8370 {
8371 context->recordError(error);
8372 return;
8373 }
Geoff Langbfdea662014-07-23 14:16:32 -04008374 }
8375 break;
8376
8377 case GL_TEXTURE_CUBE_MAP:
8378 {
8379 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008380 gl::Error error = textureCube->storage(levels, internalformat, width);
8381 if (error.isError())
8382 {
8383 context->recordError(error);
8384 return;
8385 }
Geoff Langbfdea662014-07-23 14:16:32 -04008386 }
8387 break;
8388
8389 default:
Geoff Langb1196682014-07-23 13:47:29 -04008390 context->recordError(gl::Error(GL_INVALID_ENUM));
8391 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008392 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008393 }
8394}
8395
Kenneth Russell67ea1902014-10-06 16:44:50 -07008396void 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 +00008397{
8398 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8399 "GLsizei height = %d, GLsizei depth = %d)",
8400 target, levels, internalformat, width, height, depth);
8401
Geoff Langbfdea662014-07-23 14:16:32 -04008402 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008403 if (context)
8404 {
8405 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008406 {
Geoff Langb1196682014-07-23 13:47:29 -04008407 context->recordError(gl::Error(GL_INVALID_OPERATION));
8408 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008409 }
Geoff Langbfdea662014-07-23 14:16:32 -04008410
8411 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8412 {
8413 return;
8414 }
8415
8416 switch (target)
8417 {
8418 case GL_TEXTURE_3D:
8419 {
8420 gl::Texture3D *texture3d = context->getTexture3D();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008421 gl::Error error = texture3d->storage(levels, internalformat, width, height, depth);
8422 if (error.isError())
8423 {
8424 context->recordError(error);
8425 return;
8426 }
Geoff Langbfdea662014-07-23 14:16:32 -04008427 }
8428 break;
8429
8430 case GL_TEXTURE_2D_ARRAY:
8431 {
8432 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
Geoff Lang1f8532b2014-09-05 09:46:13 -04008433 gl::Error error = texture2darray->storage(levels, internalformat, width, height, depth);
8434 if (error.isError())
8435 {
8436 context->recordError(error);
8437 return;
8438 }
Geoff Langbfdea662014-07-23 14:16:32 -04008439 }
8440 break;
8441
8442 default:
8443 UNREACHABLE();
8444 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008445 }
8446}
8447
Kenneth Russell67ea1902014-10-06 16:44:50 -07008448void GL_APIENTRY glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008449{
8450 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8451 "GLint* params = 0x%0.8p)",
8452 target, internalformat, pname, bufSize, params);
8453
Geoff Langbfdea662014-07-23 14:16:32 -04008454 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008455 if (context)
8456 {
8457 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008458 {
Geoff Langb1196682014-07-23 13:47:29 -04008459 context->recordError(gl::Error(GL_INVALID_OPERATION));
8460 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008461 }
Geoff Langbfdea662014-07-23 14:16:32 -04008462
8463 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8464 if (!formatCaps.renderable)
8465 {
Geoff Langb1196682014-07-23 13:47:29 -04008466 context->recordError(gl::Error(GL_INVALID_ENUM));
8467 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008468 }
8469
8470 if (target != GL_RENDERBUFFER)
8471 {
Geoff Langb1196682014-07-23 13:47:29 -04008472 context->recordError(gl::Error(GL_INVALID_ENUM));
8473 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008474 }
8475
8476 if (bufSize < 0)
8477 {
Geoff Langb1196682014-07-23 13:47:29 -04008478 context->recordError(gl::Error(GL_INVALID_VALUE));
8479 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008480 }
8481
8482 switch (pname)
8483 {
8484 case GL_NUM_SAMPLE_COUNTS:
8485 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008486 {
8487 *params = formatCaps.sampleCounts.size();
8488 }
Geoff Langbfdea662014-07-23 14:16:32 -04008489 break;
Geoff Langb1196682014-07-23 13:47:29 -04008490
Geoff Langbfdea662014-07-23 14:16:32 -04008491 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008492 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008493 break;
Geoff Langb1196682014-07-23 13:47:29 -04008494
Geoff Langbfdea662014-07-23 14:16:32 -04008495 default:
Geoff Langb1196682014-07-23 13:47:29 -04008496 context->recordError(gl::Error(GL_INVALID_ENUM));
8497 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008499 }
8500}
8501
8502// Extension functions
8503
Kenneth Russell67ea1902014-10-06 16:44:50 -07008504void 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 +00008505 GLbitfield mask, GLenum filter)
8506{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008507 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008508 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8509 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8510 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8511
Geoff Langbfdea662014-07-23 14:16:32 -04008512 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008513 if (context)
8514 {
8515 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8516 dstX0, dstY0, dstX1, dstY1, mask, filter,
8517 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008518 {
Geoff Langbfdea662014-07-23 14:16:32 -04008519 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008520 }
Geoff Langbfdea662014-07-23 14:16:32 -04008521
Geoff Lang64839152014-08-26 16:23:25 -04008522 gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8523 mask, filter);
8524 if (error.isError())
8525 {
8526 context->recordError(error);
8527 return;
8528 }
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008529 }
8530}
8531
Kenneth Russell67ea1902014-10-06 16:44:50 -07008532void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008533 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008534{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008535 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008536 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008537 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008538 target, level, internalformat, width, height, depth, border, format, type, pixels);
8539
Geoff Langbfdea662014-07-23 14:16:32 -04008540 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008541}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008542
Kenneth Russell67ea1902014-10-06 16:44:50 -07008543void GL_APIENTRY glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008544 GLenum *binaryFormat, void *binary)
8545{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008546 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 +00008547 program, bufSize, length, binaryFormat, binary);
8548
Geoff Langbfdea662014-07-23 14:16:32 -04008549 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008550 if (context)
8551 {
8552 gl::Program *programObject = context->getProgram(program);
8553
8554 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008555 {
Geoff Langb1196682014-07-23 13:47:29 -04008556 context->recordError(gl::Error(GL_INVALID_OPERATION));
8557 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008558 }
Geoff Langbfdea662014-07-23 14:16:32 -04008559
8560 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8561
8562 if (!programBinary)
8563 {
Geoff Langb1196682014-07-23 13:47:29 -04008564 context->recordError(gl::Error(GL_INVALID_OPERATION));
8565 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008566 }
8567
Geoff Langb543aff2014-09-30 14:52:54 -04008568 gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length);
8569 if (error.isError())
Geoff Langbfdea662014-07-23 14:16:32 -04008570 {
Geoff Langb543aff2014-09-30 14:52:54 -04008571 context->recordError(error);
Geoff Langb1196682014-07-23 13:47:29 -04008572 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008573 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008574 }
8575}
8576
Kenneth Russell67ea1902014-10-06 16:44:50 -07008577void GL_APIENTRY glProgramBinaryOES(GLuint program, GLenum binaryFormat,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008578 const void *binary, GLint length)
8579{
8580 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
8581 program, binaryFormat, binary, length);
8582
Geoff Langbfdea662014-07-23 14:16:32 -04008583 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008584 if (context)
8585 {
Geoff Lang900013c2014-07-07 11:32:19 -04008586 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8587 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008588 {
Geoff Langb1196682014-07-23 13:47:29 -04008589 context->recordError(gl::Error(GL_INVALID_ENUM));
8590 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008591 }
Geoff Langbfdea662014-07-23 14:16:32 -04008592
8593 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008594 if (!programObject)
8595 {
Geoff Langb1196682014-07-23 13:47:29 -04008596 context->recordError(gl::Error(GL_INVALID_OPERATION));
8597 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008598 }
8599
Geoff Langb543aff2014-09-30 14:52:54 -04008600 gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length);
8601 if (error.isError())
8602 {
8603 context->recordError(error);
8604 return;
8605 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008606 }
8607}
8608
Kenneth Russell67ea1902014-10-06 16:44:50 -07008609void GL_APIENTRY glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008610{
8611 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8612
Geoff Langbfdea662014-07-23 14:16:32 -04008613 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008614 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008615 {
Geoff Langbfdea662014-07-23 14:16:32 -04008616 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008617 {
Geoff Langb1196682014-07-23 13:47:29 -04008618 context->recordError(gl::Error(GL_INVALID_VALUE));
8619 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008620 }
8621
Jamie Madill48faf802014-11-06 15:27:22 -05008622 ASSERT(context->getState().getDrawFramebuffer());
8623
Geoff Langbfdea662014-07-23 14:16:32 -04008624 if (context->getState().getDrawFramebuffer()->id() == 0)
8625 {
8626 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008627 {
Geoff Langb1196682014-07-23 13:47:29 -04008628 context->recordError(gl::Error(GL_INVALID_OPERATION));
8629 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008630 }
8631
Geoff Langbfdea662014-07-23 14:16:32 -04008632 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008633 {
Geoff Langb1196682014-07-23 13:47:29 -04008634 context->recordError(gl::Error(GL_INVALID_OPERATION));
8635 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008636 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008637 }
Geoff Langbfdea662014-07-23 14:16:32 -04008638 else
8639 {
8640 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8641 {
8642 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8643 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8644 {
Geoff Langb1196682014-07-23 13:47:29 -04008645 context->recordError(gl::Error(GL_INVALID_OPERATION));
8646 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008647 }
8648 }
8649 }
8650
8651 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
Jamie Madill48faf802014-11-06 15:27:22 -05008652 ASSERT(framebuffer);
Geoff Langbfdea662014-07-23 14:16:32 -04008653
8654 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8655 {
8656 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8657 }
8658
8659 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8660 {
8661 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8662 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008663 }
8664}
8665
Kenneth Russell67ea1902014-10-06 16:44:50 -07008666void GL_APIENTRY glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
Shannon Woodsb3801742014-03-27 14:59:19 -04008667{
8668 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8669
Geoff Langbfdea662014-07-23 14:16:32 -04008670 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008671 if (context)
8672 {
8673 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008674 {
Geoff Langb1196682014-07-23 13:47:29 -04008675 context->recordError(gl::Error(GL_INVALID_ENUM));
8676 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008677 }
Geoff Langbfdea662014-07-23 14:16:32 -04008678
8679 if (pname != GL_BUFFER_MAP_POINTER)
8680 {
Geoff Langb1196682014-07-23 13:47:29 -04008681 context->recordError(gl::Error(GL_INVALID_ENUM));
8682 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008683 }
8684
8685 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8686
8687 if (!buffer || !buffer->isMapped())
8688 {
8689 *params = NULL;
8690 }
8691 else
8692 {
8693 *params = buffer->getMapPointer();
8694 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008695 }
8696}
8697
Kenneth Russell67ea1902014-10-06 16:44:50 -07008698void * GL_APIENTRY glMapBufferOES(GLenum target, GLenum access)
Shannon Woodsb3801742014-03-27 14:59:19 -04008699{
8700 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8701
Geoff Langbfdea662014-07-23 14:16:32 -04008702 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008703 if (context)
8704 {
8705 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008706 {
Geoff Langb1196682014-07-23 13:47:29 -04008707 context->recordError(gl::Error(GL_INVALID_ENUM));
8708 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008709 }
Geoff Langbfdea662014-07-23 14:16:32 -04008710
8711 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8712
8713 if (buffer == NULL)
8714 {
Geoff Langb1196682014-07-23 13:47:29 -04008715 context->recordError(gl::Error(GL_INVALID_OPERATION));
8716 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008717 }
8718
8719 if (access != GL_WRITE_ONLY_OES)
8720 {
Geoff Langb1196682014-07-23 13:47:29 -04008721 context->recordError(gl::Error(GL_INVALID_ENUM));
8722 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008723 }
8724
8725 if (buffer->isMapped())
8726 {
Geoff Langb1196682014-07-23 13:47:29 -04008727 context->recordError(gl::Error(GL_INVALID_OPERATION));
8728 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008729 }
8730
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008731 gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
8732 if (error.isError())
8733 {
8734 context->recordError(error);
8735 return NULL;
8736 }
8737
8738 return buffer->getMapPointer();
Shannon Woodsb3801742014-03-27 14:59:19 -04008739 }
8740
8741 return NULL;
8742}
8743
Kenneth Russell67ea1902014-10-06 16:44:50 -07008744GLboolean GL_APIENTRY glUnmapBufferOES(GLenum target)
Shannon Woodsb3801742014-03-27 14:59:19 -04008745{
8746 EVENT("(GLenum target = 0x%X)", target);
8747
Geoff Langbfdea662014-07-23 14:16:32 -04008748 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008749 if (context)
8750 {
8751 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008752 {
Geoff Langb1196682014-07-23 13:47:29 -04008753 context->recordError(gl::Error(GL_INVALID_ENUM));
8754 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008755 }
Geoff Langbfdea662014-07-23 14:16:32 -04008756
8757 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8758
8759 if (buffer == NULL || !buffer->isMapped())
8760 {
Geoff Langb1196682014-07-23 13:47:29 -04008761 context->recordError(gl::Error(GL_INVALID_OPERATION));
8762 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008763 }
8764
8765 // TODO: detect if we had corruption. if so, throw an error and return false.
8766
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008767 gl::Error error = buffer->unmap();
8768 if (error.isError())
8769 {
8770 context->recordError(error);
8771 return GL_FALSE;
8772 }
Geoff Langbfdea662014-07-23 14:16:32 -04008773
8774 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008775 }
8776
8777 return GL_FALSE;
8778}
8779
Kenneth Russell67ea1902014-10-06 16:44:50 -07008780void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
Shannon Woods916e7692014-03-27 16:58:22 -04008781{
8782 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8783 target, offset, length, access);
8784
Geoff Langbfdea662014-07-23 14:16:32 -04008785 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008786 if (context)
8787 {
8788 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008789 {
Geoff Langb1196682014-07-23 13:47:29 -04008790 context->recordError(gl::Error(GL_INVALID_ENUM));
8791 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008792 }
Geoff Langbfdea662014-07-23 14:16:32 -04008793
8794 if (offset < 0 || length < 0)
8795 {
Geoff Langb1196682014-07-23 13:47:29 -04008796 context->recordError(gl::Error(GL_INVALID_VALUE));
8797 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008798 }
8799
8800 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8801
8802 if (buffer == NULL)
8803 {
Geoff Langb1196682014-07-23 13:47:29 -04008804 context->recordError(gl::Error(GL_INVALID_OPERATION));
8805 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008806 }
8807
8808 // Check for buffer overflow
8809 size_t offsetSize = static_cast<size_t>(offset);
8810 size_t lengthSize = static_cast<size_t>(length);
8811
8812 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8813 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8814 {
Geoff Langb1196682014-07-23 13:47:29 -04008815 context->recordError(gl::Error(GL_INVALID_VALUE));
8816 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008817 }
8818
8819 // Check for invalid bits in the mask
8820 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8821 GL_MAP_WRITE_BIT |
8822 GL_MAP_INVALIDATE_RANGE_BIT |
8823 GL_MAP_INVALIDATE_BUFFER_BIT |
8824 GL_MAP_FLUSH_EXPLICIT_BIT |
8825 GL_MAP_UNSYNCHRONIZED_BIT;
8826
8827 if (access & ~(allAccessBits))
8828 {
Geoff Langb1196682014-07-23 13:47:29 -04008829 context->recordError(gl::Error(GL_INVALID_VALUE));
8830 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008831 }
8832
8833 if (length == 0 || buffer->isMapped())
8834 {
Geoff Langb1196682014-07-23 13:47:29 -04008835 context->recordError(gl::Error(GL_INVALID_OPERATION));
8836 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008837 }
8838
8839 // Check for invalid bit combinations
8840 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8841 {
Geoff Langb1196682014-07-23 13:47:29 -04008842 context->recordError(gl::Error(GL_INVALID_OPERATION));
8843 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008844 }
8845
8846 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8847 GL_MAP_INVALIDATE_BUFFER_BIT |
8848 GL_MAP_UNSYNCHRONIZED_BIT;
8849
8850 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8851 {
Geoff Langb1196682014-07-23 13:47:29 -04008852 context->recordError(gl::Error(GL_INVALID_OPERATION));
8853 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008854 }
8855
8856 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8857 {
Geoff Langb1196682014-07-23 13:47:29 -04008858 context->recordError(gl::Error(GL_INVALID_OPERATION));
8859 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008860 }
8861
Geoff Lang2a1c15a2014-07-25 11:43:00 -04008862 gl::Error error = buffer->mapRange(offset, length, access);
8863 if (error.isError())
8864 {
8865 context->recordError(error);
8866 return NULL;
8867 }
8868
8869 return buffer->getMapPointer();
Shannon Woods916e7692014-03-27 16:58:22 -04008870 }
8871
8872 return NULL;
8873}
8874
Kenneth Russell67ea1902014-10-06 16:44:50 -07008875void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
Shannon Woods916e7692014-03-27 16:58:22 -04008876{
8877 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8878
Geoff Langbfdea662014-07-23 14:16:32 -04008879 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008880 if (context)
8881 {
8882 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008883 {
Geoff Langb1196682014-07-23 13:47:29 -04008884 context->recordError(gl::Error(GL_INVALID_VALUE));
8885 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008886 }
Geoff Langbfdea662014-07-23 14:16:32 -04008887
8888 if (!gl::ValidBufferTarget(context, target))
8889 {
Geoff Langb1196682014-07-23 13:47:29 -04008890 context->recordError(gl::Error(GL_INVALID_ENUM));
8891 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008892 }
8893
8894 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8895
8896 if (buffer == NULL)
8897 {
Geoff Langb1196682014-07-23 13:47:29 -04008898 context->recordError(gl::Error(GL_INVALID_OPERATION));
8899 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008900 }
8901
8902 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8903 {
Geoff Langb1196682014-07-23 13:47:29 -04008904 context->recordError(gl::Error(GL_INVALID_OPERATION));
8905 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008906 }
8907
8908 // Check for buffer overflow
8909 size_t offsetSize = static_cast<size_t>(offset);
8910 size_t lengthSize = static_cast<size_t>(length);
8911
8912 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8913 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8914 {
Geoff Langb1196682014-07-23 13:47:29 -04008915 context->recordError(gl::Error(GL_INVALID_VALUE));
8916 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008917 }
8918
8919 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008920 }
8921}
8922
Kenneth Russell67ea1902014-10-06 16:44:50 -07008923__eglMustCastToProperFunctionPointerType EGLAPIENTRY glGetProcAddress(const char *procname)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008924{
8925 struct Extension
8926 {
8927 const char *name;
8928 __eglMustCastToProperFunctionPointerType address;
8929 };
8930
8931 static const Extension glExtensions[] =
8932 {
8933 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008934 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008935 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008936 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8937 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8938 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8939 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8940 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8941 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8942 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008943 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008944 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008945 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8946 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8947 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8948 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008949 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8950 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8951 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8952 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8953 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8954 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8955 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008956 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008957 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8958 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8959 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008960 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008961 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8962 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8963 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008964 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8965 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8966 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008967
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008968 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008969 {
8970 if (strcmp(procname, glExtensions[ext].name) == 0)
8971 {
8972 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8973 }
8974 }
8975
8976 return NULL;
8977}
8978
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008979// Non-public functions used by EGL
8980
Kenneth Russell67ea1902014-10-06 16:44:50 -07008981bool EGLAPIENTRY glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008982{
8983 EVENT("(egl::Surface* surface = 0x%0.8p)",
8984 surface);
8985
Geoff Langbfdea662014-07-23 14:16:32 -04008986 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008987 if (context)
8988 {
8989 gl::Texture2D *textureObject = context->getTexture2D();
8990 ASSERT(textureObject != NULL);
8991
8992 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008993 {
Geoff Langbfdea662014-07-23 14:16:32 -04008994 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008995 }
Geoff Langbfdea662014-07-23 14:16:32 -04008996
8997 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008998 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008999
9000 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00009001}
9002
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009003}