blob: 62f98d8a781f77819f9cd1bf6a2042fb76c27b8f [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
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000038void __stdcall glActiveTexture(GLenum texture)
39{
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
55void __stdcall glAttachShader(GLuint program, GLuint shader)
56{
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
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000101void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
102{
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
113 context->beginQuery(target, id);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000114 }
115}
116
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000117void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000118{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000119 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000120
Geoff Langbfdea662014-07-23 14:16:32 -0400121 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400122 if (context)
123 {
Geoff Langb1196682014-07-23 13:47:29 -0400124 if (index >= gl::MAX_VERTEX_ATTRIBS)
125 {
126 context->recordError(gl::Error(GL_INVALID_VALUE));
127 return;
128 }
129
Geoff Langbfdea662014-07-23 14:16:32 -0400130 gl::Program *programObject = context->getProgram(program);
131
132 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000133 {
Geoff Langbfdea662014-07-23 14:16:32 -0400134 if (context->getShader(program))
daniel@transgaming.com98079832010-04-13 03:26:29 +0000135 {
Geoff Langb1196682014-07-23 13:47:29 -0400136 context->recordError(gl::Error(GL_INVALID_OPERATION));
137 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138 }
Geoff Langbfdea662014-07-23 14:16:32 -0400139 else
140 {
Geoff Langb1196682014-07-23 13:47:29 -0400141 context->recordError(gl::Error(GL_INVALID_VALUE));
142 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400143 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000144 }
Geoff Langbfdea662014-07-23 14:16:32 -0400145
146 if (strncmp(name, "gl_", 3) == 0)
147 {
Geoff Langb1196682014-07-23 13:47:29 -0400148 context->recordError(gl::Error(GL_INVALID_OPERATION));
149 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400150 }
151
152 programObject->bindAttributeLocation(index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000153 }
154}
155
156void __stdcall glBindBuffer(GLenum target, GLuint buffer)
157{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000158 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000159
Geoff Langbfdea662014-07-23 14:16:32 -0400160 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400161 if (context)
162 {
163 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000164 {
Geoff Langb1196682014-07-23 13:47:29 -0400165 context->recordError(gl::Error(GL_INVALID_ENUM));
166 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000167 }
Geoff Langbfdea662014-07-23 14:16:32 -0400168
169 switch (target)
170 {
171 case GL_ARRAY_BUFFER:
172 context->bindArrayBuffer(buffer);
173 return;
174 case GL_ELEMENT_ARRAY_BUFFER:
175 context->bindElementArrayBuffer(buffer);
176 return;
177 case GL_COPY_READ_BUFFER:
178 context->bindCopyReadBuffer(buffer);
179 return;
180 case GL_COPY_WRITE_BUFFER:
181 context->bindCopyWriteBuffer(buffer);
182 return;
183 case GL_PIXEL_PACK_BUFFER:
184 context->bindPixelPackBuffer(buffer);
185 return;
186 case GL_PIXEL_UNPACK_BUFFER:
187 context->bindPixelUnpackBuffer(buffer);
188 return;
189 case GL_UNIFORM_BUFFER:
190 context->bindGenericUniformBuffer(buffer);
191 return;
192 case GL_TRANSFORM_FEEDBACK_BUFFER:
193 context->bindGenericTransformFeedbackBuffer(buffer);
194 return;
Geoff Langb1196682014-07-23 13:47:29 -0400195
Geoff Langbfdea662014-07-23 14:16:32 -0400196 default:
Geoff Langb1196682014-07-23 13:47:29 -0400197 context->recordError(gl::Error(GL_INVALID_ENUM));
198 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400199 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000200 }
201}
202
203void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
204{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000205 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000206
Geoff Langbfdea662014-07-23 14:16:32 -0400207 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400208 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000209 {
Geoff Langb1196682014-07-23 13:47:29 -0400210 if (!gl::ValidFramebufferTarget(target))
211 {
212 context->recordError(gl::Error(GL_INVALID_ENUM));
213 return;
214 }
215
Geoff Langbfdea662014-07-23 14:16:32 -0400216 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
217 {
218 context->bindReadFramebuffer(framebuffer);
219 }
220
221 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
222 {
223 context->bindDrawFramebuffer(framebuffer);
224 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000225 }
226}
227
228void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
229{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000230 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000231
Geoff Langbfdea662014-07-23 14:16:32 -0400232 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400233 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234 {
Geoff Langb1196682014-07-23 13:47:29 -0400235 if (target != GL_RENDERBUFFER)
236 {
237 context->recordError(gl::Error(GL_INVALID_ENUM));
238 return;
239 }
240
Geoff Langbfdea662014-07-23 14:16:32 -0400241 context->bindRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000242 }
243}
244
245void __stdcall glBindTexture(GLenum target, GLuint texture)
246{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000247 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000248
Geoff Langbfdea662014-07-23 14:16:32 -0400249 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400250 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000251 {
Geoff Langbfdea662014-07-23 14:16:32 -0400252 gl::Texture *textureObject = context->getTexture(texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
Geoff Langbfdea662014-07-23 14:16:32 -0400254 if (textureObject && textureObject->getTarget() != target && texture != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000255 {
Geoff Langb1196682014-07-23 13:47:29 -0400256 context->recordError(gl::Error(GL_INVALID_OPERATION));
257 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400258 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000259
Geoff Langbfdea662014-07-23 14:16:32 -0400260 switch (target)
261 {
262 case GL_TEXTURE_2D:
263 context->bindTexture2D(texture);
264 return;
Geoff Langb1196682014-07-23 13:47:29 -0400265
Geoff Langbfdea662014-07-23 14:16:32 -0400266 case GL_TEXTURE_CUBE_MAP:
267 context->bindTextureCubeMap(texture);
268 return;
Geoff Langb1196682014-07-23 13:47:29 -0400269
Geoff Langbfdea662014-07-23 14:16:32 -0400270 case GL_TEXTURE_3D:
271 if (context->getClientVersion() < 3)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000272 {
Geoff Langb1196682014-07-23 13:47:29 -0400273 context->recordError(gl::Error(GL_INVALID_ENUM));
274 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000275 }
Geoff Langbfdea662014-07-23 14:16:32 -0400276 context->bindTexture3D(texture);
277 return;
Geoff Langb1196682014-07-23 13:47:29 -0400278
Geoff Langbfdea662014-07-23 14:16:32 -0400279 case GL_TEXTURE_2D_ARRAY:
280 if (context->getClientVersion() < 3)
281 {
Geoff Langb1196682014-07-23 13:47:29 -0400282 context->recordError(gl::Error(GL_INVALID_ENUM));
283 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400284 }
285 context->bindTexture2DArray(texture);
286 return;
Geoff Langb1196682014-07-23 13:47:29 -0400287
Geoff Langbfdea662014-07-23 14:16:32 -0400288 default:
Geoff Langb1196682014-07-23 13:47:29 -0400289 context->recordError(gl::Error(GL_INVALID_ENUM));
290 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000291 }
292 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293}
294
295void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
296{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000297 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000298 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000299
Geoff Langbfdea662014-07-23 14:16:32 -0400300 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000301
Geoff Langbfdea662014-07-23 14:16:32 -0400302 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000303 {
Geoff Langbfdea662014-07-23 14:16:32 -0400304 context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000305 }
306}
307
308void __stdcall glBlendEquation(GLenum mode)
309{
310 glBlendEquationSeparate(mode, mode);
311}
312
313void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
314{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000315 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000316
Geoff Langbfdea662014-07-23 14:16:32 -0400317 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400318 if (context)
319 {
Geoff Langb1196682014-07-23 13:47:29 -0400320 switch (modeRGB)
321 {
322 case GL_FUNC_ADD:
323 case GL_FUNC_SUBTRACT:
324 case GL_FUNC_REVERSE_SUBTRACT:
325 case GL_MIN:
326 case GL_MAX:
327 break;
328
329 default:
330 context->recordError(gl::Error(GL_INVALID_ENUM));
331 return;
332 }
333
334 switch (modeAlpha)
335 {
336 case GL_FUNC_ADD:
337 case GL_FUNC_SUBTRACT:
338 case GL_FUNC_REVERSE_SUBTRACT:
339 case GL_MIN:
340 case GL_MAX:
341 break;
342
343 default:
344 context->recordError(gl::Error(GL_INVALID_ENUM));
345 return;
346 }
347
Geoff Langbfdea662014-07-23 14:16:32 -0400348 context->getState().setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000349 }
350}
351
352void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
353{
354 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
355}
356
357void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000359 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 +0000360 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000361
Geoff Langbfdea662014-07-23 14:16:32 -0400362 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400363 if (context)
364 {
Geoff Langb1196682014-07-23 13:47:29 -0400365 switch (srcRGB)
366 {
367 case GL_ZERO:
368 case GL_ONE:
369 case GL_SRC_COLOR:
370 case GL_ONE_MINUS_SRC_COLOR:
371 case GL_DST_COLOR:
372 case GL_ONE_MINUS_DST_COLOR:
373 case GL_SRC_ALPHA:
374 case GL_ONE_MINUS_SRC_ALPHA:
375 case GL_DST_ALPHA:
376 case GL_ONE_MINUS_DST_ALPHA:
377 case GL_CONSTANT_COLOR:
378 case GL_ONE_MINUS_CONSTANT_COLOR:
379 case GL_CONSTANT_ALPHA:
380 case GL_ONE_MINUS_CONSTANT_ALPHA:
381 case GL_SRC_ALPHA_SATURATE:
382 break;
383
384 default:
385 context->recordError(gl::Error(GL_INVALID_ENUM));
386 return;
387 }
388
389 switch (dstRGB)
390 {
391 case GL_ZERO:
392 case GL_ONE:
393 case GL_SRC_COLOR:
394 case GL_ONE_MINUS_SRC_COLOR:
395 case GL_DST_COLOR:
396 case GL_ONE_MINUS_DST_COLOR:
397 case GL_SRC_ALPHA:
398 case GL_ONE_MINUS_SRC_ALPHA:
399 case GL_DST_ALPHA:
400 case GL_ONE_MINUS_DST_ALPHA:
401 case GL_CONSTANT_COLOR:
402 case GL_ONE_MINUS_CONSTANT_COLOR:
403 case GL_CONSTANT_ALPHA:
404 case GL_ONE_MINUS_CONSTANT_ALPHA:
405 break;
406
407 case GL_SRC_ALPHA_SATURATE:
408 if (context->getClientVersion() < 3)
409 {
410 context->recordError(gl::Error(GL_INVALID_ENUM));
411 return;
412 }
413 break;
414
415 default:
416 context->recordError(gl::Error(GL_INVALID_ENUM));
417 return;
418 }
419
420 switch (srcAlpha)
421 {
422 case GL_ZERO:
423 case GL_ONE:
424 case GL_SRC_COLOR:
425 case GL_ONE_MINUS_SRC_COLOR:
426 case GL_DST_COLOR:
427 case GL_ONE_MINUS_DST_COLOR:
428 case GL_SRC_ALPHA:
429 case GL_ONE_MINUS_SRC_ALPHA:
430 case GL_DST_ALPHA:
431 case GL_ONE_MINUS_DST_ALPHA:
432 case GL_CONSTANT_COLOR:
433 case GL_ONE_MINUS_CONSTANT_COLOR:
434 case GL_CONSTANT_ALPHA:
435 case GL_ONE_MINUS_CONSTANT_ALPHA:
436 case GL_SRC_ALPHA_SATURATE:
437 break;
438
439 default:
440 context->recordError(gl::Error(GL_INVALID_ENUM));
441 return;
442 }
443
444 switch (dstAlpha)
445 {
446 case GL_ZERO:
447 case GL_ONE:
448 case GL_SRC_COLOR:
449 case GL_ONE_MINUS_SRC_COLOR:
450 case GL_DST_COLOR:
451 case GL_ONE_MINUS_DST_COLOR:
452 case GL_SRC_ALPHA:
453 case GL_ONE_MINUS_SRC_ALPHA:
454 case GL_DST_ALPHA:
455 case GL_ONE_MINUS_DST_ALPHA:
456 case GL_CONSTANT_COLOR:
457 case GL_ONE_MINUS_CONSTANT_COLOR:
458 case GL_CONSTANT_ALPHA:
459 case GL_ONE_MINUS_CONSTANT_ALPHA:
460 break;
461
462 case GL_SRC_ALPHA_SATURATE:
463 if (context->getClientVersion() < 3)
464 {
465 context->recordError(gl::Error(GL_INVALID_ENUM));
466 return;
467 }
468 break;
469
470 default:
471 context->recordError(gl::Error(GL_INVALID_ENUM));
472 return;
473 }
474
475 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
476 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
477
478 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
479 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
480
481 if (constantColorUsed && constantAlphaUsed)
482 {
483 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
484 context->recordError(gl::Error(GL_INVALID_OPERATION));
485 return;
486 }
487
Geoff Langbfdea662014-07-23 14:16:32 -0400488 context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000489 }
490}
491
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000492void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000493{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000494 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 +0000495 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000496
Geoff Langbfdea662014-07-23 14:16:32 -0400497 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400498 if (context)
499 {
Geoff Langb1196682014-07-23 13:47:29 -0400500 if (size < 0)
501 {
502 context->recordError(gl::Error(GL_INVALID_VALUE));
503 return;
504 }
505
506 switch (usage)
507 {
508 case GL_STREAM_DRAW:
509 case GL_STATIC_DRAW:
510 case GL_DYNAMIC_DRAW:
511 break;
512
513 case GL_STREAM_READ:
514 case GL_STREAM_COPY:
515 case GL_STATIC_READ:
516 case GL_STATIC_COPY:
517 case GL_DYNAMIC_READ:
518 case GL_DYNAMIC_COPY:
519 if (context->getClientVersion() < 3)
520 {
521 context->recordError(gl::Error(GL_INVALID_ENUM));
522 return;
523 }
524 break;
525
526 default:
527 context->recordError(gl::Error(GL_INVALID_ENUM));
528 return;
529 }
530
Geoff Langbfdea662014-07-23 14:16:32 -0400531 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000532 {
Geoff Langb1196682014-07-23 13:47:29 -0400533 context->recordError(gl::Error(GL_INVALID_ENUM));
534 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000535 }
536
Geoff Langbfdea662014-07-23 14:16:32 -0400537 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
538
539 if (!buffer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000540 {
Geoff Langb1196682014-07-23 13:47:29 -0400541 context->recordError(gl::Error(GL_INVALID_OPERATION));
542 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000543 }
Geoff Langbfdea662014-07-23 14:16:32 -0400544
545 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000546 }
547}
548
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000549void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000550{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000551 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 +0000552 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000553
Geoff Langbfdea662014-07-23 14:16:32 -0400554 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400555 if (context)
556 {
Geoff Langb1196682014-07-23 13:47:29 -0400557 if (size < 0 || offset < 0)
558 {
559 context->recordError(gl::Error(GL_INVALID_VALUE));
560 return;
561 }
562
563 if (data == NULL)
564 {
565 return;
566 }
567
Geoff Langbfdea662014-07-23 14:16:32 -0400568 if (!gl::ValidBufferTarget(context, target))
569 {
Geoff Langb1196682014-07-23 13:47:29 -0400570 context->recordError(gl::Error(GL_INVALID_ENUM));
571 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400572 }
573
574 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
575
576 if (!buffer)
577 {
Geoff Langb1196682014-07-23 13:47:29 -0400578 context->recordError(gl::Error(GL_INVALID_OPERATION));
579 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400580 }
581
582 if (buffer->isMapped())
583 {
Geoff Langb1196682014-07-23 13:47:29 -0400584 context->recordError(gl::Error(GL_INVALID_OPERATION));
585 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400586 }
587
588 // Check for possible overflow of size + offset
589 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
590 {
Geoff Langb1196682014-07-23 13:47:29 -0400591 context->recordError(gl::Error(GL_OUT_OF_MEMORY));
592 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400593 }
594
595 if (size + offset > buffer->getSize())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000596 {
Geoff Langb1196682014-07-23 13:47:29 -0400597 context->recordError(gl::Error(GL_INVALID_VALUE));
598 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000599 }
600
Geoff Langbfdea662014-07-23 14:16:32 -0400601 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000602 }
603}
604
605GLenum __stdcall glCheckFramebufferStatus(GLenum target)
606{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000607 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000608
Geoff Langbfdea662014-07-23 14:16:32 -0400609 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400610 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000611 {
Geoff Langb1196682014-07-23 13:47:29 -0400612 if (!gl::ValidFramebufferTarget(target))
613 {
614 context->recordError(gl::Error(GL_INVALID_ENUM));
615 return 0;
616 }
617
Geoff Langbfdea662014-07-23 14:16:32 -0400618 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
619 ASSERT(framebuffer);
620 return framebuffer->completeness();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000621 }
622
623 return 0;
624}
625
626void __stdcall glClear(GLbitfield mask)
627{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000628 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000629
Geoff Langbfdea662014-07-23 14:16:32 -0400630 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400631 if (context)
632 {
633 gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer();
634
635 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000636 {
Geoff Langb1196682014-07-23 13:47:29 -0400637 context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION));
638 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000639 }
Geoff Langbfdea662014-07-23 14:16:32 -0400640
641 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
642 {
Geoff Langb1196682014-07-23 13:47:29 -0400643 context->recordError(gl::Error(GL_INVALID_VALUE));
644 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400645 }
646
647 context->clear(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000648 }
649}
650
651void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
652{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000653 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000654 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000655
Geoff Langbfdea662014-07-23 14:16:32 -0400656 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400657 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000658 {
Geoff Langbfdea662014-07-23 14:16:32 -0400659 context->getState().setClearColor(red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000660 }
661}
662
663void __stdcall glClearDepthf(GLclampf depth)
664{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000665 EVENT("(GLclampf depth = %f)", depth);
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().setClearDepth(depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 }
672}
673
674void __stdcall glClearStencil(GLint s)
675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000676 EVENT("(GLint s = %d)", s);
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().setClearStencil(s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000682 }
683}
684
685void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
686{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000687 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000688 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000689
Geoff Langbfdea662014-07-23 14:16:32 -0400690 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400691 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000692 {
Geoff Langbfdea662014-07-23 14:16:32 -0400693 context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000694 }
695}
696
697void __stdcall glCompileShader(GLuint shader)
698{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000699 EVENT("(GLuint shader = %d)", shader);
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)
703 {
704 gl::Shader *shaderObject = context->getShader(shader);
705
706 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000707 {
Geoff Langbfdea662014-07-23 14:16:32 -0400708 if (context->getProgram(shader))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000709 {
Geoff Langb1196682014-07-23 13:47:29 -0400710 context->recordError(gl::Error(GL_INVALID_OPERATION));
711 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000712 }
Geoff Langbfdea662014-07-23 14:16:32 -0400713 else
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000714 {
Geoff Langb1196682014-07-23 13:47:29 -0400715 context->recordError(gl::Error(GL_INVALID_VALUE));
716 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000717 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000718 }
Geoff Langbfdea662014-07-23 14:16:32 -0400719
720 shaderObject->compile();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000721 }
Geoff Langbfdea662014-07-23 14:16:32 -0400722}
723
724void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
725 GLint border, GLsizei imageSize, const GLvoid* data)
726{
727 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
728 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
729 target, level, internalformat, width, height, border, imageSize, data);
730
731 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400732 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000733 {
Geoff Langbfdea662014-07-23 14:16:32 -0400734 if (context->getClientVersion() < 3 &&
735 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
736 0, 0, width, height, border, GL_NONE, GL_NONE, data))
737 {
738 return;
739 }
740
741 if (context->getClientVersion() >= 3 &&
742 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
743 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
744 {
745 return;
746 }
747
Geoff Lang5d601382014-07-22 15:14:06 -0400748 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
749 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400750 {
Geoff Langb1196682014-07-23 13:47:29 -0400751 context->recordError(gl::Error(GL_INVALID_VALUE));
752 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400753 }
754
755 switch (target)
756 {
757 case GL_TEXTURE_2D:
758 {
759 gl::Texture2D *texture = context->getTexture2D();
760 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
761 }
762 break;
763
764 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
765 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
766 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
767 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
768 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
769 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
770 {
771 gl::TextureCubeMap *texture = context->getTextureCubeMap();
772 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
773 }
774 break;
775
776 default:
Geoff Langb1196682014-07-23 13:47:29 -0400777 context->recordError(gl::Error(GL_INVALID_ENUM));
778 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400779 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000780 }
781}
782
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000783void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
784 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000785{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000786 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000787 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000788 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000789 target, level, xoffset, yoffset, width, height, format, imageSize, data);
790
Geoff Langbfdea662014-07-23 14:16:32 -0400791 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400792 if (context)
793 {
794 if (context->getClientVersion() < 3 &&
795 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
796 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
daniel@transgaming.com01868132010-08-24 19:21:17 +0000797 {
Geoff Langbfdea662014-07-23 14:16:32 -0400798 return;
daniel@transgaming.com01868132010-08-24 19:21:17 +0000799 }
Geoff Langbfdea662014-07-23 14:16:32 -0400800
801 if (context->getClientVersion() >= 3 &&
802 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
803 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
804 {
805 return;
806 }
807
Geoff Lang5d601382014-07-22 15:14:06 -0400808 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
809 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -0400810 {
Geoff Langb1196682014-07-23 13:47:29 -0400811 context->recordError(gl::Error(GL_INVALID_VALUE));
812 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400813 }
814
815 switch (target)
816 {
817 case GL_TEXTURE_2D:
818 {
819 gl::Texture2D *texture = context->getTexture2D();
820 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
821 }
822 break;
823
824 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
825 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
826 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
827 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
828 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
829 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
830 {
831 gl::TextureCubeMap *texture = context->getTextureCubeMap();
832 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
833 }
834 break;
835
836 default:
Geoff Langb1196682014-07-23 13:47:29 -0400837 context->recordError(gl::Error(GL_INVALID_ENUM));
838 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400839 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000840 }
841}
842
843void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000845 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000846 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000847 target, level, internalformat, x, y, width, height, border);
848
Geoff Langbfdea662014-07-23 14:16:32 -0400849 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400850 if (context)
851 {
852 if (context->getClientVersion() < 3 &&
853 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
854 0, 0, x, y, width, height, border))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000855 {
Geoff Langbfdea662014-07-23 14:16:32 -0400856 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000857 }
Geoff Langbfdea662014-07-23 14:16:32 -0400858
859 if (context->getClientVersion() >= 3 &&
860 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
861 0, 0, 0, x, y, width, height, border))
862 {
863 return;
864 }
865
866 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
867
868 switch (target)
869 {
870 case GL_TEXTURE_2D:
871 {
872 gl::Texture2D *texture = context->getTexture2D();
873 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
874 }
875 break;
876
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
879 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
880 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
881 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
882 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
883 {
884 gl::TextureCubeMap *texture = context->getTextureCubeMap();
885 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
886 }
887 break;
888
Geoff Langb1196682014-07-23 13:47:29 -0400889 default:
890 context->recordError(gl::Error(GL_INVALID_ENUM));
891 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400892 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000893 }
894}
895
896void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000898 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000899 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000900 target, level, xoffset, yoffset, x, y, width, height);
901
Geoff Langbfdea662014-07-23 14:16:32 -0400902 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400903 if (context)
904 {
905 if (context->getClientVersion() < 3 &&
906 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
907 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000908 {
Geoff Langbfdea662014-07-23 14:16:32 -0400909 return;
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000910 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000911
Geoff Langbfdea662014-07-23 14:16:32 -0400912 if (context->getClientVersion() >= 3 &&
913 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
914 xoffset, yoffset, 0, x, y, width, height, 0))
915 {
916 return;
917 }
918
919 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
920
921 switch (target)
922 {
923 case GL_TEXTURE_2D:
924 {
925 gl::Texture2D *texture = context->getTexture2D();
926 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
927 }
928 break;
929
930 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
931 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
932 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
933 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
934 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
935 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
936 {
937 gl::TextureCubeMap *texture = context->getTextureCubeMap();
938 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
939 }
940 break;
941
942 default:
Geoff Langb1196682014-07-23 13:47:29 -0400943 context->recordError(gl::Error(GL_INVALID_ENUM));
944 return;
Geoff Langbfdea662014-07-23 14:16:32 -0400945 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000946 }
947}
948
949GLuint __stdcall glCreateProgram(void)
950{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000951 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000952
Geoff Langbfdea662014-07-23 14:16:32 -0400953 gl::Context *context = gl::getNonLostContext();
954 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000955 {
Geoff Langbfdea662014-07-23 14:16:32 -0400956 return context->createProgram();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000957 }
958
959 return 0;
960}
961
962GLuint __stdcall glCreateShader(GLenum type)
963{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000964 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000965
Geoff Langbfdea662014-07-23 14:16:32 -0400966 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -0400967 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000968 {
Geoff Langbfdea662014-07-23 14:16:32 -0400969 switch (type)
970 {
971 case GL_FRAGMENT_SHADER:
972 case GL_VERTEX_SHADER:
973 return context->createShader(type);
Geoff Langb1196682014-07-23 13:47:29 -0400974
Geoff Langbfdea662014-07-23 14:16:32 -0400975 default:
Geoff Langb1196682014-07-23 13:47:29 -0400976 context->recordError(gl::Error(GL_INVALID_ENUM));
977 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -0400978 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000979 }
980
981 return 0;
982}
983
984void __stdcall glCullFace(GLenum mode)
985{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000986 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000987
Geoff Langb1196682014-07-23 13:47:29 -0400988 gl::Context *context = gl::getNonLostContext();
989 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000990 {
Geoff Langb1196682014-07-23 13:47:29 -0400991 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000992 {
Geoff Langb1196682014-07-23 13:47:29 -0400993 case GL_FRONT:
994 case GL_BACK:
995 case GL_FRONT_AND_BACK:
996 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000997
Geoff Langb1196682014-07-23 13:47:29 -0400998 default:
999 context->recordError(gl::Error(GL_INVALID_ENUM));
1000 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001001 }
Geoff Langb1196682014-07-23 13:47:29 -04001002
1003 context->getState().setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001004 }
1005}
1006
1007void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
1008{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001009 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001010
Geoff Langbfdea662014-07-23 14:16:32 -04001011 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001012 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001013 {
Geoff Langb1196682014-07-23 13:47:29 -04001014 if (n < 0)
1015 {
1016 context->recordError(gl::Error(GL_INVALID_VALUE));
1017 return;
1018 }
1019
Geoff Langbfdea662014-07-23 14:16:32 -04001020 for (int i = 0; i < n; i++)
1021 {
1022 context->deleteBuffer(buffers[i]);
1023 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001024 }
1025}
1026
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001027void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
1028{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001029 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001030
Geoff Langbfdea662014-07-23 14:16:32 -04001031 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001032 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001033 {
Geoff Langb1196682014-07-23 13:47:29 -04001034 if (n < 0)
1035 {
1036 context->recordError(gl::Error(GL_INVALID_VALUE));
1037 return;
1038 }
1039
Geoff Langbfdea662014-07-23 14:16:32 -04001040 for (int i = 0; i < n; i++)
1041 {
1042 context->deleteFenceNV(fences[i]);
1043 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001044 }
1045}
1046
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001047void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
1048{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001049 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001050
Geoff Langbfdea662014-07-23 14:16:32 -04001051 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001052 if (context)
1053 {
Geoff Langb1196682014-07-23 13:47:29 -04001054 if (n < 0)
1055 {
1056 context->recordError(gl::Error(GL_INVALID_VALUE));
1057 return;
1058 }
1059
Geoff Langbfdea662014-07-23 14:16:32 -04001060 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001061 {
Geoff Langbfdea662014-07-23 14:16:32 -04001062 if (framebuffers[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001063 {
Geoff Langbfdea662014-07-23 14:16:32 -04001064 context->deleteFramebuffer(framebuffers[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001065 }
1066 }
1067 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001068}
1069
1070void __stdcall glDeleteProgram(GLuint program)
1071{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001072 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001073
Geoff Langbfdea662014-07-23 14:16:32 -04001074 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001075 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001076 {
Geoff Langb1196682014-07-23 13:47:29 -04001077 if (program == 0)
1078 {
1079 return;
1080 }
1081
Geoff Langbfdea662014-07-23 14:16:32 -04001082 if (!context->getProgram(program))
1083 {
1084 if(context->getShader(program))
1085 {
Geoff Langb1196682014-07-23 13:47:29 -04001086 context->recordError(gl::Error(GL_INVALID_OPERATION));
1087 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001088 }
1089 else
1090 {
Geoff Langb1196682014-07-23 13:47:29 -04001091 context->recordError(gl::Error(GL_INVALID_VALUE));
1092 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001093 }
1094 }
1095
1096 context->deleteProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001097 }
1098}
1099
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001100void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
1101{
1102 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1103
Geoff Langbfdea662014-07-23 14:16:32 -04001104 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001105 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001106 {
Geoff Langb1196682014-07-23 13:47:29 -04001107 if (n < 0)
1108 {
1109 context->recordError(gl::Error(GL_INVALID_VALUE));
1110 return;
1111 }
1112
Geoff Langbfdea662014-07-23 14:16:32 -04001113 for (int i = 0; i < n; i++)
1114 {
1115 context->deleteQuery(ids[i]);
1116 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001117 }
1118}
1119
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001120void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
1121{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001122 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001123
Geoff Langbfdea662014-07-23 14:16:32 -04001124 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001125 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001126 {
Geoff Langb1196682014-07-23 13:47:29 -04001127 if (n < 0)
1128 {
1129 context->recordError(gl::Error(GL_INVALID_VALUE));
1130 return;
1131 }
1132
Geoff Langbfdea662014-07-23 14:16:32 -04001133 for (int i = 0; i < n; i++)
1134 {
1135 context->deleteRenderbuffer(renderbuffers[i]);
1136 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001137 }
1138}
1139
1140void __stdcall glDeleteShader(GLuint shader)
1141{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001142 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001143
Geoff Langbfdea662014-07-23 14:16:32 -04001144 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001145 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146 {
Geoff Langb1196682014-07-23 13:47:29 -04001147 if (shader == 0)
1148 {
1149 return;
1150 }
1151
Geoff Langbfdea662014-07-23 14:16:32 -04001152 if (!context->getShader(shader))
1153 {
1154 if(context->getProgram(shader))
1155 {
Geoff Langb1196682014-07-23 13:47:29 -04001156 context->recordError(gl::Error(GL_INVALID_OPERATION));
1157 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001158 }
1159 else
1160 {
Geoff Langb1196682014-07-23 13:47:29 -04001161 context->recordError(gl::Error(GL_INVALID_VALUE));
1162 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001163 }
1164 }
1165
1166 context->deleteShader(shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001167 }
1168}
1169
1170void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
1171{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001172 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001173
Geoff Langbfdea662014-07-23 14:16:32 -04001174 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001175 if (context)
1176 {
Geoff Langb1196682014-07-23 13:47:29 -04001177 if (n < 0)
1178 {
1179 context->recordError(gl::Error(GL_INVALID_VALUE));
1180 return;
1181 }
1182
Geoff Langbfdea662014-07-23 14:16:32 -04001183 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001184 {
Geoff Langbfdea662014-07-23 14:16:32 -04001185 if (textures[i] != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001186 {
Geoff Langbfdea662014-07-23 14:16:32 -04001187 context->deleteTexture(textures[i]);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001188 }
1189 }
1190 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001191}
1192
1193void __stdcall glDepthFunc(GLenum func)
1194{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001195 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001196
Geoff Langbfdea662014-07-23 14:16:32 -04001197 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001198 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001199 {
Geoff Langb1196682014-07-23 13:47:29 -04001200 switch (func)
1201 {
1202 case GL_NEVER:
1203 case GL_ALWAYS:
1204 case GL_LESS:
1205 case GL_LEQUAL:
1206 case GL_EQUAL:
1207 case GL_GREATER:
1208 case GL_GEQUAL:
1209 case GL_NOTEQUAL:
1210 context->getState().setDepthFunc(func);
1211 break;
1212
1213 default:
1214 context->recordError(gl::Error(GL_INVALID_ENUM));
1215 return;
1216 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001217 }
1218}
1219
1220void __stdcall glDepthMask(GLboolean flag)
1221{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001222 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001223
Geoff Langbfdea662014-07-23 14:16:32 -04001224 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001225 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001226 {
Geoff Langbfdea662014-07-23 14:16:32 -04001227 context->getState().setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001228 }
1229}
1230
1231void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
1232{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001233 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001234
Geoff Langbfdea662014-07-23 14:16:32 -04001235 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001236 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001237 {
Geoff Langbfdea662014-07-23 14:16:32 -04001238 context->getState().setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001239 }
1240}
1241
1242void __stdcall glDetachShader(GLuint program, GLuint shader)
1243{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001244 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001245
Geoff Langbfdea662014-07-23 14:16:32 -04001246 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001247 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001248 {
Geoff Langbfdea662014-07-23 14:16:32 -04001249 gl::Program *programObject = context->getProgram(program);
1250 gl::Shader *shaderObject = context->getShader(shader);
1251
1252 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001253 {
Geoff Langbfdea662014-07-23 14:16:32 -04001254 gl::Shader *shaderByProgramHandle;
1255 shaderByProgramHandle = context->getShader(program);
1256 if (!shaderByProgramHandle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001257 {
Geoff Langb1196682014-07-23 13:47:29 -04001258 context->recordError(gl::Error(GL_INVALID_VALUE));
1259 return;
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001260 }
Geoff Langbfdea662014-07-23 14:16:32 -04001261 else
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001262 {
Geoff Langb1196682014-07-23 13:47:29 -04001263 context->recordError(gl::Error(GL_INVALID_OPERATION));
1264 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001265 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001266 }
Geoff Langbfdea662014-07-23 14:16:32 -04001267
1268 if (!shaderObject)
1269 {
1270 gl::Program *programByShaderHandle = context->getProgram(shader);
1271 if (!programByShaderHandle)
1272 {
Geoff Langb1196682014-07-23 13:47:29 -04001273 context->recordError(gl::Error(GL_INVALID_VALUE));
1274 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001275 }
1276 else
1277 {
Geoff Langb1196682014-07-23 13:47:29 -04001278 context->recordError(gl::Error(GL_INVALID_OPERATION));
1279 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001280 }
1281 }
1282
1283 if (!programObject->detachShader(shaderObject))
1284 {
Geoff Langb1196682014-07-23 13:47:29 -04001285 context->recordError(gl::Error(GL_INVALID_OPERATION));
1286 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001287 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001288 }
1289}
1290
1291void __stdcall glDisable(GLenum cap)
1292{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001293 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001294
Geoff Langbfdea662014-07-23 14:16:32 -04001295 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001296 if (context)
1297 {
1298 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001299 {
Geoff Langb1196682014-07-23 13:47:29 -04001300 context->recordError(gl::Error(GL_INVALID_ENUM));
1301 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001302 }
Geoff Langbfdea662014-07-23 14:16:32 -04001303
1304 context->getState().setEnableFeature(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001305 }
1306}
1307
1308void __stdcall glDisableVertexAttribArray(GLuint index)
1309{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001310 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001311
Geoff Langbfdea662014-07-23 14:16:32 -04001312 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001313 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001314 {
Geoff Langb1196682014-07-23 13:47:29 -04001315 if (index >= gl::MAX_VERTEX_ATTRIBS)
1316 {
1317 context->recordError(gl::Error(GL_INVALID_VALUE));
1318 return;
1319 }
1320
Geoff Langbfdea662014-07-23 14:16:32 -04001321 context->getState().setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001322 }
1323}
1324
1325void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
1326{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001327 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001328
Geoff Langbfdea662014-07-23 14:16:32 -04001329 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001330 if (context)
1331 {
Jamie Madill2b976812014-08-25 15:47:49 -04001332 if (!ValidateDrawArrays(context, mode, first, count, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001333 {
Geoff Langbfdea662014-07-23 14:16:32 -04001334 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001335 }
Geoff Langbfdea662014-07-23 14:16:32 -04001336
1337 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001338 }
1339}
1340
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001341void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
1342{
1343 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1344
Geoff Langbfdea662014-07-23 14:16:32 -04001345 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001346 if (context)
1347 {
1348 if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001349 {
Geoff Langbfdea662014-07-23 14:16:32 -04001350 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001351 }
Geoff Langbfdea662014-07-23 14:16:32 -04001352
1353 context->drawArrays(mode, first, count, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001354 }
1355}
1356
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001357void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001358{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001359 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 +00001360 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001361
Geoff Langbfdea662014-07-23 14:16:32 -04001362 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001363 if (context)
1364 {
Jamie Madill2b976812014-08-25 15:47:49 -04001365 rx::RangeUI indexRange;
1366 if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001367 {
Geoff Langbfdea662014-07-23 14:16:32 -04001368 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001369 }
Geoff Langbfdea662014-07-23 14:16:32 -04001370
Jamie Madill2b976812014-08-25 15:47:49 -04001371 context->drawElements(mode, count, type, indices, 0, indexRange);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001372 }
1373}
1374
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001375void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
1376{
1377 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1378 mode, count, type, indices, primcount);
1379
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 rx::RangeUI indexRange;
1384 if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, &indexRange))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001385 {
Geoff Langbfdea662014-07-23 14:16:32 -04001386 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001387 }
Geoff Langbfdea662014-07-23 14:16:32 -04001388
Jamie Madill2b976812014-08-25 15:47:49 -04001389 context->drawElements(mode, count, type, indices, primcount, indexRange);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001390 }
1391}
1392
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001393void __stdcall glEnable(GLenum cap)
1394{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001395 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001396
Geoff Langbfdea662014-07-23 14:16:32 -04001397 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001398 if (context)
1399 {
1400 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001401 {
Geoff Langb1196682014-07-23 13:47:29 -04001402 context->recordError(gl::Error(GL_INVALID_ENUM));
1403 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001404 }
Geoff Langbfdea662014-07-23 14:16:32 -04001405
1406 context->getState().setEnableFeature(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001407 }
1408}
1409
1410void __stdcall glEnableVertexAttribArray(GLuint index)
1411{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001412 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001413
Geoff Langbfdea662014-07-23 14:16:32 -04001414 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001415 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001416 {
Geoff Langb1196682014-07-23 13:47:29 -04001417 if (index >= gl::MAX_VERTEX_ATTRIBS)
1418 {
1419 context->recordError(gl::Error(GL_INVALID_VALUE));
1420 return;
1421 }
1422
Geoff Langbfdea662014-07-23 14:16:32 -04001423 context->getState().setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001424 }
1425}
1426
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001427void __stdcall glEndQueryEXT(GLenum target)
1428{
1429 EVENT("GLenum target = 0x%X)", target);
1430
Geoff Langbfdea662014-07-23 14:16:32 -04001431 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001432 if (context)
1433 {
1434 if (!ValidateEndQuery(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001435 {
Geoff Langbfdea662014-07-23 14:16:32 -04001436 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001437 }
Geoff Langbfdea662014-07-23 14:16:32 -04001438
1439 context->endQuery(target);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001440 }
1441}
1442
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001443void __stdcall glFinishFenceNV(GLuint fence)
1444{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001445 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001446
Geoff Langbfdea662014-07-23 14:16:32 -04001447 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001448 if (context)
1449 {
1450 gl::FenceNV *fenceObject = context->getFenceNV(fence);
1451
1452 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001453 {
Geoff Langb1196682014-07-23 13:47:29 -04001454 context->recordError(gl::Error(GL_INVALID_OPERATION));
1455 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001456 }
Geoff Langbfdea662014-07-23 14:16:32 -04001457
1458 if (fenceObject->isFence() != GL_TRUE)
1459 {
Geoff Langb1196682014-07-23 13:47:29 -04001460 context->recordError(gl::Error(GL_INVALID_OPERATION));
1461 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001462 }
1463
1464 fenceObject->finishFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001465 }
1466}
1467
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001468void __stdcall glFinish(void)
1469{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001470 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001471
Geoff Langbfdea662014-07-23 14:16:32 -04001472 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001473 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001474 {
Geoff Langbfdea662014-07-23 14:16:32 -04001475 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001476 }
1477}
1478
1479void __stdcall glFlush(void)
1480{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001481 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
Geoff Langbfdea662014-07-23 14:16:32 -04001483 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001484 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001485 {
Geoff Langbfdea662014-07-23 14:16:32 -04001486 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001487 }
1488}
1489
1490void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
1491{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001492 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001493 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001494
Geoff Langbfdea662014-07-23 14:16:32 -04001495 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001496 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001497 {
Geoff Langb1196682014-07-23 13:47:29 -04001498 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
1499 {
1500 context->recordError(gl::Error(GL_INVALID_ENUM));
1501 return;
1502 }
1503
Geoff Langbfdea662014-07-23 14:16:32 -04001504 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
1505 {
1506 return;
1507 }
1508
1509 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
1510 ASSERT(framebuffer);
1511
1512 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1513 {
1514 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1515 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
1516 }
1517 else
1518 {
1519 switch (attachment)
1520 {
1521 case GL_DEPTH_ATTACHMENT:
1522 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1523 break;
1524 case GL_STENCIL_ATTACHMENT:
1525 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1526 break;
1527 case GL_DEPTH_STENCIL_ATTACHMENT:
1528 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1529 break;
1530 default:
1531 UNREACHABLE();
1532 break;
1533 }
1534 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001535 }
1536}
1537
1538void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1539{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001540 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001541 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001542
Geoff Langbfdea662014-07-23 14:16:32 -04001543 gl::Context *context = gl::getNonLostContext();
1544 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001545 {
Geoff Langbfdea662014-07-23 14:16:32 -04001546 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547 {
Geoff Langbfdea662014-07-23 14:16:32 -04001548 return;
1549 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001550
Geoff Langbfdea662014-07-23 14:16:32 -04001551 if (texture == 0)
1552 {
1553 textarget = GL_NONE;
1554 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555
Geoff Langbfdea662014-07-23 14:16:32 -04001556 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557
Geoff Langbfdea662014-07-23 14:16:32 -04001558 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
1559 {
1560 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
1561 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
1562 }
1563 else
1564 {
1565 switch (attachment)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001566 {
Geoff Langbfdea662014-07-23 14:16:32 -04001567 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1568 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1569 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001570 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 }
1572 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573}
1574
1575void __stdcall glFrontFace(GLenum mode)
1576{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001577 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001578
Geoff Langb1196682014-07-23 13:47:29 -04001579 gl::Context *context = gl::getNonLostContext();
1580 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
Geoff Langb1196682014-07-23 13:47:29 -04001582 switch (mode)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583 {
Geoff Langb1196682014-07-23 13:47:29 -04001584 case GL_CW:
1585 case GL_CCW:
1586 context->getState().setFrontFace(mode);
1587 break;
1588 default:
1589 context->recordError(gl::Error(GL_INVALID_ENUM));
1590 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001591 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001592 }
1593}
1594
1595void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
1596{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001597 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001598
Geoff Langbfdea662014-07-23 14:16:32 -04001599 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001600 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001601 {
Geoff Langb1196682014-07-23 13:47:29 -04001602 if (n < 0)
1603 {
1604 context->recordError(gl::Error(GL_INVALID_VALUE));
1605 return;
1606 }
1607
Geoff Langbfdea662014-07-23 14:16:32 -04001608 for (int i = 0; i < n; i++)
1609 {
1610 buffers[i] = context->createBuffer();
1611 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001612 }
1613}
1614
1615void __stdcall glGenerateMipmap(GLenum target)
1616{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001617 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001618
Geoff Langbfdea662014-07-23 14:16:32 -04001619 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001620 if (context)
1621 {
1622 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001623 {
Geoff Langb1196682014-07-23 13:47:29 -04001624 context->recordError(gl::Error(GL_INVALID_ENUM));
1625 return;
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001626 }
Geoff Langbfdea662014-07-23 14:16:32 -04001627
1628 gl::Texture *texture = context->getTargetTexture(target);
1629
1630 if (texture == NULL)
1631 {
Geoff Langb1196682014-07-23 13:47:29 -04001632 context->recordError(gl::Error(GL_INVALID_OPERATION));
1633 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001634 }
1635
1636 GLenum internalFormat = texture->getBaseLevelInternalFormat();
1637 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat);
Geoff Lang5d601382014-07-22 15:14:06 -04001638 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
Geoff Langbfdea662014-07-23 14:16:32 -04001639
1640 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1641 // unsized formats or that are color renderable and filterable. Since we do not track if
1642 // the texture was created with sized or unsized format (only sized formats are stored),
1643 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1644 // be able to) because they aren't color renderable. Simply do a special case for LUMA
1645 // textures since they're the only texture format that can be created with unsized formats
1646 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
1647 // was the last version to use add them.
1648 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
1649 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
1650 internalFormat == GL_ALPHA8_EXT;
1651
Geoff Lang5d601382014-07-22 15:14:06 -04001652 if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable ||
1653 (!formatCaps.renderable && !isLUMA) || formatInfo.compressed)
Geoff Langbfdea662014-07-23 14:16:32 -04001654 {
Geoff Langb1196682014-07-23 13:47:29 -04001655 context->recordError(gl::Error(GL_INVALID_OPERATION));
1656 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001657 }
1658
1659 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lang5d601382014-07-22 15:14:06 -04001660 if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB)
Geoff Langbfdea662014-07-23 14:16:32 -04001661 {
Geoff Langb1196682014-07-23 13:47:29 -04001662 context->recordError(gl::Error(GL_INVALID_OPERATION));
1663 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001664 }
1665
1666 // Non-power of 2 ES2 check
1667 if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
1668 {
1669 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
Geoff Langb1196682014-07-23 13:47:29 -04001670 context->recordError(gl::Error(GL_INVALID_OPERATION));
1671 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001672 }
1673
1674 // Cube completeness check
1675 if (target == GL_TEXTURE_CUBE_MAP)
1676 {
1677 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
1678 if (!textureCube->isCubeComplete())
1679 {
Geoff Langb1196682014-07-23 13:47:29 -04001680 context->recordError(gl::Error(GL_INVALID_OPERATION));
1681 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001682 }
1683 }
1684
1685 texture->generateMipmaps();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001686 }
1687}
1688
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001689void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
1690{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001691 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001692
Geoff Langbfdea662014-07-23 14:16:32 -04001693 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001694 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001695 {
Geoff Langb1196682014-07-23 13:47:29 -04001696 if (n < 0)
1697 {
1698 context->recordError(gl::Error(GL_INVALID_VALUE));
1699 return;
1700 }
1701
Geoff Langbfdea662014-07-23 14:16:32 -04001702 for (int i = 0; i < n; i++)
1703 {
1704 fences[i] = context->createFenceNV();
1705 }
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001706 }
1707}
1708
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001709void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
1710{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001711 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001712
Geoff Langbfdea662014-07-23 14:16:32 -04001713 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001714 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001715 {
Geoff Langb1196682014-07-23 13:47:29 -04001716 if (n < 0)
1717 {
1718 context->recordError(gl::Error(GL_INVALID_VALUE));
1719 return;
1720 }
1721
Geoff Langbfdea662014-07-23 14:16:32 -04001722 for (int i = 0; i < n; i++)
1723 {
1724 framebuffers[i] = context->createFramebuffer();
1725 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001726 }
1727}
1728
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001729void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
1730{
1731 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
1732
Geoff Langbfdea662014-07-23 14:16:32 -04001733 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001734 if (context)
1735 {
1736 if (n < 0)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001737 {
Geoff Langb1196682014-07-23 13:47:29 -04001738 context->recordError(gl::Error(GL_INVALID_VALUE));
1739 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001740 }
Geoff Langbfdea662014-07-23 14:16:32 -04001741
1742 for (GLsizei i = 0; i < n; i++)
1743 {
1744 ids[i] = context->createQuery();
1745 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001746 }
1747}
1748
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001749void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
1750{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001751 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001752
Geoff Langbfdea662014-07-23 14:16:32 -04001753 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001754 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001755 {
Geoff Langb1196682014-07-23 13:47:29 -04001756 if (n < 0)
1757 {
1758 context->recordError(gl::Error(GL_INVALID_VALUE));
1759 return;
1760 }
1761
Geoff Langbfdea662014-07-23 14:16:32 -04001762 for (int i = 0; i < n; i++)
1763 {
1764 renderbuffers[i] = context->createRenderbuffer();
1765 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001766 }
1767}
1768
1769void __stdcall glGenTextures(GLsizei n, GLuint* textures)
1770{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001771 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001772
Geoff Langbfdea662014-07-23 14:16:32 -04001773 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001774 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001775 {
Geoff Langb1196682014-07-23 13:47:29 -04001776 if (n < 0)
1777 {
1778 context->recordError(gl::Error(GL_INVALID_VALUE));
1779 return;
1780 }
1781
Geoff Langbfdea662014-07-23 14:16:32 -04001782 for (int i = 0; i < n; i++)
1783 {
1784 textures[i] = context->createTexture();
1785 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001786 }
1787}
1788
daniel@transgaming.com85423182010-04-22 13:35:27 +00001789void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001790{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001791 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00001792 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001793 program, index, bufsize, length, size, type, name);
1794
Geoff Langbfdea662014-07-23 14:16:32 -04001795 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001796 if (context)
1797 {
Geoff Langb1196682014-07-23 13:47:29 -04001798 if (bufsize < 0)
1799 {
1800 context->recordError(gl::Error(GL_INVALID_VALUE));
1801 return;
1802 }
1803
Geoff Langbfdea662014-07-23 14:16:32 -04001804 gl::Program *programObject = context->getProgram(program);
1805
1806 if (!programObject)
1807 {
1808 if (context->getShader(program))
1809 {
Geoff Langb1196682014-07-23 13:47:29 -04001810 context->recordError(gl::Error(GL_INVALID_OPERATION));
1811 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001812 }
1813 else
1814 {
Geoff Langb1196682014-07-23 13:47:29 -04001815 context->recordError(gl::Error(GL_INVALID_VALUE));
1816 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001817 }
1818 }
1819
1820 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001821 {
Geoff Langb1196682014-07-23 13:47:29 -04001822 context->recordError(gl::Error(GL_INVALID_VALUE));
1823 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001824 }
1825
Geoff Langbfdea662014-07-23 14:16:32 -04001826 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001827 }
1828}
1829
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001830void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001831{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001832 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001833 "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 +00001834 program, index, bufsize, length, size, type, name);
1835
Geoff Langbfdea662014-07-23 14:16:32 -04001836
1837 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001838 if (context)
1839 {
Geoff Langb1196682014-07-23 13:47:29 -04001840 if (bufsize < 0)
1841 {
1842 context->recordError(gl::Error(GL_INVALID_VALUE));
1843 return;
1844 }
1845
Geoff Langbfdea662014-07-23 14:16:32 -04001846 gl::Program *programObject = context->getProgram(program);
1847
1848 if (!programObject)
1849 {
1850 if (context->getShader(program))
1851 {
Geoff Langb1196682014-07-23 13:47:29 -04001852 context->recordError(gl::Error(GL_INVALID_OPERATION));
1853 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001854 }
1855 else
1856 {
Geoff Langb1196682014-07-23 13:47:29 -04001857 context->recordError(gl::Error(GL_INVALID_VALUE));
1858 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001859 }
1860 }
1861
1862 if (index >= (GLuint)programObject->getActiveUniformCount())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001863 {
Geoff Langb1196682014-07-23 13:47:29 -04001864 context->recordError(gl::Error(GL_INVALID_VALUE));
1865 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001866 }
1867
Geoff Langbfdea662014-07-23 14:16:32 -04001868 programObject->getActiveUniform(index, bufsize, length, size, type, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001869 }
1870}
1871
1872void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
1873{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001874 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 +00001875 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001876
Geoff Langbfdea662014-07-23 14:16:32 -04001877 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001878 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001879 {
Geoff Langb1196682014-07-23 13:47:29 -04001880 if (maxcount < 0)
1881 {
1882 context->recordError(gl::Error(GL_INVALID_VALUE));
1883 return;
1884 }
1885
Geoff Langbfdea662014-07-23 14:16:32 -04001886 gl::Program *programObject = context->getProgram(program);
1887
1888 if (!programObject)
1889 {
1890 if (context->getShader(program))
1891 {
Geoff Langb1196682014-07-23 13:47:29 -04001892 context->recordError(gl::Error(GL_INVALID_OPERATION));
1893 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001894 }
1895 else
1896 {
Geoff Langb1196682014-07-23 13:47:29 -04001897 context->recordError(gl::Error(GL_INVALID_VALUE));
1898 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001899 }
1900 }
1901
1902 return programObject->getAttachedShaders(maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001903 }
1904}
1905
Geoff Langb1196682014-07-23 13:47:29 -04001906GLint __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001907{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001908 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001909
Geoff Langbfdea662014-07-23 14:16:32 -04001910 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001911 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001912 {
Geoff Langbfdea662014-07-23 14:16:32 -04001913 gl::Program *programObject = context->getProgram(program);
1914
1915 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001916 {
Geoff Langbfdea662014-07-23 14:16:32 -04001917 if (context->getShader(program))
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001918 {
Geoff Langb1196682014-07-23 13:47:29 -04001919 context->recordError(gl::Error(GL_INVALID_OPERATION));
1920 return -1;
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00001921 }
Geoff Langbfdea662014-07-23 14:16:32 -04001922 else
1923 {
Geoff Langb1196682014-07-23 13:47:29 -04001924 context->recordError(gl::Error(GL_INVALID_VALUE));
1925 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04001926 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001927 }
Geoff Langbfdea662014-07-23 14:16:32 -04001928
1929 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
1930 if (!programObject->isLinked() || !programBinary)
1931 {
Geoff Langb1196682014-07-23 13:47:29 -04001932 context->recordError(gl::Error(GL_INVALID_OPERATION));
1933 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04001934 }
1935
1936 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001937 }
1938
1939 return -1;
1940}
1941
1942void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
1943{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001944 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001945
Geoff Langbfdea662014-07-23 14:16:32 -04001946 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001947 if (context)
1948 {
1949 GLenum nativeType;
1950 unsigned int numParams = 0;
1951 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001952 {
Geoff Langbfdea662014-07-23 14:16:32 -04001953 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001954 }
Geoff Langbfdea662014-07-23 14:16:32 -04001955
1956 if (nativeType == GL_BOOL)
1957 {
1958 context->getBooleanv(pname, params);
1959 }
1960 else
1961 {
1962 CastStateValues(context, nativeType, pname, numParams, params);
1963 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001964 }
1965}
1966
1967void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
1968{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001969 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 +00001970
Geoff Langbfdea662014-07-23 14:16:32 -04001971 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04001972 if (context)
1973 {
1974 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00001975 {
Geoff Langb1196682014-07-23 13:47:29 -04001976 context->recordError(gl::Error(GL_INVALID_ENUM));
1977 return;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00001978 }
Geoff Langbfdea662014-07-23 14:16:32 -04001979
1980 if (!gl::ValidBufferParameter(context, pname))
1981 {
Geoff Langb1196682014-07-23 13:47:29 -04001982 context->recordError(gl::Error(GL_INVALID_ENUM));
1983 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001984 }
1985
1986 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
1987
1988 if (!buffer)
1989 {
1990 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04001991 context->recordError(gl::Error(GL_INVALID_OPERATION));
1992 return;
Geoff Langbfdea662014-07-23 14:16:32 -04001993 }
1994
1995 switch (pname)
1996 {
1997 case GL_BUFFER_USAGE:
1998 *params = static_cast<GLint>(buffer->getUsage());
1999 break;
2000 case GL_BUFFER_SIZE:
2001 *params = gl::clampCast<GLint>(buffer->getSize());
2002 break;
2003 case GL_BUFFER_ACCESS_FLAGS:
2004 *params = buffer->getAccessFlags();
2005 break;
2006 case GL_BUFFER_MAPPED:
2007 *params = static_cast<GLint>(buffer->isMapped());
2008 break;
2009 case GL_BUFFER_MAP_OFFSET:
2010 *params = gl::clampCast<GLint>(buffer->getMapOffset());
2011 break;
2012 case GL_BUFFER_MAP_LENGTH:
2013 *params = gl::clampCast<GLint>(buffer->getMapLength());
2014 break;
2015 default: UNREACHABLE(); break;
2016 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002017 }
2018}
2019
2020GLenum __stdcall glGetError(void)
2021{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002022 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002023
2024 gl::Context *context = gl::getContext();
2025
2026 if (context)
2027 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002028 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002029 }
2030
2031 return GL_NO_ERROR;
2032}
2033
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002034void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
2035{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002036 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +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 gl::FenceNV *fenceObject = context->getFenceNV(fence);
2042
2043 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002044 {
Geoff Langb1196682014-07-23 13:47:29 -04002045 context->recordError(gl::Error(GL_INVALID_OPERATION));
2046 return;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002047 }
Geoff Langbfdea662014-07-23 14:16:32 -04002048
2049 if (fenceObject->isFence() != GL_TRUE)
2050 {
Geoff Langb1196682014-07-23 13:47:29 -04002051 context->recordError(gl::Error(GL_INVALID_OPERATION));
2052 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002053 }
2054
2055 switch (pname)
2056 {
2057 case GL_FENCE_STATUS_NV:
2058 case GL_FENCE_CONDITION_NV:
2059 break;
2060
Geoff Langb1196682014-07-23 13:47:29 -04002061 default:
2062 context->recordError(gl::Error(GL_INVALID_ENUM));
2063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002064 }
2065
2066 params[0] = fenceObject->getFencei(pname);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002067 }
2068}
2069
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002070void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
2071{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002072 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002073
Geoff Langbfdea662014-07-23 14:16:32 -04002074 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002075 if (context)
2076 {
2077 GLenum nativeType;
2078 unsigned int numParams = 0;
2079 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002080 {
Geoff Langbfdea662014-07-23 14:16:32 -04002081 return;
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002082 }
Geoff Langbfdea662014-07-23 14:16:32 -04002083
2084 if (nativeType == GL_FLOAT)
2085 {
2086 context->getFloatv(pname, params);
2087 }
2088 else
2089 {
2090 CastStateValues(context, nativeType, pname, numParams, params);
2091 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002092 }
2093}
2094
2095void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
2096{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002097 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 +00002098 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002099
Geoff Langbfdea662014-07-23 14:16:32 -04002100 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002101 if (context)
2102 {
2103 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002104 {
Geoff Langb1196682014-07-23 13:47:29 -04002105 context->recordError(gl::Error(GL_INVALID_ENUM));
2106 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002107 }
2108
2109 int clientVersion = context->getClientVersion();
2110
2111 switch (pname)
2112 {
2113 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2114 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2115 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2116 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2117 break;
Geoff Langb1196682014-07-23 13:47:29 -04002118
Geoff Langbfdea662014-07-23 14:16:32 -04002119 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2120 if (clientVersion < 3 && !context->getExtensions().sRGB)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002121 {
Geoff Langb1196682014-07-23 13:47:29 -04002122 context->recordError(gl::Error(GL_INVALID_ENUM));
2123 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002124 }
Geoff Langbfdea662014-07-23 14:16:32 -04002125 break;
Geoff Langb1196682014-07-23 13:47:29 -04002126
Geoff Langbfdea662014-07-23 14:16:32 -04002127 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2128 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2129 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2130 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2131 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2132 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2133 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2134 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2135 if (clientVersion < 3)
2136 {
Geoff Langb1196682014-07-23 13:47:29 -04002137 context->recordError(gl::Error(GL_INVALID_ENUM));
2138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002139 }
2140 break;
Geoff Langb1196682014-07-23 13:47:29 -04002141
Geoff Langbfdea662014-07-23 14:16:32 -04002142 default:
Geoff Langb1196682014-07-23 13:47:29 -04002143 context->recordError(gl::Error(GL_INVALID_ENUM));
2144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002145 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002146
Geoff Langbfdea662014-07-23 14:16:32 -04002147 // Determine if the attachment is a valid enum
2148 switch (attachment)
2149 {
2150 case GL_BACK:
2151 case GL_FRONT:
2152 case GL_DEPTH:
2153 case GL_STENCIL:
2154 case GL_DEPTH_STENCIL_ATTACHMENT:
2155 if (clientVersion < 3)
2156 {
Geoff Langb1196682014-07-23 13:47:29 -04002157 context->recordError(gl::Error(GL_INVALID_ENUM));
2158 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002159 }
2160 break;
2161
2162 case GL_DEPTH_ATTACHMENT:
2163 case GL_STENCIL_ATTACHMENT:
2164 break;
2165
2166 default:
2167 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2168 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
2169 {
Geoff Langb1196682014-07-23 13:47:29 -04002170 context->recordError(gl::Error(GL_INVALID_ENUM));
2171 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002172 }
2173 break;
2174 }
2175
2176 GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id();
2177 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2178
2179 if (framebufferHandle == 0)
2180 {
2181 if (clientVersion < 3)
2182 {
Geoff Langb1196682014-07-23 13:47:29 -04002183 context->recordError(gl::Error(GL_INVALID_OPERATION));
2184 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002185 }
2186
2187 switch (attachment)
2188 {
2189 case GL_BACK:
2190 case GL_DEPTH:
2191 case GL_STENCIL:
2192 break;
Geoff Langb1196682014-07-23 13:47:29 -04002193
Geoff Langbfdea662014-07-23 14:16:32 -04002194 default:
Geoff Langb1196682014-07-23 13:47:29 -04002195 context->recordError(gl::Error(GL_INVALID_OPERATION));
2196 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002197 }
2198 }
2199 else
2200 {
2201 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2202 {
2203 // Valid attachment query
2204 }
2205 else
2206 {
2207 switch (attachment)
2208 {
2209 case GL_DEPTH_ATTACHMENT:
2210 case GL_STENCIL_ATTACHMENT:
2211 break;
Geoff Langb1196682014-07-23 13:47:29 -04002212
Geoff Langbfdea662014-07-23 14:16:32 -04002213 case GL_DEPTH_STENCIL_ATTACHMENT:
2214 if (framebuffer->hasValidDepthStencil())
2215 {
Geoff Langb1196682014-07-23 13:47:29 -04002216 context->recordError(gl::Error(GL_INVALID_OPERATION));
2217 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002218 }
2219 break;
Geoff Langb1196682014-07-23 13:47:29 -04002220
Geoff Langbfdea662014-07-23 14:16:32 -04002221 default:
Geoff Langb1196682014-07-23 13:47:29 -04002222 context->recordError(gl::Error(GL_INVALID_OPERATION));
2223 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002224 }
2225 }
2226 }
2227
2228 GLenum attachmentType = GL_NONE;
2229 GLuint attachmentHandle = 0;
2230 GLuint attachmentLevel = 0;
2231 GLuint attachmentLayer = 0;
2232
2233 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2234
2235 if (attachmentObject)
2236 {
2237 attachmentType = attachmentObject->type();
2238 attachmentHandle = attachmentObject->id();
2239 attachmentLevel = attachmentObject->mipLevel();
2240 attachmentLayer = attachmentObject->layer();
2241 }
2242
2243 GLenum attachmentObjectType; // Type category
2244 if (framebufferHandle == 0)
2245 {
2246 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2247 }
2248 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
2249 {
2250 attachmentObjectType = attachmentType;
2251 }
2252 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
2253 {
2254 attachmentObjectType = GL_TEXTURE;
2255 }
2256 else
2257 {
2258 UNREACHABLE();
2259 return;
2260 }
2261
2262 if (attachmentObjectType == GL_NONE)
2263 {
2264 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2265 // is NONE, then querying any other pname will generate INVALID_ENUM.
2266
2267 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2268 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2269 // INVALID_OPERATION for all other pnames
Jamie Madill1e3fa742014-06-16 10:34:00 -04002270
Geoff Lang646559f2013-08-15 11:08:15 -04002271 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002272 {
Geoff Lang646559f2013-08-15 11:08:15 -04002273 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
Geoff Langbfdea662014-07-23 14:16:32 -04002274 *params = attachmentObjectType;
2275 break;
2276
Geoff Lang646559f2013-08-15 11:08:15 -04002277 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Geoff Lang05b05022014-06-11 15:31:45 -04002278 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002279 {
Geoff Langb1196682014-07-23 13:47:29 -04002280 context->recordError(gl::Error(GL_INVALID_ENUM));
2281 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002282 }
Geoff Langbfdea662014-07-23 14:16:32 -04002283 *params = 0;
Geoff Lang646559f2013-08-15 11:08:15 -04002284 break;
2285
2286 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002287 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002288 {
Geoff Langb1196682014-07-23 13:47:29 -04002289 context->recordError(gl::Error(GL_INVALID_ENUM));
2290 return;
Geoff Lang646559f2013-08-15 11:08:15 -04002291 }
2292 else
2293 {
Geoff Langb1196682014-07-23 13:47:29 -04002294 context->recordError(gl::Error(GL_INVALID_OPERATION));
2295 return;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002296 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002297 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002298 }
Geoff Langbfdea662014-07-23 14:16:32 -04002299 else
2300 {
2301 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2302 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
2303 ASSERT(attachmentObject != NULL);
2304
2305 switch (pname)
2306 {
2307 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2308 *params = attachmentObjectType;
2309 break;
2310
2311 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2312 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2313 {
Geoff Langb1196682014-07-23 13:47:29 -04002314 context->recordError(gl::Error(GL_INVALID_ENUM));
2315 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002316 }
2317 *params = attachmentHandle;
2318 break;
2319
2320 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2321 if (attachmentObjectType != GL_TEXTURE)
2322 {
Geoff Langb1196682014-07-23 13:47:29 -04002323 context->recordError(gl::Error(GL_INVALID_ENUM));
2324 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002325 }
2326 *params = attachmentLevel;
2327 break;
2328
2329 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2330 if (attachmentObjectType != GL_TEXTURE)
2331 {
Geoff Langb1196682014-07-23 13:47:29 -04002332 context->recordError(gl::Error(GL_INVALID_ENUM));
2333 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002334 }
2335 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2336 break;
2337
2338 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2339 *params = attachmentObject->getRedSize();
2340 break;
2341
2342 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2343 *params = attachmentObject->getGreenSize();
2344 break;
2345
2346 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2347 *params = attachmentObject->getBlueSize();
2348 break;
2349
2350 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2351 *params = attachmentObject->getAlphaSize();
2352 break;
2353
2354 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2355 *params = attachmentObject->getDepthSize();
2356 break;
2357
2358 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2359 *params = attachmentObject->getStencilSize();
2360 break;
2361
2362 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2363 if (attachment == GL_DEPTH_STENCIL)
2364 {
Geoff Langb1196682014-07-23 13:47:29 -04002365 context->recordError(gl::Error(GL_INVALID_OPERATION));
2366 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002367 }
2368 *params = attachmentObject->getComponentType();
2369 break;
2370
2371 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2372 *params = attachmentObject->getColorEncoding();
2373 break;
2374
2375 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2376 if (attachmentObjectType != GL_TEXTURE)
2377 {
Geoff Langb1196682014-07-23 13:47:29 -04002378 context->recordError(gl::Error(GL_INVALID_ENUM));
2379 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002380 }
2381 *params = attachmentLayer;
2382 break;
2383
2384 default:
2385 UNREACHABLE();
2386 break;
2387 }
2388 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002389 }
2390}
2391
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002392GLenum __stdcall glGetGraphicsResetStatusEXT(void)
2393{
2394 EVENT("()");
2395
Geoff Langbfdea662014-07-23 14:16:32 -04002396 gl::Context *context = gl::getContext();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002397
Geoff Langbfdea662014-07-23 14:16:32 -04002398 if (context)
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002399 {
Geoff Langbfdea662014-07-23 14:16:32 -04002400 return context->getResetStatus();
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002401 }
Geoff Langbfdea662014-07-23 14:16:32 -04002402
2403 return GL_NO_ERROR;
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002404}
2405
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002406void __stdcall glGetIntegerv(GLenum pname, GLint* params)
2407{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002408 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002409
Geoff Langbfdea662014-07-23 14:16:32 -04002410 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002411 if (context)
2412 {
2413 GLenum nativeType;
2414 unsigned int numParams = 0;
2415
2416 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002417 {
Geoff Langbfdea662014-07-23 14:16:32 -04002418 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002419 }
Geoff Langbfdea662014-07-23 14:16:32 -04002420
2421 if (nativeType == GL_INT)
2422 {
2423 context->getIntegerv(pname, params);
2424 }
2425 else
2426 {
2427 CastStateValues(context, nativeType, pname, numParams, params);
2428 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002429 }
2430}
2431
2432void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
2433{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002434 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002435
Geoff Langbfdea662014-07-23 14:16:32 -04002436 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002437 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002438 {
Geoff Langbfdea662014-07-23 14:16:32 -04002439 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002440
Geoff Langbfdea662014-07-23 14:16:32 -04002441 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002442 {
Geoff Langb1196682014-07-23 13:47:29 -04002443 context->recordError(gl::Error(GL_INVALID_VALUE));
2444 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002445 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002446
Geoff Langbfdea662014-07-23 14:16:32 -04002447 if (context->getClientVersion() < 3)
2448 {
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002449 switch (pname)
2450 {
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002451 case GL_ACTIVE_UNIFORM_BLOCKS:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002452 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002453 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002454 case GL_TRANSFORM_FEEDBACK_VARYINGS:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002455 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
Geoff Langb1196682014-07-23 13:47:29 -04002456 context->recordError(gl::Error(GL_INVALID_ENUM));
2457 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002458 }
2459 }
Geoff Langbfdea662014-07-23 14:16:32 -04002460
2461 switch (pname)
2462 {
2463 case GL_DELETE_STATUS:
2464 *params = programObject->isFlaggedForDeletion();
2465 return;
2466 case GL_LINK_STATUS:
2467 *params = programObject->isLinked();
2468 return;
2469 case GL_VALIDATE_STATUS:
2470 *params = programObject->isValidated();
2471 return;
2472 case GL_INFO_LOG_LENGTH:
2473 *params = programObject->getInfoLogLength();
2474 return;
2475 case GL_ATTACHED_SHADERS:
2476 *params = programObject->getAttachedShadersCount();
2477 return;
2478 case GL_ACTIVE_ATTRIBUTES:
2479 *params = programObject->getActiveAttributeCount();
2480 return;
2481 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
2482 *params = programObject->getActiveAttributeMaxLength();
2483 return;
2484 case GL_ACTIVE_UNIFORMS:
2485 *params = programObject->getActiveUniformCount();
2486 return;
2487 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
2488 *params = programObject->getActiveUniformMaxLength();
2489 return;
2490 case GL_PROGRAM_BINARY_LENGTH_OES:
2491 *params = programObject->getProgramBinaryLength();
2492 return;
2493 case GL_ACTIVE_UNIFORM_BLOCKS:
2494 *params = programObject->getActiveUniformBlockCount();
2495 return;
2496 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2497 *params = programObject->getActiveUniformBlockMaxLength();
2498 break;
2499 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2500 *params = programObject->getTransformFeedbackBufferMode();
2501 break;
2502 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2503 *params = programObject->getTransformFeedbackVaryingCount();
2504 break;
2505 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2506 *params = programObject->getTransformFeedbackVaryingMaxLength();
2507 break;
Geoff Langb1196682014-07-23 13:47:29 -04002508
Geoff Langbfdea662014-07-23 14:16:32 -04002509 default:
Geoff Langb1196682014-07-23 13:47:29 -04002510 context->recordError(gl::Error(GL_INVALID_ENUM));
2511 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002512 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002513 }
2514}
2515
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002516void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002517{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002518 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 +00002519 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002520
Geoff Langbfdea662014-07-23 14:16:32 -04002521 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002522 if (context)
2523 {
Geoff Langb1196682014-07-23 13:47:29 -04002524 if (bufsize < 0)
2525 {
2526 context->recordError(gl::Error(GL_INVALID_VALUE));
2527 return;
2528 }
2529
Geoff Langbfdea662014-07-23 14:16:32 -04002530 gl::Program *programObject = context->getProgram(program);
2531
2532 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002533 {
Geoff Langb1196682014-07-23 13:47:29 -04002534 context->recordError(gl::Error(GL_INVALID_VALUE));
2535 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002536 }
2537
Geoff Langbfdea662014-07-23 14:16:32 -04002538 programObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002539 }
2540}
2541
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002542void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
2543{
2544 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2545
Geoff Langbfdea662014-07-23 14:16:32 -04002546 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002547 if (context)
2548 {
2549 if (!ValidQueryType(context, target))
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002550 {
Geoff Langb1196682014-07-23 13:47:29 -04002551 context->recordError(gl::Error(GL_INVALID_ENUM));
2552 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002553 }
Geoff Langbfdea662014-07-23 14:16:32 -04002554
2555 switch (pname)
2556 {
2557 case GL_CURRENT_QUERY_EXT:
2558 params[0] = context->getState().getActiveQueryId(target);
2559 break;
2560
2561 default:
Geoff Langb1196682014-07-23 13:47:29 -04002562 context->recordError(gl::Error(GL_INVALID_ENUM));
2563 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002564 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002565 }
2566}
2567
2568void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
2569{
2570 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
2571
Geoff Langbfdea662014-07-23 14:16:32 -04002572 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002573 if (context)
2574 {
2575 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
2576
2577 if (!queryObject)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002578 {
Geoff Langb1196682014-07-23 13:47:29 -04002579 context->recordError(gl::Error(GL_INVALID_OPERATION));
2580 return;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002581 }
Geoff Langbfdea662014-07-23 14:16:32 -04002582
2583 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
2584 {
Geoff Langb1196682014-07-23 13:47:29 -04002585 context->recordError(gl::Error(GL_INVALID_OPERATION));
2586 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002587 }
2588
2589 switch(pname)
2590 {
2591 case GL_QUERY_RESULT_EXT:
2592 params[0] = queryObject->getResult();
2593 break;
2594 case GL_QUERY_RESULT_AVAILABLE_EXT:
2595 params[0] = queryObject->isResultAvailable();
2596 break;
2597 default:
Geoff Langb1196682014-07-23 13:47:29 -04002598 context->recordError(gl::Error(GL_INVALID_ENUM));
2599 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002600 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002601 }
2602}
2603
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002604void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
2605{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002606 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 +00002607
Geoff Langbfdea662014-07-23 14:16:32 -04002608 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002609 if (context)
2610 {
2611 if (target != GL_RENDERBUFFER)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002612 {
Geoff Langb1196682014-07-23 13:47:29 -04002613 context->recordError(gl::Error(GL_INVALID_ENUM));
2614 return;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00002615 }
Geoff Langbfdea662014-07-23 14:16:32 -04002616
2617 if (context->getState().getRenderbufferId() == 0)
2618 {
Geoff Langb1196682014-07-23 13:47:29 -04002619 context->recordError(gl::Error(GL_INVALID_OPERATION));
2620 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002621 }
2622
2623 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId());
2624
2625 switch (pname)
2626 {
2627 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
2628 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
2629 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
2630 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
2631 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
2632 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
2633 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
2634 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
2635 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
Geoff Langb1196682014-07-23 13:47:29 -04002636
Geoff Langbfdea662014-07-23 14:16:32 -04002637 case GL_RENDERBUFFER_SAMPLES_ANGLE:
2638 if (!context->getExtensions().framebufferMultisample)
2639 {
Geoff Langb1196682014-07-23 13:47:29 -04002640 context->recordError(gl::Error(GL_INVALID_ENUM));
2641 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002642 }
2643 *params = renderbuffer->getSamples();
2644 break;
Geoff Langb1196682014-07-23 13:47:29 -04002645
Geoff Langbfdea662014-07-23 14:16:32 -04002646 default:
Geoff Langb1196682014-07-23 13:47:29 -04002647 context->recordError(gl::Error(GL_INVALID_ENUM));
2648 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002649 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002650 }
2651}
2652
2653void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
2654{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002655 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002656
Geoff Langbfdea662014-07-23 14:16:32 -04002657 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002658 if (context)
2659 {
2660 gl::Shader *shaderObject = context->getShader(shader);
2661
2662 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002663 {
Geoff Langb1196682014-07-23 13:47:29 -04002664 context->recordError(gl::Error(GL_INVALID_VALUE));
2665 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002666 }
Geoff Langbfdea662014-07-23 14:16:32 -04002667
2668 switch (pname)
2669 {
2670 case GL_SHADER_TYPE:
2671 *params = shaderObject->getType();
2672 return;
2673 case GL_DELETE_STATUS:
2674 *params = shaderObject->isFlaggedForDeletion();
2675 return;
2676 case GL_COMPILE_STATUS:
2677 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
2678 return;
2679 case GL_INFO_LOG_LENGTH:
2680 *params = shaderObject->getInfoLogLength();
2681 return;
2682 case GL_SHADER_SOURCE_LENGTH:
2683 *params = shaderObject->getSourceLength();
2684 return;
2685 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
2686 *params = shaderObject->getTranslatedSourceLength();
2687 return;
Geoff Langb1196682014-07-23 13:47:29 -04002688
Geoff Langbfdea662014-07-23 14:16:32 -04002689 default:
Geoff Langb1196682014-07-23 13:47:29 -04002690 context->recordError(gl::Error(GL_INVALID_ENUM));
2691 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002692 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002693 }
2694}
2695
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002696void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002697{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002698 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 +00002699 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002700
Geoff Langbfdea662014-07-23 14:16:32 -04002701 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002702 if (context)
2703 {
Geoff Langb1196682014-07-23 13:47:29 -04002704 if (bufsize < 0)
2705 {
2706 context->recordError(gl::Error(GL_INVALID_VALUE));
2707 return;
2708 }
2709
Geoff Langbfdea662014-07-23 14:16:32 -04002710 gl::Shader *shaderObject = context->getShader(shader);
2711
2712 if (!shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002713 {
Geoff Langb1196682014-07-23 13:47:29 -04002714 context->recordError(gl::Error(GL_INVALID_VALUE));
2715 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002716 }
2717
Geoff Langbfdea662014-07-23 14:16:32 -04002718 shaderObject->getInfoLog(bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002719 }
2720}
2721
2722void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
2723{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002724 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 +00002725 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002726
Geoff Langb1196682014-07-23 13:47:29 -04002727 gl::Context *context = gl::getNonLostContext();
2728 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002729 {
Geoff Langb1196682014-07-23 13:47:29 -04002730 switch (shadertype)
2731 {
2732 case GL_VERTEX_SHADER:
2733 case GL_FRAGMENT_SHADER:
2734 break;
Geoff Langbfdea662014-07-23 14:16:32 -04002735
Geoff Langb1196682014-07-23 13:47:29 -04002736 default:
2737 context->recordError(gl::Error(GL_INVALID_ENUM));
2738 return;
2739 }
2740
2741 switch (precisiontype)
2742 {
2743 case GL_LOW_FLOAT:
2744 case GL_MEDIUM_FLOAT:
2745 case GL_HIGH_FLOAT:
2746 // Assume IEEE 754 precision
2747 range[0] = 127;
2748 range[1] = 127;
2749 *precision = 23;
2750 break;
2751
2752 case GL_LOW_INT:
2753 case GL_MEDIUM_INT:
2754 case GL_HIGH_INT:
2755 // Some (most) hardware only supports single-precision floating-point numbers,
2756 // which can accurately represent integers up to +/-16777216
2757 range[0] = 24;
2758 range[1] = 24;
2759 *precision = 0;
2760 break;
2761
2762 default:
2763 context->recordError(gl::Error(GL_INVALID_ENUM));
2764 return;
2765 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002766 }
2767}
2768
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002769void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002770{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002771 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 +00002772 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002773
Geoff Langbfdea662014-07-23 14:16:32 -04002774 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002775 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002776 {
Geoff Langb1196682014-07-23 13:47:29 -04002777 if (bufsize < 0)
2778 {
2779 context->recordError(gl::Error(GL_INVALID_VALUE));
2780 return;
2781 }
2782
Geoff Langbfdea662014-07-23 14:16:32 -04002783 gl::Shader *shaderObject = context->getShader(shader);
2784
2785 if (!shaderObject)
2786 {
Geoff Langb1196682014-07-23 13:47:29 -04002787 context->recordError(gl::Error(GL_INVALID_OPERATION));
2788 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002789 }
2790
2791 shaderObject->getSource(bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002792 }
2793}
2794
zmo@google.coma574f782011-10-03 21:45:23 +00002795void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
2796{
2797 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
2798 shader, bufsize, length, source);
2799
Geoff Langbfdea662014-07-23 14:16:32 -04002800 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002801 if (context)
zmo@google.coma574f782011-10-03 21:45:23 +00002802 {
Geoff Langb1196682014-07-23 13:47:29 -04002803 if (bufsize < 0)
2804 {
2805 context->recordError(gl::Error(GL_INVALID_VALUE));
2806 return;
2807 }
2808
Geoff Langbfdea662014-07-23 14:16:32 -04002809 gl::Shader *shaderObject = context->getShader(shader);
2810
2811 if (!shaderObject)
2812 {
Geoff Langb1196682014-07-23 13:47:29 -04002813 context->recordError(gl::Error(GL_INVALID_OPERATION));
2814 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002815 }
2816
2817 shaderObject->getTranslatedSource(bufsize, length, source);
zmo@google.coma574f782011-10-03 21:45:23 +00002818 }
2819}
2820
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002821const GLubyte* __stdcall glGetString(GLenum name)
2822{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002823 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002824
Geoff Langbfdea662014-07-23 14:16:32 -04002825 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00002826
Geoff Langbfdea662014-07-23 14:16:32 -04002827 switch (name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002828 {
Geoff Langbfdea662014-07-23 14:16:32 -04002829 case GL_VENDOR:
2830 return (GLubyte*)"Google Inc.";
Geoff Langb1196682014-07-23 13:47:29 -04002831
Geoff Langbfdea662014-07-23 14:16:32 -04002832 case GL_RENDERER:
2833 return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE");
Geoff Langb1196682014-07-23 13:47:29 -04002834
Geoff Langbfdea662014-07-23 14:16:32 -04002835 case GL_VERSION:
2836 if (context->getClientVersion() == 2)
2837 {
2838 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
2839 }
2840 else
2841 {
2842 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
2843 }
Geoff Langb1196682014-07-23 13:47:29 -04002844
Geoff Langbfdea662014-07-23 14:16:32 -04002845 case GL_SHADING_LANGUAGE_VERSION:
2846 if (context->getClientVersion() == 2)
2847 {
2848 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
2849 }
2850 else
2851 {
2852 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
2853 }
Geoff Langb1196682014-07-23 13:47:29 -04002854
Geoff Langbfdea662014-07-23 14:16:32 -04002855 case GL_EXTENSIONS:
2856 return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : "");
Geoff Langb1196682014-07-23 13:47:29 -04002857
Geoff Langbfdea662014-07-23 14:16:32 -04002858 default:
Geoff Langb1196682014-07-23 13:47:29 -04002859 if (context)
2860 {
2861 context->recordError(gl::Error(GL_INVALID_ENUM));
2862 }
2863 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002864 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002865}
2866
2867void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
2868{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002869 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 +00002870
Geoff Langbfdea662014-07-23 14:16:32 -04002871 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04002872 if (context)
2873 {
2874 gl::Texture *texture = context->getTargetTexture(target);
2875
2876 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002877 {
Geoff Langb1196682014-07-23 13:47:29 -04002878 context->recordError(gl::Error(GL_INVALID_ENUM));
2879 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00002880 }
Geoff Langbfdea662014-07-23 14:16:32 -04002881
2882 switch (pname)
2883 {
2884 case GL_TEXTURE_MAG_FILTER:
2885 *params = (GLfloat)texture->getSamplerState().magFilter;
2886 break;
2887 case GL_TEXTURE_MIN_FILTER:
2888 *params = (GLfloat)texture->getSamplerState().minFilter;
2889 break;
2890 case GL_TEXTURE_WRAP_S:
2891 *params = (GLfloat)texture->getSamplerState().wrapS;
2892 break;
2893 case GL_TEXTURE_WRAP_T:
2894 *params = (GLfloat)texture->getSamplerState().wrapT;
2895 break;
2896 case GL_TEXTURE_WRAP_R:
2897 if (context->getClientVersion() < 3)
2898 {
Geoff Langb1196682014-07-23 13:47:29 -04002899 context->recordError(gl::Error(GL_INVALID_ENUM));
2900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002901 }
2902 *params = (GLfloat)texture->getSamplerState().wrapR;
2903 break;
2904 case GL_TEXTURE_IMMUTABLE_FORMAT:
2905 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
2906 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
2907 break;
2908 case GL_TEXTURE_IMMUTABLE_LEVELS:
2909 if (context->getClientVersion() < 3)
2910 {
Geoff Langb1196682014-07-23 13:47:29 -04002911 context->recordError(gl::Error(GL_INVALID_ENUM));
2912 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002913 }
2914 *params = (GLfloat)texture->immutableLevelCount();
2915 break;
2916 case GL_TEXTURE_USAGE_ANGLE:
2917 *params = (GLfloat)texture->getUsage();
2918 break;
2919 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
2920 if (!context->getExtensions().textureFilterAnisotropic)
2921 {
Geoff Langb1196682014-07-23 13:47:29 -04002922 context->recordError(gl::Error(GL_INVALID_ENUM));
2923 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002924 }
2925 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
2926 break;
2927 case GL_TEXTURE_SWIZZLE_R:
2928 if (context->getClientVersion() < 3)
2929 {
Geoff Langb1196682014-07-23 13:47:29 -04002930 context->recordError(gl::Error(GL_INVALID_ENUM));
2931 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002932 }
2933 *params = (GLfloat)texture->getSamplerState().swizzleRed;
2934 break;
2935 case GL_TEXTURE_SWIZZLE_G:
2936 if (context->getClientVersion() < 3)
2937 {
Geoff Langb1196682014-07-23 13:47:29 -04002938 context->recordError(gl::Error(GL_INVALID_ENUM));
2939 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002940 }
2941 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
2942 break;
2943 case GL_TEXTURE_SWIZZLE_B:
2944 if (context->getClientVersion() < 3)
2945 {
Geoff Langb1196682014-07-23 13:47:29 -04002946 context->recordError(gl::Error(GL_INVALID_ENUM));
2947 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002948 }
2949 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
2950 break;
2951 case GL_TEXTURE_SWIZZLE_A:
2952 if (context->getClientVersion() < 3)
2953 {
Geoff Langb1196682014-07-23 13:47:29 -04002954 context->recordError(gl::Error(GL_INVALID_ENUM));
2955 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002956 }
2957 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
2958 break;
2959 case GL_TEXTURE_BASE_LEVEL:
2960 if (context->getClientVersion() < 3)
2961 {
Geoff Langb1196682014-07-23 13:47:29 -04002962 context->recordError(gl::Error(GL_INVALID_ENUM));
2963 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002964 }
2965 *params = (GLfloat)texture->getSamplerState().baseLevel;
2966 break;
2967 case GL_TEXTURE_MAX_LEVEL:
2968 if (context->getClientVersion() < 3)
2969 {
Geoff Langb1196682014-07-23 13:47:29 -04002970 context->recordError(gl::Error(GL_INVALID_ENUM));
2971 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002972 }
2973 *params = (GLfloat)texture->getSamplerState().maxLevel;
2974 break;
2975 case GL_TEXTURE_MIN_LOD:
2976 if (context->getClientVersion() < 3)
2977 {
Geoff Langb1196682014-07-23 13:47:29 -04002978 context->recordError(gl::Error(GL_INVALID_ENUM));
2979 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002980 }
2981 *params = texture->getSamplerState().minLod;
2982 break;
2983 case GL_TEXTURE_MAX_LOD:
2984 if (context->getClientVersion() < 3)
2985 {
Geoff Langb1196682014-07-23 13:47:29 -04002986 context->recordError(gl::Error(GL_INVALID_ENUM));
2987 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002988 }
2989 *params = texture->getSamplerState().maxLod;
2990 break;
Geoff Langb1196682014-07-23 13:47:29 -04002991
Geoff Langbfdea662014-07-23 14:16:32 -04002992 default:
Geoff Langb1196682014-07-23 13:47:29 -04002993 context->recordError(gl::Error(GL_INVALID_ENUM));
2994 return;
Geoff Langbfdea662014-07-23 14:16:32 -04002995 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002996 }
2997}
2998
2999void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
3000{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003001 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 +00003002
Geoff Langbfdea662014-07-23 14:16:32 -04003003 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003004 if (context)
3005 {
3006 gl::Texture *texture = context->getTargetTexture(target);
3007
3008 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003009 {
Geoff Langb1196682014-07-23 13:47:29 -04003010 context->recordError(gl::Error(GL_INVALID_ENUM));
3011 return;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003012 }
Geoff Langbfdea662014-07-23 14:16:32 -04003013
3014 switch (pname)
3015 {
3016 case GL_TEXTURE_MAG_FILTER:
3017 *params = texture->getSamplerState().magFilter;
3018 break;
3019 case GL_TEXTURE_MIN_FILTER:
3020 *params = texture->getSamplerState().minFilter;
3021 break;
3022 case GL_TEXTURE_WRAP_S:
3023 *params = texture->getSamplerState().wrapS;
3024 break;
3025 case GL_TEXTURE_WRAP_T:
3026 *params = texture->getSamplerState().wrapT;
3027 break;
3028 case GL_TEXTURE_WRAP_R:
3029 if (context->getClientVersion() < 3)
3030 {
Geoff Langb1196682014-07-23 13:47:29 -04003031 context->recordError(gl::Error(GL_INVALID_ENUM));
3032 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003033 }
3034 *params = texture->getSamplerState().wrapR;
3035 break;
3036 case GL_TEXTURE_IMMUTABLE_FORMAT:
3037 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
3038 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3039 break;
3040 case GL_TEXTURE_IMMUTABLE_LEVELS:
3041 if (context->getClientVersion() < 3)
3042 {
Geoff Langb1196682014-07-23 13:47:29 -04003043 context->recordError(gl::Error(GL_INVALID_ENUM));
3044 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003045 }
3046 *params = texture->immutableLevelCount();
3047 break;
3048 case GL_TEXTURE_USAGE_ANGLE:
3049 *params = texture->getUsage();
3050 break;
3051 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
3052 if (!context->getExtensions().textureFilterAnisotropic)
3053 {
Geoff Langb1196682014-07-23 13:47:29 -04003054 context->recordError(gl::Error(GL_INVALID_ENUM));
3055 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003056 }
3057 *params = (GLint)texture->getSamplerState().maxAnisotropy;
3058 break;
3059 case GL_TEXTURE_SWIZZLE_R:
3060 if (context->getClientVersion() < 3)
3061 {
Geoff Langb1196682014-07-23 13:47:29 -04003062 context->recordError(gl::Error(GL_INVALID_ENUM));
3063 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003064 }
3065 *params = texture->getSamplerState().swizzleRed;
3066 break;
3067 case GL_TEXTURE_SWIZZLE_G:
3068 if (context->getClientVersion() < 3)
3069 {
Geoff Langb1196682014-07-23 13:47:29 -04003070 context->recordError(gl::Error(GL_INVALID_ENUM));
3071 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003072 }
3073 *params = texture->getSamplerState().swizzleGreen;
3074 break;
3075 case GL_TEXTURE_SWIZZLE_B:
3076 if (context->getClientVersion() < 3)
3077 {
Geoff Langb1196682014-07-23 13:47:29 -04003078 context->recordError(gl::Error(GL_INVALID_ENUM));
3079 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003080 }
3081 *params = texture->getSamplerState().swizzleBlue;
3082 break;
3083 case GL_TEXTURE_SWIZZLE_A:
3084 if (context->getClientVersion() < 3)
3085 {
Geoff Langb1196682014-07-23 13:47:29 -04003086 context->recordError(gl::Error(GL_INVALID_ENUM));
3087 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003088 }
3089 *params = texture->getSamplerState().swizzleAlpha;
3090 break;
3091 case GL_TEXTURE_BASE_LEVEL:
3092 if (context->getClientVersion() < 3)
3093 {
Geoff Langb1196682014-07-23 13:47:29 -04003094 context->recordError(gl::Error(GL_INVALID_ENUM));
3095 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003096 }
3097 *params = texture->getSamplerState().baseLevel;
3098 break;
3099 case GL_TEXTURE_MAX_LEVEL:
3100 if (context->getClientVersion() < 3)
3101 {
Geoff Langb1196682014-07-23 13:47:29 -04003102 context->recordError(gl::Error(GL_INVALID_ENUM));
3103 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003104 }
3105 *params = texture->getSamplerState().maxLevel;
3106 break;
3107 case GL_TEXTURE_MIN_LOD:
3108 if (context->getClientVersion() < 3)
3109 {
Geoff Langb1196682014-07-23 13:47:29 -04003110 context->recordError(gl::Error(GL_INVALID_ENUM));
3111 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003112 }
3113 *params = (GLint)texture->getSamplerState().minLod;
3114 break;
3115 case GL_TEXTURE_MAX_LOD:
3116 if (context->getClientVersion() < 3)
3117 {
Geoff Langb1196682014-07-23 13:47:29 -04003118 context->recordError(gl::Error(GL_INVALID_ENUM));
3119 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003120 }
3121 *params = (GLint)texture->getSamplerState().maxLod;
3122 break;
Geoff Langb1196682014-07-23 13:47:29 -04003123
Geoff Langbfdea662014-07-23 14:16:32 -04003124 default:
Geoff Langb1196682014-07-23 13:47:29 -04003125 context->recordError(gl::Error(GL_INVALID_ENUM));
3126 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003127 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003128 }
3129}
3130
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003131void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
3132{
3133 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3134 program, location, bufSize, params);
3135
Geoff Langbfdea662014-07-23 14:16:32 -04003136 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003137 if (context)
3138 {
Jamie Madill0063c512014-08-25 15:47:53 -04003139 if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003140 {
Jamie Madill0063c512014-08-25 15:47:53 -04003141 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003142 }
3143
Jamie Madilla502c742014-08-28 17:19:13 -04003144 gl::Program *programObject = context->getProgram(program);
3145 ASSERT(programObject);
3146 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003147 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003148
Jamie Madill99a1e982014-08-25 15:47:54 -04003149 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003150 }
3151}
3152
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003153void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
3154{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003155 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003156
Geoff Langbfdea662014-07-23 14:16:32 -04003157 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003158 if (context)
3159 {
Jamie Madill0063c512014-08-25 15:47:53 -04003160 if (!ValidateGetUniformfv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003161 {
Jamie Madill0063c512014-08-25 15:47:53 -04003162 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003163 }
Geoff Langbfdea662014-07-23 14:16:32 -04003164
Jamie Madilla502c742014-08-28 17:19:13 -04003165 gl::Program *programObject = context->getProgram(program);
3166 ASSERT(programObject);
3167 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003168 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003169
Jamie Madill99a1e982014-08-25 15:47:54 -04003170 programBinary->getUniformfv(location, params);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003171 }
3172}
3173
3174void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
3175{
Geoff Langbfdea662014-07-23 14:16:32 -04003176 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003177 program, location, bufSize, params);
3178
Geoff Langbfdea662014-07-23 14:16:32 -04003179 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003180 if (context)
3181 {
Jamie Madill0063c512014-08-25 15:47:53 -04003182 if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003183 {
Jamie Madill0063c512014-08-25 15:47:53 -04003184 return;
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003185 }
3186
Jamie Madilla502c742014-08-28 17:19:13 -04003187 gl::Program *programObject = context->getProgram(program);
3188 ASSERT(programObject);
3189 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003190 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003191
Jamie Madill99a1e982014-08-25 15:47:54 -04003192 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003193 }
3194}
3195
3196void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
3197{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003198 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003199
Geoff Langbfdea662014-07-23 14:16:32 -04003200 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003201 if (context)
3202 {
Jamie Madill0063c512014-08-25 15:47:53 -04003203 if (!ValidateGetUniformiv(context, program, location, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003204 {
Jamie Madill0063c512014-08-25 15:47:53 -04003205 return;
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003206 }
Geoff Langbfdea662014-07-23 14:16:32 -04003207
Jamie Madilla502c742014-08-28 17:19:13 -04003208 gl::Program *programObject = context->getProgram(program);
3209 ASSERT(programObject);
3210 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04003211 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04003212
Jamie Madill99a1e982014-08-25 15:47:54 -04003213 programBinary->getUniformiv(location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003214 }
3215}
3216
Geoff Langb1196682014-07-23 13:47:29 -04003217GLint __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003218{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003219 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003220
Geoff Langbfdea662014-07-23 14:16:32 -04003221 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003222 if (context)
3223 {
Geoff Langb1196682014-07-23 13:47:29 -04003224 if (strstr(name, "gl_") == name)
3225 {
3226 return -1;
3227 }
3228
Geoff Langbfdea662014-07-23 14:16:32 -04003229 gl::Program *programObject = context->getProgram(program);
3230
3231 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003232 {
Geoff Langbfdea662014-07-23 14:16:32 -04003233 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003234 {
Geoff Langb1196682014-07-23 13:47:29 -04003235 context->recordError(gl::Error(GL_INVALID_OPERATION));
3236 return -1;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003237 }
Geoff Langbfdea662014-07-23 14:16:32 -04003238 else
3239 {
Geoff Langb1196682014-07-23 13:47:29 -04003240 context->recordError(gl::Error(GL_INVALID_VALUE));
3241 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003242 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003243 }
Geoff Langbfdea662014-07-23 14:16:32 -04003244
3245 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3246 if (!programObject->isLinked() || !programBinary)
3247 {
Geoff Langb1196682014-07-23 13:47:29 -04003248 context->recordError(gl::Error(GL_INVALID_OPERATION));
3249 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04003250 }
3251
3252 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003253 }
3254
3255 return -1;
3256}
3257
3258void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
3259{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003260 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003261
Geoff Langbfdea662014-07-23 14:16:32 -04003262 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003263 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003264 {
Geoff Langbfdea662014-07-23 14:16:32 -04003265 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003266 {
Geoff Langb1196682014-07-23 13:47:29 -04003267 context->recordError(gl::Error(GL_INVALID_VALUE));
3268 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003269 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003270
Geoff Langbfdea662014-07-23 14:16:32 -04003271 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Geoff Langb1196682014-07-23 13:47:29 -04003272 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003273 {
3274 return;
3275 }
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003276
Geoff Langbfdea662014-07-23 14:16:32 -04003277 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3278 {
3279 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3280 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003281 {
Geoff Langbfdea662014-07-23 14:16:32 -04003282 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003283 }
3284 }
Geoff Langbfdea662014-07-23 14:16:32 -04003285 else
3286 {
3287 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
3288 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003289 }
3290}
3291
3292void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
3293{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003294 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003295
Geoff Langbfdea662014-07-23 14:16:32 -04003296 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003297 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003298 {
Geoff Langbfdea662014-07-23 14:16:32 -04003299 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003300 {
Geoff Langb1196682014-07-23 13:47:29 -04003301 context->recordError(gl::Error(GL_INVALID_VALUE));
3302 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003303 }
daniel@transgaming.come0078962010-04-15 20:45:08 +00003304
Geoff Langbfdea662014-07-23 14:16:32 -04003305 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003306
Geoff Langb1196682014-07-23 13:47:29 -04003307 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04003308 {
3309 return;
3310 }
Jamie Madillaff71502013-07-02 11:57:05 -04003311
Geoff Langbfdea662014-07-23 14:16:32 -04003312 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3313 {
3314 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
3315 for (int i = 0; i < 4; ++i)
Jamie Madillaff71502013-07-02 11:57:05 -04003316 {
Geoff Langbfdea662014-07-23 14:16:32 -04003317 float currentValue = currentValueData.FloatValues[i];
3318 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003319 }
3320 }
Geoff Langbfdea662014-07-23 14:16:32 -04003321 else
3322 {
3323 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
3324 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003325 }
3326}
3327
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003328void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003329{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003330 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003331
Geoff Langbfdea662014-07-23 14:16:32 -04003332 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003333 if (context)
3334 {
3335 if (index >= gl::MAX_VERTEX_ATTRIBS)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003336 {
Geoff Langb1196682014-07-23 13:47:29 -04003337 context->recordError(gl::Error(GL_INVALID_VALUE));
3338 return;
daniel@transgaming.come0078962010-04-15 20:45:08 +00003339 }
Geoff Langbfdea662014-07-23 14:16:32 -04003340
3341 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3342 {
Geoff Langb1196682014-07-23 13:47:29 -04003343 context->recordError(gl::Error(GL_INVALID_ENUM));
3344 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003345 }
3346
3347 *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003348 }
3349}
3350
3351void __stdcall glHint(GLenum target, GLenum mode)
3352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003353 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003354
Geoff Langbfdea662014-07-23 14:16:32 -04003355 gl::Context *context = gl::getNonLostContext();
Geoff Langb1196682014-07-23 13:47:29 -04003356 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003357 {
Geoff Langb1196682014-07-23 13:47:29 -04003358 switch (mode)
3359 {
3360 case GL_FASTEST:
3361 case GL_NICEST:
3362 case GL_DONT_CARE:
3363 break;
3364
3365 default:
3366 context->recordError(gl::Error(GL_INVALID_ENUM));
3367 return;
3368 }
3369
3370 switch (target)
3371 {
3372 case GL_GENERATE_MIPMAP_HINT:
3373 context->getState().setGenerateMipmapHint(mode);
3374 break;
3375
3376 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3377 context->getState().setFragmentShaderDerivativeHint(mode);
3378 break;
3379
3380 default:
3381 context->recordError(gl::Error(GL_INVALID_ENUM));
3382 return;
3383 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003384 }
3385}
3386
3387GLboolean __stdcall glIsBuffer(GLuint buffer)
3388{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003389 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003390
Geoff Langbfdea662014-07-23 14:16:32 -04003391 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003392 if (context && buffer)
3393 {
3394 gl::Buffer *bufferObject = context->getBuffer(buffer);
3395
3396 if (bufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003397 {
Geoff Langbfdea662014-07-23 14:16:32 -04003398 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003399 }
3400 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003401
3402 return GL_FALSE;
3403}
3404
3405GLboolean __stdcall glIsEnabled(GLenum cap)
3406{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003407 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003408
Geoff Langbfdea662014-07-23 14:16:32 -04003409 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003410 if (context)
3411 {
3412 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003413 {
Geoff Langb1196682014-07-23 13:47:29 -04003414 context->recordError(gl::Error(GL_INVALID_ENUM));
3415 return GL_FALSE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003416 }
Geoff Langbfdea662014-07-23 14:16:32 -04003417
3418 return context->getState().getEnableFeature(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003419 }
3420
3421 return false;
3422}
3423
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003424GLboolean __stdcall glIsFenceNV(GLuint fence)
3425{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003426 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003427
Geoff Langbfdea662014-07-23 14:16:32 -04003428 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003429 if (context)
3430 {
3431 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3432
3433 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003434 {
Geoff Langbfdea662014-07-23 14:16:32 -04003435 return GL_FALSE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003436 }
Geoff Langbfdea662014-07-23 14:16:32 -04003437
3438 return fenceObject->isFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003439 }
3440
3441 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003442}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003443
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003444GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
3445{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003446 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003447
Geoff Langbfdea662014-07-23 14:16:32 -04003448 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003449 if (context && framebuffer)
3450 {
3451 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
3452
3453 if (framebufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003454 {
Geoff Langbfdea662014-07-23 14:16:32 -04003455 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003456 }
3457 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003458
3459 return GL_FALSE;
3460}
3461
3462GLboolean __stdcall glIsProgram(GLuint program)
3463{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003464 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003465
Geoff Langbfdea662014-07-23 14:16:32 -04003466 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003467 if (context && program)
3468 {
3469 gl::Program *programObject = context->getProgram(program);
3470
3471 if (programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003472 {
Geoff Langbfdea662014-07-23 14:16:32 -04003473 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003474 }
3475 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003476
3477 return GL_FALSE;
3478}
3479
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003480GLboolean __stdcall glIsQueryEXT(GLuint id)
3481{
3482 EVENT("(GLuint id = %d)", id);
3483
Geoff Langbfdea662014-07-23 14:16:32 -04003484 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003485 if (context)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003486 {
Geoff Langbfdea662014-07-23 14:16:32 -04003487 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003488 }
3489
3490 return GL_FALSE;
3491}
3492
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003493GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
3494{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003495 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496
Geoff Langbfdea662014-07-23 14:16:32 -04003497 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003498 if (context && renderbuffer)
3499 {
3500 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
3501
3502 if (renderbufferObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003503 {
Geoff Langbfdea662014-07-23 14:16:32 -04003504 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003505 }
3506 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003507
3508 return GL_FALSE;
3509}
3510
3511GLboolean __stdcall glIsShader(GLuint shader)
3512{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003513 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003514
Geoff Langbfdea662014-07-23 14:16:32 -04003515 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003516 if (context && shader)
3517 {
3518 gl::Shader *shaderObject = context->getShader(shader);
3519
3520 if (shaderObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003521 {
Geoff Langbfdea662014-07-23 14:16:32 -04003522 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003523 }
3524 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003525
3526 return GL_FALSE;
3527}
3528
3529GLboolean __stdcall glIsTexture(GLuint texture)
3530{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003531 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003532
Geoff Langbfdea662014-07-23 14:16:32 -04003533 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003534 if (context && texture)
3535 {
3536 gl::Texture *textureObject = context->getTexture(texture);
3537
3538 if (textureObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003539 {
Geoff Langbfdea662014-07-23 14:16:32 -04003540 return GL_TRUE;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003541 }
3542 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003543
3544 return GL_FALSE;
3545}
3546
3547void __stdcall glLineWidth(GLfloat width)
3548{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003549 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003550
Geoff Langbfdea662014-07-23 14:16:32 -04003551 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003552 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003553 {
Geoff Langb1196682014-07-23 13:47:29 -04003554 if (width <= 0.0f)
3555 {
3556 context->recordError(gl::Error(GL_INVALID_VALUE));
3557 return;
3558 }
3559
Geoff Langbfdea662014-07-23 14:16:32 -04003560 context->getState().setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003561 }
3562}
3563
3564void __stdcall glLinkProgram(GLuint program)
3565{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003566 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003567
Geoff Langbfdea662014-07-23 14:16:32 -04003568 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003569 if (context)
3570 {
3571 gl::Program *programObject = context->getProgram(program);
3572
3573 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003574 {
Geoff Langbfdea662014-07-23 14:16:32 -04003575 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003576 {
Geoff Langb1196682014-07-23 13:47:29 -04003577 context->recordError(gl::Error(GL_INVALID_OPERATION));
3578 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003579 }
Geoff Langbfdea662014-07-23 14:16:32 -04003580 else
3581 {
Geoff Langb1196682014-07-23 13:47:29 -04003582 context->recordError(gl::Error(GL_INVALID_VALUE));
3583 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003584 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003585 }
Geoff Langbfdea662014-07-23 14:16:32 -04003586
3587 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003588 }
3589}
3590
3591void __stdcall glPixelStorei(GLenum pname, GLint param)
3592{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003593 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003594
Geoff Langbfdea662014-07-23 14:16:32 -04003595 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003596 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003597 {
Geoff Langbfdea662014-07-23 14:16:32 -04003598 switch (pname)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003599 {
Geoff Langbfdea662014-07-23 14:16:32 -04003600 case GL_UNPACK_ALIGNMENT:
3601 if (param != 1 && param != 2 && param != 4 && param != 8)
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003602 {
Geoff Langb1196682014-07-23 13:47:29 -04003603 context->recordError(gl::Error(GL_INVALID_VALUE));
3604 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003605 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003606
Geoff Langbfdea662014-07-23 14:16:32 -04003607 context->getState().setUnpackAlignment(param);
3608 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003609
Geoff Langbfdea662014-07-23 14:16:32 -04003610 case GL_PACK_ALIGNMENT:
3611 if (param != 1 && param != 2 && param != 4 && param != 8)
3612 {
Geoff Langb1196682014-07-23 13:47:29 -04003613 context->recordError(gl::Error(GL_INVALID_VALUE));
3614 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003615 }
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003616
Geoff Langbfdea662014-07-23 14:16:32 -04003617 context->getState().setPackAlignment(param);
3618 break;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003619
Geoff Langbfdea662014-07-23 14:16:32 -04003620 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
3621 context->getState().setPackReverseRowOrder(param != 0);
3622 break;
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00003623
Geoff Langbfdea662014-07-23 14:16:32 -04003624 case GL_UNPACK_IMAGE_HEIGHT:
3625 case GL_UNPACK_SKIP_IMAGES:
3626 case GL_UNPACK_ROW_LENGTH:
3627 case GL_UNPACK_SKIP_ROWS:
3628 case GL_UNPACK_SKIP_PIXELS:
3629 case GL_PACK_ROW_LENGTH:
3630 case GL_PACK_SKIP_ROWS:
3631 case GL_PACK_SKIP_PIXELS:
3632 if (context->getClientVersion() < 3)
3633 {
Geoff Langb1196682014-07-23 13:47:29 -04003634 context->recordError(gl::Error(GL_INVALID_ENUM));
3635 return;
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00003636 }
Geoff Langbfdea662014-07-23 14:16:32 -04003637 UNIMPLEMENTED();
3638 break;
3639
3640 default:
Geoff Langb1196682014-07-23 13:47:29 -04003641 context->recordError(gl::Error(GL_INVALID_ENUM));
3642 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003643 }
3644 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645}
3646
3647void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
3648{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003649 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003650
Geoff Langbfdea662014-07-23 14:16:32 -04003651 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003652 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003653 {
Geoff Langbfdea662014-07-23 14:16:32 -04003654 context->getState().setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003655 }
3656}
3657
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003658void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
3659 GLenum format, GLenum type, GLsizei bufSize,
3660 GLvoid *data)
3661{
3662 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
3663 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
3664 x, y, width, height, format, type, bufSize, data);
3665
Geoff Langbfdea662014-07-23 14:16:32 -04003666 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003667 if (context)
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003668 {
Geoff Langb1196682014-07-23 13:47:29 -04003669 if (width < 0 || height < 0 || bufSize < 0)
3670 {
3671 context->recordError(gl::Error(GL_INVALID_VALUE));
3672 return;
3673 }
3674
Geoff Langbfdea662014-07-23 14:16:32 -04003675 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3676 format, type, &bufSize, data))
3677 {
3678 return;
3679 }
3680
3681 context->readPixels(x, y, width, height, format, type, &bufSize, data);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00003682 }
3683}
3684
3685void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
3686 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003687{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003688 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003689 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003690 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003691
Geoff Langbfdea662014-07-23 14:16:32 -04003692 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003693 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003694 {
Geoff Langb1196682014-07-23 13:47:29 -04003695 if (width < 0 || height < 0)
3696 {
3697 context->recordError(gl::Error(GL_INVALID_VALUE));
3698 return;
3699 }
3700
Geoff Langbfdea662014-07-23 14:16:32 -04003701 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
3702 format, type, NULL, pixels))
3703 {
3704 return;
3705 }
3706
3707 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003708 }
3709}
3710
3711void __stdcall glReleaseShaderCompiler(void)
3712{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003713 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003714
Brandon Jonesf05cdee2014-08-27 15:24:07 -07003715 gl::Context *context = gl::getNonLostContext();
3716
3717 if (context)
3718 {
3719 context->releaseShaderCompiler();
3720 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003721}
3722
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003723void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003724{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003725 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 +00003726 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003727
Geoff Langbfdea662014-07-23 14:16:32 -04003728 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003729 if (context)
3730 {
3731 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
3732 width, height, true))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 {
Geoff Langbfdea662014-07-23 14:16:32 -04003734 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003735 }
Geoff Langbfdea662014-07-23 14:16:32 -04003736
3737 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003738 }
3739}
3740
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003741void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
3742{
3743 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
3744}
3745
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003746void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
3747{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00003748 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003749
Geoff Langbfdea662014-07-23 14:16:32 -04003750 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003751
Geoff Langbfdea662014-07-23 14:16:32 -04003752 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003753 {
Geoff Langbfdea662014-07-23 14:16:32 -04003754 context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003755 }
3756}
3757
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003758void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
3759{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003760 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003761
Geoff Langbfdea662014-07-23 14:16:32 -04003762 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003763 if (context)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003764 {
Geoff Langb1196682014-07-23 13:47:29 -04003765 if (condition != GL_ALL_COMPLETED_NV)
3766 {
3767 context->recordError(gl::Error(GL_INVALID_ENUM));
3768 return;
3769 }
3770
Geoff Langbfdea662014-07-23 14:16:32 -04003771 gl::FenceNV *fenceObject = context->getFenceNV(fence);
3772
3773 if (fenceObject == NULL)
3774 {
Geoff Langb1196682014-07-23 13:47:29 -04003775 context->recordError(gl::Error(GL_INVALID_OPERATION));
3776 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003777 }
3778
3779 fenceObject->setFence(condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003780 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00003781}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00003782
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003783void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
3784{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003785 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 +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 Langb1196682014-07-23 13:47:29 -04003790 if (width < 0 || height < 0)
3791 {
3792 context->recordError(gl::Error(GL_INVALID_VALUE));
3793 return;
3794 }
3795
Geoff Langbfdea662014-07-23 14:16:32 -04003796 context->getState().setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003797 }
3798}
3799
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003800void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003801{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003802 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003803 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00003804 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003805
Geoff Lang900013c2014-07-07 11:32:19 -04003806 gl::Context* context = gl::getNonLostContext();
3807 if (context)
3808 {
3809 const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats;
3810 if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end())
3811 {
Geoff Langb1196682014-07-23 13:47:29 -04003812 context->recordError(gl::Error(GL_INVALID_ENUM));
3813 return;
Geoff Lang900013c2014-07-07 11:32:19 -04003814 }
3815
3816 // No binary shader formats are supported.
3817 UNIMPLEMENTED();
3818 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003819}
3820
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00003821void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003822{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003823 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 +00003824 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003825
Geoff Langbfdea662014-07-23 14:16:32 -04003826 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003827 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828 {
Geoff Langb1196682014-07-23 13:47:29 -04003829 if (count < 0)
3830 {
3831 context->recordError(gl::Error(GL_INVALID_VALUE));
3832 return;
3833 }
3834
Geoff Langbfdea662014-07-23 14:16:32 -04003835 gl::Shader *shaderObject = context->getShader(shader);
3836
3837 if (!shaderObject)
3838 {
3839 if (context->getProgram(shader))
3840 {
Geoff Langb1196682014-07-23 13:47:29 -04003841 context->recordError(gl::Error(GL_INVALID_OPERATION));
3842 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003843 }
3844 else
3845 {
Geoff Langb1196682014-07-23 13:47:29 -04003846 context->recordError(gl::Error(GL_INVALID_VALUE));
3847 return;
Geoff Langbfdea662014-07-23 14:16:32 -04003848 }
3849 }
3850
3851 shaderObject->setSource(count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003852 }
3853}
3854
3855void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
3856{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003857 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003858}
3859
3860void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
3861{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003862 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 +00003863
Geoff Langbfdea662014-07-23 14:16:32 -04003864 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003865 if (context)
3866 {
Geoff Langb1196682014-07-23 13:47:29 -04003867 switch (face)
3868 {
3869 case GL_FRONT:
3870 case GL_BACK:
3871 case GL_FRONT_AND_BACK:
3872 break;
3873
3874 default:
3875 context->recordError(gl::Error(GL_INVALID_ENUM));
3876 return;
3877 }
3878
3879 switch (func)
3880 {
3881 case GL_NEVER:
3882 case GL_ALWAYS:
3883 case GL_LESS:
3884 case GL_LEQUAL:
3885 case GL_EQUAL:
3886 case GL_GEQUAL:
3887 case GL_GREATER:
3888 case GL_NOTEQUAL:
3889 break;
3890
3891 default:
3892 context->recordError(gl::Error(GL_INVALID_ENUM));
3893 return;
3894 }
3895
Geoff Langbfdea662014-07-23 14:16:32 -04003896 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
3897 {
3898 context->getState().setStencilParams(func, ref, mask);
3899 }
3900
3901 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
3902 {
3903 context->getState().setStencilBackParams(func, ref, mask);
3904 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003905 }
3906}
3907
3908void __stdcall glStencilMask(GLuint mask)
3909{
3910 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
3911}
3912
3913void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
3914{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003915 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003916
Geoff Langbfdea662014-07-23 14:16:32 -04003917 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003918 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003919 {
Geoff Langb1196682014-07-23 13:47:29 -04003920 switch (face)
3921 {
3922 case GL_FRONT:
3923 case GL_BACK:
3924 case GL_FRONT_AND_BACK:
3925 break;
3926
3927 default:
3928 context->recordError(gl::Error(GL_INVALID_ENUM));
3929 return;
3930 }
3931
Geoff Langbfdea662014-07-23 14:16:32 -04003932 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
3933 {
3934 context->getState().setStencilWritemask(mask);
3935 }
3936
3937 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
3938 {
3939 context->getState().setStencilBackWritemask(mask);
3940 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003941 }
3942}
3943
3944void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
3945{
3946 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
3947}
3948
3949void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
3950{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003951 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 +00003952 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003953
Geoff Langbfdea662014-07-23 14:16:32 -04003954 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04003955 if (context)
3956 {
Geoff Langb1196682014-07-23 13:47:29 -04003957 switch (face)
3958 {
3959 case GL_FRONT:
3960 case GL_BACK:
3961 case GL_FRONT_AND_BACK:
3962 break;
3963
3964 default:
3965 context->recordError(gl::Error(GL_INVALID_ENUM));
3966 return;
3967 }
3968
3969 switch (fail)
3970 {
3971 case GL_ZERO:
3972 case GL_KEEP:
3973 case GL_REPLACE:
3974 case GL_INCR:
3975 case GL_DECR:
3976 case GL_INVERT:
3977 case GL_INCR_WRAP:
3978 case GL_DECR_WRAP:
3979 break;
3980
3981 default:
3982 context->recordError(gl::Error(GL_INVALID_ENUM));
3983 return;
3984 }
3985
3986 switch (zfail)
3987 {
3988 case GL_ZERO:
3989 case GL_KEEP:
3990 case GL_REPLACE:
3991 case GL_INCR:
3992 case GL_DECR:
3993 case GL_INVERT:
3994 case GL_INCR_WRAP:
3995 case GL_DECR_WRAP:
3996 break;
3997
3998 default:
3999 context->recordError(gl::Error(GL_INVALID_ENUM));
4000 return;
4001 }
4002
4003 switch (zpass)
4004 {
4005 case GL_ZERO:
4006 case GL_KEEP:
4007 case GL_REPLACE:
4008 case GL_INCR:
4009 case GL_DECR:
4010 case GL_INVERT:
4011 case GL_INCR_WRAP:
4012 case GL_DECR_WRAP:
4013 break;
4014
4015 default:
4016 context->recordError(gl::Error(GL_INVALID_ENUM));
4017 return;
4018 }
4019
Geoff Langbfdea662014-07-23 14:16:32 -04004020 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4021 {
4022 context->getState().setStencilOperations(fail, zfail, zpass);
4023 }
4024
4025 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4026 {
4027 context->getState().setStencilBackOperations(fail, zfail, zpass);
4028 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004029 }
4030}
4031
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004032GLboolean __stdcall glTestFenceNV(GLuint fence)
4033{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004034 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004035
Geoff Langbfdea662014-07-23 14:16:32 -04004036 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004037 if (context)
4038 {
4039 gl::FenceNV *fenceObject = context->getFenceNV(fence);
4040
4041 if (fenceObject == NULL)
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004042 {
Geoff Langb1196682014-07-23 13:47:29 -04004043 context->recordError(gl::Error(GL_INVALID_OPERATION));
4044 return GL_TRUE;
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004045 }
Geoff Langbfdea662014-07-23 14:16:32 -04004046
4047 if (fenceObject->isFence() != GL_TRUE)
4048 {
Geoff Langb1196682014-07-23 13:47:29 -04004049 context->recordError(gl::Error(GL_INVALID_OPERATION));
4050 return GL_TRUE;
Geoff Langbfdea662014-07-23 14:16:32 -04004051 }
4052
4053 return fenceObject->testFence();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004054 }
Geoff Langbfdea662014-07-23 14:16:32 -04004055
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004056 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004057}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004058
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004059void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
4060 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004061{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004062 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004063 "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 +00004064 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004065
Geoff Langbfdea662014-07-23 14:16:32 -04004066 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004067 if (context)
4068 {
4069 if (context->getClientVersion() < 3 &&
4070 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
4071 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072 {
Geoff Langbfdea662014-07-23 14:16:32 -04004073 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004074 }
Geoff Langbfdea662014-07-23 14:16:32 -04004075
4076 if (context->getClientVersion() >= 3 &&
4077 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4078 0, 0, 0, width, height, 1, border, format, type, pixels))
4079 {
4080 return;
4081 }
4082
4083 switch (target)
4084 {
4085 case GL_TEXTURE_2D:
4086 {
4087 gl::Texture2D *texture = context->getTexture2D();
4088 texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4089 }
4090 break;
4091 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4092 {
4093 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4094 texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4095 }
4096 break;
4097 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4098 {
4099 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4100 texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4101 }
4102 break;
4103 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4104 {
4105 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4106 texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4107 }
4108 break;
4109 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4110 {
4111 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4112 texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4113 }
4114 break;
4115 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4116 {
4117 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4118 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4119 }
4120 break;
4121 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4122 {
4123 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4124 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
4125 }
4126 break;
4127 default: UNREACHABLE();
4128 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004129 }
4130}
4131
4132void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
4133{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004134 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4135
Geoff Langbfdea662014-07-23 14:16:32 -04004136 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004137 if (context)
4138 {
4139 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004140 {
Geoff Langbfdea662014-07-23 14:16:32 -04004141 return;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004142 }
Geoff Langbfdea662014-07-23 14:16:32 -04004143
4144 gl::Texture *texture = context->getTargetTexture(target);
4145
4146 if (!texture)
4147 {
Geoff Langb1196682014-07-23 13:47:29 -04004148 context->recordError(gl::Error(GL_INVALID_ENUM));
4149 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004150 }
4151
4152 switch (pname)
4153 {
4154 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4155 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4156 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4157 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4158 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4159 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4160 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break;
4161 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4162 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4163 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4164 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4165 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4166 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4167 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4168 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4169 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4170 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
4171 default: UNREACHABLE(); break;
4172 }
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004173 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004174}
4175
4176void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
4177{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004178 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004179}
4180
4181void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
4182{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004183 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004184
Geoff Langbfdea662014-07-23 14:16:32 -04004185 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004186 if (context)
4187 {
4188 if (!ValidateTexParamParameters(context, pname, param))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004189 {
Geoff Langbfdea662014-07-23 14:16:32 -04004190 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004191 }
Geoff Langbfdea662014-07-23 14:16:32 -04004192
4193 gl::Texture *texture = context->getTargetTexture(target);
4194
4195 if (!texture)
4196 {
Geoff Langb1196682014-07-23 13:47:29 -04004197 context->recordError(gl::Error(GL_INVALID_ENUM));
4198 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004199 }
4200
4201 switch (pname)
4202 {
4203 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4204 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4205 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4206 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4207 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4208 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4209 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break;
4210 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4211 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4212 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4213 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4214 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4215 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4216 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4217 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4218 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4219 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
4220 default: UNREACHABLE(); break;
4221 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004222 }
4223}
4224
4225void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
4226{
4227 glTexParameteri(target, pname, *params);
4228}
4229
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004230void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
4231{
4232 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4233 target, levels, internalformat, width, height);
4234
Geoff Langbfdea662014-07-23 14:16:32 -04004235 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004236 if (context)
4237 {
4238 if (!context->getExtensions().textureStorage)
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004239 {
Geoff Langb1196682014-07-23 13:47:29 -04004240 context->recordError(gl::Error(GL_INVALID_OPERATION));
4241 return;
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004242 }
Geoff Langbfdea662014-07-23 14:16:32 -04004243
4244 if (context->getClientVersion() < 3 &&
4245 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
4246 {
4247 return;
4248 }
4249
4250 if (context->getClientVersion() >= 3 &&
4251 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
4252 {
4253 return;
4254 }
4255
4256 switch (target)
4257 {
4258 case GL_TEXTURE_2D:
4259 {
4260 gl::Texture2D *texture2d = context->getTexture2D();
4261 texture2d->storage(levels, internalformat, width, height);
4262 }
4263 break;
4264
4265 case GL_TEXTURE_CUBE_MAP:
4266 {
4267 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
4268 textureCube->storage(levels, internalformat, width);
4269 }
4270 break;
4271
4272 default:
Geoff Langb1196682014-07-23 13:47:29 -04004273 context->recordError(gl::Error(GL_INVALID_ENUM));
4274 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004275 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004276 }
4277}
4278
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004279void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
4280 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004282 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004283 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004284 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004285 target, level, xoffset, yoffset, width, height, format, type, pixels);
4286
Geoff Langbfdea662014-07-23 14:16:32 -04004287 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004288 if (context)
4289 {
4290 if (context->getClientVersion() < 3 &&
4291 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
4292 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004293 {
Geoff Langbfdea662014-07-23 14:16:32 -04004294 return;
daniel@transgaming.com00c75962010-03-11 20:36:15 +00004295 }
Geoff Langbfdea662014-07-23 14:16:32 -04004296
4297 if (context->getClientVersion() >= 3 &&
4298 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4299 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
4300 {
4301 return;
4302 }
4303
4304 // Zero sized uploads are valid but no-ops
4305 if (width == 0 || height == 0)
4306 {
4307 return;
4308 }
4309
4310 switch (target)
4311 {
4312 case GL_TEXTURE_2D:
4313 {
4314 gl::Texture2D *texture = context->getTexture2D();
4315 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4316 }
4317 break;
4318
4319 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
4320 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4321 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4322 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4323 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4324 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4325 {
4326 gl::TextureCubeMap *texture = context->getTextureCubeMap();
4327 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
4328 }
4329 break;
4330
4331 default:
4332 UNREACHABLE();
4333 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004334 }
4335}
4336
4337void __stdcall glUniform1f(GLint location, GLfloat x)
4338{
4339 glUniform1fv(location, 1, &x);
4340}
4341
4342void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
4343{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004344 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004345
Geoff Langbfdea662014-07-23 14:16:32 -04004346 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004347 if (context)
4348 {
4349 if (!ValidateUniform(context, GL_FLOAT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004350 {
Geoff Langbfdea662014-07-23 14:16:32 -04004351 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004352 }
Geoff Langbfdea662014-07-23 14:16:32 -04004353
4354 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4355 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004356 }
4357}
4358
4359void __stdcall glUniform1i(GLint location, GLint x)
4360{
4361 glUniform1iv(location, 1, &x);
4362}
4363
4364void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
4365{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004366 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004367
Geoff Langbfdea662014-07-23 14:16:32 -04004368 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004369 if (context)
4370 {
4371 if (!ValidateUniform(context, GL_INT, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004372 {
Geoff Langbfdea662014-07-23 14:16:32 -04004373 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004374 }
Geoff Langbfdea662014-07-23 14:16:32 -04004375
4376 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4377 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004378 }
4379}
4380
4381void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
4382{
4383 GLfloat xy[2] = {x, y};
4384
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004385 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004386}
4387
4388void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
4389{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004390 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004391
Geoff Langbfdea662014-07-23 14:16:32 -04004392 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004393 if (context)
4394 {
4395 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004396 {
Geoff Langbfdea662014-07-23 14:16:32 -04004397 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004398 }
Geoff Langbfdea662014-07-23 14:16:32 -04004399
4400 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4401 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004402 }
4403}
4404
4405void __stdcall glUniform2i(GLint location, GLint x, GLint y)
4406{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004407 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004408
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004409 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004410}
4411
4412void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
4413{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004414 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004415
Geoff Langbfdea662014-07-23 14:16:32 -04004416 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004417 if (context)
4418 {
4419 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004420 {
Geoff Langbfdea662014-07-23 14:16:32 -04004421 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004422 }
Geoff Langbfdea662014-07-23 14:16:32 -04004423
4424 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4425 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004426 }
4427}
4428
4429void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
4430{
4431 GLfloat xyz[3] = {x, y, z};
4432
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004433 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004434}
4435
4436void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
4437{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004438 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004439
Geoff Langbfdea662014-07-23 14:16:32 -04004440 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004441 if (context)
4442 {
4443 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004444 {
Geoff Langbfdea662014-07-23 14:16:32 -04004445 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004446 }
Geoff Langbfdea662014-07-23 14:16:32 -04004447
4448 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4449 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004450 }
4451}
4452
4453void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
4454{
4455 GLint xyz[3] = {x, y, z};
4456
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004457 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004458}
4459
4460void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
4461{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004462 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004463
Geoff Langbfdea662014-07-23 14:16:32 -04004464 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004465 if (context)
4466 {
4467 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004468 {
Geoff Langbfdea662014-07-23 14:16:32 -04004469 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004470 }
Geoff Langbfdea662014-07-23 14:16:32 -04004471
4472 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4473 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004474 }
4475}
4476
4477void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4478{
4479 GLfloat xyzw[4] = {x, y, z, w};
4480
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004481 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004482}
4483
4484void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
4485{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004486 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004487
Geoff Langbfdea662014-07-23 14:16:32 -04004488 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004489 if (context)
4490 {
4491 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492 {
Geoff Langbfdea662014-07-23 14:16:32 -04004493 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004494 }
Geoff Langbfdea662014-07-23 14:16:32 -04004495
4496 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4497 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004498 }
4499}
4500
4501void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
4502{
4503 GLint xyzw[4] = {x, y, z, w};
4504
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05004505 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004506}
4507
4508void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
4509{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004510 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004511
Geoff Langbfdea662014-07-23 14:16:32 -04004512 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004513 if (context)
4514 {
4515 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004516 {
Geoff Langbfdea662014-07-23 14:16:32 -04004517 return;
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00004518 }
Geoff Langbfdea662014-07-23 14:16:32 -04004519
4520 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4521 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004522 }
4523}
4524
4525void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
4526{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004527 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004528 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004529
Geoff Langbfdea662014-07-23 14:16:32 -04004530 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004531 if (context)
4532 {
4533 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004534 {
Geoff Langbfdea662014-07-23 14:16:32 -04004535 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004536 }
Geoff Langbfdea662014-07-23 14:16:32 -04004537
4538 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4539 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004540 }
4541}
4542
4543void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
4544{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004545 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004546 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004547
Geoff Langbfdea662014-07-23 14:16:32 -04004548 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004549 if (context)
4550 {
4551 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004552 {
Geoff Langbfdea662014-07-23 14:16:32 -04004553 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004554 }
Geoff Langbfdea662014-07-23 14:16:32 -04004555
4556 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4557 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004558 }
4559}
4560
4561void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
4562{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004563 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004564 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004565
Geoff Langbfdea662014-07-23 14:16:32 -04004566 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004567 if (context)
4568 {
4569 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570 {
Geoff Langbfdea662014-07-23 14:16:32 -04004571 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004572 }
Geoff Langbfdea662014-07-23 14:16:32 -04004573
4574 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
4575 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004576 }
4577}
4578
4579void __stdcall glUseProgram(GLuint program)
4580{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004581 EVENT("(GLuint program = %d)", program);
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)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004585 {
Geoff Langbfdea662014-07-23 14:16:32 -04004586 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004587
Geoff Langbfdea662014-07-23 14:16:32 -04004588 if (!programObject && program != 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004589 {
Geoff Langbfdea662014-07-23 14:16:32 -04004590 if (context->getShader(program))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004591 {
Geoff Langb1196682014-07-23 13:47:29 -04004592 context->recordError(gl::Error(GL_INVALID_OPERATION));
4593 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004594 }
Geoff Langbfdea662014-07-23 14:16:32 -04004595 else
4596 {
Geoff Langb1196682014-07-23 13:47:29 -04004597 context->recordError(gl::Error(GL_INVALID_VALUE));
4598 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004599 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004600 }
Geoff Langbfdea662014-07-23 14:16:32 -04004601
4602 if (program != 0 && !programObject->isLinked())
4603 {
Geoff Langb1196682014-07-23 13:47:29 -04004604 context->recordError(gl::Error(GL_INVALID_OPERATION));
4605 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004606 }
4607
4608 context->useProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609 }
4610}
4611
4612void __stdcall glValidateProgram(GLuint program)
4613{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004614 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004615
Geoff Langbfdea662014-07-23 14:16:32 -04004616 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004617 if (context)
4618 {
4619 gl::Program *programObject = context->getProgram(program);
4620
4621 if (!programObject)
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004622 {
Geoff Langbfdea662014-07-23 14:16:32 -04004623 if (context->getShader(program))
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004624 {
Geoff Langb1196682014-07-23 13:47:29 -04004625 context->recordError(gl::Error(GL_INVALID_OPERATION));
4626 return;
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004627 }
Geoff Langbfdea662014-07-23 14:16:32 -04004628 else
4629 {
Geoff Langb1196682014-07-23 13:47:29 -04004630 context->recordError(gl::Error(GL_INVALID_VALUE));
4631 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004632 }
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00004633 }
Geoff Langbfdea662014-07-23 14:16:32 -04004634
Brandon Jones43a53e22014-08-28 16:23:22 -07004635 programObject->validate(context->getCaps());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004636 }
4637}
4638
4639void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
4640{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004641 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004642
Geoff Langbfdea662014-07-23 14:16:32 -04004643 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004644 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004645 {
Geoff Langb1196682014-07-23 13:47:29 -04004646 if (index >= gl::MAX_VERTEX_ATTRIBS)
4647 {
4648 context->recordError(gl::Error(GL_INVALID_VALUE));
4649 return;
4650 }
4651
Geoff Langbfdea662014-07-23 14:16:32 -04004652 GLfloat vals[4] = { x, 0, 0, 1 };
4653 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004654 }
4655}
4656
4657void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
4658{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004659 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004660
Geoff Langbfdea662014-07-23 14:16:32 -04004661 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004662 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004663 {
Geoff Langb1196682014-07-23 13:47:29 -04004664 if (index >= gl::MAX_VERTEX_ATTRIBS)
4665 {
4666 context->recordError(gl::Error(GL_INVALID_VALUE));
4667 return;
4668 }
4669
Geoff Langbfdea662014-07-23 14:16:32 -04004670 GLfloat vals[4] = { values[0], 0, 0, 1 };
4671 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004672 }
4673}
4674
4675void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
4676{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004677 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
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)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004681 {
Geoff Langb1196682014-07-23 13:47:29 -04004682 if (index >= gl::MAX_VERTEX_ATTRIBS)
4683 {
4684 context->recordError(gl::Error(GL_INVALID_VALUE));
4685 return;
4686 }
4687
Geoff Langbfdea662014-07-23 14:16:32 -04004688 GLfloat vals[4] = { x, y, 0, 1 };
4689 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004690 }
4691}
4692
4693void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
4694{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004695 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
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)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004699 {
Geoff Langb1196682014-07-23 13:47:29 -04004700 if (index >= gl::MAX_VERTEX_ATTRIBS)
4701 {
4702 context->recordError(gl::Error(GL_INVALID_VALUE));
4703 return;
4704 }
4705
Geoff Langbfdea662014-07-23 14:16:32 -04004706 GLfloat vals[4] = { values[0], values[1], 0, 1 };
4707 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004708 }
4709}
4710
4711void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
4712{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004713 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 +00004714
Geoff Langbfdea662014-07-23 14:16:32 -04004715 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004716 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004717 {
Geoff Langb1196682014-07-23 13:47:29 -04004718 if (index >= gl::MAX_VERTEX_ATTRIBS)
4719 {
4720 context->recordError(gl::Error(GL_INVALID_VALUE));
4721 return;
4722 }
4723
Geoff Langbfdea662014-07-23 14:16:32 -04004724 GLfloat vals[4] = { x, y, z, 1 };
4725 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004726 }
4727}
4728
4729void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
4730{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004731 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
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)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004735 {
Geoff Langb1196682014-07-23 13:47:29 -04004736 if (index >= gl::MAX_VERTEX_ATTRIBS)
4737 {
4738 context->recordError(gl::Error(GL_INVALID_VALUE));
4739 return;
4740 }
4741
Geoff Langbfdea662014-07-23 14:16:32 -04004742 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
4743 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004744 }
4745}
4746
4747void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
4748{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004749 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 +00004750
Geoff Langbfdea662014-07-23 14:16:32 -04004751 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004752 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004753 {
Geoff Langb1196682014-07-23 13:47:29 -04004754 if (index >= gl::MAX_VERTEX_ATTRIBS)
4755 {
4756 context->recordError(gl::Error(GL_INVALID_VALUE));
4757 return;
4758 }
4759
Geoff Langbfdea662014-07-23 14:16:32 -04004760 GLfloat vals[4] = { x, y, z, w };
4761 context->getState().setVertexAttribf(index, vals);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004762 }
4763}
4764
4765void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
4766{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004767 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004768
Geoff Langbfdea662014-07-23 14:16:32 -04004769 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004770 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004771 {
Geoff Langb1196682014-07-23 13:47:29 -04004772 if (index >= gl::MAX_VERTEX_ATTRIBS)
4773 {
4774 context->recordError(gl::Error(GL_INVALID_VALUE));
4775 return;
4776 }
4777
Geoff Langbfdea662014-07-23 14:16:32 -04004778 context->getState().setVertexAttribf(index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004779 }
4780}
4781
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004782void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
4783{
4784 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
4785
Geoff Langbfdea662014-07-23 14:16:32 -04004786 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004787 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004788 {
Geoff Langb1196682014-07-23 13:47:29 -04004789 if (index >= gl::MAX_VERTEX_ATTRIBS)
4790 {
4791 context->recordError(gl::Error(GL_INVALID_VALUE));
4792 return;
4793 }
4794
Geoff Langbfdea662014-07-23 14:16:32 -04004795 context->setVertexAttribDivisor(index, divisor);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00004796 }
4797}
4798
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004799void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004800{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004801 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004802 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004803 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004804
Geoff Langbfdea662014-07-23 14:16:32 -04004805 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004806 if (context)
4807 {
Geoff Langb1196682014-07-23 13:47:29 -04004808 if (index >= gl::MAX_VERTEX_ATTRIBS)
4809 {
4810 context->recordError(gl::Error(GL_INVALID_VALUE));
4811 return;
4812 }
4813
4814 if (size < 1 || size > 4)
4815 {
4816 context->recordError(gl::Error(GL_INVALID_VALUE));
4817 return;
4818 }
4819
4820 switch (type)
4821 {
4822 case GL_BYTE:
4823 case GL_UNSIGNED_BYTE:
4824 case GL_SHORT:
4825 case GL_UNSIGNED_SHORT:
4826 case GL_FIXED:
4827 case GL_FLOAT:
4828 break;
4829
4830 case GL_HALF_FLOAT:
4831 case GL_INT:
4832 case GL_UNSIGNED_INT:
4833 case GL_INT_2_10_10_10_REV:
4834 case GL_UNSIGNED_INT_2_10_10_10_REV:
4835 if (context->getClientVersion() < 3)
4836 {
4837 context->recordError(gl::Error(GL_INVALID_ENUM));
4838 return;
4839 }
4840 break;
4841
4842 default:
4843 context->recordError(gl::Error(GL_INVALID_ENUM));
4844 return;
4845 }
4846
4847 if (stride < 0)
4848 {
4849 context->recordError(gl::Error(GL_INVALID_VALUE));
4850 return;
4851 }
4852
4853 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
4854 {
4855 context->recordError(gl::Error(GL_INVALID_OPERATION));
4856 return;
4857 }
4858
Geoff Langbfdea662014-07-23 14:16:32 -04004859 // [OpenGL ES 3.0.2] Section 2.8 page 24:
4860 // An INVALID_OPERATION error is generated when a non-zero vertex array object
4861 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
4862 // and the pointer argument is not NULL.
4863 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00004864 {
Geoff Langb1196682014-07-23 13:47:29 -04004865 context->recordError(gl::Error(GL_INVALID_OPERATION));
4866 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00004867 }
4868
Geoff Langbfdea662014-07-23 14:16:32 -04004869 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type,
4870 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004871 }
4872}
4873
4874void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
4875{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004876 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 +00004877
Geoff Langbfdea662014-07-23 14:16:32 -04004878 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004879 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004880 {
Geoff Langb1196682014-07-23 13:47:29 -04004881 if (width < 0 || height < 0)
4882 {
4883 context->recordError(gl::Error(GL_INVALID_VALUE));
4884 return;
4885 }
4886
Geoff Langbfdea662014-07-23 14:16:32 -04004887 context->getState().setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004888 }
4889}
4890
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004891// OpenGL ES 3.0 functions
4892
4893void __stdcall glReadBuffer(GLenum mode)
4894{
4895 EVENT("(GLenum mode = 0x%X)", mode);
4896
Geoff Langbfdea662014-07-23 14:16:32 -04004897 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004898 if (context)
4899 {
4900 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004901 {
Geoff Langb1196682014-07-23 13:47:29 -04004902 context->recordError(gl::Error(GL_INVALID_OPERATION));
4903 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00004904 }
Geoff Langbfdea662014-07-23 14:16:32 -04004905
4906 // glReadBuffer
4907 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004908 }
4909}
4910
4911void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
4912{
4913 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
4914 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
4915
Geoff Langbfdea662014-07-23 14:16:32 -04004916 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004917 if (context)
4918 {
4919 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004920 {
Geoff Langb1196682014-07-23 13:47:29 -04004921 context->recordError(gl::Error(GL_INVALID_OPERATION));
4922 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00004923 }
Geoff Langbfdea662014-07-23 14:16:32 -04004924
4925 // glDrawRangeElements
4926 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004927 }
4928}
4929
4930void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
4931{
4932 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
4933 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
4934 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
4935 target, level, internalformat, width, height, depth, border, format, type, pixels);
4936
Geoff Langbfdea662014-07-23 14:16:32 -04004937 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004938 if (context)
4939 {
4940 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004941 {
Geoff Langb1196682014-07-23 13:47:29 -04004942 context->recordError(gl::Error(GL_INVALID_OPERATION));
4943 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00004944 }
Geoff Langbfdea662014-07-23 14:16:32 -04004945
4946 // validateES3TexImageFormat sets the error code if there is an error
4947 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
4948 0, 0, 0, width, height, depth, border, format, type, pixels))
4949 {
4950 return;
4951 }
4952
4953 switch(target)
4954 {
4955 case GL_TEXTURE_3D:
4956 {
4957 gl::Texture3D *texture = context->getTexture3D();
4958 texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
4959 }
4960 break;
4961
4962 case GL_TEXTURE_2D_ARRAY:
4963 {
4964 gl::Texture2DArray *texture = context->getTexture2DArray();
4965 texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
4966 }
4967 break;
4968
4969 default:
Geoff Langb1196682014-07-23 13:47:29 -04004970 context->recordError(gl::Error(GL_INVALID_ENUM));
4971 return;
Geoff Langbfdea662014-07-23 14:16:32 -04004972 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004973 }
4974}
4975
4976void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels)
4977{
4978 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
4979 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
4980 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
4981 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
4982
Geoff Langbfdea662014-07-23 14:16:32 -04004983 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04004984 if (context)
4985 {
4986 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004987 {
Geoff Langb1196682014-07-23 13:47:29 -04004988 context->recordError(gl::Error(GL_INVALID_OPERATION));
4989 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00004990 }
Geoff Langbfdea662014-07-23 14:16:32 -04004991
4992 // validateES3TexImageFormat sets the error code if there is an error
4993 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
4994 xoffset, yoffset, zoffset, width, height, depth, 0,
4995 format, type, pixels))
4996 {
4997 return;
4998 }
4999
5000 // Zero sized uploads are valid but no-ops
5001 if (width == 0 || height == 0 || depth == 0)
5002 {
5003 return;
5004 }
5005
5006 switch(target)
5007 {
5008 case GL_TEXTURE_3D:
5009 {
5010 gl::Texture3D *texture = context->getTexture3D();
5011 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5012 }
5013 break;
5014
5015 case GL_TEXTURE_2D_ARRAY:
5016 {
5017 gl::Texture2DArray *texture = context->getTexture2DArray();
5018 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
5019 }
5020 break;
5021
5022 default:
Geoff Langb1196682014-07-23 13:47:29 -04005023 context->recordError(gl::Error(GL_INVALID_ENUM));
5024 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005025 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005026 }
5027}
5028
5029void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
5030{
5031 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5032 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5033 target, level, xoffset, yoffset, zoffset, x, y, width, height);
5034
Geoff Langbfdea662014-07-23 14:16:32 -04005035 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005036 if (context)
5037 {
5038 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005039 {
Geoff Langb1196682014-07-23 13:47:29 -04005040 context->recordError(gl::Error(GL_INVALID_OPERATION));
5041 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005042 }
Geoff Langbfdea662014-07-23 14:16:32 -04005043
5044 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
5045 x, y, width, height, 0))
5046 {
5047 return;
5048 }
5049
5050 gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer();
5051 gl::Texture *texture = NULL;
5052 switch (target)
5053 {
5054 case GL_TEXTURE_3D:
5055 texture = context->getTexture3D();
5056 break;
5057
5058 case GL_TEXTURE_2D_ARRAY:
5059 texture = context->getTexture2DArray();
5060 break;
5061
5062 default:
Geoff Langb1196682014-07-23 13:47:29 -04005063 context->recordError(gl::Error(GL_INVALID_ENUM));
5064 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005065 }
5066
5067 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005068 }
5069}
5070
5071void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
5072{
Geoff Langeef52cc2013-10-16 15:07:39 -04005073 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 +00005074 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
5075 "const GLvoid* data = 0x%0.8p)",
5076 target, level, internalformat, width, height, depth, border, imageSize, data);
5077
Geoff Langbfdea662014-07-23 14:16:32 -04005078 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005079 if (context)
5080 {
5081 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005082 {
Geoff Langb1196682014-07-23 13:47:29 -04005083 context->recordError(gl::Error(GL_INVALID_OPERATION));
5084 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005085 }
Geoff Langbfdea662014-07-23 14:16:32 -04005086
Geoff Lang5d601382014-07-22 15:14:06 -04005087 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
5088 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005089 {
Geoff Langb1196682014-07-23 13:47:29 -04005090 context->recordError(gl::Error(GL_INVALID_VALUE));
5091 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005092 }
5093
5094 // validateES3TexImageFormat sets the error code if there is an error
5095 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
5096 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
5097 {
5098 return;
5099 }
5100
5101 switch(target)
5102 {
5103 case GL_TEXTURE_3D:
5104 {
5105 gl::Texture3D *texture = context->getTexture3D();
5106 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5107 }
5108 break;
5109
5110 case GL_TEXTURE_2D_ARRAY:
5111 {
5112 gl::Texture2DArray *texture = context->getTexture2DArray();
5113 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
5114 }
5115 break;
5116
5117 default:
Geoff Langb1196682014-07-23 13:47:29 -04005118 context->recordError(gl::Error(GL_INVALID_ENUM));
5119 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005120 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005121 }
5122}
5123
5124void __stdcall glCompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data)
5125{
5126 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5127 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5128 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
5129 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
5130
Geoff Langbfdea662014-07-23 14:16:32 -04005131 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005132 if (context)
5133 {
5134 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005135 {
Geoff Langb1196682014-07-23 13:47:29 -04005136 context->recordError(gl::Error(GL_INVALID_OPERATION));
5137 return;
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005138 }
Geoff Langbfdea662014-07-23 14:16:32 -04005139
Geoff Lang5d601382014-07-22 15:14:06 -04005140 const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format);
5141 if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
Geoff Langbfdea662014-07-23 14:16:32 -04005142 {
Geoff Langb1196682014-07-23 13:47:29 -04005143 context->recordError(gl::Error(GL_INVALID_VALUE));
5144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005145 }
5146
5147 if (!data)
5148 {
Geoff Langb1196682014-07-23 13:47:29 -04005149 context->recordError(gl::Error(GL_INVALID_VALUE));
5150 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005151 }
5152
5153 // validateES3TexImageFormat sets the error code if there is an error
5154 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
5155 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
5156 {
5157 return;
5158 }
5159
5160 // Zero sized uploads are valid but no-ops
5161 if (width == 0 || height == 0)
5162 {
5163 return;
5164 }
5165
5166 switch(target)
5167 {
5168 case GL_TEXTURE_3D:
5169 {
5170 gl::Texture3D *texture = context->getTexture3D();
5171 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5172 format, imageSize, data);
5173 }
5174 break;
5175
5176 case GL_TEXTURE_2D_ARRAY:
5177 {
5178 gl::Texture2DArray *texture = context->getTexture2DArray();
5179 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
5180 format, imageSize, data);
5181 }
5182 break;
5183
Geoff Langb1196682014-07-23 13:47:29 -04005184 default:
5185 context->recordError(gl::Error(GL_INVALID_ENUM));
5186 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005187 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005188 }
5189}
5190
5191void __stdcall glGenQueries(GLsizei n, GLuint* ids)
5192{
5193 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5194
Geoff Langbfdea662014-07-23 14:16:32 -04005195 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005196 if (context)
5197 {
5198 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005199 {
Geoff Langb1196682014-07-23 13:47:29 -04005200 context->recordError(gl::Error(GL_INVALID_OPERATION));
5201 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005202 }
Geoff Langbfdea662014-07-23 14:16:32 -04005203
5204 if (n < 0)
5205 {
Geoff Langb1196682014-07-23 13:47:29 -04005206 context->recordError(gl::Error(GL_INVALID_VALUE));
5207 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005208 }
5209
5210 for (GLsizei i = 0; i < n; i++)
5211 {
5212 ids[i] = context->createQuery();
5213 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005214 }
5215}
5216
5217void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
5218{
5219 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
5220
Geoff Langbfdea662014-07-23 14:16:32 -04005221 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005222 if (context)
5223 {
5224 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005225 {
Geoff Langb1196682014-07-23 13:47:29 -04005226 context->recordError(gl::Error(GL_INVALID_OPERATION));
5227 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005228 }
Geoff Langbfdea662014-07-23 14:16:32 -04005229
5230 if (n < 0)
5231 {
Geoff Langb1196682014-07-23 13:47:29 -04005232 context->recordError(gl::Error(GL_INVALID_VALUE));
5233 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005234 }
5235
5236 for (GLsizei i = 0; i < n; i++)
5237 {
5238 context->deleteQuery(ids[i]);
5239 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005240 }
5241}
5242
5243GLboolean __stdcall glIsQuery(GLuint id)
5244{
5245 EVENT("(GLuint id = %u)", id);
5246
Geoff Langbfdea662014-07-23 14:16:32 -04005247 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005248 if (context)
5249 {
5250 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005251 {
Geoff Langb1196682014-07-23 13:47:29 -04005252 context->recordError(gl::Error(GL_INVALID_OPERATION));
5253 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005254 }
Geoff Langbfdea662014-07-23 14:16:32 -04005255
5256 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005257 }
5258
5259 return GL_FALSE;
5260}
5261
5262void __stdcall glBeginQuery(GLenum target, GLuint id)
5263{
5264 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
5265
Geoff Langbfdea662014-07-23 14:16:32 -04005266 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005267 if (context)
5268 {
5269 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005270 {
Geoff Langb1196682014-07-23 13:47:29 -04005271 context->recordError(gl::Error(GL_INVALID_OPERATION));
5272 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005273 }
Geoff Langbfdea662014-07-23 14:16:32 -04005274
5275 if (!ValidateBeginQuery(context, target, id))
5276 {
5277 return;
5278 }
5279 context->beginQuery(target, id);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005280 }
5281}
5282
5283void __stdcall glEndQuery(GLenum target)
5284{
5285 EVENT("(GLenum target = 0x%X)", target);
5286
Geoff Langbfdea662014-07-23 14:16:32 -04005287 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005288 if (context)
5289 {
5290 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005291 {
Geoff Langb1196682014-07-23 13:47:29 -04005292 context->recordError(gl::Error(GL_INVALID_OPERATION));
5293 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005294 }
Geoff Langbfdea662014-07-23 14:16:32 -04005295
5296 if (!ValidateEndQuery(context, target))
5297 {
5298 return;
5299 }
5300
5301 context->endQuery(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005302 }
5303}
5304
5305void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
5306{
5307 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
5308
Geoff Langbfdea662014-07-23 14:16:32 -04005309 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005310 if (context)
5311 {
5312 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005313 {
Geoff Langb1196682014-07-23 13:47:29 -04005314 context->recordError(gl::Error(GL_INVALID_OPERATION));
5315 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005316 }
Geoff Langbfdea662014-07-23 14:16:32 -04005317
5318 if (!ValidQueryType(context, target))
5319 {
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 }
5323
5324 switch (pname)
5325 {
5326 case GL_CURRENT_QUERY:
5327 params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target));
5328 break;
5329
5330 default:
Geoff Langb1196682014-07-23 13:47:29 -04005331 context->recordError(gl::Error(GL_INVALID_ENUM));
5332 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005333 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005334 }
5335}
5336
5337void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
5338{
5339 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
5340
Geoff Langbfdea662014-07-23 14:16:32 -04005341 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005342 if (context)
5343 {
5344 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005345 {
Geoff Langb1196682014-07-23 13:47:29 -04005346 context->recordError(gl::Error(GL_INVALID_OPERATION));
5347 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005348 }
Geoff Langbfdea662014-07-23 14:16:32 -04005349
5350 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
5351
5352 if (!queryObject)
5353 {
Geoff Langb1196682014-07-23 13:47:29 -04005354 context->recordError(gl::Error(GL_INVALID_OPERATION));
5355 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005356 }
5357
5358 if (context->getState().getActiveQueryId(queryObject->getType()) == id)
5359 {
Geoff Langb1196682014-07-23 13:47:29 -04005360 context->recordError(gl::Error(GL_INVALID_OPERATION));
5361 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005362 }
5363
5364 switch(pname)
5365 {
5366 case GL_QUERY_RESULT:
5367 params[0] = queryObject->getResult();
5368 break;
Geoff Langb1196682014-07-23 13:47:29 -04005369
Geoff Langbfdea662014-07-23 14:16:32 -04005370 case GL_QUERY_RESULT_AVAILABLE:
5371 params[0] = queryObject->isResultAvailable();
5372 break;
Geoff Langb1196682014-07-23 13:47:29 -04005373
Geoff Langbfdea662014-07-23 14:16:32 -04005374 default:
Geoff Langb1196682014-07-23 13:47:29 -04005375 context->recordError(gl::Error(GL_INVALID_ENUM));
5376 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005377 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005378 }
5379}
5380
5381GLboolean __stdcall glUnmapBuffer(GLenum target)
5382{
5383 EVENT("(GLenum target = 0x%X)", target);
5384
Geoff Langbfdea662014-07-23 14:16:32 -04005385 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005386 if (context)
5387 {
5388 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005389 {
Geoff Langb1196682014-07-23 13:47:29 -04005390 context->recordError(gl::Error(GL_INVALID_OPERATION));
5391 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005392 }
Geoff Langbfdea662014-07-23 14:16:32 -04005393
5394 return glUnmapBufferOES(target);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005395 }
5396
5397 return GL_FALSE;
5398}
5399
5400void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
5401{
5402 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
5403
Geoff Langbfdea662014-07-23 14:16:32 -04005404 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005405 if (context)
5406 {
5407 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005408 {
Geoff Langb1196682014-07-23 13:47:29 -04005409 context->recordError(gl::Error(GL_INVALID_OPERATION));
5410 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005411 }
Geoff Langbfdea662014-07-23 14:16:32 -04005412
5413 glGetBufferPointervOES(target, pname, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005414 }
5415}
5416
5417void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
5418{
Geoff Langbfdea662014-07-23 14:16:32 -04005419 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005420 if (context)
5421 {
5422 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005423 {
Geoff Langb1196682014-07-23 13:47:29 -04005424 context->recordError(gl::Error(GL_INVALID_OPERATION));
5425 return;
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00005426 }
Geoff Langbfdea662014-07-23 14:16:32 -04005427
5428 glDrawBuffersEXT(n, bufs);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005429 }
5430}
5431
5432void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5433{
5434 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5435 location, count, transpose, value);
5436
Geoff Langbfdea662014-07-23 14:16:32 -04005437 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005438 if (context)
5439 {
5440 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005441 {
Geoff Langbfdea662014-07-23 14:16:32 -04005442 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005443 }
Geoff Langbfdea662014-07-23 14:16:32 -04005444
5445 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5446 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005447 }
5448}
5449
5450void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5451{
5452 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5453 location, count, transpose, value);
5454
Geoff Langbfdea662014-07-23 14:16:32 -04005455 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005456 if (context)
5457 {
5458 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005459 {
Geoff Langbfdea662014-07-23 14:16:32 -04005460 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005461 }
Geoff Langbfdea662014-07-23 14:16:32 -04005462
5463 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5464 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005465 }
5466}
5467
5468void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5469{
5470 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5471 location, count, transpose, value);
5472
Geoff Langbfdea662014-07-23 14:16:32 -04005473 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005474 if (context)
5475 {
5476 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005477 {
Geoff Langbfdea662014-07-23 14:16:32 -04005478 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005479 }
Geoff Langbfdea662014-07-23 14:16:32 -04005480
5481 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5482 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005483 }
5484}
5485
5486void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5487{
5488 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5489 location, count, transpose, value);
5490
Geoff Langbfdea662014-07-23 14:16:32 -04005491 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005492 if (context)
5493 {
5494 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005495 {
Geoff Langbfdea662014-07-23 14:16:32 -04005496 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005497 }
Geoff Langbfdea662014-07-23 14:16:32 -04005498
5499 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5500 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005501 }
5502}
5503
5504void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5505{
5506 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5507 location, count, transpose, value);
5508
Geoff Langbfdea662014-07-23 14:16:32 -04005509 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005510 if (context)
5511 {
5512 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005513 {
Geoff Langbfdea662014-07-23 14:16:32 -04005514 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005515 }
Geoff Langbfdea662014-07-23 14:16:32 -04005516
5517 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5518 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005519 }
5520}
5521
5522void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5523{
5524 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
5525 location, count, transpose, value);
5526
Geoff Langbfdea662014-07-23 14:16:32 -04005527 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005528 if (context)
5529 {
5530 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005531 {
Geoff Langbfdea662014-07-23 14:16:32 -04005532 return;
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00005533 }
Geoff Langbfdea662014-07-23 14:16:32 -04005534
5535 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
5536 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005537 }
5538}
5539
5540void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
5541{
5542 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
5543 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
5544 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
5545
Geoff Langbfdea662014-07-23 14:16:32 -04005546 gl::Context *context = gl::getNonLostContext();
5547 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005548 {
Geoff Langbfdea662014-07-23 14:16:32 -04005549 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005550 {
Geoff Langb1196682014-07-23 13:47:29 -04005551 context->recordError(gl::Error(GL_INVALID_OPERATION));
5552 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005553 }
Geoff Langbfdea662014-07-23 14:16:32 -04005554
5555 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
5556 dstX0, dstY0, dstX1, dstY1, mask, filter,
5557 false))
5558 {
5559 return;
5560 }
5561
5562 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
5563 mask, filter);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005564 }
5565}
5566
5567void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
5568{
5569 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5570 target, samples, internalformat, width, height);
5571
Geoff Langbfdea662014-07-23 14:16:32 -04005572 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005573 if (context)
5574 {
5575 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005576 {
Geoff Langb1196682014-07-23 13:47:29 -04005577 context->recordError(gl::Error(GL_INVALID_OPERATION));
5578 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005579 }
Geoff Langbfdea662014-07-23 14:16:32 -04005580
5581 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
5582 width, height, false))
5583 {
5584 return;
5585 }
5586
5587 context->setRenderbufferStorage(width, height, internalformat, samples);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005588 }
5589}
5590
5591void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
5592{
5593 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
5594 target, attachment, texture, level, layer);
5595
Geoff Langbfdea662014-07-23 14:16:32 -04005596 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005597 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005598 {
Geoff Langbfdea662014-07-23 14:16:32 -04005599 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
5600 level, layer))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005601 {
Geoff Langbfdea662014-07-23 14:16:32 -04005602 return;
5603 }
Geoff Lang3ed0c482013-07-25 17:03:18 -04005604
Geoff Langbfdea662014-07-23 14:16:32 -04005605 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
5606 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04005607
Geoff Langbfdea662014-07-23 14:16:32 -04005608 gl::Texture *textureObject = context->getTexture(texture);
5609 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005610
Geoff Langbfdea662014-07-23 14:16:32 -04005611 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
5612 {
5613 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
5614 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
5615 }
5616 else
5617 {
5618 switch (attachment)
Geoff Lang3ed0c482013-07-25 17:03:18 -04005619 {
Geoff Langbfdea662014-07-23 14:16:32 -04005620 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
5621 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
5622 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04005623 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005624 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005625 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005626}
5627
5628GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
5629{
5630 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
5631 target, offset, length, access);
5632
Geoff Langbfdea662014-07-23 14:16:32 -04005633 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005634 if (context)
5635 {
5636 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005637 {
Geoff Langb1196682014-07-23 13:47:29 -04005638 context->recordError(gl::Error(GL_INVALID_OPERATION));
5639 return NULL;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005640 }
Geoff Langbfdea662014-07-23 14:16:32 -04005641
5642 return glMapBufferRangeEXT(target, offset, length, access);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005643 }
5644
5645 return NULL;
5646}
5647
5648void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
5649{
5650 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
5651
Geoff Langbfdea662014-07-23 14:16:32 -04005652 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005653 if (context)
5654 {
5655 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005656 {
Geoff Langb1196682014-07-23 13:47:29 -04005657 context->recordError(gl::Error(GL_INVALID_OPERATION));
5658 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005659 }
Geoff Langbfdea662014-07-23 14:16:32 -04005660
5661 glFlushMappedBufferRangeEXT(target, offset, length);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005662 }
5663}
5664
5665void __stdcall glBindVertexArray(GLuint array)
5666{
5667 EVENT("(GLuint array = %u)", array);
5668
Geoff Langbfdea662014-07-23 14:16:32 -04005669 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005670 if (context)
5671 {
5672 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005673 {
Geoff Langb1196682014-07-23 13:47:29 -04005674 context->recordError(gl::Error(GL_INVALID_OPERATION));
5675 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005676 }
Geoff Langbfdea662014-07-23 14:16:32 -04005677
5678 gl::VertexArray *vao = context->getVertexArray(array);
5679
5680 if (!vao)
5681 {
5682 // The default VAO should always exist
5683 ASSERT(array != 0);
Geoff Langb1196682014-07-23 13:47:29 -04005684 context->recordError(gl::Error(GL_INVALID_OPERATION));
5685 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005686 }
5687
5688 context->bindVertexArray(array);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005689 }
5690}
5691
5692void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
5693{
5694 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
5695
Geoff Langbfdea662014-07-23 14:16:32 -04005696 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005697 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005698 {
Geoff Langbfdea662014-07-23 14:16:32 -04005699 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005700 {
Geoff Langb1196682014-07-23 13:47:29 -04005701 context->recordError(gl::Error(GL_INVALID_OPERATION));
5702 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005703 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005704
Geoff Langbfdea662014-07-23 14:16:32 -04005705 if (n < 0)
5706 {
Geoff Langb1196682014-07-23 13:47:29 -04005707 context->recordError(gl::Error(GL_INVALID_VALUE));
5708 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005709 }
Jamie Madilld1028542013-07-02 11:57:04 -04005710
Geoff Langbfdea662014-07-23 14:16:32 -04005711 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5712 {
5713 if (arrays[arrayIndex] != 0)
Jamie Madilld1028542013-07-02 11:57:04 -04005714 {
Geoff Langbfdea662014-07-23 14:16:32 -04005715 context->deleteVertexArray(arrays[arrayIndex]);
Jamie Madilld1028542013-07-02 11:57:04 -04005716 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005717 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005718 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005719}
5720
5721void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
5722{
5723 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
5724
Geoff Langbfdea662014-07-23 14:16:32 -04005725 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005726 if (context)
5727 {
5728 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005729 {
Geoff Langb1196682014-07-23 13:47:29 -04005730 context->recordError(gl::Error(GL_INVALID_OPERATION));
5731 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005732 }
Geoff Langbfdea662014-07-23 14:16:32 -04005733
5734 if (n < 0)
5735 {
Geoff Langb1196682014-07-23 13:47:29 -04005736 context->recordError(gl::Error(GL_INVALID_VALUE));
5737 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005738 }
5739
5740 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
5741 {
5742 arrays[arrayIndex] = context->createVertexArray();
5743 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005744 }
5745}
5746
5747GLboolean __stdcall glIsVertexArray(GLuint array)
5748{
5749 EVENT("(GLuint array = %u)", array);
5750
Geoff Langbfdea662014-07-23 14:16:32 -04005751 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005752 if (context)
5753 {
5754 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005755 {
Geoff Langb1196682014-07-23 13:47:29 -04005756 context->recordError(gl::Error(GL_INVALID_OPERATION));
5757 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005758 }
Geoff Langbfdea662014-07-23 14:16:32 -04005759
5760 if (array == 0)
5761 {
5762 return GL_FALSE;
5763 }
5764
5765 gl::VertexArray *vao = context->getVertexArray(array);
5766
5767 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005768 }
5769
5770 return GL_FALSE;
5771}
5772
5773void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
5774{
5775 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
5776 target, index, data);
5777
Geoff Langbfdea662014-07-23 14:16:32 -04005778 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005779 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005780 {
Geoff Langbfdea662014-07-23 14:16:32 -04005781 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005782 {
Geoff Langb1196682014-07-23 13:47:29 -04005783 context->recordError(gl::Error(GL_INVALID_OPERATION));
5784 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005785 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005786
Geoff Lang3a61c322014-07-10 13:01:54 -04005787 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04005788 switch (target)
5789 {
5790 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
5791 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
5792 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04005793 if (index >= caps.maxTransformFeedbackSeparateAttributes)
5794 {
Geoff Langb1196682014-07-23 13:47:29 -04005795 context->recordError(gl::Error(GL_INVALID_VALUE));
5796 return;
Geoff Lang05881a02014-07-10 14:05:30 -04005797 }
Geoff Langbfdea662014-07-23 14:16:32 -04005798 break;
Geoff Langb1196682014-07-23 13:47:29 -04005799
Geoff Langbfdea662014-07-23 14:16:32 -04005800 case GL_UNIFORM_BUFFER_START:
5801 case GL_UNIFORM_BUFFER_SIZE:
5802 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04005803 if (index >= caps.maxCombinedUniformBlocks)
5804 {
Geoff Langb1196682014-07-23 13:47:29 -04005805 context->recordError(gl::Error(GL_INVALID_VALUE));
5806 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04005807 }
Geoff Langbfdea662014-07-23 14:16:32 -04005808 break;
Geoff Langb1196682014-07-23 13:47:29 -04005809
Geoff Langbfdea662014-07-23 14:16:32 -04005810 default:
Geoff Langb1196682014-07-23 13:47:29 -04005811 context->recordError(gl::Error(GL_INVALID_ENUM));
5812 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005813 }
5814
5815 if (!(context->getIndexedIntegerv(target, index, data)))
5816 {
5817 GLenum nativeType;
5818 unsigned int numParams = 0;
5819 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04005820 {
5821 context->recordError(gl::Error(GL_INVALID_ENUM));
5822 return;
5823 }
Shannon Woods15934d52013-08-19 14:28:49 -04005824
Geoff Langbfdea662014-07-23 14:16:32 -04005825 if (numParams == 0)
Geoff Langb1196682014-07-23 13:47:29 -04005826 {
Geoff Langbfdea662014-07-23 14:16:32 -04005827 return; // it is known that pname is valid, but there are no parameters to return
Geoff Langb1196682014-07-23 13:47:29 -04005828 }
Geoff Langbfdea662014-07-23 14:16:32 -04005829
5830 if (nativeType == GL_INT_64_ANGLEX)
Shannon Woods15934d52013-08-19 14:28:49 -04005831 {
Geoff Langbfdea662014-07-23 14:16:32 -04005832 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
5833 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
5834 GLint64 *int64Params = new GLint64[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04005835
Geoff Langbfdea662014-07-23 14:16:32 -04005836 context->getIndexedInteger64v(target, index, int64Params);
Shannon Woods15934d52013-08-19 14:28:49 -04005837
Geoff Langbfdea662014-07-23 14:16:32 -04005838 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04005839 {
Geoff Langbfdea662014-07-23 14:16:32 -04005840 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
5841 data[i] = static_cast<GLint>(clampedValue);
Shannon Woods15934d52013-08-19 14:28:49 -04005842 }
Geoff Langbfdea662014-07-23 14:16:32 -04005843
5844 delete [] int64Params;
5845 }
5846 else
5847 {
5848 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04005849 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005850 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005851 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005852}
5853
5854void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
5855{
5856 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
5857
Geoff Langbfdea662014-07-23 14:16:32 -04005858 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005859 if (context)
5860 {
5861 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005862 {
Geoff Langb1196682014-07-23 13:47:29 -04005863 context->recordError(gl::Error(GL_INVALID_OPERATION));
5864 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005865 }
Geoff Langbfdea662014-07-23 14:16:32 -04005866
5867 switch (primitiveMode)
5868 {
5869 case GL_TRIANGLES:
5870 case GL_LINES:
5871 case GL_POINTS:
5872 break;
Geoff Langb1196682014-07-23 13:47:29 -04005873
Geoff Langbfdea662014-07-23 14:16:32 -04005874 default:
Geoff Langb1196682014-07-23 13:47:29 -04005875 context->recordError(gl::Error(GL_INVALID_ENUM));
5876 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005877 }
5878
5879 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
5880 ASSERT(transformFeedback != NULL);
5881
5882 if (transformFeedback->isStarted())
5883 {
Geoff Langb1196682014-07-23 13:47:29 -04005884 context->recordError(gl::Error(GL_INVALID_OPERATION));
5885 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005886 }
5887
5888 if (transformFeedback->isPaused())
5889 {
5890 transformFeedback->resume();
5891 }
5892 else
5893 {
5894 transformFeedback->start(primitiveMode);
5895 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005896 }
5897}
5898
5899void __stdcall glEndTransformFeedback(void)
5900{
5901 EVENT("(void)");
5902
Geoff Langbfdea662014-07-23 14:16:32 -04005903 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005904 if (context)
5905 {
5906 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005907 {
Geoff Langb1196682014-07-23 13:47:29 -04005908 context->recordError(gl::Error(GL_INVALID_OPERATION));
5909 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005910 }
Geoff Langbfdea662014-07-23 14:16:32 -04005911
5912 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
5913 ASSERT(transformFeedback != NULL);
5914
5915 if (!transformFeedback->isStarted())
5916 {
Geoff Langb1196682014-07-23 13:47:29 -04005917 context->recordError(gl::Error(GL_INVALID_OPERATION));
5918 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005919 }
5920
5921 transformFeedback->stop();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005922 }
5923}
5924
5925void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
5926{
5927 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
5928 target, index, buffer, offset, size);
5929
Geoff Langbfdea662014-07-23 14:16:32 -04005930 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04005931 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005932 {
Geoff Langbfdea662014-07-23 14:16:32 -04005933 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005934 {
Geoff Langb1196682014-07-23 13:47:29 -04005935 context->recordError(gl::Error(GL_INVALID_OPERATION));
5936 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005937 }
5938
Geoff Lang3a61c322014-07-10 13:01:54 -04005939 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04005940 switch (target)
5941 {
5942 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04005943 if (index >= caps.maxTransformFeedbackSeparateAttributes)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005944 {
Geoff Langb1196682014-07-23 13:47:29 -04005945 context->recordError(gl::Error(GL_INVALID_VALUE));
5946 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005947 }
Geoff Langbfdea662014-07-23 14:16:32 -04005948 break;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005949
Geoff Langbfdea662014-07-23 14:16:32 -04005950 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04005951 if (index >= caps.maxUniformBufferBindings)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005952 {
Geoff Langb1196682014-07-23 13:47:29 -04005953 context->recordError(gl::Error(GL_INVALID_VALUE));
5954 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005955 }
Geoff Langbfdea662014-07-23 14:16:32 -04005956 break;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005957
Geoff Langbfdea662014-07-23 14:16:32 -04005958 default:
Geoff Langb1196682014-07-23 13:47:29 -04005959 context->recordError(gl::Error(GL_INVALID_ENUM));
5960 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005961 }
5962
5963 if (buffer != 0 && size <= 0)
5964 {
Geoff Langb1196682014-07-23 13:47:29 -04005965 context->recordError(gl::Error(GL_INVALID_VALUE));
5966 return;
Geoff Langbfdea662014-07-23 14:16:32 -04005967 }
5968
5969 switch (target)
5970 {
5971 case GL_TRANSFORM_FEEDBACK_BUFFER:
5972
5973 // size and offset must be a multiple of 4
5974 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005975 {
Geoff Langb1196682014-07-23 13:47:29 -04005976 context->recordError(gl::Error(GL_INVALID_VALUE));
5977 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005978 }
5979
Geoff Langbfdea662014-07-23 14:16:32 -04005980 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
5981 context->bindGenericTransformFeedbackBuffer(buffer);
5982 break;
5983
5984 case GL_UNIFORM_BUFFER:
5985
5986 // it is an error to bind an offset not a multiple of the alignment
Geoff Lang3a61c322014-07-10 13:01:54 -04005987 if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005988 {
Geoff Langb1196682014-07-23 13:47:29 -04005989 context->recordError(gl::Error(GL_INVALID_VALUE));
5990 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005991 }
Geoff Langbfdea662014-07-23 14:16:32 -04005992
5993 context->bindIndexedUniformBuffer(buffer, index, offset, size);
5994 context->bindGenericUniformBuffer(buffer);
5995 break;
5996
5997 default:
5998 UNREACHABLE();
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00005999 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006000 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006001}
6002
6003void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
6004{
6005 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
6006 target, index, buffer);
6007
Geoff Langbfdea662014-07-23 14:16:32 -04006008 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006009 if (context)
6010 {
6011 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006012 {
Geoff Langb1196682014-07-23 13:47:29 -04006013 context->recordError(gl::Error(GL_INVALID_OPERATION));
6014 return;
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00006015 }
Geoff Langbfdea662014-07-23 14:16:32 -04006016
Geoff Lang3a61c322014-07-10 13:01:54 -04006017 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006018 switch (target)
6019 {
6020 case GL_TRANSFORM_FEEDBACK_BUFFER:
Geoff Lang05881a02014-07-10 14:05:30 -04006021 if (index >= caps.maxTransformFeedbackSeparateAttributes)
Geoff Langbfdea662014-07-23 14:16:32 -04006022 {
Geoff Langb1196682014-07-23 13:47:29 -04006023 context->recordError(gl::Error(GL_INVALID_VALUE));
6024 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006025 }
6026 break;
6027
6028 case GL_UNIFORM_BUFFER:
Geoff Lang3a61c322014-07-10 13:01:54 -04006029 if (index >= caps.maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04006030 {
Geoff Langb1196682014-07-23 13:47:29 -04006031 context->recordError(gl::Error(GL_INVALID_VALUE));
6032 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006033 }
6034 break;
6035
6036 default:
Geoff Langb1196682014-07-23 13:47:29 -04006037 context->recordError(gl::Error(GL_INVALID_ENUM));
6038 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006039 }
6040
6041 switch (target)
6042 {
6043 case GL_TRANSFORM_FEEDBACK_BUFFER:
6044 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
6045 context->bindGenericTransformFeedbackBuffer(buffer);
6046 break;
6047
6048 case GL_UNIFORM_BUFFER:
6049 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
6050 context->bindGenericUniformBuffer(buffer);
6051 break;
6052
6053 default:
6054 UNREACHABLE();
6055 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006056 }
6057}
6058
6059void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
6060{
6061 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
6062 program, count, varyings, bufferMode);
6063
Geoff Langbfdea662014-07-23 14:16:32 -04006064 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006065 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006066 {
Geoff Langbfdea662014-07-23 14:16:32 -04006067 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006068 {
Geoff Langb1196682014-07-23 13:47:29 -04006069 context->recordError(gl::Error(GL_INVALID_OPERATION));
6070 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006071 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006072
Geoff Langbfdea662014-07-23 14:16:32 -04006073 if (count < 0)
6074 {
Geoff Langb1196682014-07-23 13:47:29 -04006075 context->recordError(gl::Error(GL_INVALID_VALUE));
6076 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006077 }
6078
Geoff Lang05881a02014-07-10 14:05:30 -04006079 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04006080 switch (bufferMode)
6081 {
6082 case GL_INTERLEAVED_ATTRIBS:
6083 break;
6084 case GL_SEPARATE_ATTRIBS:
Geoff Lang05881a02014-07-10 14:05:30 -04006085 if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes)
Geoff Lang48dcae72014-02-05 16:28:24 -05006086 {
Geoff Langb1196682014-07-23 13:47:29 -04006087 context->recordError(gl::Error(GL_INVALID_VALUE));
6088 return;
Geoff Lang48dcae72014-02-05 16:28:24 -05006089 }
Geoff Langbfdea662014-07-23 14:16:32 -04006090 break;
6091 default:
Geoff Langb1196682014-07-23 13:47:29 -04006092 context->recordError(gl::Error(GL_INVALID_ENUM));
6093 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006094 }
Geoff Langbfdea662014-07-23 14:16:32 -04006095
6096 if (!gl::ValidProgram(context, program))
6097 {
6098 return;
6099 }
6100
6101 gl::Program *programObject = context->getProgram(program);
6102 ASSERT(programObject);
6103
6104 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006105 }
6106}
6107
6108void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
6109{
6110 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
6111 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
6112 program, index, bufSize, length, size, type, name);
6113
Geoff Langbfdea662014-07-23 14:16:32 -04006114 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006115 if (context)
6116 {
6117 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006118 {
Geoff Langb1196682014-07-23 13:47:29 -04006119 context->recordError(gl::Error(GL_INVALID_OPERATION));
6120 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006121 }
Geoff Langbfdea662014-07-23 14:16:32 -04006122
6123 if (bufSize < 0)
6124 {
Geoff Langb1196682014-07-23 13:47:29 -04006125 context->recordError(gl::Error(GL_INVALID_VALUE));
6126 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006127 }
6128
6129 if (!gl::ValidProgram(context, program))
6130 {
6131 return;
6132 }
6133
6134 gl::Program *programObject = context->getProgram(program);
6135 ASSERT(programObject);
6136
6137 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
6138 {
Geoff Langb1196682014-07-23 13:47:29 -04006139 context->recordError(gl::Error(GL_INVALID_VALUE));
6140 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006141 }
6142
6143 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006144 }
6145}
6146
6147void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
6148{
6149 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
6150 index, size, type, stride, pointer);
6151
Geoff Langbfdea662014-07-23 14:16:32 -04006152 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006153 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006154 {
Geoff Langbfdea662014-07-23 14:16:32 -04006155 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006156 {
Geoff Langb1196682014-07-23 13:47:29 -04006157 context->recordError(gl::Error(GL_INVALID_OPERATION));
6158 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006159 }
6160
Geoff Langb1196682014-07-23 13:47:29 -04006161 if (index >= gl::MAX_VERTEX_ATTRIBS)
6162 {
6163 context->recordError(gl::Error(GL_INVALID_VALUE));
6164 return;
6165 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006166
Geoff Langb1196682014-07-23 13:47:29 -04006167 if (size < 1 || size > 4)
6168 {
6169 context->recordError(gl::Error(GL_INVALID_VALUE));
6170 return;
6171 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006172
Geoff Langb1196682014-07-23 13:47:29 -04006173 switch (type)
6174 {
6175 case GL_BYTE:
6176 case GL_UNSIGNED_BYTE:
6177 case GL_SHORT:
6178 case GL_UNSIGNED_SHORT:
6179 case GL_INT:
6180 case GL_UNSIGNED_INT:
6181 case GL_INT_2_10_10_10_REV:
6182 case GL_UNSIGNED_INT_2_10_10_10_REV:
6183 break;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006184
Geoff Langb1196682014-07-23 13:47:29 -04006185 default:
6186 context->recordError(gl::Error(GL_INVALID_ENUM));
6187 return;
6188 }
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006189
Geoff Langb1196682014-07-23 13:47:29 -04006190 if (stride < 0)
6191 {
6192 context->recordError(gl::Error(GL_INVALID_VALUE));
6193 return;
6194 }
Geoff Langbfdea662014-07-23 14:16:32 -04006195
Geoff Langb1196682014-07-23 13:47:29 -04006196 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
6197 {
6198 context->recordError(gl::Error(GL_INVALID_OPERATION));
6199 return;
6200 }
6201
Geoff Langbfdea662014-07-23 14:16:32 -04006202 // [OpenGL ES 3.0.2] Section 2.8 page 24:
6203 // An INVALID_OPERATION error is generated when a non-zero vertex array object
6204 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
6205 // and the pointer argument is not NULL.
6206 if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL)
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006207 {
Geoff Langb1196682014-07-23 13:47:29 -04006208 context->recordError(gl::Error(GL_INVALID_OPERATION));
6209 return;
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00006210 }
6211
Geoff Langbfdea662014-07-23 14:16:32 -04006212 context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true,
6213 stride, pointer);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006214 }
6215}
6216
6217void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
6218{
6219 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6220 index, pname, params);
6221
Geoff Langbfdea662014-07-23 14:16:32 -04006222 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006223 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006224 {
Geoff Langbfdea662014-07-23 14:16:32 -04006225 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006226 {
Geoff Langb1196682014-07-23 13:47:29 -04006227 context->recordError(gl::Error(GL_INVALID_OPERATION));
6228 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006229 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006230
Geoff Langbfdea662014-07-23 14:16:32 -04006231 if (index >= gl::MAX_VERTEX_ATTRIBS)
6232 {
Geoff Langb1196682014-07-23 13:47:29 -04006233 context->recordError(gl::Error(GL_INVALID_VALUE));
6234 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006235 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006236
Geoff Langbfdea662014-07-23 14:16:32 -04006237 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006238
Geoff Langb1196682014-07-23 13:47:29 -04006239 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006240 {
6241 return;
6242 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006243
Geoff Langbfdea662014-07-23 14:16:32 -04006244 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6245 {
6246 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6247 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006248 {
Geoff Langbfdea662014-07-23 14:16:32 -04006249 params[i] = currentValueData.IntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006250 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006251 }
Geoff Langbfdea662014-07-23 14:16:32 -04006252 else
6253 {
6254 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
6255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006256 }
6257}
6258
6259void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
6260{
6261 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
6262 index, pname, params);
6263
Geoff Langbfdea662014-07-23 14:16:32 -04006264 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006265 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006266 {
Geoff Langbfdea662014-07-23 14:16:32 -04006267 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006268 {
Geoff Langb1196682014-07-23 13:47:29 -04006269 context->recordError(gl::Error(GL_INVALID_OPERATION));
6270 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006271 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006272
Geoff Langbfdea662014-07-23 14:16:32 -04006273 if (index >= gl::MAX_VERTEX_ATTRIBS)
6274 {
Geoff Langb1196682014-07-23 13:47:29 -04006275 context->recordError(gl::Error(GL_INVALID_VALUE));
6276 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006277 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006278
Geoff Langbfdea662014-07-23 14:16:32 -04006279 const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index);
Jamie Madilla7d05862013-07-02 11:57:06 -04006280
Geoff Langb1196682014-07-23 13:47:29 -04006281 if (!gl::ValidateGetVertexAttribParameters(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04006282 {
6283 return;
6284 }
Jamie Madilla7d05862013-07-02 11:57:06 -04006285
Geoff Langbfdea662014-07-23 14:16:32 -04006286 if (pname == GL_CURRENT_VERTEX_ATTRIB)
6287 {
6288 const gl::VertexAttribCurrentValueData &currentValueData = context->getState().getVertexAttribCurrentValue(index);
6289 for (int i = 0; i < 4; ++i)
Jamie Madilla7d05862013-07-02 11:57:06 -04006290 {
Geoff Langbfdea662014-07-23 14:16:32 -04006291 params[i] = currentValueData.UnsignedIntValues[i];
Jamie Madilla7d05862013-07-02 11:57:06 -04006292 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006293 }
Geoff Langbfdea662014-07-23 14:16:32 -04006294 else
6295 {
6296 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
6297 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006298 }
6299}
6300
6301void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
6302{
6303 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
6304 index, x, y, z, w);
6305
Geoff Langbfdea662014-07-23 14:16:32 -04006306 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006307 if (context)
6308 {
6309 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006310 {
Geoff Langb1196682014-07-23 13:47:29 -04006311 context->recordError(gl::Error(GL_INVALID_OPERATION));
6312 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006313 }
Geoff Langbfdea662014-07-23 14:16:32 -04006314
6315 if (index >= gl::MAX_VERTEX_ATTRIBS)
6316 {
Geoff Langb1196682014-07-23 13:47:29 -04006317 context->recordError(gl::Error(GL_INVALID_VALUE));
6318 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006319 }
6320
6321 GLint vals[4] = { x, y, z, w };
6322 context->getState().setVertexAttribi(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006323 }
6324}
6325
6326void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
6327{
6328 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
6329 index, x, y, z, w);
6330
Geoff Langbfdea662014-07-23 14:16:32 -04006331 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006332 if (context)
6333 {
6334 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006335 {
Geoff Langb1196682014-07-23 13:47:29 -04006336 context->recordError(gl::Error(GL_INVALID_OPERATION));
6337 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006338 }
Geoff Langbfdea662014-07-23 14:16:32 -04006339
6340 if (index >= gl::MAX_VERTEX_ATTRIBS)
6341 {
Geoff Langb1196682014-07-23 13:47:29 -04006342 context->recordError(gl::Error(GL_INVALID_VALUE));
6343 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006344 }
6345
6346 GLuint vals[4] = { x, y, z, w };
6347 context->getState().setVertexAttribu(index, vals);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006348 }
6349}
6350
6351void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
6352{
6353 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
6354
Geoff Langbfdea662014-07-23 14:16:32 -04006355 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006356 if (context)
6357 {
6358 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006359 {
Geoff Langb1196682014-07-23 13:47:29 -04006360 context->recordError(gl::Error(GL_INVALID_OPERATION));
6361 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006362 }
Geoff Langbfdea662014-07-23 14:16:32 -04006363
6364 if (index >= gl::MAX_VERTEX_ATTRIBS)
6365 {
Geoff Langb1196682014-07-23 13:47:29 -04006366 context->recordError(gl::Error(GL_INVALID_VALUE));
6367 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006368 }
6369
6370 context->getState().setVertexAttribi(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006371 }
6372}
6373
6374void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
6375{
6376 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
6377
Geoff Langbfdea662014-07-23 14:16:32 -04006378 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006379 if (context)
6380 {
6381 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006382 {
Geoff Langb1196682014-07-23 13:47:29 -04006383 context->recordError(gl::Error(GL_INVALID_OPERATION));
6384 return;
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00006385 }
Geoff Langbfdea662014-07-23 14:16:32 -04006386
6387 if (index >= gl::MAX_VERTEX_ATTRIBS)
6388 {
Geoff Langb1196682014-07-23 13:47:29 -04006389 context->recordError(gl::Error(GL_INVALID_VALUE));
6390 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006391 }
6392
6393 context->getState().setVertexAttribu(index, v);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006394 }
6395}
6396
6397void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
6398{
6399 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
6400 program, location, params);
6401
Geoff Langbfdea662014-07-23 14:16:32 -04006402 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006403 if (context)
6404 {
Jamie Madill0063c512014-08-25 15:47:53 -04006405 if (!ValidateGetUniformuiv(context, program, location, params))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006406 {
Jamie Madill0063c512014-08-25 15:47:53 -04006407 return;
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00006408 }
Geoff Langbfdea662014-07-23 14:16:32 -04006409
Jamie Madilla502c742014-08-28 17:19:13 -04006410 gl::Program *programObject = context->getProgram(program);
6411 ASSERT(programObject);
6412 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
Jamie Madill0063c512014-08-25 15:47:53 -04006413 ASSERT(programBinary);
Geoff Langbfdea662014-07-23 14:16:32 -04006414
Jamie Madill99a1e982014-08-25 15:47:54 -04006415 programBinary->getUniformuiv(location, params);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006416 }
6417}
6418
6419GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
6420{
6421 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
6422 program, name);
6423
Geoff Langbfdea662014-07-23 14:16:32 -04006424 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006425 if (context)
6426 {
6427 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006428 {
Geoff Langb1196682014-07-23 13:47:29 -04006429 context->recordError(gl::Error(GL_INVALID_OPERATION));
6430 return -1;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006431 }
Geoff Langbfdea662014-07-23 14:16:32 -04006432
6433 if (program == 0)
6434 {
Geoff Langb1196682014-07-23 13:47:29 -04006435 context->recordError(gl::Error(GL_INVALID_VALUE));
6436 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006437 }
6438
6439 gl::Program *programObject = context->getProgram(program);
6440
6441 if (!programObject || !programObject->isLinked())
6442 {
Geoff Langb1196682014-07-23 13:47:29 -04006443 context->recordError(gl::Error(GL_INVALID_OPERATION));
6444 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006445 }
6446
6447 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6448 if (!programBinary)
6449 {
Geoff Langb1196682014-07-23 13:47:29 -04006450 context->recordError(gl::Error(GL_INVALID_OPERATION));
6451 return -1;
Geoff Langbfdea662014-07-23 14:16:32 -04006452 }
6453
6454 return programBinary->getFragDataLocation(name);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006455 }
6456
6457 return 0;
6458}
6459
6460void __stdcall glUniform1ui(GLint location, GLuint v0)
6461{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006462 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006463}
6464
6465void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
6466{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006467 const GLuint xy[] = { v0, v1 };
6468 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006469}
6470
6471void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
6472{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006473 const GLuint xyz[] = { v0, v1, v2 };
6474 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006475}
6476
6477void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
6478{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00006479 const GLuint xyzw[] = { v0, v1, v2, v3 };
6480 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006481}
6482
6483void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
6484{
6485 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6486 location, count, value);
6487
Geoff Langbfdea662014-07-23 14:16:32 -04006488 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006489 if (context)
6490 {
6491 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006492 {
Geoff Langbfdea662014-07-23 14:16:32 -04006493 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006494 }
Geoff Langbfdea662014-07-23 14:16:32 -04006495
6496 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6497 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006498 }
6499}
6500
6501void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
6502{
6503 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6504 location, count, value);
6505
Geoff Langbfdea662014-07-23 14:16:32 -04006506 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006507 if (context)
6508 {
6509 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006510 {
Geoff Langbfdea662014-07-23 14:16:32 -04006511 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006512 }
Geoff Langbfdea662014-07-23 14:16:32 -04006513
6514 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6515 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006516 }
6517}
6518
6519void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
6520{
6521 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
6522 location, count, value);
6523
Geoff Langbfdea662014-07-23 14:16:32 -04006524 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006525 if (context)
6526 {
6527 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006528 {
Geoff Langbfdea662014-07-23 14:16:32 -04006529 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006530 }
Geoff Langbfdea662014-07-23 14:16:32 -04006531
6532 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6533 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006534 }
6535}
6536
6537void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
6538{
6539 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
6540 location, count, value);
6541
Geoff Langbfdea662014-07-23 14:16:32 -04006542 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006543 if (context)
6544 {
6545 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006546 {
Geoff Langbfdea662014-07-23 14:16:32 -04006547 return;
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00006548 }
Geoff Langbfdea662014-07-23 14:16:32 -04006549
6550 gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
6551 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006552 }
6553}
6554
6555void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
6556{
6557 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
6558 buffer, drawbuffer, value);
6559
Geoff Langbfdea662014-07-23 14:16:32 -04006560 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006561 if (context)
6562 {
6563 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006564 {
Geoff Langbfdea662014-07-23 14:16:32 -04006565 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006566 }
Geoff Langbfdea662014-07-23 14:16:32 -04006567
6568 switch (buffer)
6569 {
6570 case GL_COLOR:
6571 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6572 {
Geoff Langb1196682014-07-23 13:47:29 -04006573 context->recordError(gl::Error(GL_INVALID_VALUE));
6574 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006575 }
6576 break;
Geoff Langb1196682014-07-23 13:47:29 -04006577
Geoff Langbfdea662014-07-23 14:16:32 -04006578 case GL_STENCIL:
6579 if (drawbuffer != 0)
6580 {
Geoff Langb1196682014-07-23 13:47:29 -04006581 context->recordError(gl::Error(GL_INVALID_VALUE));
6582 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006583 }
6584 break;
Geoff Langb1196682014-07-23 13:47:29 -04006585
Geoff Langbfdea662014-07-23 14:16:32 -04006586 default:
Geoff Langb1196682014-07-23 13:47:29 -04006587 context->recordError(gl::Error(GL_INVALID_ENUM));
6588 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006589 }
6590
6591 context->clearBufferiv(buffer, drawbuffer, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006592 }
6593}
6594
6595void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
6596{
6597 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
6598 buffer, drawbuffer, value);
6599
Geoff Langbfdea662014-07-23 14:16:32 -04006600 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006601 if (context)
6602 {
6603 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006604 {
Geoff Langbfdea662014-07-23 14:16:32 -04006605 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006606 }
Geoff Langbfdea662014-07-23 14:16:32 -04006607
6608 switch (buffer)
6609 {
6610 case GL_COLOR:
6611 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6612 {
Geoff Langb1196682014-07-23 13:47:29 -04006613 context->recordError(gl::Error(GL_INVALID_VALUE));
6614 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006615 }
6616 break;
Geoff Langb1196682014-07-23 13:47:29 -04006617
Geoff Langbfdea662014-07-23 14:16:32 -04006618 default:
Geoff Langb1196682014-07-23 13:47:29 -04006619 context->recordError(gl::Error(GL_INVALID_ENUM));
6620 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006621 }
6622
6623 context->clearBufferuiv(buffer, drawbuffer, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006624 }
6625}
6626
6627void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
6628{
6629 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
6630 buffer, drawbuffer, value);
6631
Geoff Langbfdea662014-07-23 14:16:32 -04006632 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006633 if (context)
6634 {
6635 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006636 {
Geoff Langbfdea662014-07-23 14:16:32 -04006637 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006638 }
Geoff Langbfdea662014-07-23 14:16:32 -04006639
6640 switch (buffer)
6641 {
6642 case GL_COLOR:
6643 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
6644 {
Geoff Langb1196682014-07-23 13:47:29 -04006645 context->recordError(gl::Error(GL_INVALID_VALUE));
6646 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006647 }
6648 break;
Geoff Langb1196682014-07-23 13:47:29 -04006649
Geoff Langbfdea662014-07-23 14:16:32 -04006650 case GL_DEPTH:
6651 if (drawbuffer != 0)
6652 {
Geoff Langb1196682014-07-23 13:47:29 -04006653 context->recordError(gl::Error(GL_INVALID_VALUE));
6654 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006655 }
6656 break;
Geoff Langb1196682014-07-23 13:47:29 -04006657
Geoff Langbfdea662014-07-23 14:16:32 -04006658 default:
Geoff Langb1196682014-07-23 13:47:29 -04006659 context->recordError(gl::Error(GL_INVALID_ENUM));
6660 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006661 }
6662
6663 context->clearBufferfv(buffer, drawbuffer, value);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006664 }
6665}
6666
6667void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
6668{
6669 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
6670 buffer, drawbuffer, depth, stencil);
6671
Geoff Langbfdea662014-07-23 14:16:32 -04006672 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006673 if (context)
6674 {
6675 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006676 {
Geoff Langbfdea662014-07-23 14:16:32 -04006677 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006678 }
Geoff Langbfdea662014-07-23 14:16:32 -04006679
6680 switch (buffer)
6681 {
6682 case GL_DEPTH_STENCIL:
6683 if (drawbuffer != 0)
6684 {
Geoff Langb1196682014-07-23 13:47:29 -04006685 context->recordError(gl::Error(GL_INVALID_VALUE));
6686 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006687 }
6688 break;
Geoff Langb1196682014-07-23 13:47:29 -04006689
Geoff Langbfdea662014-07-23 14:16:32 -04006690 default:
Geoff Langb1196682014-07-23 13:47:29 -04006691 context->recordError(gl::Error(GL_INVALID_ENUM));
6692 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006693 }
6694
6695 context->clearBufferfi(buffer, drawbuffer, depth, stencil);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006696 }
6697}
6698
6699const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
6700{
6701 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
6702
Geoff Langbfdea662014-07-23 14:16:32 -04006703 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006704 if (context)
6705 {
6706 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006707 {
Geoff Langb1196682014-07-23 13:47:29 -04006708 context->recordError(gl::Error(GL_INVALID_OPERATION));
6709 return NULL;
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00006710 }
Geoff Langbfdea662014-07-23 14:16:32 -04006711
6712 if (name != GL_EXTENSIONS)
6713 {
Geoff Langb1196682014-07-23 13:47:29 -04006714 context->recordError(gl::Error(GL_INVALID_ENUM));
6715 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006716 }
6717
6718 if (index >= context->getExtensionStringCount())
6719 {
Geoff Langb1196682014-07-23 13:47:29 -04006720 context->recordError(gl::Error(GL_INVALID_VALUE));
6721 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04006722 }
6723
6724 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str());
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006725 }
6726
6727 return NULL;
6728}
6729
6730void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
6731{
6732 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
6733 readTarget, writeTarget, readOffset, writeOffset, size);
6734
Geoff Langbfdea662014-07-23 14:16:32 -04006735 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006736 if (context)
6737 {
6738 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006739 {
Geoff Langb1196682014-07-23 13:47:29 -04006740 context->recordError(gl::Error(GL_INVALID_OPERATION));
6741 return;
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00006742 }
Geoff Langbfdea662014-07-23 14:16:32 -04006743
6744 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
6745 {
Geoff Langb1196682014-07-23 13:47:29 -04006746 context->recordError(gl::Error(GL_INVALID_ENUM));
6747 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006748 }
6749
6750 gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget);
6751 gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget);
6752
6753 if (!readBuffer || !writeBuffer)
6754 {
Geoff Langb1196682014-07-23 13:47:29 -04006755 context->recordError(gl::Error(GL_INVALID_OPERATION));
6756 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006757 }
6758
Jamie Madillcfaaf722014-07-31 10:47:54 -04006759 // Verify that readBuffer and writeBuffer are not currently mapped
Geoff Langbfdea662014-07-23 14:16:32 -04006760 if (readBuffer->isMapped() || writeBuffer->isMapped())
6761 {
Geoff Langb1196682014-07-23 13:47:29 -04006762 context->recordError(gl::Error(GL_INVALID_OPERATION));
6763 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006764 }
6765
6766 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
6767 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
6768 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
6769 {
Geoff Langb1196682014-07-23 13:47:29 -04006770 context->recordError(gl::Error(GL_INVALID_VALUE));
6771 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006772 }
6773
6774 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
6775 {
Geoff Langb1196682014-07-23 13:47:29 -04006776 context->recordError(gl::Error(GL_INVALID_VALUE));
6777 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006778 }
6779
Geoff Langbfdea662014-07-23 14:16:32 -04006780 // if size is zero, the copy is a successful no-op
6781 if (size > 0)
6782 {
6783 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
6784 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006785 }
6786}
6787
6788void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
6789{
6790 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
6791 program, uniformCount, uniformNames, uniformIndices);
6792
Geoff Langbfdea662014-07-23 14:16:32 -04006793 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006794 if (context)
6795 {
6796 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006797 {
Geoff Langb1196682014-07-23 13:47:29 -04006798 context->recordError(gl::Error(GL_INVALID_OPERATION));
6799 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006800 }
6801
6802 if (uniformCount < 0)
6803 {
Geoff Langb1196682014-07-23 13:47:29 -04006804 context->recordError(gl::Error(GL_INVALID_VALUE));
6805 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006806 }
6807
6808 gl::Program *programObject = context->getProgram(program);
6809
6810 if (!programObject)
6811 {
6812 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006813 {
Geoff Langb1196682014-07-23 13:47:29 -04006814 context->recordError(gl::Error(GL_INVALID_OPERATION));
6815 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006816 }
Geoff Langbfdea662014-07-23 14:16:32 -04006817 else
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00006818 {
Geoff Langb1196682014-07-23 13:47:29 -04006819 context->recordError(gl::Error(GL_INVALID_VALUE));
6820 return;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00006821 }
Geoff Langbfdea662014-07-23 14:16:32 -04006822 }
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00006823
Geoff Langbfdea662014-07-23 14:16:32 -04006824 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6825 if (!programObject->isLinked() || !programBinary)
6826 {
6827 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00006828 {
Geoff Langbfdea662014-07-23 14:16:32 -04006829 uniformIndices[uniformId] = GL_INVALID_INDEX;
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00006830 }
6831 }
Geoff Langbfdea662014-07-23 14:16:32 -04006832 else
6833 {
6834 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
6835 {
6836 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
6837 }
6838 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006839 }
6840}
6841
6842void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
6843{
6844 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6845 program, uniformCount, uniformIndices, pname, params);
6846
Geoff Langbfdea662014-07-23 14:16:32 -04006847 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006848 if (context)
6849 {
6850 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006851 {
Geoff Langb1196682014-07-23 13:47:29 -04006852 context->recordError(gl::Error(GL_INVALID_OPERATION));
6853 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006854 }
6855
6856 if (uniformCount < 0)
6857 {
Geoff Langb1196682014-07-23 13:47:29 -04006858 context->recordError(gl::Error(GL_INVALID_VALUE));
6859 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006860 }
6861
6862 gl::Program *programObject = context->getProgram(program);
6863
6864 if (!programObject)
6865 {
6866 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006867 {
Geoff Langb1196682014-07-23 13:47:29 -04006868 context->recordError(gl::Error(GL_INVALID_OPERATION));
6869 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006870 }
Geoff Langbfdea662014-07-23 14:16:32 -04006871 else
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00006872 {
Geoff Langb1196682014-07-23 13:47:29 -04006873 context->recordError(gl::Error(GL_INVALID_VALUE));
6874 return;
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00006875 }
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00006876 }
Geoff Langbfdea662014-07-23 14:16:32 -04006877
6878 switch (pname)
6879 {
6880 case GL_UNIFORM_TYPE:
6881 case GL_UNIFORM_SIZE:
6882 case GL_UNIFORM_NAME_LENGTH:
6883 case GL_UNIFORM_BLOCK_INDEX:
6884 case GL_UNIFORM_OFFSET:
6885 case GL_UNIFORM_ARRAY_STRIDE:
6886 case GL_UNIFORM_MATRIX_STRIDE:
6887 case GL_UNIFORM_IS_ROW_MAJOR:
6888 break;
Geoff Langb1196682014-07-23 13:47:29 -04006889
Geoff Langbfdea662014-07-23 14:16:32 -04006890 default:
Geoff Langb1196682014-07-23 13:47:29 -04006891 context->recordError(gl::Error(GL_INVALID_ENUM));
6892 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006893 }
6894
6895 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6896
6897 if (!programBinary && uniformCount > 0)
6898 {
Geoff Langb1196682014-07-23 13:47:29 -04006899 context->recordError(gl::Error(GL_INVALID_VALUE));
6900 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006901 }
6902
6903 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
6904 {
6905 const GLuint index = uniformIndices[uniformId];
6906
6907 if (index >= (GLuint)programBinary->getActiveUniformCount())
6908 {
Geoff Langb1196682014-07-23 13:47:29 -04006909 context->recordError(gl::Error(GL_INVALID_VALUE));
6910 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006911 }
6912 }
6913
6914 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
6915 {
6916 const GLuint index = uniformIndices[uniformId];
6917 params[uniformId] = programBinary->getActiveUniformi(index, pname);
6918 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006919 }
6920}
6921
6922GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
6923{
6924 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
6925
Geoff Langbfdea662014-07-23 14:16:32 -04006926 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006927 if (context)
6928 {
6929 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006930 {
Geoff Langb1196682014-07-23 13:47:29 -04006931 context->recordError(gl::Error(GL_INVALID_OPERATION));
6932 return GL_INVALID_INDEX;
Geoff Langbfdea662014-07-23 14:16:32 -04006933 }
6934
6935 gl::Program *programObject = context->getProgram(program);
6936
6937 if (!programObject)
6938 {
6939 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006940 {
Geoff Langb1196682014-07-23 13:47:29 -04006941 context->recordError(gl::Error(GL_INVALID_OPERATION));
6942 return GL_INVALID_INDEX;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006943 }
Geoff Langbfdea662014-07-23 14:16:32 -04006944 else
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00006945 {
Geoff Langb1196682014-07-23 13:47:29 -04006946 context->recordError(gl::Error(GL_INVALID_VALUE));
6947 return GL_INVALID_INDEX;
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00006948 }
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00006949 }
Geoff Langbfdea662014-07-23 14:16:32 -04006950
6951 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6952 if (!programBinary)
6953 {
6954 return GL_INVALID_INDEX;
6955 }
6956
6957 return programBinary->getUniformBlockIndex(uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006958 }
6959
6960 return 0;
6961}
6962
6963void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
6964{
6965 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
6966 program, uniformBlockIndex, pname, params);
6967
Geoff Langbfdea662014-07-23 14:16:32 -04006968 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04006969 if (context)
6970 {
6971 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006972 {
Geoff Langb1196682014-07-23 13:47:29 -04006973 context->recordError(gl::Error(GL_INVALID_OPERATION));
6974 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006975 }
6976 gl::Program *programObject = context->getProgram(program);
6977
6978 if (!programObject)
6979 {
6980 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006981 {
Geoff Langb1196682014-07-23 13:47:29 -04006982 context->recordError(gl::Error(GL_INVALID_OPERATION));
6983 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006984 }
Geoff Langbfdea662014-07-23 14:16:32 -04006985 else
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00006986 {
Geoff Langb1196682014-07-23 13:47:29 -04006987 context->recordError(gl::Error(GL_INVALID_VALUE));
6988 return;
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00006989 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00006990 }
Geoff Langbfdea662014-07-23 14:16:32 -04006991
6992 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
6993
6994 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
6995 {
Geoff Langb1196682014-07-23 13:47:29 -04006996 context->recordError(gl::Error(GL_INVALID_VALUE));
6997 return;
Geoff Langbfdea662014-07-23 14:16:32 -04006998 }
6999
7000 switch (pname)
7001 {
7002 case GL_UNIFORM_BLOCK_BINDING:
7003 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
7004 break;
7005
7006 case GL_UNIFORM_BLOCK_DATA_SIZE:
7007 case GL_UNIFORM_BLOCK_NAME_LENGTH:
7008 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
7009 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
7010 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
7011 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
7012 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
7013 break;
7014
7015 default:
Geoff Langb1196682014-07-23 13:47:29 -04007016 context->recordError(gl::Error(GL_INVALID_ENUM));
7017 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007018 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007019 }
7020}
7021
7022void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
7023{
7024 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
7025 program, uniformBlockIndex, bufSize, length, uniformBlockName);
7026
Geoff Langbfdea662014-07-23 14:16:32 -04007027 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007028 if (context)
7029 {
7030 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007031 {
Geoff Langb1196682014-07-23 13:47:29 -04007032 context->recordError(gl::Error(GL_INVALID_OPERATION));
7033 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007034 }
7035
7036 gl::Program *programObject = context->getProgram(program);
7037
7038 if (!programObject)
7039 {
7040 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007041 {
Geoff Langb1196682014-07-23 13:47:29 -04007042 context->recordError(gl::Error(GL_INVALID_OPERATION));
7043 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007044 }
Geoff Langbfdea662014-07-23 14:16:32 -04007045 else
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007046 {
Geoff Langb1196682014-07-23 13:47:29 -04007047 context->recordError(gl::Error(GL_INVALID_VALUE));
7048 return;
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007049 }
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00007050 }
Geoff Langbfdea662014-07-23 14:16:32 -04007051
7052 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7053
7054 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7055 {
Geoff Langb1196682014-07-23 13:47:29 -04007056 context->recordError(gl::Error(GL_INVALID_VALUE));
7057 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007058 }
7059
7060 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007061 }
7062}
7063
7064void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
7065{
7066 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
7067 program, uniformBlockIndex, uniformBlockBinding);
7068
Geoff Langbfdea662014-07-23 14:16:32 -04007069 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007070 if (context)
7071 {
7072 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007073 {
Geoff Langb1196682014-07-23 13:47:29 -04007074 context->recordError(gl::Error(GL_INVALID_OPERATION));
7075 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007076 }
7077
Geoff Lang3a61c322014-07-10 13:01:54 -04007078 if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings)
Geoff Langbfdea662014-07-23 14:16:32 -04007079 {
Geoff Langb1196682014-07-23 13:47:29 -04007080 context->recordError(gl::Error(GL_INVALID_VALUE));
7081 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007082 }
7083
7084 gl::Program *programObject = context->getProgram(program);
7085
7086 if (!programObject)
7087 {
7088 if (context->getShader(program))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007089 {
Geoff Langb1196682014-07-23 13:47:29 -04007090 context->recordError(gl::Error(GL_INVALID_OPERATION));
7091 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007092 }
Geoff Langbfdea662014-07-23 14:16:32 -04007093 else
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007094 {
Geoff Langb1196682014-07-23 13:47:29 -04007095 context->recordError(gl::Error(GL_INVALID_VALUE));
7096 return;
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007097 }
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00007098 }
Geoff Langbfdea662014-07-23 14:16:32 -04007099
7100 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7101
7102 // if never linked, there won't be any uniform blocks
7103 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
7104 {
Geoff Langb1196682014-07-23 13:47:29 -04007105 context->recordError(gl::Error(GL_INVALID_VALUE));
7106 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007107 }
7108
7109 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007110 }
7111}
7112
7113void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
7114{
7115 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
7116 mode, first, count, instanceCount);
7117
Geoff Langbfdea662014-07-23 14:16:32 -04007118 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007119 if (context)
7120 {
7121 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007122 {
Geoff Langb1196682014-07-23 13:47:29 -04007123 context->recordError(gl::Error(GL_INVALID_OPERATION));
7124 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007125 }
Geoff Langbfdea662014-07-23 14:16:32 -04007126
7127 // glDrawArraysInstanced
7128 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007129 }
7130}
7131
7132void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
7133{
7134 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
7135 mode, count, type, indices, instanceCount);
7136
Geoff Langbfdea662014-07-23 14:16:32 -04007137 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007138 if (context)
7139 {
7140 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007141 {
Geoff Langb1196682014-07-23 13:47:29 -04007142 context->recordError(gl::Error(GL_INVALID_OPERATION));
7143 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007144 }
Geoff Langbfdea662014-07-23 14:16:32 -04007145
7146 // glDrawElementsInstanced
7147 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007148 }
7149}
7150
7151GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
7152{
7153 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
7154
Geoff Langbfdea662014-07-23 14:16:32 -04007155 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007156 if (context)
7157 {
7158 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007159 {
Geoff Langb1196682014-07-23 13:47:29 -04007160 context->recordError(gl::Error(GL_INVALID_OPERATION));
7161 return 0;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007162 }
Geoff Langbfdea662014-07-23 14:16:32 -04007163
7164 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
7165 {
Geoff Langb1196682014-07-23 13:47:29 -04007166 context->recordError(gl::Error(GL_INVALID_ENUM));
7167 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007168 }
7169
7170 if (flags != 0)
7171 {
Geoff Langb1196682014-07-23 13:47:29 -04007172 context->recordError(gl::Error(GL_INVALID_VALUE));
7173 return 0;
Geoff Langbfdea662014-07-23 14:16:32 -04007174 }
7175
7176 return context->createFenceSync(condition);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007177 }
7178
7179 return NULL;
7180}
7181
7182GLboolean __stdcall glIsSync(GLsync sync)
7183{
7184 EVENT("(GLsync sync = 0x%0.8p)", sync);
7185
Geoff Langbfdea662014-07-23 14:16:32 -04007186 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007187 if (context)
7188 {
7189 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007190 {
Geoff Langb1196682014-07-23 13:47:29 -04007191 context->recordError(gl::Error(GL_INVALID_OPERATION));
7192 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007193 }
Geoff Langbfdea662014-07-23 14:16:32 -04007194
7195 return (context->getFenceSync(sync) != NULL);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007196 }
7197
7198 return GL_FALSE;
7199}
7200
7201void __stdcall glDeleteSync(GLsync sync)
7202{
7203 EVENT("(GLsync sync = 0x%0.8p)", sync);
7204
Geoff Langbfdea662014-07-23 14:16:32 -04007205 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007206 if (context)
7207 {
7208 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007209 {
Geoff Langb1196682014-07-23 13:47:29 -04007210 context->recordError(gl::Error(GL_INVALID_OPERATION));
7211 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007212 }
Geoff Langbfdea662014-07-23 14:16:32 -04007213
7214 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
7215 {
Geoff Langb1196682014-07-23 13:47:29 -04007216 context->recordError(gl::Error(GL_INVALID_VALUE));
7217 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007218 }
7219
7220 context->deleteFenceSync(sync);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007221 }
7222}
7223
7224GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
7225{
7226 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7227 sync, flags, timeout);
7228
Geoff Langbfdea662014-07-23 14:16:32 -04007229 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007230 if (context)
7231 {
7232 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007233 {
Geoff Langb1196682014-07-23 13:47:29 -04007234 context->recordError(gl::Error(GL_INVALID_OPERATION));
7235 return GL_WAIT_FAILED;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007236 }
Geoff Langbfdea662014-07-23 14:16:32 -04007237
7238 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
7239 {
Geoff Langb1196682014-07-23 13:47:29 -04007240 context->recordError(gl::Error(GL_INVALID_VALUE));
7241 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007242 }
7243
7244 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7245
7246 if (!fenceSync)
7247 {
Geoff Langb1196682014-07-23 13:47:29 -04007248 context->recordError(gl::Error(GL_INVALID_VALUE));
7249 return GL_WAIT_FAILED;
Geoff Langbfdea662014-07-23 14:16:32 -04007250 }
7251
7252 return fenceSync->clientWait(flags, timeout);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007253 }
7254
7255 return GL_FALSE;
7256}
7257
7258void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
7259{
7260 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
7261 sync, flags, timeout);
7262
Geoff Langbfdea662014-07-23 14:16:32 -04007263 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007264 if (context)
7265 {
7266 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007267 {
Geoff Langb1196682014-07-23 13:47:29 -04007268 context->recordError(gl::Error(GL_INVALID_OPERATION));
7269 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007270 }
Geoff Langbfdea662014-07-23 14:16:32 -04007271
7272 if (flags != 0)
7273 {
Geoff Langb1196682014-07-23 13:47:29 -04007274 context->recordError(gl::Error(GL_INVALID_VALUE));
7275 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007276 }
7277
7278 if (timeout != GL_TIMEOUT_IGNORED)
7279 {
Geoff Langb1196682014-07-23 13:47:29 -04007280 context->recordError(gl::Error(GL_INVALID_VALUE));
7281 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007282 }
7283
7284 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7285
7286 if (!fenceSync)
7287 {
Geoff Langb1196682014-07-23 13:47:29 -04007288 context->recordError(gl::Error(GL_INVALID_VALUE));
7289 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007290 }
7291
7292 fenceSync->serverWait();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007293 }
7294}
7295
7296void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
7297{
7298 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7299 pname, params);
7300
Geoff Langbfdea662014-07-23 14:16:32 -04007301 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007302 if (context)
7303 {
7304 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007305 {
Geoff Langb1196682014-07-23 13:47:29 -04007306 context->recordError(gl::Error(GL_INVALID_OPERATION));
7307 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007308 }
Geoff Langbfdea662014-07-23 14:16:32 -04007309
7310 GLenum nativeType;
7311 unsigned int numParams = 0;
7312 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
7313 {
7314 return;
7315 }
7316
7317 if (nativeType == GL_INT_64_ANGLEX)
7318 {
7319 context->getInteger64v(pname, params);
7320 }
7321 else
7322 {
7323 CastStateValues(context, nativeType, pname, numParams, params);
7324 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007325 }
7326}
7327
7328void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
7329{
7330 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
7331 sync, pname, bufSize, length, values);
7332
Geoff Langbfdea662014-07-23 14:16:32 -04007333 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007334 if (context)
7335 {
7336 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007337 {
Geoff Langb1196682014-07-23 13:47:29 -04007338 context->recordError(gl::Error(GL_INVALID_OPERATION));
7339 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007340 }
Geoff Langbfdea662014-07-23 14:16:32 -04007341
7342 if (bufSize < 0)
7343 {
Geoff Langb1196682014-07-23 13:47:29 -04007344 context->recordError(gl::Error(GL_INVALID_VALUE));
7345 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007346 }
7347
7348 gl::FenceSync *fenceSync = context->getFenceSync(sync);
7349
7350 if (!fenceSync)
7351 {
Geoff Langb1196682014-07-23 13:47:29 -04007352 context->recordError(gl::Error(GL_INVALID_VALUE));
7353 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007354 }
7355
7356 switch (pname)
7357 {
7358 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
7359 case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break;
7360 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
7361 case GL_SYNC_FLAGS: values[0] = 0; break;
7362
7363 default:
Geoff Langb1196682014-07-23 13:47:29 -04007364 context->recordError(gl::Error(GL_INVALID_ENUM));
7365 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007366 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007367 }
7368}
7369
7370void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
7371{
7372 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
7373 target, index, data);
7374
Geoff Langbfdea662014-07-23 14:16:32 -04007375 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007376 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007377 {
Geoff Langbfdea662014-07-23 14:16:32 -04007378 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007379 {
Geoff Langb1196682014-07-23 13:47:29 -04007380 context->recordError(gl::Error(GL_INVALID_OPERATION));
7381 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007382 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007383
Geoff Lang3a61c322014-07-10 13:01:54 -04007384 const gl::Caps &caps = context->getCaps();
Geoff Langbfdea662014-07-23 14:16:32 -04007385 switch (target)
7386 {
7387 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
7388 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
7389 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
Geoff Lang05881a02014-07-10 14:05:30 -04007390 if (index >= caps.maxTransformFeedbackSeparateAttributes)
7391 {
Geoff Langb1196682014-07-23 13:47:29 -04007392 context->recordError(gl::Error(GL_INVALID_VALUE));
7393 return;
Geoff Lang05881a02014-07-10 14:05:30 -04007394 }
Geoff Langbfdea662014-07-23 14:16:32 -04007395 break;
Geoff Langb1196682014-07-23 13:47:29 -04007396
Geoff Langbfdea662014-07-23 14:16:32 -04007397 case GL_UNIFORM_BUFFER_START:
7398 case GL_UNIFORM_BUFFER_SIZE:
7399 case GL_UNIFORM_BUFFER_BINDING:
Geoff Lang3a61c322014-07-10 13:01:54 -04007400 if (index >= caps.maxUniformBufferBindings)
7401 {
Geoff Langb1196682014-07-23 13:47:29 -04007402 context->recordError(gl::Error(GL_INVALID_VALUE));
7403 return;
Geoff Lang3a61c322014-07-10 13:01:54 -04007404 }
Geoff Langbfdea662014-07-23 14:16:32 -04007405 break;
Geoff Langb1196682014-07-23 13:47:29 -04007406
Geoff Langbfdea662014-07-23 14:16:32 -04007407 default:
Geoff Langb1196682014-07-23 13:47:29 -04007408 context->recordError(gl::Error(GL_INVALID_ENUM));
7409 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007410 }
7411
7412 if (!(context->getIndexedInteger64v(target, index, data)))
7413 {
7414 GLenum nativeType;
7415 unsigned int numParams = 0;
7416 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
Geoff Langb1196682014-07-23 13:47:29 -04007417 {
7418 context->recordError(gl::Error(GL_INVALID_ENUM));
7419 return;
7420 }
Shannon Woods15934d52013-08-19 14:28:49 -04007421
Geoff Langbfdea662014-07-23 14:16:32 -04007422 if (numParams == 0)
7423 return; // it is known that pname is valid, but there are no parameters to return
7424
7425 if (nativeType == GL_INT)
Shannon Woods15934d52013-08-19 14:28:49 -04007426 {
Geoff Langbfdea662014-07-23 14:16:32 -04007427 GLint *intParams = new GLint[numParams];
Shannon Woods15934d52013-08-19 14:28:49 -04007428
Geoff Langbfdea662014-07-23 14:16:32 -04007429 context->getIndexedIntegerv(target, index, intParams);
Shannon Woods15934d52013-08-19 14:28:49 -04007430
Geoff Langbfdea662014-07-23 14:16:32 -04007431 for (unsigned int i = 0; i < numParams; ++i)
Shannon Woods15934d52013-08-19 14:28:49 -04007432 {
Geoff Langbfdea662014-07-23 14:16:32 -04007433 data[i] = static_cast<GLint64>(intParams[i]);
Shannon Woods15934d52013-08-19 14:28:49 -04007434 }
Geoff Langbfdea662014-07-23 14:16:32 -04007435
7436 delete [] intParams;
7437 }
7438 else
7439 {
7440 UNREACHABLE();
Shannon Woods15934d52013-08-19 14:28:49 -04007441 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007442 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007443 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007444}
7445
7446void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
7447{
7448 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
7449 target, pname, params);
7450
Geoff Langbfdea662014-07-23 14:16:32 -04007451 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007452 if (context)
7453 {
7454 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007455 {
Geoff Langb1196682014-07-23 13:47:29 -04007456 context->recordError(gl::Error(GL_INVALID_OPERATION));
7457 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007458 }
Geoff Langbfdea662014-07-23 14:16:32 -04007459
7460 if (!gl::ValidBufferTarget(context, target))
7461 {
Geoff Langb1196682014-07-23 13:47:29 -04007462 context->recordError(gl::Error(GL_INVALID_ENUM));
7463 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007464 }
7465
7466 if (!gl::ValidBufferParameter(context, pname))
7467 {
Geoff Langb1196682014-07-23 13:47:29 -04007468 context->recordError(gl::Error(GL_INVALID_ENUM));
7469 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007470 }
7471
7472 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
7473
7474 if (!buffer)
7475 {
7476 // A null buffer means that "0" is bound to the requested buffer target
Geoff Langb1196682014-07-23 13:47:29 -04007477 context->recordError(gl::Error(GL_INVALID_OPERATION));
7478 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007479 }
7480
7481 switch (pname)
7482 {
7483 case GL_BUFFER_USAGE:
7484 *params = static_cast<GLint64>(buffer->getUsage());
7485 break;
7486 case GL_BUFFER_SIZE:
7487 *params = buffer->getSize();
7488 break;
7489 case GL_BUFFER_ACCESS_FLAGS:
7490 *params = static_cast<GLint64>(buffer->getAccessFlags());
7491 break;
7492 case GL_BUFFER_MAPPED:
7493 *params = static_cast<GLint64>(buffer->isMapped());
7494 break;
7495 case GL_BUFFER_MAP_OFFSET:
7496 *params = buffer->getMapOffset();
7497 break;
7498 case GL_BUFFER_MAP_LENGTH:
7499 *params = buffer->getMapLength();
7500 break;
7501 default: UNREACHABLE(); break;
7502 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007503 }
7504}
7505
7506void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
7507{
7508 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
7509
Geoff Langbfdea662014-07-23 14:16:32 -04007510 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007511 if (context)
7512 {
7513 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007514 {
Geoff Langb1196682014-07-23 13:47:29 -04007515 context->recordError(gl::Error(GL_INVALID_OPERATION));
7516 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007517 }
Geoff Langbfdea662014-07-23 14:16:32 -04007518
7519 if (count < 0)
7520 {
Geoff Langb1196682014-07-23 13:47:29 -04007521 context->recordError(gl::Error(GL_INVALID_VALUE));
7522 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007523 }
7524
7525 for (int i = 0; i < count; i++)
7526 {
7527 samplers[i] = context->createSampler();
7528 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007529 }
7530}
7531
7532void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
7533{
7534 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
7535
Geoff Langbfdea662014-07-23 14:16:32 -04007536 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007537 if (context)
7538 {
7539 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007540 {
Geoff Langb1196682014-07-23 13:47:29 -04007541 context->recordError(gl::Error(GL_INVALID_OPERATION));
7542 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007543 }
Geoff Langbfdea662014-07-23 14:16:32 -04007544
7545 if (count < 0)
7546 {
Geoff Langb1196682014-07-23 13:47:29 -04007547 context->recordError(gl::Error(GL_INVALID_VALUE));
7548 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007549 }
7550
7551 for (int i = 0; i < count; i++)
7552 {
7553 context->deleteSampler(samplers[i]);
7554 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007555 }
7556}
7557
7558GLboolean __stdcall glIsSampler(GLuint sampler)
7559{
7560 EVENT("(GLuint sampler = %u)", sampler);
7561
Geoff Langbfdea662014-07-23 14:16:32 -04007562 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007563 if (context)
7564 {
7565 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007566 {
Geoff Langb1196682014-07-23 13:47:29 -04007567 context->recordError(gl::Error(GL_INVALID_OPERATION));
7568 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007569 }
Geoff Langbfdea662014-07-23 14:16:32 -04007570
7571 return context->isSampler(sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007572 }
7573
7574 return GL_FALSE;
7575}
7576
7577void __stdcall glBindSampler(GLuint unit, GLuint sampler)
7578{
7579 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
7580
Geoff Langbfdea662014-07-23 14:16:32 -04007581 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007582 if (context)
7583 {
7584 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007585 {
Geoff Langb1196682014-07-23 13:47:29 -04007586 context->recordError(gl::Error(GL_INVALID_OPERATION));
7587 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007588 }
Geoff Langbfdea662014-07-23 14:16:32 -04007589
7590 if (sampler != 0 && !context->isSampler(sampler))
7591 {
Geoff Langb1196682014-07-23 13:47:29 -04007592 context->recordError(gl::Error(GL_INVALID_OPERATION));
7593 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007594 }
7595
Geoff Lang3a61c322014-07-10 13:01:54 -04007596 if (unit >= context->getCaps().maxCombinedTextureImageUnits)
Geoff Langbfdea662014-07-23 14:16:32 -04007597 {
Geoff Langb1196682014-07-23 13:47:29 -04007598 context->recordError(gl::Error(GL_INVALID_VALUE));
7599 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007600 }
7601
7602 context->bindSampler(unit, sampler);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007603 }
7604}
7605
7606void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
7607{
7608 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
7609
Geoff Langbfdea662014-07-23 14:16:32 -04007610 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007611 if (context)
7612 {
7613 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007614 {
Geoff Langb1196682014-07-23 13:47:29 -04007615 context->recordError(gl::Error(GL_INVALID_OPERATION));
7616 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007617 }
Geoff Langbfdea662014-07-23 14:16:32 -04007618
Geoff Langb1196682014-07-23 13:47:29 -04007619 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007620 {
7621 return;
7622 }
7623
7624 if (!gl::ValidateTexParamParameters(context, pname, param))
7625 {
7626 return;
7627 }
7628
7629 if (!context->isSampler(sampler))
7630 {
Geoff Langb1196682014-07-23 13:47:29 -04007631 context->recordError(gl::Error(GL_INVALID_OPERATION));
7632 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007633 }
7634
7635 context->samplerParameteri(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007636 }
7637}
7638
7639void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
7640{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007641 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007642}
7643
7644void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
7645{
7646 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
7647
Geoff Langbfdea662014-07-23 14:16:32 -04007648 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007649 if (context)
7650 {
7651 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007652 {
Geoff Langb1196682014-07-23 13:47:29 -04007653 context->recordError(gl::Error(GL_INVALID_OPERATION));
7654 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007655 }
Geoff Langbfdea662014-07-23 14:16:32 -04007656
Geoff Langb1196682014-07-23 13:47:29 -04007657 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007658 {
7659 return;
7660 }
7661
7662 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
7663 {
7664 return;
7665 }
7666
7667 if (!context->isSampler(sampler))
7668 {
Geoff Langb1196682014-07-23 13:47:29 -04007669 context->recordError(gl::Error(GL_INVALID_OPERATION));
7670 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007671 }
7672
7673 context->samplerParameterf(sampler, pname, param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007674 }
7675}
7676
7677void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
7678{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04007679 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007680}
7681
7682void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
7683{
7684 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
7685
Geoff Langbfdea662014-07-23 14:16:32 -04007686 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007687 if (context)
7688 {
7689 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007690 {
Geoff Langb1196682014-07-23 13:47:29 -04007691 context->recordError(gl::Error(GL_INVALID_OPERATION));
7692 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007693 }
Geoff Langbfdea662014-07-23 14:16:32 -04007694
Geoff Langb1196682014-07-23 13:47:29 -04007695 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007696 {
7697 return;
7698 }
7699
7700 if (!context->isSampler(sampler))
7701 {
Geoff Langb1196682014-07-23 13:47:29 -04007702 context->recordError(gl::Error(GL_INVALID_OPERATION));
7703 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007704 }
7705
7706 *params = context->getSamplerParameteri(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007707 }
7708}
7709
7710void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
7711{
7712 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
7713
Geoff Langbfdea662014-07-23 14:16:32 -04007714 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007715 if (context)
7716 {
7717 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007718 {
Geoff Langb1196682014-07-23 13:47:29 -04007719 context->recordError(gl::Error(GL_INVALID_OPERATION));
7720 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007721 }
Geoff Langbfdea662014-07-23 14:16:32 -04007722
Geoff Langb1196682014-07-23 13:47:29 -04007723 if (!gl::ValidateSamplerObjectParameter(context, pname))
Geoff Langbfdea662014-07-23 14:16:32 -04007724 {
7725 return;
7726 }
7727
7728 if (!context->isSampler(sampler))
7729 {
Geoff Langb1196682014-07-23 13:47:29 -04007730 context->recordError(gl::Error(GL_INVALID_OPERATION));
7731 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007732 }
7733
7734 *params = context->getSamplerParameterf(sampler, pname);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007735 }
7736}
7737
7738void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
7739{
7740 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
7741
Geoff Langbfdea662014-07-23 14:16:32 -04007742 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007743 if (context)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007744 {
Geoff Langbfdea662014-07-23 14:16:32 -04007745 if (context->getClientVersion() < 3)
7746 {
Geoff Langb1196682014-07-23 13:47:29 -04007747 context->recordError(gl::Error(GL_INVALID_OPERATION));
7748 return;
7749 }
7750
7751 if (index >= gl::MAX_VERTEX_ATTRIBS)
7752 {
7753 context->recordError(gl::Error(GL_INVALID_VALUE));
7754 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007755 }
7756
7757 context->setVertexAttribDivisor(index, divisor);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007758 }
7759}
7760
7761void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
7762{
7763 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
7764
Geoff Langbfdea662014-07-23 14:16:32 -04007765 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007766 if (context)
7767 {
7768 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007769 {
Geoff Langb1196682014-07-23 13:47:29 -04007770 context->recordError(gl::Error(GL_INVALID_OPERATION));
7771 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007772 }
Geoff Langbfdea662014-07-23 14:16:32 -04007773
7774 switch (target)
7775 {
7776 case GL_TRANSFORM_FEEDBACK:
7777 {
7778 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
7779 gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback();
7780 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
7781 {
Geoff Langb1196682014-07-23 13:47:29 -04007782 context->recordError(gl::Error(GL_INVALID_OPERATION));
7783 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007784 }
7785
7786 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
7787 if (context->getTransformFeedback(id) == NULL)
7788 {
Geoff Langb1196682014-07-23 13:47:29 -04007789 context->recordError(gl::Error(GL_INVALID_OPERATION));
7790 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007791 }
7792
7793 context->bindTransformFeedback(id);
7794 }
7795 break;
7796
7797 default:
Geoff Langb1196682014-07-23 13:47:29 -04007798 context->recordError(gl::Error(GL_INVALID_ENUM));
7799 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007800 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007801 }
7802}
7803
7804void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
7805{
7806 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
7807
Geoff Langbfdea662014-07-23 14:16:32 -04007808 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007809 if (context)
7810 {
7811 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007812 {
Geoff Langb1196682014-07-23 13:47:29 -04007813 context->recordError(gl::Error(GL_INVALID_OPERATION));
7814 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007815 }
Geoff Langbfdea662014-07-23 14:16:32 -04007816
7817 for (int i = 0; i < n; i++)
7818 {
7819 context->deleteTransformFeedback(ids[i]);
7820 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007821 }
7822}
7823
7824void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
7825{
7826 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
7827
Geoff Langbfdea662014-07-23 14:16:32 -04007828 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007829 if (context)
7830 {
7831 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007832 {
Geoff Langb1196682014-07-23 13:47:29 -04007833 context->recordError(gl::Error(GL_INVALID_OPERATION));
7834 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007835 }
Geoff Langbfdea662014-07-23 14:16:32 -04007836
7837 for (int i = 0; i < n; i++)
7838 {
7839 ids[i] = context->createTransformFeedback();
7840 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007841 }
7842}
7843
7844GLboolean __stdcall glIsTransformFeedback(GLuint id)
7845{
7846 EVENT("(GLuint id = %u)", id);
7847
Geoff Langbfdea662014-07-23 14:16:32 -04007848 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007849 if (context)
7850 {
7851 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007852 {
Geoff Langb1196682014-07-23 13:47:29 -04007853 context->recordError(gl::Error(GL_INVALID_OPERATION));
7854 return GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007855 }
Geoff Langbfdea662014-07-23 14:16:32 -04007856
7857 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007858 }
7859
7860 return GL_FALSE;
7861}
7862
7863void __stdcall glPauseTransformFeedback(void)
7864{
7865 EVENT("(void)");
7866
Geoff Langbfdea662014-07-23 14:16:32 -04007867 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007868 if (context)
7869 {
7870 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007871 {
Geoff Langb1196682014-07-23 13:47:29 -04007872 context->recordError(gl::Error(GL_INVALID_OPERATION));
7873 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007874 }
Geoff Langbfdea662014-07-23 14:16:32 -04007875
7876 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
7877 ASSERT(transformFeedback != NULL);
7878
7879 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
7880 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
7881 {
Geoff Langb1196682014-07-23 13:47:29 -04007882 context->recordError(gl::Error(GL_INVALID_OPERATION));
7883 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007884 }
7885
7886 transformFeedback->pause();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007887 }
7888}
7889
7890void __stdcall glResumeTransformFeedback(void)
7891{
7892 EVENT("(void)");
7893
Geoff Langbfdea662014-07-23 14:16:32 -04007894 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007895 if (context)
7896 {
7897 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007898 {
Geoff Langb1196682014-07-23 13:47:29 -04007899 context->recordError(gl::Error(GL_INVALID_OPERATION));
7900 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007901 }
Geoff Langbfdea662014-07-23 14:16:32 -04007902
7903 gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback();
7904 ASSERT(transformFeedback != NULL);
7905
7906 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
7907 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
7908 {
Geoff Langb1196682014-07-23 13:47:29 -04007909 context->recordError(gl::Error(GL_INVALID_OPERATION));
7910 return;
Geoff Langbfdea662014-07-23 14:16:32 -04007911 }
7912
7913 transformFeedback->resume();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007914 }
7915}
7916
7917void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
7918{
7919 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
7920 program, bufSize, length, binaryFormat, binary);
7921
Geoff Langbfdea662014-07-23 14:16:32 -04007922 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007923 if (context)
7924 {
7925 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007926 {
Geoff Langb1196682014-07-23 13:47:29 -04007927 context->recordError(gl::Error(GL_INVALID_OPERATION));
7928 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007929 }
Geoff Langbfdea662014-07-23 14:16:32 -04007930
7931 // glGetProgramBinary
7932 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007933 }
7934}
7935
7936void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
7937{
7938 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
7939 program, binaryFormat, binary, length);
7940
Geoff Langbfdea662014-07-23 14:16:32 -04007941 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007942 if (context)
7943 {
7944 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007945 {
Geoff Langb1196682014-07-23 13:47:29 -04007946 context->recordError(gl::Error(GL_INVALID_OPERATION));
7947 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007948 }
Geoff Langbfdea662014-07-23 14:16:32 -04007949
7950 // glProgramBinary
7951 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007952 }
7953}
7954
7955void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
7956{
7957 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
7958 program, pname, value);
7959
Geoff Langbfdea662014-07-23 14:16:32 -04007960 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007961 if (context)
7962 {
7963 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007964 {
Geoff Langb1196682014-07-23 13:47:29 -04007965 context->recordError(gl::Error(GL_INVALID_OPERATION));
7966 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007967 }
Geoff Langbfdea662014-07-23 14:16:32 -04007968
7969 // glProgramParameteri
7970 UNIMPLEMENTED();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007971 }
7972}
7973
7974void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
7975{
7976 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
7977 target, numAttachments, attachments);
7978
Geoff Langbfdea662014-07-23 14:16:32 -04007979 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04007980 if (context)
7981 {
7982 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007983 {
Geoff Langb1196682014-07-23 13:47:29 -04007984 context->recordError(gl::Error(GL_INVALID_OPERATION));
7985 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00007986 }
Geoff Langbfdea662014-07-23 14:16:32 -04007987
7988 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
7989 {
7990 return;
7991 }
7992
Jamie Madill2d96b9e2014-08-29 15:46:47 -04007993 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
7994 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
7995 {
7996 framebuffer->invalidate(context->getCaps(), numAttachments, attachments);
7997 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007998 }
7999}
8000
8001void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
8002{
8003 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
8004 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
8005 target, numAttachments, attachments, x, y, width, height);
8006
Geoff Langbfdea662014-07-23 14:16:32 -04008007 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008008 if (context)
8009 {
8010 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008011 {
Geoff Langb1196682014-07-23 13:47:29 -04008012 context->recordError(gl::Error(GL_INVALID_OPERATION));
8013 return;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00008014 }
Geoff Langbfdea662014-07-23 14:16:32 -04008015
8016 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
8017 {
8018 return;
8019 }
8020
Jamie Madill2d96b9e2014-08-29 15:46:47 -04008021 gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
8022 if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE)
8023 {
8024 framebuffer->invalidateSub(context->getCaps(), numAttachments, attachments, x, y, width, height);
8025 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008026 }
8027}
8028
8029void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
8030{
8031 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
8032 target, levels, internalformat, width, height);
8033
Geoff Langbfdea662014-07-23 14:16:32 -04008034 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008035 if (context)
8036 {
8037 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008038 {
Geoff Langb1196682014-07-23 13:47:29 -04008039 context->recordError(gl::Error(GL_INVALID_OPERATION));
8040 return;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00008041 }
Geoff Langbfdea662014-07-23 14:16:32 -04008042
8043 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
8044 {
8045 return;
8046 }
8047
8048 switch (target)
8049 {
8050 case GL_TEXTURE_2D:
8051 {
8052 gl::Texture2D *texture2d = context->getTexture2D();
8053 texture2d->storage(levels, internalformat, width, height);
8054 }
8055 break;
8056
8057 case GL_TEXTURE_CUBE_MAP:
8058 {
8059 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
8060 textureCube->storage(levels, internalformat, width);
8061 }
8062 break;
8063
8064 default:
Geoff Langb1196682014-07-23 13:47:29 -04008065 context->recordError(gl::Error(GL_INVALID_ENUM));
8066 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008067 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008068 }
8069}
8070
8071void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
8072{
8073 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
8074 "GLsizei height = %d, GLsizei depth = %d)",
8075 target, levels, internalformat, width, height, depth);
8076
Geoff Langbfdea662014-07-23 14:16:32 -04008077 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008078 if (context)
8079 {
8080 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008081 {
Geoff Langb1196682014-07-23 13:47:29 -04008082 context->recordError(gl::Error(GL_INVALID_OPERATION));
8083 return;
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00008084 }
Geoff Langbfdea662014-07-23 14:16:32 -04008085
8086 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
8087 {
8088 return;
8089 }
8090
8091 switch (target)
8092 {
8093 case GL_TEXTURE_3D:
8094 {
8095 gl::Texture3D *texture3d = context->getTexture3D();
8096 texture3d->storage(levels, internalformat, width, height, depth);
8097 }
8098 break;
8099
8100 case GL_TEXTURE_2D_ARRAY:
8101 {
8102 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
8103 texture2darray->storage(levels, internalformat, width, height, depth);
8104 }
8105 break;
8106
8107 default:
8108 UNREACHABLE();
8109 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008110 }
8111}
8112
8113void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
8114{
8115 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
8116 "GLint* params = 0x%0.8p)",
8117 target, internalformat, pname, bufSize, params);
8118
Geoff Langbfdea662014-07-23 14:16:32 -04008119 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008120 if (context)
8121 {
8122 if (context->getClientVersion() < 3)
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008123 {
Geoff Langb1196682014-07-23 13:47:29 -04008124 context->recordError(gl::Error(GL_INVALID_OPERATION));
8125 return;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008126 }
Geoff Langbfdea662014-07-23 14:16:32 -04008127
8128 const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
8129 if (!formatCaps.renderable)
8130 {
Geoff Langb1196682014-07-23 13:47:29 -04008131 context->recordError(gl::Error(GL_INVALID_ENUM));
8132 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008133 }
8134
8135 if (target != GL_RENDERBUFFER)
8136 {
Geoff Langb1196682014-07-23 13:47:29 -04008137 context->recordError(gl::Error(GL_INVALID_ENUM));
8138 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008139 }
8140
8141 if (bufSize < 0)
8142 {
Geoff Langb1196682014-07-23 13:47:29 -04008143 context->recordError(gl::Error(GL_INVALID_VALUE));
8144 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008145 }
8146
8147 switch (pname)
8148 {
8149 case GL_NUM_SAMPLE_COUNTS:
8150 if (bufSize != 0)
Geoff Lang5f4c4632014-07-03 13:46:52 -04008151 {
8152 *params = formatCaps.sampleCounts.size();
8153 }
Geoff Langbfdea662014-07-23 14:16:32 -04008154 break;
Geoff Langb1196682014-07-23 13:47:29 -04008155
Geoff Langbfdea662014-07-23 14:16:32 -04008156 case GL_SAMPLES:
Geoff Lang5f4c4632014-07-03 13:46:52 -04008157 std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params);
Geoff Langbfdea662014-07-23 14:16:32 -04008158 break;
Geoff Langb1196682014-07-23 13:47:29 -04008159
Geoff Langbfdea662014-07-23 14:16:32 -04008160 default:
Geoff Langb1196682014-07-23 13:47:29 -04008161 context->recordError(gl::Error(GL_INVALID_ENUM));
8162 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008163 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008164 }
8165}
8166
8167// Extension functions
8168
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008169void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
8170 GLbitfield mask, GLenum filter)
8171{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008172 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008173 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
8174 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
8175 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
8176
Geoff Langbfdea662014-07-23 14:16:32 -04008177 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008178 if (context)
8179 {
8180 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
8181 dstX0, dstY0, dstX1, dstY1, mask, filter,
8182 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008183 {
Geoff Langbfdea662014-07-23 14:16:32 -04008184 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008185 }
Geoff Langbfdea662014-07-23 14:16:32 -04008186
8187 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
8188 mask, filter);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00008189 }
8190}
8191
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008192void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
8193 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008194{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00008195 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00008196 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00008197 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008198 target, level, internalformat, width, height, depth, border, format, type, pixels);
8199
Geoff Langbfdea662014-07-23 14:16:32 -04008200 UNIMPLEMENTED(); // FIXME
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008201}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008202
Geoff Langbfdea662014-07-23 14:16:32 -04008203void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008204 GLenum *binaryFormat, void *binary)
8205{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00008206 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 +00008207 program, bufSize, length, binaryFormat, binary);
8208
Geoff Langbfdea662014-07-23 14:16:32 -04008209 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008210 if (context)
8211 {
8212 gl::Program *programObject = context->getProgram(program);
8213
8214 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008215 {
Geoff Langb1196682014-07-23 13:47:29 -04008216 context->recordError(gl::Error(GL_INVALID_OPERATION));
8217 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008218 }
Geoff Langbfdea662014-07-23 14:16:32 -04008219
8220 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8221
8222 if (!programBinary)
8223 {
Geoff Langb1196682014-07-23 13:47:29 -04008224 context->recordError(gl::Error(GL_INVALID_OPERATION));
8225 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008226 }
8227
Geoff Lang900013c2014-07-07 11:32:19 -04008228 if (!programBinary->save(binaryFormat, binary, bufSize, length))
Geoff Langbfdea662014-07-23 14:16:32 -04008229 {
Geoff Langb1196682014-07-23 13:47:29 -04008230 context->recordError(gl::Error(GL_INVALID_OPERATION));
8231 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008232 }
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008233 }
8234}
8235
8236void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
8237 const void *binary, GLint length)
8238{
8239 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, 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 {
Geoff Lang900013c2014-07-07 11:32:19 -04008245 const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats;
8246 if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008247 {
Geoff Langb1196682014-07-23 13:47:29 -04008248 context->recordError(gl::Error(GL_INVALID_ENUM));
8249 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008250 }
Geoff Langbfdea662014-07-23 14:16:32 -04008251
8252 gl::Program *programObject = context->getProgram(program);
Geoff Langbfdea662014-07-23 14:16:32 -04008253 if (!programObject)
8254 {
Geoff Langb1196682014-07-23 13:47:29 -04008255 context->recordError(gl::Error(GL_INVALID_OPERATION));
8256 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008257 }
8258
Geoff Lang900013c2014-07-07 11:32:19 -04008259 context->setProgramBinary(program, binaryFormat, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008260 }
8261}
8262
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008263void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
8264{
8265 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
8266
Geoff Langbfdea662014-07-23 14:16:32 -04008267 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008268 if (context)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008269 {
Geoff Langbfdea662014-07-23 14:16:32 -04008270 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008271 {
Geoff Langb1196682014-07-23 13:47:29 -04008272 context->recordError(gl::Error(GL_INVALID_VALUE));
8273 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008274 }
8275
8276 if (context->getState().getDrawFramebuffer()->id() == 0)
8277 {
8278 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008279 {
Geoff Langb1196682014-07-23 13:47:29 -04008280 context->recordError(gl::Error(GL_INVALID_OPERATION));
8281 return;
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008282 }
8283
Geoff Langbfdea662014-07-23 14:16:32 -04008284 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008285 {
Geoff Langb1196682014-07-23 13:47:29 -04008286 context->recordError(gl::Error(GL_INVALID_OPERATION));
8287 return;
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00008288 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008289 }
Geoff Langbfdea662014-07-23 14:16:32 -04008290 else
8291 {
8292 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
8293 {
8294 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
8295 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
8296 {
Geoff Langb1196682014-07-23 13:47:29 -04008297 context->recordError(gl::Error(GL_INVALID_OPERATION));
8298 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008299 }
8300 }
8301 }
8302
8303 gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
8304
8305 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
8306 {
8307 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
8308 }
8309
8310 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
8311 {
8312 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
8313 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00008314 }
8315}
8316
Shannon Woodsb3801742014-03-27 14:59:19 -04008317void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
8318{
8319 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
8320
Geoff Langbfdea662014-07-23 14:16:32 -04008321 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008322 if (context)
8323 {
8324 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008325 {
Geoff Langb1196682014-07-23 13:47:29 -04008326 context->recordError(gl::Error(GL_INVALID_ENUM));
8327 return;
Shannon Woodsb3801742014-03-27 14:59:19 -04008328 }
Geoff Langbfdea662014-07-23 14:16:32 -04008329
8330 if (pname != GL_BUFFER_MAP_POINTER)
8331 {
Geoff Langb1196682014-07-23 13:47:29 -04008332 context->recordError(gl::Error(GL_INVALID_ENUM));
8333 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008334 }
8335
8336 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8337
8338 if (!buffer || !buffer->isMapped())
8339 {
8340 *params = NULL;
8341 }
8342 else
8343 {
8344 *params = buffer->getMapPointer();
8345 }
Shannon Woodsb3801742014-03-27 14:59:19 -04008346 }
8347}
8348
8349void * __stdcall glMapBufferOES(GLenum target, GLenum access)
8350{
8351 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
8352
Geoff Langbfdea662014-07-23 14:16:32 -04008353 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008354 if (context)
8355 {
8356 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008357 {
Geoff Langb1196682014-07-23 13:47:29 -04008358 context->recordError(gl::Error(GL_INVALID_ENUM));
8359 return NULL;
Shannon Woodsb3801742014-03-27 14:59:19 -04008360 }
Geoff Langbfdea662014-07-23 14:16:32 -04008361
8362 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8363
8364 if (buffer == NULL)
8365 {
Geoff Langb1196682014-07-23 13:47:29 -04008366 context->recordError(gl::Error(GL_INVALID_OPERATION));
8367 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008368 }
8369
8370 if (access != GL_WRITE_ONLY_OES)
8371 {
Geoff Langb1196682014-07-23 13:47:29 -04008372 context->recordError(gl::Error(GL_INVALID_ENUM));
8373 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008374 }
8375
8376 if (buffer->isMapped())
8377 {
Geoff Langb1196682014-07-23 13:47:29 -04008378 context->recordError(gl::Error(GL_INVALID_OPERATION));
8379 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008380 }
8381
8382 return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
Shannon Woodsb3801742014-03-27 14:59:19 -04008383 }
8384
8385 return NULL;
8386}
8387
8388GLboolean __stdcall glUnmapBufferOES(GLenum target)
8389{
8390 EVENT("(GLenum target = 0x%X)", target);
8391
Geoff Langbfdea662014-07-23 14:16:32 -04008392 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008393 if (context)
8394 {
8395 if (!gl::ValidBufferTarget(context, target))
Shannon Woodsb3801742014-03-27 14:59:19 -04008396 {
Geoff Langb1196682014-07-23 13:47:29 -04008397 context->recordError(gl::Error(GL_INVALID_ENUM));
8398 return GL_FALSE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008399 }
Geoff Langbfdea662014-07-23 14:16:32 -04008400
8401 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8402
8403 if (buffer == NULL || !buffer->isMapped())
8404 {
Geoff Langb1196682014-07-23 13:47:29 -04008405 context->recordError(gl::Error(GL_INVALID_OPERATION));
8406 return GL_FALSE;
Geoff Langbfdea662014-07-23 14:16:32 -04008407 }
8408
8409 // TODO: detect if we had corruption. if so, throw an error and return false.
8410
8411 buffer->unmap();
8412
8413 return GL_TRUE;
Shannon Woodsb3801742014-03-27 14:59:19 -04008414 }
8415
8416 return GL_FALSE;
8417}
8418
Shannon Woods916e7692014-03-27 16:58:22 -04008419void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
8420{
8421 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
8422 target, offset, length, access);
8423
Geoff Langbfdea662014-07-23 14:16:32 -04008424 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008425 if (context)
8426 {
8427 if (!gl::ValidBufferTarget(context, target))
Shannon Woods916e7692014-03-27 16:58:22 -04008428 {
Geoff Langb1196682014-07-23 13:47:29 -04008429 context->recordError(gl::Error(GL_INVALID_ENUM));
8430 return NULL;
Shannon Woods916e7692014-03-27 16:58:22 -04008431 }
Geoff Langbfdea662014-07-23 14:16:32 -04008432
8433 if (offset < 0 || length < 0)
8434 {
Geoff Langb1196682014-07-23 13:47:29 -04008435 context->recordError(gl::Error(GL_INVALID_VALUE));
8436 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008437 }
8438
8439 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8440
8441 if (buffer == NULL)
8442 {
Geoff Langb1196682014-07-23 13:47:29 -04008443 context->recordError(gl::Error(GL_INVALID_OPERATION));
8444 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008445 }
8446
8447 // Check for buffer overflow
8448 size_t offsetSize = static_cast<size_t>(offset);
8449 size_t lengthSize = static_cast<size_t>(length);
8450
8451 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8452 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
8453 {
Geoff Langb1196682014-07-23 13:47:29 -04008454 context->recordError(gl::Error(GL_INVALID_VALUE));
8455 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008456 }
8457
8458 // Check for invalid bits in the mask
8459 GLbitfield allAccessBits = GL_MAP_READ_BIT |
8460 GL_MAP_WRITE_BIT |
8461 GL_MAP_INVALIDATE_RANGE_BIT |
8462 GL_MAP_INVALIDATE_BUFFER_BIT |
8463 GL_MAP_FLUSH_EXPLICIT_BIT |
8464 GL_MAP_UNSYNCHRONIZED_BIT;
8465
8466 if (access & ~(allAccessBits))
8467 {
Geoff Langb1196682014-07-23 13:47:29 -04008468 context->recordError(gl::Error(GL_INVALID_VALUE));
8469 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008470 }
8471
8472 if (length == 0 || buffer->isMapped())
8473 {
Geoff Langb1196682014-07-23 13:47:29 -04008474 context->recordError(gl::Error(GL_INVALID_OPERATION));
8475 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008476 }
8477
8478 // Check for invalid bit combinations
8479 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
8480 {
Geoff Langb1196682014-07-23 13:47:29 -04008481 context->recordError(gl::Error(GL_INVALID_OPERATION));
8482 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008483 }
8484
8485 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
8486 GL_MAP_INVALIDATE_BUFFER_BIT |
8487 GL_MAP_UNSYNCHRONIZED_BIT;
8488
8489 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
8490 {
Geoff Langb1196682014-07-23 13:47:29 -04008491 context->recordError(gl::Error(GL_INVALID_OPERATION));
8492 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008493 }
8494
8495 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
8496 {
Geoff Langb1196682014-07-23 13:47:29 -04008497 context->recordError(gl::Error(GL_INVALID_OPERATION));
8498 return NULL;
Geoff Langbfdea662014-07-23 14:16:32 -04008499 }
8500
8501 return buffer->mapRange(offset, length, access);
Shannon Woods916e7692014-03-27 16:58:22 -04008502 }
8503
8504 return NULL;
8505}
8506
8507void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
8508{
8509 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
8510
Geoff Langbfdea662014-07-23 14:16:32 -04008511 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008512 if (context)
8513 {
8514 if (offset < 0 || length < 0)
Shannon Woods916e7692014-03-27 16:58:22 -04008515 {
Geoff Langb1196682014-07-23 13:47:29 -04008516 context->recordError(gl::Error(GL_INVALID_VALUE));
8517 return;
Shannon Woods916e7692014-03-27 16:58:22 -04008518 }
Geoff Langbfdea662014-07-23 14:16:32 -04008519
8520 if (!gl::ValidBufferTarget(context, target))
8521 {
Geoff Langb1196682014-07-23 13:47:29 -04008522 context->recordError(gl::Error(GL_INVALID_ENUM));
8523 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008524 }
8525
8526 gl::Buffer *buffer = context->getState().getTargetBuffer(target);
8527
8528 if (buffer == NULL)
8529 {
Geoff Langb1196682014-07-23 13:47:29 -04008530 context->recordError(gl::Error(GL_INVALID_OPERATION));
8531 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008532 }
8533
8534 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
8535 {
Geoff Langb1196682014-07-23 13:47:29 -04008536 context->recordError(gl::Error(GL_INVALID_OPERATION));
8537 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008538 }
8539
8540 // Check for buffer overflow
8541 size_t offsetSize = static_cast<size_t>(offset);
8542 size_t lengthSize = static_cast<size_t>(length);
8543
8544 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
8545 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
8546 {
Geoff Langb1196682014-07-23 13:47:29 -04008547 context->recordError(gl::Error(GL_INVALID_VALUE));
8548 return;
Geoff Langbfdea662014-07-23 14:16:32 -04008549 }
8550
8551 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
Shannon Woods916e7692014-03-27 16:58:22 -04008552 }
8553}
8554
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008555__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
8556{
8557 struct Extension
8558 {
8559 const char *name;
8560 __eglMustCastToProperFunctionPointerType address;
8561 };
8562
8563 static const Extension glExtensions[] =
8564 {
8565 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +00008566 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +00008567 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00008568 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
8569 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
8570 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
8571 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
8572 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
8573 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
8574 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +00008575 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +00008576 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +00008577 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
8578 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
8579 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
8580 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00008581 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
8582 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
8583 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
8584 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
8585 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
8586 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
8587 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +00008588 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +00008589 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
8590 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
8591 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00008592 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -04008593 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
8594 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
8595 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -04008596 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
8597 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
8598 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008599
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +00008600 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00008601 {
8602 if (strcmp(procname, glExtensions[ext].name) == 0)
8603 {
8604 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
8605 }
8606 }
8607
8608 return NULL;
8609}
8610
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00008611// Non-public functions used by EGL
8612
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008613bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008614{
8615 EVENT("(egl::Surface* surface = 0x%0.8p)",
8616 surface);
8617
Geoff Langbfdea662014-07-23 14:16:32 -04008618 gl::Context *context = gl::getNonLostContext();
Geoff Langbfdea662014-07-23 14:16:32 -04008619 if (context)
8620 {
8621 gl::Texture2D *textureObject = context->getTexture2D();
8622 ASSERT(textureObject != NULL);
8623
8624 if (textureObject->isImmutable())
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008625 {
Geoff Langbfdea662014-07-23 14:16:32 -04008626 return false;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008627 }
Geoff Langbfdea662014-07-23 14:16:32 -04008628
8629 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008630 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00008631
8632 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +00008633}
8634
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00008635}