blob: 630330c0a3abdad9b52eb1165de7daf02b358b0f [file] [log] [blame]
shannon.woods@transgaming.combdf2d802013-02-28 23:16:20 +00001#include "precompiled.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002//
Geoff Lang48dcae72014-02-05 16:28:24 -05003// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6//
7
8// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
9
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +000010#include "common/version.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011
12#include "libGLESv2/main.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/utilities.h"
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +000014#include "libGLESv2/formatutils.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000015#include "libGLESv2/Buffer.h"
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000016#include "libGLESv2/Fence.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017#include "libGLESv2/Framebuffer.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000018#include "libGLESv2/Renderbuffer.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "libGLESv2/Program.h"
apatrick@chromium.orgea09f9b2012-06-08 00:45:32 +000020#include "libGLESv2/ProgramBinary.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000021#include "libGLESv2/Texture.h"
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000022#include "libGLESv2/Query.h"
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023#include "libGLESv2/Context.h"
Jamie Madill57a89722013-07-02 11:57:03 -040024#include "libGLESv2/VertexArray.h"
Brandon Jones5bf98292014-06-06 17:19:38 -070025#include "libGLESv2/VertexAttribute.h"
Geoff Langc8058452014-02-03 12:04:11 -050026#include "libGLESv2/TransformFeedback.h"
Jamie Madille261b442014-06-25 12:42:21 -040027#include "libGLESv2/FramebufferAttachment.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000028
Geoff Lange8ebe7f2013-08-05 15:03:13 -040029#include "libGLESv2/validationES.h"
30#include "libGLESv2/validationES2.h"
31#include "libGLESv2/validationES3.h"
Jamie Madill55856b12014-01-02 13:59:50 -050032#include "libGLESv2/queryconversions.h"
Jamie Madill478fdb22013-07-19 16:36:59 -040033
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000034extern "C"
35{
36
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +000037// OpenGL ES 2.0 functions
38
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000039void __stdcall glActiveTexture(GLenum texture)
40{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000041 EVENT("(GLenum texture = 0x%X)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000042
Ehsan Akhgari10530c32014-07-02 20:37:53 -040043 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000044 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000045 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000046
47 if (context)
48 {
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +000049 if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1)
50 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000051 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f74c7a2011-05-11 15:36:51 +000052 }
53
daniel@transgaming.com428d1582010-05-04 03:35:25 +000054 context->setActiveSampler(texture - GL_TEXTURE0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055 }
56 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040057 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000058 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000059 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000060 }
61}
62
63void __stdcall glAttachShader(GLuint program, GLuint shader)
64{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +000065 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066
Ehsan Akhgari10530c32014-07-02 20:37:53 -040067 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000069 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000070
71 if (context)
72 {
73 gl::Program *programObject = context->getProgram(program);
74 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +000075
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000076 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077 {
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000078 if (context->getShader(program))
79 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000080 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000081 }
82 else
83 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000084 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000085 }
86 }
87
88 if (!shaderObject)
89 {
90 if (context->getProgram(shader))
91 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000092 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000093 }
94 else
95 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000096 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come9d6ed02010-04-13 03:26:23 +000097 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000098 }
99
100 if (!programObject->attachShader(shaderObject))
101 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000102 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000103 }
104 }
105 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400106 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000107 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000108 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000109 }
110}
111
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000112void __stdcall glBeginQueryEXT(GLenum target, GLuint id)
113{
114 EVENT("(GLenum target = 0x%X, GLuint %d)", target, id);
115
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400116 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000117 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000118 gl::Context *context = gl::getNonLostContext();
119
120 if (context)
121 {
Jamie Madilldb2f14c2014-05-13 13:56:30 -0400122 if (!ValidateBeginQuery(context, target, id))
Geoff Lang37dde692014-01-31 16:34:54 -0500123 {
Jamie Madilldb2f14c2014-05-13 13:56:30 -0400124 return;
Geoff Lang37dde692014-01-31 16:34:54 -0500125 }
126
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000127 context->beginQuery(target, id);
128 }
129 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400130 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000131 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000132 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +0000133 }
134}
135
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000136void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000137{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000138 EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000139
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400140 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000141 {
142 if (index >= gl::MAX_VERTEX_ATTRIBS)
143 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000144 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000145 }
146
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000147 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000148
149 if (context)
150 {
151 gl::Program *programObject = context->getProgram(program);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +0000152
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000153 if (!programObject)
154 {
daniel@transgaming.com98079832010-04-13 03:26:29 +0000155 if (context->getShader(program))
156 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000157 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com98079832010-04-13 03:26:29 +0000158 }
159 else
160 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000161 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com98079832010-04-13 03:26:29 +0000162 }
163 }
164
165 if (strncmp(name, "gl_", 3) == 0)
166 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000167 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000168 }
169
170 programObject->bindAttributeLocation(index, name);
171 }
172 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400173 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000174 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000175 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000176 }
177}
178
179void __stdcall glBindBuffer(GLenum target, GLuint buffer)
180{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000181 EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000182
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400183 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000184 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000185 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000186
187 if (context)
188 {
Jamie Madill8c96d582014-03-05 15:01:23 -0500189 if (!gl::ValidBufferTarget(context, target))
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000190 {
Jamie Madill8c96d582014-03-05 15:01:23 -0500191 return gl::error(GL_INVALID_ENUM);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000192 }
193
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000194 switch (target)
195 {
196 case GL_ARRAY_BUFFER:
197 context->bindArrayBuffer(buffer);
198 return;
199 case GL_ELEMENT_ARRAY_BUFFER:
200 context->bindElementArrayBuffer(buffer);
201 return;
shannon.woods%transgaming.com@gtempaccount.com51171882013-04-13 03:39:10 +0000202 case GL_COPY_READ_BUFFER:
203 context->bindCopyReadBuffer(buffer);
204 return;
205 case GL_COPY_WRITE_BUFFER:
206 context->bindCopyWriteBuffer(buffer);
207 return;
shannon.woods%transgaming.com@gtempaccount.comc926e5f2013-04-13 03:39:18 +0000208 case GL_PIXEL_PACK_BUFFER:
209 context->bindPixelPackBuffer(buffer);
210 return;
211 case GL_PIXEL_UNPACK_BUFFER:
212 context->bindPixelUnpackBuffer(buffer);
213 return;
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000214 case GL_UNIFORM_BUFFER:
215 context->bindGenericUniformBuffer(buffer);
216 return;
217 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org7a1ebad2013-05-30 00:05:20 +0000218 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000219 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000220 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000221 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000222 }
223 }
224 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400225 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000226 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000227 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000228 }
229}
230
231void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer)
232{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000233 EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000234
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400235 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000236 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -0500237 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000238 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000239 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000240 }
241
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000242 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000243
244 if (context)
245 {
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +0000246 if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
247 {
248 context->bindReadFramebuffer(framebuffer);
249 }
250
251 if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
252 {
253 context->bindDrawFramebuffer(framebuffer);
254 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000255 }
256 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400257 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000259 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260 }
261}
262
263void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer)
264{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000265 EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000266
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400267 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000268 {
269 if (target != GL_RENDERBUFFER)
270 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000271 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000272 }
273
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000274 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000275
276 if (context)
277 {
278 context->bindRenderbuffer(renderbuffer);
279 }
280 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400281 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000282 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000283 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000284 }
285}
286
287void __stdcall glBindTexture(GLenum target, GLuint texture)
288{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000289 EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400291 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000292 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000293 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000294
295 if (context)
296 {
297 gl::Texture *textureObject = context->getTexture(texture);
298
299 if (textureObject && textureObject->getTarget() != target && texture != 0)
300 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000301 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000302 }
303
304 switch (target)
305 {
306 case GL_TEXTURE_2D:
307 context->bindTexture2D(texture);
308 return;
309 case GL_TEXTURE_CUBE_MAP:
310 context->bindTextureCubeMap(texture);
311 return;
shannon.woods%transgaming.com@gtempaccount.comc416e1c2013-04-13 03:45:05 +0000312 case GL_TEXTURE_3D:
313 if (context->getClientVersion() < 3)
314 {
315 return gl::error(GL_INVALID_ENUM);
316 }
317 context->bindTexture3D(texture);
318 return;
shannon.woods%transgaming.com@gtempaccount.com90dbc442013-04-13 03:46:14 +0000319 case GL_TEXTURE_2D_ARRAY:
320 if (context->getClientVersion() < 3)
321 {
322 return gl::error(GL_INVALID_ENUM);
323 }
324 context->bindTexture2DArray(texture);
325 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000326 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000327 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000328 }
329 }
330 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400331 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000332 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000333 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000334 }
335}
336
337void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
338{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000339 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000340 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000341
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400342 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000343 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000344 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000345
346 if (context)
347 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +0000348 context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000349 }
350 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400351 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000353 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000354 }
355}
356
357void __stdcall glBlendEquation(GLenum mode)
358{
359 glBlendEquationSeparate(mode, mode);
360}
361
362void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
363{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000364 EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000365
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400366 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000367 {
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +0000368 gl::Context *context = gl::getNonLostContext();
369
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000370 switch (modeRGB)
371 {
372 case GL_FUNC_ADD:
373 case GL_FUNC_SUBTRACT:
374 case GL_FUNC_REVERSE_SUBTRACT:
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +0000375 case GL_MIN:
376 case GL_MAX:
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +0000377 break;
378
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000379 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000380 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000381 }
382
383 switch (modeAlpha)
384 {
385 case GL_FUNC_ADD:
386 case GL_FUNC_SUBTRACT:
387 case GL_FUNC_REVERSE_SUBTRACT:
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +0000388 case GL_MIN:
389 case GL_MAX:
shannon.woods%transgaming.com@gtempaccount.com00b6a0e2013-04-13 03:38:00 +0000390 break;
391
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000392 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000393 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000394 }
395
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000396 if (context)
397 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +0000398 context->setBlendEquation(modeRGB, modeAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000399 }
400 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400401 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000402 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000403 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000404 }
405}
406
407void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor)
408{
409 glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
410}
411
412void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
413{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000414 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 +0000415 srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000416
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400417 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000418 {
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +0000419 gl::Context *context = gl::getNonLostContext();
420
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000421 switch (srcRGB)
422 {
423 case GL_ZERO:
424 case GL_ONE:
425 case GL_SRC_COLOR:
426 case GL_ONE_MINUS_SRC_COLOR:
427 case GL_DST_COLOR:
428 case GL_ONE_MINUS_DST_COLOR:
429 case GL_SRC_ALPHA:
430 case GL_ONE_MINUS_SRC_ALPHA:
431 case GL_DST_ALPHA:
432 case GL_ONE_MINUS_DST_ALPHA:
433 case GL_CONSTANT_COLOR:
434 case GL_ONE_MINUS_CONSTANT_COLOR:
435 case GL_CONSTANT_ALPHA:
436 case GL_ONE_MINUS_CONSTANT_ALPHA:
437 case GL_SRC_ALPHA_SATURATE:
438 break;
439 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000440 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000441 }
442
443 switch (dstRGB)
444 {
445 case GL_ZERO:
446 case GL_ONE:
447 case GL_SRC_COLOR:
448 case GL_ONE_MINUS_SRC_COLOR:
449 case GL_DST_COLOR:
450 case GL_ONE_MINUS_DST_COLOR:
451 case GL_SRC_ALPHA:
452 case GL_ONE_MINUS_SRC_ALPHA:
453 case GL_DST_ALPHA:
454 case GL_ONE_MINUS_DST_ALPHA:
455 case GL_CONSTANT_COLOR:
456 case GL_ONE_MINUS_CONSTANT_COLOR:
457 case GL_CONSTANT_ALPHA:
458 case GL_ONE_MINUS_CONSTANT_ALPHA:
459 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +0000460
461 case GL_SRC_ALPHA_SATURATE:
462 if (!context || context->getClientVersion() < 3)
463 {
464 return gl::error(GL_INVALID_ENUM);
465 }
466 break;
467
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000468 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000469 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000470 }
471
472 switch (srcAlpha)
473 {
474 case GL_ZERO:
475 case GL_ONE:
476 case GL_SRC_COLOR:
477 case GL_ONE_MINUS_SRC_COLOR:
478 case GL_DST_COLOR:
479 case GL_ONE_MINUS_DST_COLOR:
480 case GL_SRC_ALPHA:
481 case GL_ONE_MINUS_SRC_ALPHA:
482 case GL_DST_ALPHA:
483 case GL_ONE_MINUS_DST_ALPHA:
484 case GL_CONSTANT_COLOR:
485 case GL_ONE_MINUS_CONSTANT_COLOR:
486 case GL_CONSTANT_ALPHA:
487 case GL_ONE_MINUS_CONSTANT_ALPHA:
488 case GL_SRC_ALPHA_SATURATE:
489 break;
490 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000491 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000492 }
493
494 switch (dstAlpha)
495 {
496 case GL_ZERO:
497 case GL_ONE:
498 case GL_SRC_COLOR:
499 case GL_ONE_MINUS_SRC_COLOR:
500 case GL_DST_COLOR:
501 case GL_ONE_MINUS_DST_COLOR:
502 case GL_SRC_ALPHA:
503 case GL_ONE_MINUS_SRC_ALPHA:
504 case GL_DST_ALPHA:
505 case GL_ONE_MINUS_DST_ALPHA:
506 case GL_CONSTANT_COLOR:
507 case GL_ONE_MINUS_CONSTANT_COLOR:
508 case GL_CONSTANT_ALPHA:
509 case GL_ONE_MINUS_CONSTANT_ALPHA:
510 break;
shannonwoods@chromium.org48ae0252013-05-30 00:13:22 +0000511
512 case GL_SRC_ALPHA_SATURATE:
513 if (!context || context->getClientVersion() < 3)
514 {
515 return gl::error(GL_INVALID_ENUM);
516 }
517 break;
518
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000519 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000520 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000521 }
522
daniel@transgaming.comfe453652010-03-16 06:23:28 +0000523 bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR ||
524 dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR);
525
526 bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA ||
527 dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA);
528
529 if (constantColorUsed && constantAlphaUsed)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000530 {
daniel@transgaming.comfe453652010-03-16 06:23:28 +0000531 ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL");
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000532 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000533 }
534
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000535 if (context)
536 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +0000537 context->setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000538 }
539 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400540 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000542 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000543 }
544}
545
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000546void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000547{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000548 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 +0000549 target, size, data, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000550
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400551 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000552 {
553 if (size < 0)
554 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000555 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000556 }
557
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +0000558 gl::Context *context = gl::getNonLostContext();
559
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000560 switch (usage)
561 {
562 case GL_STREAM_DRAW:
563 case GL_STATIC_DRAW:
564 case GL_DYNAMIC_DRAW:
565 break;
shannon.woods%transgaming.com@gtempaccount.comf2db40b2013-04-13 03:37:09 +0000566
567 case GL_STREAM_READ:
568 case GL_STREAM_COPY:
569 case GL_STATIC_READ:
570 case GL_STATIC_COPY:
571 case GL_DYNAMIC_READ:
572 case GL_DYNAMIC_COPY:
573 if (context && context->getClientVersion() < 3)
574 {
575 return gl::error(GL_INVALID_ENUM);
576 }
577 break;
578
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000579 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000580 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000581 }
582
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000583 if (context)
584 {
Jamie Madill8c96d582014-03-05 15:01:23 -0500585 if (!gl::ValidBufferTarget(context, target))
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000586 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000587 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000588 }
589
Jamie Madill8c96d582014-03-05 15:01:23 -0500590 gl::Buffer *buffer = context->getTargetBuffer(target);
591
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000592 if (!buffer)
593 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000594 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000595 }
596
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000597 buffer->bufferData(data, size, usage);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000598 }
599 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400600 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000601 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000602 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000603 }
604}
605
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000606void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000607{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000608 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 +0000609 target, offset, size, data);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400611 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000612 {
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +0000613 if (size < 0 || offset < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000614 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000615 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000616 }
617
daniel@transgaming.comd4620a32010-03-21 04:31:28 +0000618 if (data == NULL)
619 {
620 return;
621 }
622
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000623 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000624
625 if (context)
626 {
Jamie Madill8c96d582014-03-05 15:01:23 -0500627 if (!gl::ValidBufferTarget(context, target))
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +0000628 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000629 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000630 }
631
Jamie Madill8c96d582014-03-05 15:01:23 -0500632 gl::Buffer *buffer = context->getTargetBuffer(target);
633
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000634 if (!buffer)
635 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000636 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000637 }
638
Brandon Jonesd38f9262014-06-18 16:26:45 -0700639 if (buffer->isMapped())
Jamie Madill7a5f7382014-03-05 15:01:24 -0500640 {
641 return gl::error(GL_INVALID_OPERATION);
642 }
643
Geoff Lang876dc722014-05-01 17:10:24 -0400644 // Check for possible overflow of size + offset
645 if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset))
646 {
647 return gl::error(GL_OUT_OF_MEMORY);
648 }
649
Brandon Jonesd38f9262014-06-18 16:26:45 -0700650 if (size + offset > buffer->getSize())
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000651 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000652 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000653 }
daniel@transgaming.comdefa1c32010-05-18 18:51:45 +0000654
655 buffer->bufferSubData(data, size, offset);
daniel@transgaming.com0f7aaf52010-03-11 19:41:38 +0000656 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000657 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400658 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000659 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000660 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000661 }
662}
663
664GLenum __stdcall glCheckFramebufferStatus(GLenum target)
665{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000666 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000667
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400668 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000669 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -0500670 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000672 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000673 }
674
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000675 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000676
677 if (context)
678 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -0500679 gl::Framebuffer *framebuffer = context->getTargetFramebuffer(target);
680 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000681 return framebuffer->completeness();
682 }
683 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400684 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000685 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000686 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000687 }
688
689 return 0;
690}
691
692void __stdcall glClear(GLbitfield mask)
693{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000694 EVENT("(GLbitfield mask = 0x%X)", mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000695
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400696 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000697 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000698 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000699
700 if (context)
701 {
Geoff Lang0b833232013-08-21 10:13:29 -0400702 gl::Framebuffer *framebufferObject = context->getDrawFramebuffer();
703
704 if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE)
705 {
706 return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION);
707 }
708
709 if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0)
710 {
711 return gl::error(GL_INVALID_VALUE);
712 }
713
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000714 context->clear(mask);
715 }
716 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400717 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000718 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000719 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000720 }
721}
722
723void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
724{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000725 EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000726 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000727
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400728 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000729 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000730 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000731
732 if (context)
733 {
734 context->setClearColor(red, green, blue, alpha);
735 }
736 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400737 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000738 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000739 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000740 }
741}
742
743void __stdcall glClearDepthf(GLclampf depth)
744{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000745 EVENT("(GLclampf depth = %f)", depth);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000746
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400747 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000748 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000749 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000750
751 if (context)
752 {
753 context->setClearDepth(depth);
754 }
755 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400756 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000757 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000758 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000759 }
760}
761
762void __stdcall glClearStencil(GLint s)
763{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000764 EVENT("(GLint s = %d)", s);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000765
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400766 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000767 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000768 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000769
770 if (context)
771 {
772 context->setClearStencil(s);
773 }
774 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400775 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000776 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000777 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000778 }
779}
780
781void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
782{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +0000783 EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000784 red, green, blue, alpha);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000785
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400786 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000787 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000788 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000789
790 if (context)
791 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +0000792 context->setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000793 }
794 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400795 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000796 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000797 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000798 }
799}
800
801void __stdcall glCompileShader(GLuint shader)
802{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000803 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000804
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400805 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000806 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000807 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000808
809 if (context)
810 {
811 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +0000812
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000813 if (!shaderObject)
814 {
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +0000815 if (context->getProgram(shader))
816 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000817 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +0000818 }
819 else
820 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000821 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com0cefaf42010-04-13 03:26:36 +0000822 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000823 }
824
825 shaderObject->compile();
826 }
827 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400828 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000829 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000830 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000831 }
832}
833
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000834void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
835 GLint border, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000836{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000837 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000838 "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000839 target, level, internalformat, width, height, border, imageSize, data);
840
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400841 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000842 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000843 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +0000844
845 if (context)
846 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000847 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400848 !ValidateES2TexImageParameters(context, target, level, internalformat, true, false,
Jamie Madill6f38f822014-06-06 17:12:20 -0400849 0, 0, width, height, border, GL_NONE, GL_NONE, data))
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000850 {
851 return;
852 }
853
854 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400855 !ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
Jamie Madill6f38f822014-06-06 17:12:20 -0400856 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data))
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000857 {
858 return;
859 }
860
Geoff Lange4a492b2014-06-19 14:14:41 -0400861 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000862 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000863 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000864 }
865
866 switch (target)
867 {
868 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000869 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000870 gl::Texture2D *texture = context->getTexture2D();
871 texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000872 }
873 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000874
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000875 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
876 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
877 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
878 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
879 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
880 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000881 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000882 gl::TextureCubeMap *texture = context->getTextureCubeMap();
883 texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000884 }
885 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000886
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000887 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000888 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000889 }
daniel@transgaming.com01868132010-08-24 19:21:17 +0000890 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000891 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400892 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000893 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000894 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000895 }
896}
897
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000898void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
899 GLenum format, GLsizei imageSize, const GLvoid* data)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000901 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000902 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +0000903 "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000904 target, level, xoffset, yoffset, width, height, format, imageSize, data);
905
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400906 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000907 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000908 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com01868132010-08-24 19:21:17 +0000909
910 if (context)
911 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000912 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400913 !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000914 xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data))
915 {
916 return;
917 }
918
919 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400920 !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
Jamie Madillefb2a6f2013-09-24 10:22:42 -0400921 xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data))
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000922 {
923 return;
924 }
925
Geoff Lange4a492b2014-06-19 14:14:41 -0400926 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000927 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000928 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000929 }
930
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000931 switch (target)
daniel@transgaming.com01868132010-08-24 19:21:17 +0000932 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000933 case GL_TEXTURE_2D:
daniel@transgaming.com01868132010-08-24 19:21:17 +0000934 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000935 gl::Texture2D *texture = context->getTexture2D();
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000936 texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +0000937 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000938 break;
939
940 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
941 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
942 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
943 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
944 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
945 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com01868132010-08-24 19:21:17 +0000946 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000947 gl::TextureCubeMap *texture = context->getTextureCubeMap();
daniel@transgaming.com343373a2011-11-29 19:42:32 +0000948 texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
daniel@transgaming.com01868132010-08-24 19:21:17 +0000949 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000950 break;
951
952 default:
953 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com01868132010-08-24 19:21:17 +0000954 }
955 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000956 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400957 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000958 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +0000959 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000960 }
961}
962
963void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
964{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000965 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +0000966 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000967 target, level, internalformat, x, y, width, height, border);
968
Ehsan Akhgari10530c32014-07-02 20:37:53 -0400969 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000970 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +0000971 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +0000972
973 if (context)
974 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000975 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400976 !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000977 0, 0, x, y, width, height, border))
daniel@transgaming.com32b11442011-11-19 02:42:48 +0000978 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000979 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +0000980 }
981
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000982 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -0400983 !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000984 0, 0, 0, x, y, width, height, border))
985 {
986 return;
987 }
988
989 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
990
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000991 switch (target)
992 {
993 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000994 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000995 gl::Texture2D *texture = context->getTexture2D();
996 texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +0000997 }
998 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +0000999
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001000 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1001 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1002 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1003 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1004 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1005 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001006 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001007 gl::TextureCubeMap *texture = context->getTextureCubeMap();
1008 texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001009 }
1010 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001011
1012 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001013 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001014 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00001015 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001016 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001017 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001018 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001019 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001020 }
1021}
1022
1023void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
1024{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001025 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001026 "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001027 target, level, xoffset, yoffset, x, y, width, height);
1028
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001029 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001030 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001031 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00001032
1033 if (context)
1034 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001035 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04001036 !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001037 xoffset, yoffset, x, y, width, height, 0))
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001038 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001039 return;
1040 }
1041
1042 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04001043 !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001044 xoffset, yoffset, 0, x, y, width, height, 0))
1045 {
1046 return;
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00001047 }
1048
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001049 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00001050
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001051 switch (target)
daniel@transgaming.combbc57792010-07-28 19:21:05 +00001052 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001053 case GL_TEXTURE_2D:
daniel@transgaming.com2ccbbef2012-05-09 15:49:00 +00001054 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001055 gl::Texture2D *texture = context->getTexture2D();
1056 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00001057 }
1058 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001059
1060 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1061 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1062 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1063 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1064 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1065 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00001066 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001067 gl::TextureCubeMap *texture = context->getTextureCubeMap();
1068 texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer);
daniel@transgaming.com6452adf2012-10-17 18:22:35 +00001069 }
1070 break;
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001071
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00001072 default:
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00001073 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3f85fbb2010-10-15 17:58:05 +00001074 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00001075 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001076 }
daniel@transgaming.comb8c28ed2010-04-13 03:26:32 +00001077
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001078 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001079 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001080 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001081 }
1082}
1083
1084GLuint __stdcall glCreateProgram(void)
1085{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001086 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001087
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001088 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001089 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001090 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001091
1092 if (context)
1093 {
1094 return context->createProgram();
1095 }
1096 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001097 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001098 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001099 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001100 }
1101
1102 return 0;
1103}
1104
1105GLuint __stdcall glCreateShader(GLenum type)
1106{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001107 EVENT("(GLenum type = 0x%X)", type);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001108
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001109 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001110 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001111 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001112
1113 if (context)
1114 {
1115 switch (type)
1116 {
1117 case GL_FRAGMENT_SHADER:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00001118 case GL_VERTEX_SHADER:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001119 return context->createShader(type);
1120 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001121 return gl::error(GL_INVALID_ENUM, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001122 }
1123 }
1124 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001125 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001126 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001127 return gl::error(GL_OUT_OF_MEMORY, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001128 }
1129
1130 return 0;
1131}
1132
1133void __stdcall glCullFace(GLenum mode)
1134{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001135 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001136
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001137 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001138 {
1139 switch (mode)
1140 {
1141 case GL_FRONT:
1142 case GL_BACK:
1143 case GL_FRONT_AND_BACK:
1144 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001145 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001146
1147 if (context)
1148 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001149 context->setCullMode(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001150 }
1151 }
1152 break;
1153 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001154 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001155 }
1156 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001157 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001158 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001159 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001160 }
1161}
1162
1163void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers)
1164{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001165 EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001166
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001167 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001168 {
1169 if (n < 0)
1170 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001171 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001172 }
1173
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001174 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001175
1176 if (context)
1177 {
1178 for (int i = 0; i < n; i++)
1179 {
1180 context->deleteBuffer(buffers[i]);
1181 }
1182 }
1183 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001184 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001185 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001186 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001187 }
1188}
1189
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001190void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences)
1191{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001192 EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001193
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001194 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001195 {
1196 if (n < 0)
1197 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001198 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001199 }
1200
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001201 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001202
1203 if (context)
1204 {
1205 for (int i = 0; i < n; i++)
1206 {
Jamie Madill33dc8432013-07-26 11:55:05 -04001207 context->deleteFenceNV(fences[i]);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001208 }
1209 }
1210 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001211 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001212 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001213 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001214 }
1215}
1216
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001217void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
1218{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001219 EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001220
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001221 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001222 {
1223 if (n < 0)
1224 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001225 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001226 }
1227
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001228 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001229
1230 if (context)
1231 {
1232 for (int i = 0; i < n; i++)
1233 {
1234 if (framebuffers[i] != 0)
1235 {
1236 context->deleteFramebuffer(framebuffers[i]);
1237 }
1238 }
1239 }
1240 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001241 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001242 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001243 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001244 }
1245}
1246
1247void __stdcall glDeleteProgram(GLuint program)
1248{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001249 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001250
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001251 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001252 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001253 if (program == 0)
1254 {
1255 return;
1256 }
1257
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001258 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001259
1260 if (context)
1261 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001262 if (!context->getProgram(program))
1263 {
1264 if(context->getShader(program))
1265 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001266 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001267 }
1268 else
1269 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001270 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001271 }
1272 }
1273
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001274 context->deleteProgram(program);
1275 }
1276 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001277 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001278 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001279 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001280 }
1281}
1282
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001283void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
1284{
1285 EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
1286
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001287 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001288 {
1289 if (n < 0)
1290 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001291 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001292 }
1293
1294 gl::Context *context = gl::getNonLostContext();
1295
1296 if (context)
1297 {
1298 for (int i = 0; i < n; i++)
1299 {
1300 context->deleteQuery(ids[i]);
1301 }
1302 }
1303 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001304 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001305 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001306 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001307 }
1308}
1309
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001310void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
1311{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001312 EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001313
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001314 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001315 {
1316 if (n < 0)
1317 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001318 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001319 }
1320
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001321 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001322
1323 if (context)
1324 {
daniel@transgaming.come2b22122010-03-11 19:22:14 +00001325 for (int i = 0; i < n; i++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001326 {
1327 context->deleteRenderbuffer(renderbuffers[i]);
1328 }
1329 }
1330 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001331 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001332 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001333 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001334 }
1335}
1336
1337void __stdcall glDeleteShader(GLuint shader)
1338{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001339 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001340
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001341 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001342 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001343 if (shader == 0)
1344 {
1345 return;
1346 }
1347
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001348 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001349
1350 if (context)
1351 {
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001352 if (!context->getShader(shader))
1353 {
1354 if(context->getProgram(shader))
1355 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001356 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001357 }
1358 else
1359 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001360 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com75401e62010-04-13 03:26:39 +00001361 }
1362 }
1363
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001364 context->deleteShader(shader);
1365 }
1366 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001367 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001368 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001369 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001370 }
1371}
1372
1373void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures)
1374{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001375 EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001376
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001377 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001378 {
1379 if (n < 0)
1380 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001381 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001382 }
1383
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001384 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001385
1386 if (context)
1387 {
1388 for (int i = 0; i < n; i++)
1389 {
1390 if (textures[i] != 0)
1391 {
1392 context->deleteTexture(textures[i]);
1393 }
1394 }
1395 }
1396 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001397 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001398 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001399 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001400 }
1401}
1402
1403void __stdcall glDepthFunc(GLenum func)
1404{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001405 EVENT("(GLenum func = 0x%X)", func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001406
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001407 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001408 {
1409 switch (func)
1410 {
1411 case GL_NEVER:
1412 case GL_ALWAYS:
1413 case GL_LESS:
1414 case GL_LEQUAL:
1415 case GL_EQUAL:
1416 case GL_GREATER:
1417 case GL_GEQUAL:
1418 case GL_NOTEQUAL:
1419 break;
1420 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001421 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001422 }
1423
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001424 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001425
1426 if (context)
1427 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001428 context->setDepthFunc(func);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001429 }
1430 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001431 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001432 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001433 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001434 }
1435}
1436
1437void __stdcall glDepthMask(GLboolean flag)
1438{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00001439 EVENT("(GLboolean flag = %u)", flag);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001440
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001441 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001442 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001443 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001444
1445 if (context)
1446 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001447 context->setDepthMask(flag != GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001448 }
1449 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001450 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001451 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001452 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001453 }
1454}
1455
1456void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar)
1457{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001458 EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001459
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001460 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001461 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001462 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001463
1464 if (context)
1465 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001466 context->setDepthRange(zNear, zFar);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001467 }
1468 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001469 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001470 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001471 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001472 }
1473}
1474
1475void __stdcall glDetachShader(GLuint program, GLuint shader)
1476{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001477 EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001478
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001479 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001480 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001481 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001482
1483 if (context)
1484 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001485
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001486 gl::Program *programObject = context->getProgram(program);
1487 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001488
1489 if (!programObject)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001490 {
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001491 gl::Shader *shaderByProgramHandle;
1492 shaderByProgramHandle = context->getShader(program);
1493 if (!shaderByProgramHandle)
1494 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001495 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001496 }
1497 else
1498 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001499 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001500 }
1501 }
1502
1503 if (!shaderObject)
1504 {
1505 gl::Program *programByShaderHandle = context->getProgram(shader);
1506 if (!programByShaderHandle)
1507 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001508 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001509 }
1510 else
1511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001512 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com73c2c2e2010-04-13 03:26:11 +00001513 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001514 }
1515
1516 if (!programObject->detachShader(shaderObject))
1517 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001518 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001519 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001520 }
1521 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001522 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001523 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001524 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001525 }
1526}
1527
1528void __stdcall glDisable(GLenum cap)
1529{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001530 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001531
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001532 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001533 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001534 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001535
1536 if (context)
1537 {
Geoff Lang0550d032014-01-30 11:29:07 -05001538 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001539 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001540 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001541 }
Geoff Lang0550d032014-01-30 11:29:07 -05001542
1543 context->setCap(cap, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001544 }
1545 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001546 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001547 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001548 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001549 }
1550}
1551
1552void __stdcall glDisableVertexAttribArray(GLuint index)
1553{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001554 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001555
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001556 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001557 {
1558 if (index >= gl::MAX_VERTEX_ATTRIBS)
1559 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001560 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001561 }
1562
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001563 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001564
1565 if (context)
1566 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00001567 context->setEnableVertexAttribArray(index, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001568 }
1569 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001570 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001571 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001572 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001573 }
1574}
1575
1576void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count)
1577{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001578 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001579
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001580 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001581 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001582 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001583
1584 if (context)
1585 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001586 if (!ValidateDrawArrays(context, mode, first, count))
Geoff Langeeba6e12014-02-03 13:12:30 -05001587 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001588 return;
Geoff Langeeba6e12014-02-03 13:12:30 -05001589 }
1590
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00001591 context->drawArrays(mode, first, count, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001592 }
1593 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001594 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001595 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001596 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001597 }
1598}
1599
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001600void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
1601{
1602 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount);
1603
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001604 ANGLE_TRY
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001605 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001606 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001607
Jamie Madill250d33f2014-06-06 17:09:03 -04001608 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001609 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001610 if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount))
Jamie Madill7a5f7382014-03-05 15:01:24 -05001611 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001612 return;
Jamie Madill7a5f7382014-03-05 15:01:24 -05001613 }
1614
Jamie Madill250d33f2014-06-06 17:09:03 -04001615 context->drawArrays(mode, first, count, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001616 }
1617 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001618 ANGLE_CATCH_ALL
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001619 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001620 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001621 }
1622}
1623
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00001624void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001625{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001626 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 +00001627 mode, count, type, indices);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001628
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001629 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001630 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001631 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001632
1633 if (context)
1634 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001635 if (!ValidateDrawElements(context, mode, count, type, indices))
daniel@transgaming.com83921382011-01-08 05:46:00 +00001636 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001637 return;
Jamie Madill7a5f7382014-03-05 15:01:24 -05001638 }
1639
daniel@transgaming.com8ca9c6e2012-01-27 15:38:54 +00001640 context->drawElements(mode, count, type, indices, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001641 }
1642 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001643 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001644 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001645 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001646 }
1647}
1648
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001649void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
1650{
1651 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)",
1652 mode, count, type, indices, primcount);
1653
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001654 ANGLE_TRY
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001655 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001656 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001657
Jamie Madill250d33f2014-06-06 17:09:03 -04001658 if (context)
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001659 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001660 if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount))
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001661 {
Jamie Madill250d33f2014-06-06 17:09:03 -04001662 return;
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001663 }
Jamie Madill250d33f2014-06-06 17:09:03 -04001664
1665 context->drawElements(mode, count, type, indices, primcount);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001666 }
1667 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001668 ANGLE_CATCH_ALL
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001669 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001670 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00001671 }
1672}
1673
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001674void __stdcall glEnable(GLenum cap)
1675{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001676 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001677
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001678 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001679 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001680 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001681
1682 if (context)
1683 {
Geoff Lang0550d032014-01-30 11:29:07 -05001684 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001685 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001686 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001687 }
Geoff Lang0550d032014-01-30 11:29:07 -05001688
1689 context->setCap(cap, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001690 }
1691 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001692 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001693 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001694 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001695 }
1696}
1697
1698void __stdcall glEnableVertexAttribArray(GLuint index)
1699{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001700 EVENT("(GLuint index = %d)", index);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001701
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001702 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001703 {
1704 if (index >= gl::MAX_VERTEX_ATTRIBS)
1705 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001706 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001707 }
1708
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001709 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001710
1711 if (context)
1712 {
daniel@transgaming.com83921382011-01-08 05:46:00 +00001713 context->setEnableVertexAttribArray(index, true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001714 }
1715 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001716 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001718 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001719 }
1720}
1721
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001722void __stdcall glEndQueryEXT(GLenum target)
1723{
1724 EVENT("GLenum target = 0x%X)", target);
1725
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001726 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001727 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001728 gl::Context *context = gl::getNonLostContext();
1729
1730 if (context)
1731 {
Jamie Madill45c785d2014-05-13 14:09:34 -04001732 if (!ValidateEndQuery(context, target))
Geoff Lang37dde692014-01-31 16:34:54 -05001733 {
Jamie Madill45c785d2014-05-13 14:09:34 -04001734 return;
Geoff Lang37dde692014-01-31 16:34:54 -05001735 }
1736
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001737 context->endQuery(target);
1738 }
1739 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001740 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001741 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001742 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00001743 }
1744}
1745
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001746void __stdcall glFinishFenceNV(GLuint fence)
1747{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001748 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001749
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001750 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001751 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001752 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001753
1754 if (context)
1755 {
Jamie Madill33dc8432013-07-26 11:55:05 -04001756 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001757
1758 if (fenceObject == NULL)
1759 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001760 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001761 }
1762
Jamie Madillfb9a7402013-07-26 11:55:01 -04001763 if (fenceObject->isFence() != GL_TRUE)
1764 {
1765 return gl::error(GL_INVALID_OPERATION);
1766 }
1767
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001768 fenceObject->finishFence();
1769 }
1770 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001771 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001772 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001773 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00001774 }
1775}
1776
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001777void __stdcall glFinish(void)
1778{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001779 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001780
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001781 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001782 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001783 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001784
1785 if (context)
1786 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00001787 context->sync(true);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001788 }
1789 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001790 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001791 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001792 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001793 }
1794}
1795
1796void __stdcall glFlush(void)
1797{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001798 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001799
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001800 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001801 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001802 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001803
1804 if (context)
1805 {
daniel@transgaming.com0d86aa72011-10-26 02:35:10 +00001806 context->sync(false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001807 }
1808 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001809 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001810 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001811 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001812 }
1813}
1814
1815void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
1816{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001817 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001818 "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001819
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001820 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001821 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001822 if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001823 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001824 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001825 }
1826
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001827 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001828
1829 if (context)
1830 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001831 if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer))
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001832 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001833 return;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00001834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001835
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001836 gl::Framebuffer *framebuffer = context->getTargetFramebuffer(target);
1837 ASSERT(framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001838
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001839 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001840 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001841 unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
Geoff Lang309c92a2013-07-25 16:23:19 -04001842 framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001843 }
1844 else
1845 {
1846 switch (attachment)
1847 {
1848 case GL_DEPTH_ATTACHMENT:
Geoff Lang309c92a2013-07-25 16:23:19 -04001849 framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001850 break;
1851 case GL_STENCIL_ATTACHMENT:
Geoff Lang309c92a2013-07-25 16:23:19 -04001852 framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001853 break;
Geoff Lang7e9ee232013-08-05 10:18:42 -04001854 case GL_DEPTH_STENCIL_ATTACHMENT:
Geoff Lang7e9ee232013-08-05 10:18:42 -04001855 framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0);
1856 break;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001857 default:
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001858 UNREACHABLE();
1859 break;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001860 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001861 }
1862 }
1863 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001864 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001865 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001866 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001867 }
1868}
1869
1870void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
1871{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001872 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00001873 "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001874
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001875 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001876 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001877 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001878 if (context)
1879 {
Jamie Madill570f7c82014-07-03 10:38:54 -04001880 if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level))
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001881 {
Geoff Lang3ed0c482013-07-25 17:03:18 -04001882 return;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001883 }
1884
daniel@transgaming.com93a81472010-04-20 18:52:58 +00001885 if (texture == 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001886 {
daniel@transgaming.com93a81472010-04-20 18:52:58 +00001887 textarget = GL_NONE;
1888 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001889
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001890 gl::Framebuffer *framebuffer = context->getTargetFramebuffer(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001891
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001892 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001893 {
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001894 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
Geoff Lang309c92a2013-07-25 16:23:19 -04001895 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001896 }
1897 else
1898 {
1899 switch (attachment)
1900 {
Geoff Lang309c92a2013-07-25 16:23:19 -04001901 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break;
1902 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break;
1903 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00001904 }
daniel@transgaming.comfbc09532010-04-26 15:33:41 +00001905 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001906 }
1907 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001908 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001909 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001910 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001911 }
1912}
1913
1914void __stdcall glFrontFace(GLenum mode)
1915{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001916 EVENT("(GLenum mode = 0x%X)", mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001917
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001918 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001919 {
1920 switch (mode)
1921 {
1922 case GL_CW:
1923 case GL_CCW:
1924 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001925 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001926
1927 if (context)
1928 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00001929 context->setFrontFace(mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001930 }
1931 }
1932 break;
1933 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001934 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001935 }
1936 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001937 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001938 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001939 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001940 }
1941}
1942
1943void __stdcall glGenBuffers(GLsizei n, GLuint* buffers)
1944{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001945 EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001946
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001947 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001948 {
1949 if (n < 0)
1950 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001951 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001952 }
1953
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001954 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001955
1956 if (context)
1957 {
1958 for (int i = 0; i < n; i++)
1959 {
1960 buffers[i] = context->createBuffer();
1961 }
1962 }
1963 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001964 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001965 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001966 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001967 }
1968}
1969
1970void __stdcall glGenerateMipmap(GLenum target)
1971{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00001972 EVENT("(GLenum target = 0x%X)", target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001973
Ehsan Akhgari10530c32014-07-02 20:37:53 -04001974 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001975 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00001976 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001977
1978 if (context)
1979 {
Jamie Madill35d15012013-10-07 10:46:37 -04001980 if (!ValidTextureTarget(context, target))
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001981 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00001982 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00001983 }
Geoff Langae4852a2013-06-05 15:00:34 -04001984
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05001985 gl::Texture *texture = context->getTargetTexture(target);
Jamie Madill35d15012013-10-07 10:46:37 -04001986
1987 if (texture == NULL)
Geoff Langae4852a2013-06-05 15:00:34 -04001988 {
1989 return gl::error(GL_INVALID_OPERATION);
1990 }
1991
Geoff Lang005df412013-10-16 14:12:50 -04001992 GLenum internalFormat = texture->getBaseLevelInternalFormat();
Geoff Langcec35902014-04-16 10:52:36 -04001993 const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(internalFormat);
1994
Geoff Langcbb84122014-06-11 15:30:32 -04001995 // GenerateMipmap should not generate an INVALID_OPERATION for textures created with
1996 // unsized formats or that are color renderable and filterable. Since we do not track if
1997 // the texture was created with sized or unsized format (only sized formats are stored),
1998 // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
1999 // be able to) because they aren't color renderable. Simply do a special case for LUMA
2000 // textures since they're the only texture format that can be created with unsized formats
2001 // that is not color renderable. New unsized formats are unlikely to be added, since ES2
2002 // was the last version to use add them.
2003 bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
2004 internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
2005 internalFormat == GL_ALPHA8_EXT;
Jamie Madill61b54432014-02-18 15:27:19 -05002006
Geoff Langcbb84122014-06-11 15:30:32 -04002007 if (formatCaps.depthRendering || !formatCaps.filtering || (!formatCaps.colorRendering && !isLUMA) ||
Geoff Lange4a492b2014-06-19 14:14:41 -04002008 gl::IsFormatCompressed(internalFormat))
Geoff Langae4852a2013-06-05 15:00:34 -04002009 {
2010 return gl::error(GL_INVALID_OPERATION);
2011 }
2012
Geoff Lang05b05022014-06-11 15:31:45 -04002013 // GL_EXT_sRGB does not support mipmap generation on sRGB textures
Geoff Lange4a492b2014-06-19 14:14:41 -04002014 if (context->getClientVersion() == 2 && gl::GetColorEncoding(internalFormat) == GL_SRGB)
Geoff Lang05b05022014-06-11 15:31:45 -04002015 {
2016 return gl::error(GL_INVALID_OPERATION);
2017 }
2018
Jamie Madillc1f8b162013-10-07 10:46:38 -04002019 // Non-power of 2 ES2 check
Geoff Langcec35902014-04-16 10:52:36 -04002020 if (!context->getCaps().extensions.textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight())))
Jamie Madillc1f8b162013-10-07 10:46:38 -04002021 {
2022 ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP));
2023 return gl::error(GL_INVALID_OPERATION);
2024 }
2025
2026 // Cube completeness check
2027 if (target == GL_TEXTURE_CUBE_MAP)
2028 {
2029 gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture);
2030 if (!textureCube->isCubeComplete())
2031 {
2032 return gl::error(GL_INVALID_OPERATION);
2033 }
2034 }
2035
Geoff Langae4852a2013-06-05 15:00:34 -04002036 texture->generateMipmaps();
daniel@transgaming.com8fd99e22010-04-20 18:52:00 +00002037 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002038 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002039 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002040 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002041 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002042 }
2043}
2044
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002045void __stdcall glGenFencesNV(GLsizei n, GLuint* fences)
2046{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002047 EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002048
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002049 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002050 {
2051 if (n < 0)
2052 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002053 return gl::error(GL_INVALID_VALUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002054 }
2055
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002056 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002057
2058 if (context)
2059 {
2060 for (int i = 0; i < n; i++)
2061 {
Jamie Madill33dc8432013-07-26 11:55:05 -04002062 fences[i] = context->createFenceNV();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002063 }
2064 }
2065 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002066 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002067 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002068 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002069 }
2070}
2071
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002072void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers)
2073{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002074 EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002075
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002076 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002077 {
2078 if (n < 0)
2079 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002080 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002081 }
2082
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002083 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002084
2085 if (context)
2086 {
2087 for (int i = 0; i < n; i++)
2088 {
2089 framebuffers[i] = context->createFramebuffer();
2090 }
2091 }
2092 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002093 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002094 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002095 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002096 }
2097}
2098
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002099void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids)
2100{
2101 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
2102
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002103 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002104 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002105 gl::Context *context = gl::getNonLostContext();
2106
2107 if (context)
2108 {
Geoff Lang37dde692014-01-31 16:34:54 -05002109 if (n < 0)
2110 {
2111 return gl::error(GL_INVALID_VALUE);
2112 }
2113
2114 for (GLsizei i = 0; i < n; i++)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002115 {
2116 ids[i] = context->createQuery();
2117 }
2118 }
2119 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002120 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002121 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002122 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002123 }
2124}
2125
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002126void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
2127{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002128 EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002129
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002130 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002131 {
2132 if (n < 0)
2133 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002134 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002135 }
2136
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002137 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002138
2139 if (context)
2140 {
2141 for (int i = 0; i < n; i++)
2142 {
2143 renderbuffers[i] = context->createRenderbuffer();
2144 }
2145 }
2146 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002147 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002148 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002149 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002150 }
2151}
2152
2153void __stdcall glGenTextures(GLsizei n, GLuint* textures)
2154{
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05002155 EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002156
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002157 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002158 {
2159 if (n < 0)
2160 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002161 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002162 }
2163
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002164 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002165
2166 if (context)
2167 {
2168 for (int i = 0; i < n; i++)
2169 {
2170 textures[i] = context->createTexture();
2171 }
2172 }
2173 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002174 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002175 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002176 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002177 }
2178}
2179
daniel@transgaming.com85423182010-04-22 13:35:27 +00002180void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002181{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002182 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
daniel@transgaming.com85423182010-04-22 13:35:27 +00002183 "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002184 program, index, bufsize, length, size, type, name);
2185
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002186 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002187 {
2188 if (bufsize < 0)
2189 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002190 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002191 }
2192
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002193 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com85423182010-04-22 13:35:27 +00002194
2195 if (context)
2196 {
2197 gl::Program *programObject = context->getProgram(program);
2198
2199 if (!programObject)
2200 {
2201 if (context->getShader(program))
2202 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002203 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com85423182010-04-22 13:35:27 +00002204 }
2205 else
2206 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002207 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00002208 }
2209 }
2210
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002211 if (index >= (GLuint)programObject->getActiveAttributeCount())
daniel@transgaming.com85423182010-04-22 13:35:27 +00002212 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002213 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com85423182010-04-22 13:35:27 +00002214 }
2215
2216 programObject->getActiveAttribute(index, bufsize, length, size, type, name);
2217 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002218 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002219 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002220 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002221 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002222 }
2223}
2224
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002225void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002226{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002227 EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002228 "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 +00002229 program, index, bufsize, length, size, type, name);
2230
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002231 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002232 {
2233 if (bufsize < 0)
2234 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002235 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002236 }
2237
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002238 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002239
2240 if (context)
2241 {
2242 gl::Program *programObject = context->getProgram(program);
2243
2244 if (!programObject)
2245 {
2246 if (context->getShader(program))
2247 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002248 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002249 }
2250 else
2251 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002252 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002253 }
2254 }
2255
2256 if (index >= (GLuint)programObject->getActiveUniformCount())
2257 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002258 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002259 }
2260
2261 programObject->getActiveUniform(index, bufsize, length, size, type, name);
2262 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002263 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002264 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002265 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002266 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002267 }
2268}
2269
2270void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
2271{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002272 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 +00002273 program, maxcount, count, shaders);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002274
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002275 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002276 {
2277 if (maxcount < 0)
2278 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002279 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002280 }
2281
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002282 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com6c785212010-03-30 03:36:17 +00002283
2284 if (context)
2285 {
2286 gl::Program *programObject = context->getProgram(program);
2287
2288 if (!programObject)
2289 {
daniel@transgaming.com23953e32010-04-13 19:53:31 +00002290 if (context->getShader(program))
2291 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002292 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00002293 }
2294 else
2295 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002296 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com23953e32010-04-13 19:53:31 +00002297 }
daniel@transgaming.com6c785212010-03-30 03:36:17 +00002298 }
2299
2300 return programObject->getAttachedShaders(maxcount, count, shaders);
2301 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002302 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002303 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002304 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002305 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002306 }
2307}
2308
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002309int __stdcall glGetAttribLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002310{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002311 EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002312
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002313 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002314 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002315 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002316
2317 if (context)
2318 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00002319
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002320 gl::Program *programObject = context->getProgram(program);
2321
2322 if (!programObject)
2323 {
daniel@transgaming.combb274c32010-04-13 03:26:21 +00002324 if (context->getShader(program))
2325 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002326 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00002327 }
2328 else
2329 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002330 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.combb274c32010-04-13 03:26:21 +00002331 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002332 }
2333
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00002334 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00002335 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002336 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002337 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comcf4aa872010-04-13 03:26:27 +00002338 }
2339
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00002340 return programBinary->getAttributeLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002341 }
2342 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002343 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002344 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002345 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002346 }
2347
2348 return -1;
2349}
2350
2351void __stdcall glGetBooleanv(GLenum pname, GLboolean* params)
2352{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002353 EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002354
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002355 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002356 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002357 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com777f2672010-04-07 03:25:16 +00002358
2359 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002360 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002361 GLenum nativeType;
2362 unsigned int numParams = 0;
Jamie Madill893ab082014-05-16 16:56:10 -04002363 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
2364 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002365 return;
Jamie Madill893ab082014-05-16 16:56:10 -04002366 }
Jamie Madill79f2f452013-12-19 11:13:02 -05002367
2368 if (nativeType == GL_BOOL)
daniel@transgaming.com777f2672010-04-07 03:25:16 +00002369 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002370 context->getBooleanv(pname, params);
2371 }
Jamie Madill55856b12014-01-02 13:59:50 -05002372 else
Jamie Madill79f2f452013-12-19 11:13:02 -05002373 {
Jamie Madill55856b12014-01-02 13:59:50 -05002374 CastStateValues(context, nativeType, pname, numParams, params);
daniel@transgaming.com777f2672010-04-07 03:25:16 +00002375 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002376 }
2377 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002378 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002379 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002380 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002381 }
2382}
2383
2384void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params)
2385{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002386 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 +00002387
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002388 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002389 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002390 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002391
2392 if (context)
2393 {
Jamie Madill8c96d582014-03-05 15:01:23 -05002394 if (!gl::ValidBufferTarget(context, target))
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002395 {
Jamie Madill8c96d582014-03-05 15:01:23 -05002396 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002397 }
2398
Jamie Madill70656a62014-03-05 15:01:26 -05002399 if (!gl::ValidBufferParameter(context, pname))
2400 {
2401 return gl::error(GL_INVALID_ENUM);
2402 }
2403
Jamie Madill8c96d582014-03-05 15:01:23 -05002404 gl::Buffer *buffer = context->getTargetBuffer(target);
2405
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002406 if (!buffer)
2407 {
2408 // A null buffer means that "0" is bound to the requested buffer target
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002409 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002410 }
2411
2412 switch (pname)
2413 {
2414 case GL_BUFFER_USAGE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002415 *params = static_cast<GLint>(buffer->getUsage());
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002416 break;
2417 case GL_BUFFER_SIZE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002418 *params = gl::clampCast<GLint>(buffer->getSize());
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002419 break;
Jamie Madill70656a62014-03-05 15:01:26 -05002420 case GL_BUFFER_ACCESS_FLAGS:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002421 *params = buffer->getAccessFlags();
Jamie Madill70656a62014-03-05 15:01:26 -05002422 break;
2423 case GL_BUFFER_MAPPED:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002424 *params = static_cast<GLint>(buffer->isMapped());
Jamie Madill70656a62014-03-05 15:01:26 -05002425 break;
2426 case GL_BUFFER_MAP_OFFSET:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002427 *params = gl::clampCast<GLint>(buffer->getMapOffset());
Jamie Madill70656a62014-03-05 15:01:26 -05002428 break;
2429 case GL_BUFFER_MAP_LENGTH:
Brandon Jonesd38f9262014-06-18 16:26:45 -07002430 *params = gl::clampCast<GLint>(buffer->getMapLength());
Jamie Madill70656a62014-03-05 15:01:26 -05002431 break;
2432 default: UNREACHABLE(); break;
daniel@transgaming.comaa0ccbd2010-04-15 20:45:05 +00002433 }
2434 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002435 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002436 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002437 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002438 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002439 }
2440}
2441
2442GLenum __stdcall glGetError(void)
2443{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002444 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002445
2446 gl::Context *context = gl::getContext();
2447
2448 if (context)
2449 {
daniel@transgaming.com82b28912011-12-12 21:01:35 +00002450 return context->getError();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002451 }
2452
2453 return GL_NO_ERROR;
2454}
2455
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002456void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
2457{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002458 EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002459
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002460 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002461 {
2462
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002463 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002464
2465 if (context)
2466 {
Jamie Madill33dc8432013-07-26 11:55:05 -04002467 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002468
2469 if (fenceObject == NULL)
2470 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002471 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002472 }
2473
Jamie Madillfb9a7402013-07-26 11:55:01 -04002474 if (fenceObject->isFence() != GL_TRUE)
2475 {
2476 return gl::error(GL_INVALID_OPERATION);
2477 }
2478
2479 switch (pname)
2480 {
2481 case GL_FENCE_STATUS_NV:
2482 case GL_FENCE_CONDITION_NV:
2483 break;
2484
2485 default: return gl::error(GL_INVALID_ENUM);
2486 }
2487
2488 params[0] = fenceObject->getFencei(pname);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002489 }
2490 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002491 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002492 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002493 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00002494 }
2495}
2496
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002497void __stdcall glGetFloatv(GLenum pname, GLfloat* params)
2498{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002499 EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002500
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002501 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002502 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002503 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002504
2505 if (context)
2506 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002507 GLenum nativeType;
2508 unsigned int numParams = 0;
Jamie Madill893ab082014-05-16 16:56:10 -04002509 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
2510 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002511 return;
Jamie Madill893ab082014-05-16 16:56:10 -04002512 }
Jamie Madill79f2f452013-12-19 11:13:02 -05002513
2514 if (nativeType == GL_FLOAT)
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002515 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002516 context->getFloatv(pname, params);
2517 }
Jamie Madill55856b12014-01-02 13:59:50 -05002518 else
Jamie Madill79f2f452013-12-19 11:13:02 -05002519 {
Jamie Madill55856b12014-01-02 13:59:50 -05002520 CastStateValues(context, nativeType, pname, numParams, params);
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00002521 }
2522 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002523 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002524 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002525 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002526 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002527 }
2528}
2529
2530void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
2531{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002532 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 +00002533 target, attachment, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002534
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002535 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002536 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002537 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002538
2539 if (context)
2540 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05002541 if (!gl::ValidFramebufferTarget(target))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002542 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002543 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002544 }
2545
Jamie Madill1e3fa742014-06-16 10:34:00 -04002546 int clientVersion = context->getClientVersion();
2547
Geoff Lang646559f2013-08-15 11:08:15 -04002548 switch (pname)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002549 {
Geoff Lang646559f2013-08-15 11:08:15 -04002550 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2551 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2552 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2553 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2554 break;
Geoff Lang05b05022014-06-11 15:31:45 -04002555 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
2556 if (clientVersion < 3 && !context->getCaps().extensions.sRGB)
2557 {
2558 return gl::error(GL_INVALID_ENUM);
2559 }
2560 break;
Geoff Lang646559f2013-08-15 11:08:15 -04002561 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
2562 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
2563 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
2564 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
2565 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
2566 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
2567 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
Geoff Lang646559f2013-08-15 11:08:15 -04002568 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
Geoff Lang05b05022014-06-11 15:31:45 -04002569 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002570 {
Geoff Lang05b05022014-06-11 15:31:45 -04002571 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002572 }
Geoff Lang05b05022014-06-11 15:31:45 -04002573 break;
Geoff Lang646559f2013-08-15 11:08:15 -04002574 default:
2575 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002576 }
Geoff Lang646559f2013-08-15 11:08:15 -04002577
2578 // Determine if the attachment is a valid enum
2579 switch (attachment)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002580 {
Geoff Lang646559f2013-08-15 11:08:15 -04002581 case GL_BACK:
2582 case GL_FRONT:
Jamie Madill3810bee2014-01-21 16:47:12 -05002583 case GL_DEPTH:
Geoff Lang646559f2013-08-15 11:08:15 -04002584 case GL_STENCIL:
2585 case GL_DEPTH_STENCIL_ATTACHMENT:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002586 if (clientVersion < 3)
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002587 {
Geoff Lang646559f2013-08-15 11:08:15 -04002588 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002589 }
Geoff Lang646559f2013-08-15 11:08:15 -04002590 break;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002591
Geoff Lang646559f2013-08-15 11:08:15 -04002592 case GL_DEPTH_ATTACHMENT:
2593 case GL_STENCIL_ATTACHMENT:
2594 break;
2595
2596 default:
2597 if (attachment < GL_COLOR_ATTACHMENT0_EXT ||
2598 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getMaximumRenderTargets())
2599 {
2600 return gl::error(GL_INVALID_ENUM);
2601 }
2602 break;
daniel@transgaming.coma27ff1e2010-08-24 19:20:11 +00002603 }
2604
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05002605 GLuint framebufferHandle = context->getTargetFramebufferHandle(target);
2606 ASSERT(framebufferHandle != GL_INVALID_INDEX);
Geoff Lang646559f2013-08-15 11:08:15 -04002607 gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle);
2608
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002609 GLenum attachmentType;
2610 GLuint attachmentHandle;
Geoff Lang309c92a2013-07-25 16:23:19 -04002611 GLuint attachmentLevel;
2612 GLuint attachmentLayer;
Jamie Madille261b442014-06-25 12:42:21 -04002613 const gl::FramebufferAttachment *attachmentObject;
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002614
Jamie Madill3c7fa222014-06-05 13:08:51 -04002615 if (framebufferHandle == 0)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002616 {
Jamie Madill1e3fa742014-06-16 10:34:00 -04002617 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002618 {
Geoff Lang646559f2013-08-15 11:08:15 -04002619 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002620 }
2621
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002622 switch (attachment)
2623 {
Geoff Lang646559f2013-08-15 11:08:15 -04002624 case GL_BACK:
2625 attachmentType = framebuffer->getColorbufferType(0);
2626 attachmentHandle = framebuffer->getColorbufferHandle(0);
2627 attachmentLevel = framebuffer->getColorbufferMipLevel(0);
2628 attachmentLayer = framebuffer->getColorbufferLayer(0);
Jamie Madill3c7fa222014-06-05 13:08:51 -04002629 attachmentObject = framebuffer->getColorbuffer(0);
Geoff Lang646559f2013-08-15 11:08:15 -04002630 break;
2631 case GL_DEPTH:
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002632 attachmentType = framebuffer->getDepthbufferType();
2633 attachmentHandle = framebuffer->getDepthbufferHandle();
Geoff Lang309c92a2013-07-25 16:23:19 -04002634 attachmentLevel = framebuffer->getDepthbufferMipLevel();
2635 attachmentLayer = framebuffer->getDepthbufferLayer();
Jamie Madill3c7fa222014-06-05 13:08:51 -04002636 attachmentObject = framebuffer->getDepthbuffer();
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002637 break;
Geoff Lang646559f2013-08-15 11:08:15 -04002638 case GL_STENCIL:
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002639 attachmentType = framebuffer->getStencilbufferType();
2640 attachmentHandle = framebuffer->getStencilbufferHandle();
Geoff Lang309c92a2013-07-25 16:23:19 -04002641 attachmentLevel = framebuffer->getStencilbufferMipLevel();
2642 attachmentLayer = framebuffer->getStencilbufferLayer();
Jamie Madill3c7fa222014-06-05 13:08:51 -04002643 attachmentObject = framebuffer->getStencilbuffer();
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002644 break;
Geoff Lang646559f2013-08-15 11:08:15 -04002645 default:
2646 return gl::error(GL_INVALID_OPERATION);
2647 }
2648 }
2649 else
2650 {
2651 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2652 {
2653 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
2654 attachmentType = framebuffer->getColorbufferType(colorAttachment);
2655 attachmentHandle = framebuffer->getColorbufferHandle(colorAttachment);
2656 attachmentLevel = framebuffer->getColorbufferMipLevel(colorAttachment);
2657 attachmentLayer = framebuffer->getColorbufferLayer(colorAttachment);
Jamie Madill3c7fa222014-06-05 13:08:51 -04002658 attachmentObject = framebuffer->getColorbuffer(colorAttachment);
Geoff Lang646559f2013-08-15 11:08:15 -04002659 }
2660 else
2661 {
2662 switch (attachment)
Geoff Lang55ba29c2013-07-11 16:57:53 -04002663 {
Geoff Lang646559f2013-08-15 11:08:15 -04002664 case GL_DEPTH_ATTACHMENT:
2665 attachmentType = framebuffer->getDepthbufferType();
2666 attachmentHandle = framebuffer->getDepthbufferHandle();
2667 attachmentLevel = framebuffer->getDepthbufferMipLevel();
2668 attachmentLayer = framebuffer->getDepthbufferLayer();
Jamie Madill3c7fa222014-06-05 13:08:51 -04002669 attachmentObject = framebuffer->getDepthbuffer();
Geoff Lang646559f2013-08-15 11:08:15 -04002670 break;
2671 case GL_STENCIL_ATTACHMENT:
2672 attachmentType = framebuffer->getStencilbufferType();
2673 attachmentHandle = framebuffer->getStencilbufferHandle();
2674 attachmentLevel = framebuffer->getStencilbufferMipLevel();
2675 attachmentLayer = framebuffer->getStencilbufferLayer();
Jamie Madill3c7fa222014-06-05 13:08:51 -04002676 attachmentObject = framebuffer->getStencilbuffer();
Geoff Lang646559f2013-08-15 11:08:15 -04002677 break;
2678 case GL_DEPTH_STENCIL_ATTACHMENT:
2679 if (framebuffer->getDepthbufferHandle() != framebuffer->getStencilbufferHandle())
2680 {
2681 return gl::error(GL_INVALID_OPERATION);
2682 }
2683 attachmentType = framebuffer->getDepthStencilbufferType();
2684 attachmentHandle = framebuffer->getDepthStencilbufferHandle();
2685 attachmentLevel = framebuffer->getDepthStencilbufferMipLevel();
2686 attachmentLayer = framebuffer->getDepthStencilbufferLayer();
Jamie Madill3c7fa222014-06-05 13:08:51 -04002687 attachmentObject = framebuffer->getDepthStencilBuffer();
Geoff Lang646559f2013-08-15 11:08:15 -04002688 break;
2689 default:
Geoff Lang55ba29c2013-07-11 16:57:53 -04002690 return gl::error(GL_INVALID_OPERATION);
2691 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002692 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002693 }
2694
2695 GLenum attachmentObjectType; // Type category
Geoff Lang646559f2013-08-15 11:08:15 -04002696 if (framebufferHandle == 0)
2697 {
2698 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2699 }
2700 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002701 {
2702 attachmentObjectType = attachmentType;
2703 }
Jamie Madillbb94f342014-06-23 15:23:02 -04002704 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002705 {
2706 attachmentObjectType = GL_TEXTURE;
2707 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00002708 else
2709 {
2710 UNREACHABLE();
2711 return;
2712 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002713
Geoff Lang646559f2013-08-15 11:08:15 -04002714 if (attachmentObjectType == GL_NONE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002715 {
Geoff Lang646559f2013-08-15 11:08:15 -04002716 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2717 // is NONE, then querying any other pname will generate INVALID_ENUM.
2718
2719 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2720 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2721 // INVALID_OPERATION for all other pnames
2722
2723 switch (pname)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002724 {
Geoff Lang646559f2013-08-15 11:08:15 -04002725 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2726 *params = attachmentObjectType;
2727 break;
2728
2729 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002730 if (clientVersion < 3)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002731 {
Geoff Lang646559f2013-08-15 11:08:15 -04002732 return gl::error(GL_INVALID_ENUM);
2733 }
2734 *params = 0;
2735 break;
2736
2737 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002738 if (clientVersion < 3)
Geoff Lang646559f2013-08-15 11:08:15 -04002739 {
2740 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002741 }
2742 else
2743 {
Geoff Lang646559f2013-08-15 11:08:15 -04002744 gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002745 }
2746 }
Geoff Lang646559f2013-08-15 11:08:15 -04002747 }
2748 else
2749 {
2750 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2751 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
Jamie Madill3c7fa222014-06-05 13:08:51 -04002752 ASSERT(attachmentObject != NULL);
Geoff Lang646559f2013-08-15 11:08:15 -04002753
2754 switch (pname)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002755 {
Geoff Lang646559f2013-08-15 11:08:15 -04002756 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2757 *params = attachmentObjectType;
2758 break;
2759
2760 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2761 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2762 {
2763 return gl::error(GL_INVALID_ENUM);
2764 }
2765 *params = attachmentHandle;
2766 break;
2767
2768 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2769 if (attachmentObjectType != GL_TEXTURE)
2770 {
2771 return gl::error(GL_INVALID_ENUM);
2772 }
2773 *params = attachmentLevel;
2774 break;
2775
2776 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2777 if (attachmentObjectType != GL_TEXTURE)
2778 {
2779 return gl::error(GL_INVALID_ENUM);
2780 }
2781 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2782 break;
2783
2784 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002785 *params = attachmentObject->getRedSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002786 break;
2787
2788 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002789 *params = attachmentObject->getGreenSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002790 break;
2791
2792 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002793 *params = attachmentObject->getBlueSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002794 break;
2795
2796 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002797 *params = attachmentObject->getAlphaSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002798 break;
2799
2800 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002801 *params = attachmentObject->getDepthSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002802 break;
2803
2804 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002805 *params = attachmentObject->getStencilSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002806 break;
2807
2808 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2809 if (attachment == GL_DEPTH_STENCIL)
2810 {
2811 gl::error(GL_INVALID_OPERATION);
2812 }
Geoff Lange4a492b2014-06-19 14:14:41 -04002813 *params = attachmentObject->getComponentType();
Geoff Lang646559f2013-08-15 11:08:15 -04002814 break;
2815
2816 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
Geoff Lange4a492b2014-06-19 14:14:41 -04002817 *params = attachmentObject->getColorEncoding();
Geoff Lang646559f2013-08-15 11:08:15 -04002818 break;
2819
2820 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2821 if (attachmentObjectType != GL_TEXTURE)
2822 {
2823 return gl::error(GL_INVALID_ENUM);
2824 }
2825 *params = attachmentLayer;
2826 break;
2827
2828 default:
2829 UNREACHABLE();
2830 break;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002831 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002832 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002833 }
2834 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002835 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002837 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002838 }
2839}
2840
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002841GLenum __stdcall glGetGraphicsResetStatusEXT(void)
2842{
2843 EVENT("()");
2844
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002845 ANGLE_TRY
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002846 {
2847 gl::Context *context = gl::getContext();
2848
2849 if (context)
2850 {
2851 return context->getResetStatus();
2852 }
2853
2854 return GL_NO_ERROR;
2855 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002856 ANGLE_CATCH_ALL
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002857 {
2858 return GL_OUT_OF_MEMORY;
2859 }
2860}
2861
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002862void __stdcall glGetIntegerv(GLenum pname, GLint* params)
2863{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002864 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002865
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002866 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002867 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002868 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002869
2870 if (context)
2871 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002872 GLenum nativeType;
2873 unsigned int numParams = 0;
Jamie Madill79f2f452013-12-19 11:13:02 -05002874
Jamie Madill893ab082014-05-16 16:56:10 -04002875 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
2876 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002877 return;
Jamie Madill893ab082014-05-16 16:56:10 -04002878 }
Jamie Madill79f2f452013-12-19 11:13:02 -05002879
2880 if (nativeType == GL_INT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002881 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002882 context->getIntegerv(pname, params);
2883 }
Jamie Madill55856b12014-01-02 13:59:50 -05002884 else
Jamie Madill79f2f452013-12-19 11:13:02 -05002885 {
Jamie Madill55856b12014-01-02 13:59:50 -05002886 CastStateValues(context, nativeType, pname, numParams, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002887 }
2888 }
2889 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002890 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002891 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002892 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002893 }
2894}
2895
2896void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
2897{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002898 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002899
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002900 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002901 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002902 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002903
2904 if (context)
2905 {
2906 gl::Program *programObject = context->getProgram(program);
2907
2908 if (!programObject)
2909 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002910 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002911 }
2912
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002913 if (context->getClientVersion() < 3)
2914 {
2915 switch (pname)
2916 {
2917 case GL_ACTIVE_UNIFORM_BLOCKS:
2918 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002919 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2920 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2921 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002922 return gl::error(GL_INVALID_ENUM);
2923 }
2924 }
2925
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002926 switch (pname)
2927 {
2928 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002929 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002930 return;
2931 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00002932 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002933 return;
2934 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00002935 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002936 return;
2937 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002938 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002939 return;
2940 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002941 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002942 return;
2943 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00002944 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002945 return;
2946 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00002947 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002948 return;
2949 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002950 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002951 return;
2952 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002953 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002954 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00002955 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00002956 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00002957 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002958 case GL_ACTIVE_UNIFORM_BLOCKS:
2959 *params = programObject->getActiveUniformBlockCount();
2960 return;
2961 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2962 *params = programObject->getActiveUniformBlockMaxLength();
2963 break;
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002964 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2965 *params = programObject->getTransformFeedbackBufferMode();
2966 break;
2967 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2968 *params = programObject->getTransformFeedbackVaryingCount();
2969 break;
2970 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2971 *params = programObject->getTransformFeedbackVaryingMaxLength();
2972 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002973 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002974 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002975 }
2976 }
2977 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002978 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002979 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002980 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002981 }
2982}
2983
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002984void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002985{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002986 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 +00002987 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002988
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002989 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002990 {
2991 if (bufsize < 0)
2992 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002993 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002994 }
2995
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002996 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002997
2998 if (context)
2999 {
3000 gl::Program *programObject = context->getProgram(program);
3001
3002 if (!programObject)
3003 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003004 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003005 }
3006
3007 programObject->getInfoLog(bufsize, length, infolog);
3008 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003009 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003010 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003011 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003012 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003013 }
3014}
3015
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003016void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
3017{
3018 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
3019
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003020 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003021 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003022 gl::Context *context = gl::getNonLostContext();
3023
3024 if (context)
3025 {
Geoff Lang37dde692014-01-31 16:34:54 -05003026 if (!ValidQueryType(context, target))
3027 {
3028 return gl::error(GL_INVALID_ENUM);
3029 }
3030
3031 switch (pname)
3032 {
3033 case GL_CURRENT_QUERY_EXT:
Jamie Madill45c785d2014-05-13 14:09:34 -04003034 params[0] = context->getActiveQueryId(target);
Geoff Lang37dde692014-01-31 16:34:54 -05003035 break;
3036
3037 default:
3038 return gl::error(GL_INVALID_ENUM);
3039 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003040 }
3041 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003042 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003043 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003044 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003045 }
3046}
3047
3048void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
3049{
3050 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
3051
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003052 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003053 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003054 gl::Context *context = gl::getNonLostContext();
3055
3056 if (context)
3057 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003058 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
3059
3060 if (!queryObject)
3061 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003062 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003063 }
3064
Jamie Madill45c785d2014-05-13 14:09:34 -04003065 if (context->getActiveQueryId(queryObject->getType()) == id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003066 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003067 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003068 }
3069
3070 switch(pname)
3071 {
3072 case GL_QUERY_RESULT_EXT:
3073 params[0] = queryObject->getResult();
3074 break;
3075 case GL_QUERY_RESULT_AVAILABLE_EXT:
3076 params[0] = queryObject->isResultAvailable();
3077 break;
3078 default:
Geoff Lang37dde692014-01-31 16:34:54 -05003079 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003080 }
3081 }
3082 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003083 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003084 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003085 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003086 }
3087}
3088
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003089void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
3090{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003091 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 +00003092
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003093 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003094 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003095 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003096
3097 if (context)
3098 {
3099 if (target != GL_RENDERBUFFER)
3100 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003101 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003102 }
3103
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003104 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003105 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003106 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003107 }
3108
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003109 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003110
3111 switch (pname)
3112 {
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003113 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
3114 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
3115 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
3116 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
3117 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
3118 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
3119 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
3120 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
3121 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003122 case GL_RENDERBUFFER_SAMPLES_ANGLE:
Geoff Langcec35902014-04-16 10:52:36 -04003123 if (!context->getCaps().extensions.framebufferMultisample)
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00003124 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003125 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003126 }
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003127 *params = renderbuffer->getSamples();
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003128 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003129 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003130 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003131 }
3132 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003133 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003134 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003135 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003136 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003137 }
3138}
3139
3140void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
3141{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003142 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003143
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003144 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003145 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003146 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003147
3148 if (context)
3149 {
3150 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003151
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003152 if (!shaderObject)
3153 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003154 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003155 }
3156
3157 switch (pname)
3158 {
3159 case GL_SHADER_TYPE:
3160 *params = shaderObject->getType();
3161 return;
3162 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003163 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003164 return;
3165 case GL_COMPILE_STATUS:
3166 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
3167 return;
3168 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003169 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003170 return;
3171 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003172 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003173 return;
zmo@google.coma574f782011-10-03 21:45:23 +00003174 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
3175 *params = shaderObject->getTranslatedSourceLength();
3176 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003177 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003178 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003179 }
3180 }
3181 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003182 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003183 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003184 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003185 }
3186}
3187
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003188void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003189{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003190 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 +00003191 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003192
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003193 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003194 {
3195 if (bufsize < 0)
3196 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003197 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003198 }
3199
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003200 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003201
3202 if (context)
3203 {
3204 gl::Shader *shaderObject = context->getShader(shader);
3205
3206 if (!shaderObject)
3207 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003208 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003209 }
3210
3211 shaderObject->getInfoLog(bufsize, length, infolog);
3212 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003213 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003214 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003215 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003216 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003217 }
3218}
3219
3220void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
3221{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003222 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 +00003223 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003224
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003225 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003226 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003227 switch (shadertype)
3228 {
3229 case GL_VERTEX_SHADER:
3230 case GL_FRAGMENT_SHADER:
3231 break;
3232 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003233 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003234 }
3235
3236 switch (precisiontype)
3237 {
3238 case GL_LOW_FLOAT:
3239 case GL_MEDIUM_FLOAT:
3240 case GL_HIGH_FLOAT:
3241 // Assume IEEE 754 precision
3242 range[0] = 127;
3243 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00003244 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003245 break;
3246 case GL_LOW_INT:
3247 case GL_MEDIUM_INT:
3248 case GL_HIGH_INT:
3249 // Some (most) hardware only supports single-precision floating-point numbers,
3250 // which can accurately represent integers up to +/-16777216
3251 range[0] = 24;
3252 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00003253 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003254 break;
3255 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003256 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003257 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003258 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003259 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003260 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003261 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003262 }
3263}
3264
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003265void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003266{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003267 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 +00003268 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003269
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003270 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003271 {
3272 if (bufsize < 0)
3273 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003274 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003275 }
3276
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003277 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003278
3279 if (context)
3280 {
3281 gl::Shader *shaderObject = context->getShader(shader);
3282
3283 if (!shaderObject)
3284 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003285 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003286 }
3287
3288 shaderObject->getSource(bufsize, length, source);
3289 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003290 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003291 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003292 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003293 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003294 }
3295}
3296
zmo@google.coma574f782011-10-03 21:45:23 +00003297void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
3298{
3299 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
3300 shader, bufsize, length, source);
3301
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003302 ANGLE_TRY
zmo@google.coma574f782011-10-03 21:45:23 +00003303 {
3304 if (bufsize < 0)
3305 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003306 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00003307 }
3308
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003309 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00003310
3311 if (context)
3312 {
3313 gl::Shader *shaderObject = context->getShader(shader);
3314
3315 if (!shaderObject)
3316 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003317 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00003318 }
3319
3320 shaderObject->getTranslatedSource(bufsize, length, source);
3321 }
3322 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003323 ANGLE_CATCH_ALL
zmo@google.coma574f782011-10-03 21:45:23 +00003324 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003325 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00003326 }
3327}
3328
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003329const GLubyte* __stdcall glGetString(GLenum name)
3330{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003331 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003332
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003333 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003334 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003335 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00003336
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003337 switch (name)
3338 {
3339 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00003340 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003341 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00003342 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003343 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003344 if (context->getClientVersion() == 2)
3345 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003346 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003347 }
3348 else
3349 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003350 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003351 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003352 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003353 if (context->getClientVersion() == 2)
3354 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003355 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003356 }
3357 else
3358 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003359 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003360 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003361 case GL_EXTENSIONS:
Geoff Langcec35902014-04-16 10:52:36 -04003362 return (GLubyte*)((context != NULL) ? context->getExtensionString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003363 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003364 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003365 }
3366 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003367 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003368 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003369 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003370 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003371}
3372
3373void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
3374{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003375 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 +00003376
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003377 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003378 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003379 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003380
3381 if (context)
3382 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05003383 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003384
Jamie Madillfb8a8302013-07-03 14:24:12 -04003385 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003386 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003387 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003388 }
3389
3390 switch (pname)
3391 {
3392 case GL_TEXTURE_MAG_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003393 *params = (GLfloat)texture->getSamplerState().magFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003394 break;
3395 case GL_TEXTURE_MIN_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003396 *params = (GLfloat)texture->getSamplerState().minFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003397 break;
3398 case GL_TEXTURE_WRAP_S:
Brandon Jonesa328d562014-07-01 13:52:40 -07003399 *params = (GLfloat)texture->getSamplerState().wrapS;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003400 break;
3401 case GL_TEXTURE_WRAP_T:
Brandon Jonesa328d562014-07-01 13:52:40 -07003402 *params = (GLfloat)texture->getSamplerState().wrapT;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003403 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003404 case GL_TEXTURE_WRAP_R:
3405 if (context->getClientVersion() < 3)
3406 {
3407 return gl::error(GL_INVALID_ENUM);
3408 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003409 *params = (GLfloat)texture->getSamplerState().wrapR;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003410 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003411 case GL_TEXTURE_IMMUTABLE_FORMAT:
3412 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00003413 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3414 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003415 case GL_TEXTURE_IMMUTABLE_LEVELS:
3416 if (context->getClientVersion() < 3)
3417 {
3418 return gl::error(GL_INVALID_ENUM);
3419 }
Jamie Madill51a94372013-10-24 17:49:43 -04003420 *params = (GLfloat)texture->immutableLevelCount();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003421 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00003422 case GL_TEXTURE_USAGE_ANGLE:
3423 *params = (GLfloat)texture->getUsage();
3424 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003425 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
Geoff Langcec35902014-04-16 10:52:36 -04003426 if (!context->getCaps().extensions.textureFilterAnisotropic)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003427 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003428 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003429 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003430 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003431 break;
Geoff Langbc90a482013-09-17 16:51:27 -04003432 case GL_TEXTURE_SWIZZLE_R:
3433 if (context->getClientVersion() < 3)
3434 {
3435 return gl::error(GL_INVALID_ENUM);
3436 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003437 *params = (GLfloat)texture->getSamplerState().swizzleRed;
Geoff Langbc90a482013-09-17 16:51:27 -04003438 break;
3439 case GL_TEXTURE_SWIZZLE_G:
3440 if (context->getClientVersion() < 3)
3441 {
3442 return gl::error(GL_INVALID_ENUM);
3443 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003444 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
Geoff Langbc90a482013-09-17 16:51:27 -04003445 break;
3446 case GL_TEXTURE_SWIZZLE_B:
3447 if (context->getClientVersion() < 3)
3448 {
3449 return gl::error(GL_INVALID_ENUM);
3450 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003451 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
Geoff Langbc90a482013-09-17 16:51:27 -04003452 break;
3453 case GL_TEXTURE_SWIZZLE_A:
3454 if (context->getClientVersion() < 3)
3455 {
3456 return gl::error(GL_INVALID_ENUM);
3457 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003458 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
Geoff Langbc90a482013-09-17 16:51:27 -04003459 break;
Nicolas Capens8de68282014-04-04 11:10:27 -04003460 case GL_TEXTURE_BASE_LEVEL:
3461 if (context->getClientVersion() < 3)
3462 {
3463 return gl::error(GL_INVALID_ENUM);
3464 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003465 *params = (GLfloat)texture->getSamplerState().baseLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003466 break;
3467 case GL_TEXTURE_MAX_LEVEL:
3468 if (context->getClientVersion() < 3)
3469 {
3470 return gl::error(GL_INVALID_ENUM);
3471 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003472 *params = (GLfloat)texture->getSamplerState().maxLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003473 break;
3474 case GL_TEXTURE_MIN_LOD:
3475 if (context->getClientVersion() < 3)
3476 {
3477 return gl::error(GL_INVALID_ENUM);
3478 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003479 *params = texture->getSamplerState().minLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003480 break;
3481 case GL_TEXTURE_MAX_LOD:
3482 if (context->getClientVersion() < 3)
3483 {
3484 return gl::error(GL_INVALID_ENUM);
3485 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003486 *params = texture->getSamplerState().maxLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003487 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003488 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003489 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003490 }
3491 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003492 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003493 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003494 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003495 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003496 }
3497}
3498
3499void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
3500{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003501 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 +00003502
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003503 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003504 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003505 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003506
3507 if (context)
3508 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05003509 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003510
Jamie Madillfb8a8302013-07-03 14:24:12 -04003511 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003512 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003513 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003514 }
3515
3516 switch (pname)
3517 {
3518 case GL_TEXTURE_MAG_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003519 *params = texture->getSamplerState().magFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003520 break;
3521 case GL_TEXTURE_MIN_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003522 *params = texture->getSamplerState().minFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003523 break;
3524 case GL_TEXTURE_WRAP_S:
Brandon Jonesa328d562014-07-01 13:52:40 -07003525 *params = texture->getSamplerState().wrapS;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003526 break;
3527 case GL_TEXTURE_WRAP_T:
Brandon Jonesa328d562014-07-01 13:52:40 -07003528 *params = texture->getSamplerState().wrapT;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003529 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003530 case GL_TEXTURE_WRAP_R:
3531 if (context->getClientVersion() < 3)
3532 {
3533 return gl::error(GL_INVALID_ENUM);
3534 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003535 *params = texture->getSamplerState().wrapR;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003536 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003537 case GL_TEXTURE_IMMUTABLE_FORMAT:
3538 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00003539 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3540 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003541 case GL_TEXTURE_IMMUTABLE_LEVELS:
3542 if (context->getClientVersion() < 3)
3543 {
3544 return gl::error(GL_INVALID_ENUM);
3545 }
Jamie Madill51a94372013-10-24 17:49:43 -04003546 *params = texture->immutableLevelCount();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003547 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00003548 case GL_TEXTURE_USAGE_ANGLE:
3549 *params = texture->getUsage();
3550 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003551 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
Geoff Langcec35902014-04-16 10:52:36 -04003552 if (!context->getCaps().extensions.textureFilterAnisotropic)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003553 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003554 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003555 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003556 *params = (GLint)texture->getSamplerState().maxAnisotropy;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003557 break;
Geoff Langbc90a482013-09-17 16:51:27 -04003558 case GL_TEXTURE_SWIZZLE_R:
3559 if (context->getClientVersion() < 3)
3560 {
3561 return gl::error(GL_INVALID_ENUM);
3562 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003563 *params = texture->getSamplerState().swizzleRed;
Geoff Langbc90a482013-09-17 16:51:27 -04003564 break;
3565 case GL_TEXTURE_SWIZZLE_G:
3566 if (context->getClientVersion() < 3)
3567 {
3568 return gl::error(GL_INVALID_ENUM);
3569 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003570 *params = texture->getSamplerState().swizzleGreen;
Geoff Langbc90a482013-09-17 16:51:27 -04003571 break;
3572 case GL_TEXTURE_SWIZZLE_B:
3573 if (context->getClientVersion() < 3)
3574 {
3575 return gl::error(GL_INVALID_ENUM);
3576 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003577 *params = texture->getSamplerState().swizzleBlue;
Geoff Langbc90a482013-09-17 16:51:27 -04003578 break;
3579 case GL_TEXTURE_SWIZZLE_A:
3580 if (context->getClientVersion() < 3)
3581 {
3582 return gl::error(GL_INVALID_ENUM);
3583 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003584 *params = texture->getSamplerState().swizzleAlpha;
Geoff Langbc90a482013-09-17 16:51:27 -04003585 break;
Nicolas Capens8de68282014-04-04 11:10:27 -04003586 case GL_TEXTURE_BASE_LEVEL:
3587 if (context->getClientVersion() < 3)
3588 {
3589 return gl::error(GL_INVALID_ENUM);
3590 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003591 *params = texture->getSamplerState().baseLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003592 break;
3593 case GL_TEXTURE_MAX_LEVEL:
3594 if (context->getClientVersion() < 3)
3595 {
3596 return gl::error(GL_INVALID_ENUM);
3597 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003598 *params = texture->getSamplerState().maxLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003599 break;
3600 case GL_TEXTURE_MIN_LOD:
3601 if (context->getClientVersion() < 3)
3602 {
3603 return gl::error(GL_INVALID_ENUM);
3604 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003605 *params = (GLint)texture->getSamplerState().minLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003606 break;
3607 case GL_TEXTURE_MAX_LOD:
3608 if (context->getClientVersion() < 3)
3609 {
3610 return gl::error(GL_INVALID_ENUM);
3611 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003612 *params = (GLint)texture->getSamplerState().maxLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003613 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003614 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003615 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003616 }
3617 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003618 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003619 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003620 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003621 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003622 }
3623}
3624
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003625void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
3626{
3627 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3628 program, location, bufSize, params);
3629
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003630 ANGLE_TRY
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003631 {
3632 if (bufSize < 0)
3633 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003634 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003635 }
3636
3637 gl::Context *context = gl::getNonLostContext();
3638
3639 if (context)
3640 {
3641 if (program == 0)
3642 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003643 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003644 }
3645
3646 gl::Program *programObject = context->getProgram(program);
3647
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003648 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003649 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003650 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003651 }
3652
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003653 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3654 if (!programBinary)
3655 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003656 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003657 }
3658
3659 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003660 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003661 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003662 }
3663 }
3664 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003665 ANGLE_CATCH_ALL
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003666 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003667 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003668 }
3669}
3670
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003671void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
3672{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003673 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003674
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003675 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003676 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003677 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003678
3679 if (context)
3680 {
3681 if (program == 0)
3682 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003683 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003684 }
3685
3686 gl::Program *programObject = context->getProgram(program);
3687
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003688 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003689 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003690 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003691 }
3692
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003693 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3694 if (!programBinary)
3695 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003696 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003697 }
3698
3699 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003700 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003701 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003702 }
3703 }
3704 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003705 ANGLE_CATCH_ALL
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003706 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003707 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003708 }
3709}
3710
3711void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
3712{
3713 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
3714 program, location, bufSize, params);
3715
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003716 ANGLE_TRY
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003717 {
3718 if (bufSize < 0)
3719 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003720 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003721 }
3722
3723 gl::Context *context = gl::getNonLostContext();
3724
3725 if (context)
3726 {
3727 if (program == 0)
3728 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003729 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003730 }
3731
3732 gl::Program *programObject = context->getProgram(program);
3733
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003734 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003735 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003736 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003737 }
3738
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003739 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3740 if (!programBinary)
3741 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003742 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003743 }
3744
3745 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003746 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003747 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003748 }
3749 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003750 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003751 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003752 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003753 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003754 }
3755}
3756
3757void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
3758{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003759 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003760
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003761 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003762 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003763 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003764
3765 if (context)
3766 {
3767 if (program == 0)
3768 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003769 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003770 }
3771
3772 gl::Program *programObject = context->getProgram(program);
3773
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003774 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003775 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003776 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003777 }
3778
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003779 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3780 if (!programBinary)
3781 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003782 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003783 }
3784
3785 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003786 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003787 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003788 }
3789 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003790 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003791 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003792 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003793 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003794 }
3795}
3796
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003797int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003798{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003799 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003800
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003801 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003802 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003803 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003804
3805 if (strstr(name, "gl_") == name)
3806 {
3807 return -1;
3808 }
3809
3810 if (context)
3811 {
3812 gl::Program *programObject = context->getProgram(program);
3813
3814 if (!programObject)
3815 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003816 if (context->getShader(program))
3817 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003818 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003819 }
3820 else
3821 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003822 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003823 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003824 }
3825
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003826 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003827 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003828 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003829 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003830 }
3831
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003832 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003833 }
3834 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003835 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003836 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003837 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003838 }
3839
3840 return -1;
3841}
3842
3843void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
3844{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003845 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003846
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003847 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003848 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003849 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003850
daniel@transgaming.come0078962010-04-15 20:45:08 +00003851 if (context)
3852 {
3853 if (index >= gl::MAX_VERTEX_ATTRIBS)
3854 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003855 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003856 }
3857
daniel@transgaming.com83921382011-01-08 05:46:00 +00003858 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003859
Geoff Lang34dbb6f2013-08-05 15:05:47 -04003860 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00003861 {
Jamie Madillaff71502013-07-02 11:57:05 -04003862 return;
3863 }
3864
3865 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3866 {
3867 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
3868 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003869 {
Jamie Madillaff71502013-07-02 11:57:05 -04003870 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003871 }
Jamie Madillaff71502013-07-02 11:57:05 -04003872 }
3873 else
3874 {
Brandon Jones5bf98292014-06-06 17:19:38 -07003875 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003876 }
3877 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003878 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003879 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003880 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003881 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003882 }
3883}
3884
3885void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
3886{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003887 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003888
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003889 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003890 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003891 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003892
daniel@transgaming.come0078962010-04-15 20:45:08 +00003893 if (context)
3894 {
3895 if (index >= gl::MAX_VERTEX_ATTRIBS)
3896 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003897 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003898 }
3899
daniel@transgaming.com83921382011-01-08 05:46:00 +00003900 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003901
Geoff Lang34dbb6f2013-08-05 15:05:47 -04003902 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00003903 {
Jamie Madillaff71502013-07-02 11:57:05 -04003904 return;
3905 }
3906
3907 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3908 {
3909 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
3910 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003911 {
Jamie Madillaff71502013-07-02 11:57:05 -04003912 float currentValue = currentValueData.FloatValues[i];
Jamie Madillaf496912013-07-19 16:36:54 -04003913 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003914 }
Jamie Madillaff71502013-07-02 11:57:05 -04003915 }
3916 else
3917 {
Brandon Jones5bf98292014-06-06 17:19:38 -07003918 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003919 }
3920 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003921 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003922 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003923 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003924 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003925 }
3926}
3927
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003928void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003929{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003930 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003931
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003932 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003933 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003934 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003935
daniel@transgaming.come0078962010-04-15 20:45:08 +00003936 if (context)
3937 {
3938 if (index >= gl::MAX_VERTEX_ATTRIBS)
3939 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003940 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003941 }
3942
3943 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3944 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003945 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003946 }
3947
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003948 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00003949 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003950 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003951 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003952 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003953 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003954 }
3955}
3956
3957void __stdcall glHint(GLenum target, GLenum mode)
3958{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003959 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003960
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003961 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003962 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003963 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003964 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003965 case GL_FASTEST:
3966 case GL_NICEST:
3967 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003968 break;
3969 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003970 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003971 }
3972
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003973 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003974 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003975 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003976 case GL_GENERATE_MIPMAP_HINT:
3977 if (context) context->setGenerateMipmapHint(mode);
3978 break;
3979 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3980 if (context) context->setFragmentShaderDerivativeHint(mode);
3981 break;
3982 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003983 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003984 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003985 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003986 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003987 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003988 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003989 }
3990}
3991
3992GLboolean __stdcall glIsBuffer(GLuint buffer)
3993{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003994 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003995
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003996 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003997 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003998 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003999
4000 if (context && buffer)
4001 {
4002 gl::Buffer *bufferObject = context->getBuffer(buffer);
4003
4004 if (bufferObject)
4005 {
4006 return GL_TRUE;
4007 }
4008 }
4009 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004010 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004011 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004012 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004013 }
4014
4015 return GL_FALSE;
4016}
4017
4018GLboolean __stdcall glIsEnabled(GLenum cap)
4019{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004020 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004021
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004022 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004023 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004024 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004025
4026 if (context)
4027 {
Geoff Lang0550d032014-01-30 11:29:07 -05004028 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004029 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004030 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004031 }
Geoff Lang0550d032014-01-30 11:29:07 -05004032
4033 return context->getCap(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004034 }
4035 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004036 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004037 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004038 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004039 }
4040
4041 return false;
4042}
4043
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004044GLboolean __stdcall glIsFenceNV(GLuint fence)
4045{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004046 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004047
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004048 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004049 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004050 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004051
4052 if (context)
4053 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004054 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004055
4056 if (fenceObject == NULL)
4057 {
4058 return GL_FALSE;
4059 }
4060
4061 return fenceObject->isFence();
4062 }
4063 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004064 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004065 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004066 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004067 }
4068
4069 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004070}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004071
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
4073{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004074 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004075
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004076 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004077 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004078 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004079
4080 if (context && framebuffer)
4081 {
4082 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
4083
4084 if (framebufferObject)
4085 {
4086 return GL_TRUE;
4087 }
4088 }
4089 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004090 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004091 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004092 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004093 }
4094
4095 return GL_FALSE;
4096}
4097
4098GLboolean __stdcall glIsProgram(GLuint program)
4099{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004100 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004101
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004102 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004103 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004104 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004105
4106 if (context && program)
4107 {
4108 gl::Program *programObject = context->getProgram(program);
4109
4110 if (programObject)
4111 {
4112 return GL_TRUE;
4113 }
4114 }
4115 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004116 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004117 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004118 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004119 }
4120
4121 return GL_FALSE;
4122}
4123
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004124GLboolean __stdcall glIsQueryEXT(GLuint id)
4125{
4126 EVENT("(GLuint id = %d)", id);
4127
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004128 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004129 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004130 gl::Context *context = gl::getNonLostContext();
4131
4132 if (context)
4133 {
Geoff Lang37dde692014-01-31 16:34:54 -05004134 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004135 }
4136 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004137 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004138 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004139 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004140 }
4141
4142 return GL_FALSE;
4143}
4144
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004145GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
4146{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004147 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004148
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004149 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004150 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004151 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004152
4153 if (context && renderbuffer)
4154 {
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04004155 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004156
4157 if (renderbufferObject)
4158 {
4159 return GL_TRUE;
4160 }
4161 }
4162 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004163 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004164 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004165 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004166 }
4167
4168 return GL_FALSE;
4169}
4170
4171GLboolean __stdcall glIsShader(GLuint shader)
4172{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004173 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004174
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004175 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004176 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004177 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004178
4179 if (context && shader)
4180 {
4181 gl::Shader *shaderObject = context->getShader(shader);
4182
4183 if (shaderObject)
4184 {
4185 return GL_TRUE;
4186 }
4187 }
4188 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004189 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004190 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004191 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004192 }
4193
4194 return GL_FALSE;
4195}
4196
4197GLboolean __stdcall glIsTexture(GLuint texture)
4198{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004199 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004200
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004201 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004202 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004203 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004204
4205 if (context && texture)
4206 {
4207 gl::Texture *textureObject = context->getTexture(texture);
4208
4209 if (textureObject)
4210 {
4211 return GL_TRUE;
4212 }
4213 }
4214 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004215 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004216 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004217 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004218 }
4219
4220 return GL_FALSE;
4221}
4222
4223void __stdcall glLineWidth(GLfloat width)
4224{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004225 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004226
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004227 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004228 {
4229 if (width <= 0.0f)
4230 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004231 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004232 }
4233
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004234 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004235
4236 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004237 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004238 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004239 }
4240 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004241 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004242 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004243 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004244 }
4245}
4246
4247void __stdcall glLinkProgram(GLuint program)
4248{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004249 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004250
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004251 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004252 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004253 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004254
4255 if (context)
4256 {
4257 gl::Program *programObject = context->getProgram(program);
4258
4259 if (!programObject)
4260 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004261 if (context->getShader(program))
4262 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004263 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004264 }
4265 else
4266 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004267 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004268 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004269 }
4270
daniel@transgaming.com95d29422012-07-24 18:36:10 +00004271 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004272 }
4273 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004274 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004275 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004276 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004277 }
4278}
4279
4280void __stdcall glPixelStorei(GLenum pname, GLint param)
4281{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004282 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004283
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004284 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004285 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004286 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004287
4288 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004289 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004290 switch (pname)
4291 {
4292 case GL_UNPACK_ALIGNMENT:
4293 if (param != 1 && param != 2 && param != 4 && param != 8)
4294 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004295 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004296 }
4297
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004298 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004299 break;
4300
4301 case GL_PACK_ALIGNMENT:
4302 if (param != 1 && param != 2 && param != 4 && param != 8)
4303 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004304 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004305 }
4306
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004307 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004308 break;
4309
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00004310 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
4311 context->setPackReverseRowOrder(param != 0);
4312 break;
4313
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00004314 case GL_UNPACK_IMAGE_HEIGHT:
4315 case GL_UNPACK_SKIP_IMAGES:
4316 case GL_UNPACK_ROW_LENGTH:
4317 case GL_UNPACK_SKIP_ROWS:
4318 case GL_UNPACK_SKIP_PIXELS:
4319 case GL_PACK_ROW_LENGTH:
4320 case GL_PACK_SKIP_ROWS:
4321 case GL_PACK_SKIP_PIXELS:
4322 if (context->getClientVersion() < 3)
4323 {
4324 return gl::error(GL_INVALID_ENUM);
4325 }
4326 UNIMPLEMENTED();
4327 break;
4328
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004329 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004330 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004331 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004332 }
4333 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004334 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004335 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004336 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004337 }
4338}
4339
4340void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
4341{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004342 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004343
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004344 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004345 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004346 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00004347
4348 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004349 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004350 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004351 }
4352 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004353 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004354 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004355 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004356 }
4357}
4358
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004359void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
4360 GLenum format, GLenum type, GLsizei bufSize,
4361 GLvoid *data)
4362{
4363 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
4364 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
4365 x, y, width, height, format, type, bufSize, data);
4366
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004367 ANGLE_TRY
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004368 {
4369 if (width < 0 || height < 0 || bufSize < 0)
4370 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004371 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004372 }
4373
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004374 gl::Context *context = gl::getNonLostContext();
4375
4376 if (context)
4377 {
Jamie Madill26e91952014-03-05 15:01:27 -05004378 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
4379 format, type, &bufSize, data))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004380 {
Jamie Madill26e91952014-03-05 15:01:27 -05004381 return;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004382 }
4383
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004384 context->readPixels(x, y, width, height, format, type, &bufSize, data);
4385 }
4386 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004387 ANGLE_CATCH_ALL
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004388 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004389 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004390 }
4391}
4392
4393void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
4394 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004395{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004396 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004397 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004398 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004399
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004400 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004401 {
4402 if (width < 0 || height < 0)
4403 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004404 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004405 }
4406
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004407 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004408
4409 if (context)
4410 {
Jamie Madill26e91952014-03-05 15:01:27 -05004411 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
4412 format, type, NULL, pixels))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004413 {
Jamie Madill26e91952014-03-05 15:01:27 -05004414 return;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004415 }
4416
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004417 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004418 }
4419 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004420 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004421 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004422 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004423 }
4424}
4425
4426void __stdcall glReleaseShaderCompiler(void)
4427{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004428 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004429
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004430 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004431 {
4432 gl::Shader::releaseCompiler();
4433 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004434 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004435 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004436 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004437 }
4438}
4439
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004440void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004441{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004442 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 +00004443 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004444
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004445 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004446 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004447 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004448
4449 if (context)
4450 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004451 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
Geoff Lang2e1dcd52013-05-29 10:34:08 -04004452 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00004453 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04004454 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004455 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00004456
4457 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004458 }
4459 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004460 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004461 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004462 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004463 }
4464}
4465
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004466void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
4467{
4468 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
4469}
4470
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004471void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
4472{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004473 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004474
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004475 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004476 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004477 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004478
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004479 if (context)
4480 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00004481 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004482 }
4483 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004484 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004485 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004486 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004487 }
4488}
4489
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004490void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
4491{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004492 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004493
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004494 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004495 {
4496 if (condition != GL_ALL_COMPLETED_NV)
4497 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004498 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004499 }
4500
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004501 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004502
4503 if (context)
4504 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004505 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004506
4507 if (fenceObject == NULL)
4508 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004509 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004510 }
4511
4512 fenceObject->setFence(condition);
4513 }
4514 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004515 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004516 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004517 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004518 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004519}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004520
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
4522{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004523 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 +00004524
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004525 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004526 {
4527 if (width < 0 || height < 0)
4528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004529 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004530 }
4531
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004532 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004533
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004534 if (context)
4535 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004536 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004537 }
4538 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004539 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004540 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004541 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004542 }
4543}
4544
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004545void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004546{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004547 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004548 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004549 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004550
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004551 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004552 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00004553 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004554 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004555 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004556 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004557 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004558 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004559 }
4560}
4561
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00004562void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004563{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004564 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 +00004565 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004566
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004567 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004568 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004569 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004570 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004571 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004572 }
4573
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004574 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004575
4576 if (context)
4577 {
4578 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004579
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004580 if (!shaderObject)
4581 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004582 if (context->getProgram(shader))
4583 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004584 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004585 }
4586 else
4587 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004588 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004589 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004590 }
4591
4592 shaderObject->setSource(count, string, length);
4593 }
4594 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004595 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004596 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004597 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004598 }
4599}
4600
4601void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
4602{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004603 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004604}
4605
4606void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
4607{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004608 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 +00004609
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004610 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004611 {
4612 switch (face)
4613 {
4614 case GL_FRONT:
4615 case GL_BACK:
4616 case GL_FRONT_AND_BACK:
4617 break;
4618 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004619 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004620 }
4621
4622 switch (func)
4623 {
4624 case GL_NEVER:
4625 case GL_ALWAYS:
4626 case GL_LESS:
4627 case GL_LEQUAL:
4628 case GL_EQUAL:
4629 case GL_GEQUAL:
4630 case GL_GREATER:
4631 case GL_NOTEQUAL:
4632 break;
4633 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004634 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004635 }
4636
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004637 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004638
4639 if (context)
4640 {
4641 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4642 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004643 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004644 }
4645
4646 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4647 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004648 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004649 }
4650 }
4651 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004652 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004653 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004654 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004655 }
4656}
4657
4658void __stdcall glStencilMask(GLuint mask)
4659{
4660 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4661}
4662
4663void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
4664{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004665 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004667 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004668 {
4669 switch (face)
4670 {
4671 case GL_FRONT:
4672 case GL_BACK:
4673 case GL_FRONT_AND_BACK:
4674 break;
4675 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004676 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004677 }
4678
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004679 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680
4681 if (context)
4682 {
4683 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4684 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004685 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004686 }
4687
4688 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4689 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004690 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004691 }
4692 }
4693 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004694 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004695 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004696 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004697 }
4698}
4699
4700void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
4701{
4702 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4703}
4704
4705void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
4706{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004707 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 +00004708 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004709
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004710 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004711 {
4712 switch (face)
4713 {
4714 case GL_FRONT:
4715 case GL_BACK:
4716 case GL_FRONT_AND_BACK:
4717 break;
4718 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004719 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004720 }
4721
4722 switch (fail)
4723 {
4724 case GL_ZERO:
4725 case GL_KEEP:
4726 case GL_REPLACE:
4727 case GL_INCR:
4728 case GL_DECR:
4729 case GL_INVERT:
4730 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004731 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004732 break;
4733 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004734 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004735 }
4736
4737 switch (zfail)
4738 {
4739 case GL_ZERO:
4740 case GL_KEEP:
4741 case GL_REPLACE:
4742 case GL_INCR:
4743 case GL_DECR:
4744 case GL_INVERT:
4745 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004746 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004747 break;
4748 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004749 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004750 }
4751
4752 switch (zpass)
4753 {
4754 case GL_ZERO:
4755 case GL_KEEP:
4756 case GL_REPLACE:
4757 case GL_INCR:
4758 case GL_DECR:
4759 case GL_INVERT:
4760 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004761 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004762 break;
4763 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004764 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004765 }
4766
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004767 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004768
4769 if (context)
4770 {
4771 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4772 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004773 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004774 }
4775
4776 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4777 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004778 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004779 }
4780 }
4781 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004782 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004783 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004784 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004785 }
4786}
4787
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004788GLboolean __stdcall glTestFenceNV(GLuint fence)
4789{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004790 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004791
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004792 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004793 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004794 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004795
4796 if (context)
4797 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004798 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004799
4800 if (fenceObject == NULL)
4801 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004802 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004803 }
4804
Jamie Madillfb9a7402013-07-26 11:55:01 -04004805 if (fenceObject->isFence() != GL_TRUE)
4806 {
4807 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
4808 }
4809
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004810 return fenceObject->testFence();
4811 }
4812 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004813 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004814 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004815 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004816 }
4817
4818 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004819}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004820
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004821void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
4822 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004823{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004824 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004825 "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 +00004826 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004827
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004828 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004829 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004830 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004831
4832 if (context)
4833 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004834 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004835 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004836 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00004837 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004838 return;
4839 }
4840
4841 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004842 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04004843 0, 0, 0, width, height, 1, border, format, type, pixels))
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004844 {
4845 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00004846 }
4847
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004848 switch (target)
4849 {
4850 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004851 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004852 gl::Texture2D *texture = context->getTexture2D();
Jamie Madill88f18f42013-09-18 14:36:19 -04004853 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004854 }
4855 break;
4856 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004857 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004858 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004859 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004860 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004861 break;
4862 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4863 {
4864 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004865 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004866 }
4867 break;
4868 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4869 {
4870 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004871 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004872 }
4873 break;
4874 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4875 {
4876 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004877 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004878 }
4879 break;
4880 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4881 {
4882 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004883 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004884 }
4885 break;
4886 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4887 {
4888 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004889 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004890 }
4891 break;
4892 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004893 }
4894 }
4895 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004896 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004897 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004898 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004899 }
4900}
4901
4902void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
4903{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004904 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4905
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004906 ANGLE_TRY
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004907 {
4908 gl::Context *context = gl::getNonLostContext();
4909
4910 if (context)
4911 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004912 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
Jamie Madill478fdb22013-07-19 16:36:59 -04004913 {
4914 return;
4915 }
4916
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004917 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004918
Jamie Madillfb8a8302013-07-03 14:24:12 -04004919 if (!texture)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004920 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004921 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004922 }
4923
4924 switch (pname)
4925 {
Brandon Jonesa328d562014-07-01 13:52:40 -07004926 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4927 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4928 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4929 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4930 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4931 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4932 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getCaps().extensions.maxTextureAnisotropy); break;
4933 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4934 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4935 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4936 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4937 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4938 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4939 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4940 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4941 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4942 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
Jamie Madill478fdb22013-07-19 16:36:59 -04004943 default: UNREACHABLE(); break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004944 }
4945 }
4946 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004947 ANGLE_CATCH_ALL
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004948 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004949 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004950 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004951}
4952
4953void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
4954{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004955 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004956}
4957
4958void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
4959{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004960 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004961
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004962 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004963 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004964 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004965
4966 if (context)
4967 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004968 if (!ValidateTexParamParameters(context, pname, param))
Jamie Madill478fdb22013-07-19 16:36:59 -04004969 {
4970 return;
4971 }
4972
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004973 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004974
Jamie Madillfb8a8302013-07-03 14:24:12 -04004975 if (!texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004976 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004977 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004978 }
4979
4980 switch (pname)
4981 {
Brandon Jonesa328d562014-07-01 13:52:40 -07004982 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4983 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4984 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4985 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4986 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4987 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4988 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getCaps().extensions.maxTextureAnisotropy); break;
4989 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4990 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4991 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4992 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4993 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4994 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4995 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4996 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4997 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4998 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
Jamie Madill478fdb22013-07-19 16:36:59 -04004999 default: UNREACHABLE(); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005000 }
5001 }
5002 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005003 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005004 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005005 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005006 }
5007}
5008
5009void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
5010{
5011 glTexParameteri(target, pname, *params);
5012}
5013
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005014void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
5015{
5016 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
5017 target, levels, internalformat, width, height);
5018
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005019 ANGLE_TRY
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005020 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005021 gl::Context *context = gl::getNonLostContext();
5022
5023 if (context)
5024 {
Geoff Langcec35902014-04-16 10:52:36 -04005025 if (!context->getCaps().extensions.textureStorage)
5026 {
5027 return gl::error(GL_INVALID_OPERATION);
5028 }
5029
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005030 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005031 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005032 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005033 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005034 }
5035
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005036 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005037 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005038 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005039 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005040 }
5041
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005042 switch (target)
5043 {
5044 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005045 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005046 gl::Texture2D *texture2d = context->getTexture2D();
5047 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005048 }
5049 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005050
Geoff Lang01c21d22013-09-24 11:52:16 -04005051 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005052 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005053 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
5054 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005055 }
5056 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005057
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005058 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005059 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005060 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005061 }
5062 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005063 ANGLE_CATCH_ALL
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005064 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005065 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005066 }
5067}
5068
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005069void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
5070 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005071{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005072 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005073 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005074 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005075 target, level, xoffset, yoffset, width, height, format, type, pixels);
5076
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005077 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005078 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005079 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005080
5081 if (context)
5082 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005083 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005084 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
Jamie Madillf67115c2014-04-22 13:14:05 -04005085 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00005086 {
5087 return;
5088 }
5089
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005090 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005091 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
Jamie Madillf67115c2014-04-22 13:14:05 -04005092 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005093 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005094 return;
5095 }
5096
Geoff Langc41e42d2014-04-28 10:58:16 -04005097 // Zero sized uploads are valid but no-ops
5098 if (width == 0 || height == 0)
5099 {
5100 return;
5101 }
5102
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005103 switch (target)
5104 {
5105 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005106 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005107 gl::Texture2D *texture = context->getTexture2D();
Jamie Madill88f18f42013-09-18 14:36:19 -04005108 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005109 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005110 break;
5111
5112 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
5113 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
5114 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
5115 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
5116 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
5117 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005118 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005119 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04005120 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005121 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005122 break;
5123
5124 default:
Geoff Lang01c21d22013-09-24 11:52:16 -04005125 UNREACHABLE();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005126 }
5127 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005128 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005129 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005130 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005131 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005132 }
5133}
5134
5135void __stdcall glUniform1f(GLint location, GLfloat x)
5136{
5137 glUniform1fv(location, 1, &x);
5138}
5139
5140void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
5141{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005142 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005143
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005144 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005145 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005146 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005147
5148 if (context)
5149 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005150 if (!ValidateUniform(context, GL_FLOAT, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005151 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005152 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005153 }
5154
Jamie Madillaa981bd2014-05-20 10:55:55 -04005155 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005156 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005157 }
5158 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005159 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005160 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005161 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005162 }
5163}
5164
5165void __stdcall glUniform1i(GLint location, GLint x)
5166{
5167 glUniform1iv(location, 1, &x);
5168}
5169
5170void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
5171{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005172 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005173
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005174 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005175 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005176 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005177
5178 if (context)
5179 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005180 if (!ValidateUniform(context, GL_INT, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005181 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005182 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005183 }
5184
Jamie Madillaa981bd2014-05-20 10:55:55 -04005185 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005186 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005187 }
5188 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005189 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005190 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005191 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005192 }
5193}
5194
5195void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
5196{
5197 GLfloat xy[2] = {x, y};
5198
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005199 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005200}
5201
5202void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
5203{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005204 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005205
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005206 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005207 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005208 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005209
5210 if (context)
5211 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005212 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005213 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005214 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005215 }
5216
Jamie Madillaa981bd2014-05-20 10:55:55 -04005217 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005218 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005219 }
5220 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005221 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005222 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005223 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005224 }
5225}
5226
5227void __stdcall glUniform2i(GLint location, GLint x, GLint y)
5228{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005229 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005230
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005231 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005232}
5233
5234void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
5235{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005236 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005237
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005238 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005239 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005240 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005241
5242 if (context)
5243 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005244 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005245 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005246 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005247 }
5248
Jamie Madillaa981bd2014-05-20 10:55:55 -04005249 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005250 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005251 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005252 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005253 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005254 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005255 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005256 }
5257}
5258
5259void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
5260{
5261 GLfloat xyz[3] = {x, y, z};
5262
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005263 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005264}
5265
5266void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
5267{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005268 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005269
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005270 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005271 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005272 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005273
5274 if (context)
5275 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005276 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005277 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005278 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005279 }
5280
Jamie Madillaa981bd2014-05-20 10:55:55 -04005281 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005282 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005283 }
5284 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005285 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005286 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005287 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005288 }
5289}
5290
5291void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
5292{
5293 GLint xyz[3] = {x, y, z};
5294
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005295 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005296}
5297
5298void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
5299{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005300 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005301
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005302 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005303 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005304 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005305
5306 if (context)
5307 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005308 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005309 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005310 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005311 }
5312
Jamie Madillaa981bd2014-05-20 10:55:55 -04005313 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005314 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005315 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005316 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005317 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005318 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005319 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005320 }
5321}
5322
5323void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5324{
5325 GLfloat xyzw[4] = {x, y, z, w};
5326
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005327 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005328}
5329
5330void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
5331{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005332 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005333
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005334 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005335 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005336 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005337
5338 if (context)
5339 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005340 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005341 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005342 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005343 }
5344
Jamie Madillaa981bd2014-05-20 10:55:55 -04005345 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005346 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005347 }
5348 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005349 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005350 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005351 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005352 }
5353}
5354
5355void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
5356{
5357 GLint xyzw[4] = {x, y, z, w};
5358
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005359 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005360}
5361
5362void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
5363{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005364 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005365
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005366 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005367 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005368 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005369
5370 if (context)
5371 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005372 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005373 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005374 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005375 }
5376
Jamie Madillaa981bd2014-05-20 10:55:55 -04005377 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005378 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005379 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005380 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005381 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005382 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005383 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005384 }
5385}
5386
5387void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5388{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005389 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005390 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005391
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005392 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005393 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005394 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005395
5396 if (context)
5397 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005398 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005399 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005400 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005401 }
5402
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005403 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005404 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005405 }
5406 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005407 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005408 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005409 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005410 }
5411}
5412
5413void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5414{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005415 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005416 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005417
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005418 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005419 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005420 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005421
5422 if (context)
5423 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005424 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005425 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005426 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005427 }
5428
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005429 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005430 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005431 }
5432 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005433 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005434 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005435 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005436 }
5437}
5438
5439void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5440{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005441 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005442 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005443
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005444 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005445 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005446 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005447
5448 if (context)
5449 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005450 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005451 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005452 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005453 }
5454
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005455 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005456 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005457 }
5458 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005459 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005460 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005461 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005462 }
5463}
5464
5465void __stdcall glUseProgram(GLuint program)
5466{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005467 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005468
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005469 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005470 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005471 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005472
5473 if (context)
5474 {
5475 gl::Program *programObject = context->getProgram(program);
5476
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005477 if (!programObject && program != 0)
5478 {
5479 if (context->getShader(program))
5480 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005481 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005482 }
5483 else
5484 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005485 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005486 }
5487 }
5488
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005489 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005490 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005491 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005492 }
5493
5494 context->useProgram(program);
5495 }
5496 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005497 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005498 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005499 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005500 }
5501}
5502
5503void __stdcall glValidateProgram(GLuint program)
5504{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005505 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005506
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005507 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005508 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005509 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005510
5511 if (context)
5512 {
5513 gl::Program *programObject = context->getProgram(program);
5514
5515 if (!programObject)
5516 {
5517 if (context->getShader(program))
5518 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005519 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005520 }
5521 else
5522 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005523 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005524 }
5525 }
5526
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00005527 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005528 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005529 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005530 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005531 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005532 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005533 }
5534}
5535
5536void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
5537{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005538 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005539
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005540 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005541 {
5542 if (index >= gl::MAX_VERTEX_ATTRIBS)
5543 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005544 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005545 }
5546
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005547 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005548
5549 if (context)
5550 {
5551 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005552 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005553 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005554 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005555 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005556 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005557 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005558 }
5559}
5560
5561void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
5562{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005563 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005564
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005565 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005566 {
5567 if (index >= gl::MAX_VERTEX_ATTRIBS)
5568 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005569 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005570 }
5571
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005572 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005573
5574 if (context)
5575 {
5576 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005577 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005578 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005579 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005580 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005581 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005582 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005583 }
5584}
5585
5586void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
5587{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005588 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005589
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005590 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005591 {
5592 if (index >= gl::MAX_VERTEX_ATTRIBS)
5593 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005594 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005595 }
5596
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005597 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005598
5599 if (context)
5600 {
5601 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005602 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005603 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005604 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005605 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005606 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005607 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005608 }
5609}
5610
5611void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
5612{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005613 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005614
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005615 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005616 {
5617 if (index >= gl::MAX_VERTEX_ATTRIBS)
5618 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005619 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005620 }
5621
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005622 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005623
5624 if (context)
5625 {
5626 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005627 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005628 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005629 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005630 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005631 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005632 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005633 }
5634}
5635
5636void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5637{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005638 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 +00005639
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005640 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005641 {
5642 if (index >= gl::MAX_VERTEX_ATTRIBS)
5643 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005644 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005645 }
5646
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005647 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005648
5649 if (context)
5650 {
5651 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005652 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005653 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005654 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005655 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005656 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005657 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005658 }
5659}
5660
5661void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
5662{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005663 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005664
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005665 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005666 {
5667 if (index >= gl::MAX_VERTEX_ATTRIBS)
5668 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005669 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005670 }
5671
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005672 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005673
5674 if (context)
5675 {
5676 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005677 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005678 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005679 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005680 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005681 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005682 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005683 }
5684}
5685
5686void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5687{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005688 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 +00005689
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005690 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005691 {
5692 if (index >= gl::MAX_VERTEX_ATTRIBS)
5693 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005694 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005695 }
5696
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005697 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005698
5699 if (context)
5700 {
5701 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005702 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005703 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005704 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005705 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005706 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005707 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005708 }
5709}
5710
5711void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
5712{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005713 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005714
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005715 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005716 {
5717 if (index >= gl::MAX_VERTEX_ATTRIBS)
5718 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005719 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005720 }
5721
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005722 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005723
5724 if (context)
5725 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005726 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005727 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005728 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005729 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005730 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005731 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005732 }
5733}
5734
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005735void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
5736{
5737 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
5738
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005739 ANGLE_TRY
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005740 {
5741 if (index >= gl::MAX_VERTEX_ATTRIBS)
5742 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005743 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005744 }
5745
5746 gl::Context *context = gl::getNonLostContext();
5747
5748 if (context)
5749 {
5750 context->setVertexAttribDivisor(index, divisor);
5751 }
5752 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005753 ANGLE_CATCH_ALL
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005755 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005756 }
5757}
5758
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005759void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005760{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005761 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005762 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005763 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005764
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005765 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005766 {
5767 if (index >= gl::MAX_VERTEX_ATTRIBS)
5768 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005769 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005770 }
5771
5772 if (size < 1 || size > 4)
5773 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005774 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005775 }
5776
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005777 gl::Context *context = gl::getNonLostContext();
5778
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005779 switch (type)
5780 {
5781 case GL_BYTE:
5782 case GL_UNSIGNED_BYTE:
5783 case GL_SHORT:
5784 case GL_UNSIGNED_SHORT:
5785 case GL_FIXED:
5786 case GL_FLOAT:
5787 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005788 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005789 case GL_INT:
5790 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005791 case GL_INT_2_10_10_10_REV:
5792 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005793 if (context && context->getClientVersion() < 3)
5794 {
5795 return gl::error(GL_INVALID_ENUM);
5796 }
5797 else
5798 {
5799 break;
5800 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005801 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005802 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005803 }
5804
5805 if (stride < 0)
5806 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005807 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005808 }
5809
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005810 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5811 {
5812 return gl::error(GL_INVALID_OPERATION);
5813 }
5814
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005815 if (context)
5816 {
Jamie Madilld8db8662013-07-02 11:57:04 -04005817 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5818 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5819 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5820 // and the pointer argument is not NULL.
5821 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL)
5822 {
5823 return gl::error(GL_INVALID_OPERATION);
5824 }
5825
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00005826 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
5827 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005828 }
5829 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005830 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005831 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005832 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005833 }
5834}
5835
5836void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
5837{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005838 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 +00005839
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005840 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005841 {
5842 if (width < 0 || height < 0)
5843 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005844 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005845 }
5846
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005847 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005848
5849 if (context)
5850 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005851 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005852 }
5853 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005854 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005855 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005856 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005857 }
5858}
5859
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005860// OpenGL ES 3.0 functions
5861
5862void __stdcall glReadBuffer(GLenum mode)
5863{
5864 EVENT("(GLenum mode = 0x%X)", mode);
5865
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005866 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005867 {
5868 gl::Context *context = gl::getNonLostContext();
5869
5870 if (context)
5871 {
5872 if (context->getClientVersion() < 3)
5873 {
5874 return gl::error(GL_INVALID_OPERATION);
5875 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005876
Jamie Madill54133512013-06-21 09:33:07 -04005877 // glReadBuffer
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005878 UNIMPLEMENTED();
5879 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005880 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005881 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005882 {
5883 return gl::error(GL_OUT_OF_MEMORY);
5884 }
5885}
5886
5887void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
5888{
5889 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5890 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5891
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005892 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005893 {
5894 gl::Context *context = gl::getNonLostContext();
5895
5896 if (context)
5897 {
5898 if (context->getClientVersion() < 3)
5899 {
5900 return gl::error(GL_INVALID_OPERATION);
5901 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005902
Jamie Madill54133512013-06-21 09:33:07 -04005903 // glDrawRangeElements
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005904 UNIMPLEMENTED();
5905 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005906 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005907 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005908 {
5909 return gl::error(GL_OUT_OF_MEMORY);
5910 }
5911}
5912
5913void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
5914{
5915 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5916 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5917 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5918 target, level, internalformat, width, height, depth, border, format, type, pixels);
5919
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005920 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005921 {
5922 gl::Context *context = gl::getNonLostContext();
5923
5924 if (context)
5925 {
5926 if (context->getClientVersion() < 3)
5927 {
5928 return gl::error(GL_INVALID_OPERATION);
5929 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005930
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005931 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005932 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04005933 0, 0, 0, width, height, depth, border, format, type, pixels))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005934 {
5935 return;
5936 }
5937
5938 switch(target)
5939 {
5940 case GL_TEXTURE_3D:
5941 {
5942 gl::Texture3D *texture = context->getTexture3D();
Jamie Madill88f18f42013-09-18 14:36:19 -04005943 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005944 }
5945 break;
5946
5947 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00005948 {
5949 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madill88f18f42013-09-18 14:36:19 -04005950 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00005951 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005952 break;
5953
5954 default:
5955 return gl::error(GL_INVALID_ENUM);
5956 }
5957 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005958 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005959 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005960 {
5961 return gl::error(GL_OUT_OF_MEMORY);
5962 }
5963}
5964
5965void __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)
5966{
5967 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5968 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5969 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5970 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5971
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005972 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005973 {
5974 gl::Context *context = gl::getNonLostContext();
5975
5976 if (context)
5977 {
5978 if (context->getClientVersion() < 3)
5979 {
5980 return gl::error(GL_INVALID_OPERATION);
5981 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005982
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005983 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005984 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005985 xoffset, yoffset, zoffset, width, height, depth, 0,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04005986 format, type, pixels))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005987 {
5988 return;
5989 }
5990
Geoff Langc41e42d2014-04-28 10:58:16 -04005991 // Zero sized uploads are valid but no-ops
5992 if (width == 0 || height == 0 || depth == 0)
5993 {
5994 return;
5995 }
5996
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005997 switch(target)
5998 {
5999 case GL_TEXTURE_3D:
6000 {
6001 gl::Texture3D *texture = context->getTexture3D();
Jamie Madill88f18f42013-09-18 14:36:19 -04006002 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006003 }
6004 break;
6005
6006 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006007 {
6008 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madill88f18f42013-09-18 14:36:19 -04006009 texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006010 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006011 break;
6012
6013 default:
6014 return gl::error(GL_INVALID_ENUM);
6015 }
6016 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006017 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006018 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006019 {
6020 return gl::error(GL_OUT_OF_MEMORY);
6021 }
6022}
6023
6024void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
6025{
6026 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
6027 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
6028 target, level, xoffset, yoffset, zoffset, x, y, width, height);
6029
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006030 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006031 {
6032 gl::Context *context = gl::getNonLostContext();
6033
6034 if (context)
6035 {
6036 if (context->getClientVersion() < 3)
6037 {
6038 return gl::error(GL_INVALID_OPERATION);
6039 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006040
Jamie Madill6f38f822014-06-06 17:12:20 -04006041 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00006042 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006043 {
6044 return;
6045 }
6046
6047 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
6048 gl::Texture *texture = NULL;
6049 switch (target)
6050 {
6051 case GL_TEXTURE_3D:
6052 texture = context->getTexture3D();
6053 break;
6054
6055 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006056 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006057 break;
6058
6059 default:
6060 return gl::error(GL_INVALID_ENUM);
6061 }
6062
6063 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
6064 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006065 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006066 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006067 {
6068 return gl::error(GL_OUT_OF_MEMORY);
6069 }
6070}
6071
6072void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
6073{
Geoff Langeef52cc2013-10-16 15:07:39 -04006074 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 +00006075 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
6076 "const GLvoid* data = 0x%0.8p)",
6077 target, level, internalformat, width, height, depth, border, imageSize, data);
6078
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006079 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006080 {
6081 gl::Context *context = gl::getNonLostContext();
6082
6083 if (context)
6084 {
6085 if (context->getClientVersion() < 3)
6086 {
6087 return gl::error(GL_INVALID_OPERATION);
6088 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006089
Geoff Lange4a492b2014-06-19 14:14:41 -04006090 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006091 {
6092 return gl::error(GL_INVALID_VALUE);
6093 }
6094
6095 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006096 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04006097 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006098 {
6099 return;
6100 }
6101
6102 switch(target)
6103 {
6104 case GL_TEXTURE_3D:
6105 {
6106 gl::Texture3D *texture = context->getTexture3D();
6107 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
6108 }
6109 break;
6110
6111 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006112 {
6113 gl::Texture2DArray *texture = context->getTexture2DArray();
6114 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
6115 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006116 break;
6117
6118 default:
6119 return gl::error(GL_INVALID_ENUM);
6120 }
6121 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006122 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006123 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006124 {
6125 return gl::error(GL_OUT_OF_MEMORY);
6126 }
6127}
6128
6129void __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)
6130{
6131 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
6132 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
6133 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
6134 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
6135
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006136 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006137 {
6138 gl::Context *context = gl::getNonLostContext();
6139
6140 if (context)
6141 {
6142 if (context->getClientVersion() < 3)
6143 {
6144 return gl::error(GL_INVALID_OPERATION);
6145 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006146
Geoff Lange4a492b2014-06-19 14:14:41 -04006147 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006148 {
6149 return gl::error(GL_INVALID_VALUE);
6150 }
6151
6152 if (!data)
6153 {
6154 return gl::error(GL_INVALID_VALUE);
6155 }
6156
6157 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006158 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04006159 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006160 {
6161 return;
6162 }
6163
Geoff Langc41e42d2014-04-28 10:58:16 -04006164 // Zero sized uploads are valid but no-ops
6165 if (width == 0 || height == 0)
6166 {
6167 return;
6168 }
6169
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006170 switch(target)
6171 {
6172 case GL_TEXTURE_3D:
6173 {
6174 gl::Texture3D *texture = context->getTexture3D();
6175 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
6176 format, imageSize, data);
6177 }
6178 break;
6179
6180 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006181 {
6182 gl::Texture2DArray *texture = context->getTexture2DArray();
6183 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
6184 format, imageSize, data);
6185 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006186 break;
6187
6188 default:
6189 return gl::error(GL_INVALID_ENUM);
6190 }
6191 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006192 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006193 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006194 {
6195 return gl::error(GL_OUT_OF_MEMORY);
6196 }
6197}
6198
6199void __stdcall glGenQueries(GLsizei n, GLuint* ids)
6200{
6201 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
6202
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006203 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006204 {
6205 gl::Context *context = gl::getNonLostContext();
6206
6207 if (context)
6208 {
6209 if (context->getClientVersion() < 3)
6210 {
6211 return gl::error(GL_INVALID_OPERATION);
6212 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006213
Geoff Lang37dde692014-01-31 16:34:54 -05006214 if (n < 0)
6215 {
6216 return gl::error(GL_INVALID_VALUE);
6217 }
6218
6219 for (GLsizei i = 0; i < n; i++)
6220 {
6221 ids[i] = context->createQuery();
6222 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006223 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006224 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006225 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006226 {
6227 return gl::error(GL_OUT_OF_MEMORY);
6228 }
6229}
6230
6231void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
6232{
6233 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
6234
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006235 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006236 {
6237 gl::Context *context = gl::getNonLostContext();
6238
6239 if (context)
6240 {
6241 if (context->getClientVersion() < 3)
6242 {
6243 return gl::error(GL_INVALID_OPERATION);
6244 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006245
Geoff Lang37dde692014-01-31 16:34:54 -05006246 if (n < 0)
6247 {
6248 return gl::error(GL_INVALID_VALUE);
6249 }
6250
6251 for (GLsizei i = 0; i < n; i++)
6252 {
6253 context->deleteQuery(ids[i]);
6254 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006256 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006257 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006258 {
6259 return gl::error(GL_OUT_OF_MEMORY);
6260 }
6261}
6262
6263GLboolean __stdcall glIsQuery(GLuint id)
6264{
6265 EVENT("(GLuint id = %u)", id);
6266
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006267 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006268 {
6269 gl::Context *context = gl::getNonLostContext();
6270
6271 if (context)
6272 {
6273 if (context->getClientVersion() < 3)
6274 {
6275 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6276 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006277
Geoff Lang37dde692014-01-31 16:34:54 -05006278 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006279 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006280 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006281 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006282 {
6283 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6284 }
6285
6286 return GL_FALSE;
6287}
6288
6289void __stdcall glBeginQuery(GLenum target, GLuint id)
6290{
6291 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
6292
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006293 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006294 {
6295 gl::Context *context = gl::getNonLostContext();
6296
6297 if (context)
6298 {
6299 if (context->getClientVersion() < 3)
6300 {
6301 return gl::error(GL_INVALID_OPERATION);
6302 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006303
Jamie Madilldb2f14c2014-05-13 13:56:30 -04006304 if (!ValidateBeginQuery(context, target, id))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006305 {
Jamie Madilldb2f14c2014-05-13 13:56:30 -04006306 return;
Jamie Madill3641b4b2013-07-26 12:54:59 -04006307 }
Geoff Lang37dde692014-01-31 16:34:54 -05006308 context->beginQuery(target, id);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006309 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006310 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006311 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006312 {
6313 return gl::error(GL_OUT_OF_MEMORY);
6314 }
6315}
6316
6317void __stdcall glEndQuery(GLenum target)
6318{
6319 EVENT("(GLenum target = 0x%X)", target);
6320
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006321 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006322 {
6323 gl::Context *context = gl::getNonLostContext();
6324
6325 if (context)
6326 {
6327 if (context->getClientVersion() < 3)
6328 {
6329 return gl::error(GL_INVALID_OPERATION);
6330 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006331
Jamie Madill45c785d2014-05-13 14:09:34 -04006332 if (!ValidateEndQuery(context, target))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006333 {
Jamie Madill45c785d2014-05-13 14:09:34 -04006334 return;
Jamie Madill3641b4b2013-07-26 12:54:59 -04006335 }
Geoff Lang37dde692014-01-31 16:34:54 -05006336
6337 context->endQuery(target);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006338 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006339 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006340 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006341 {
6342 return gl::error(GL_OUT_OF_MEMORY);
6343 }
6344}
6345
6346void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params)
6347{
6348 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
6349
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006350 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006351 {
6352 gl::Context *context = gl::getNonLostContext();
6353
6354 if (context)
6355 {
6356 if (context->getClientVersion() < 3)
6357 {
6358 return gl::error(GL_INVALID_OPERATION);
6359 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006360
Geoff Lang37dde692014-01-31 16:34:54 -05006361 if (!ValidQueryType(context, target))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006362 {
Geoff Lang37dde692014-01-31 16:34:54 -05006363 return gl::error(GL_INVALID_ENUM);
Jamie Madill3641b4b2013-07-26 12:54:59 -04006364 }
Geoff Lang37dde692014-01-31 16:34:54 -05006365
6366 switch (pname)
Jamie Madill3641b4b2013-07-26 12:54:59 -04006367 {
Geoff Lang37dde692014-01-31 16:34:54 -05006368 case GL_CURRENT_QUERY:
Jamie Madill45c785d2014-05-13 14:09:34 -04006369 params[0] = static_cast<GLint>(context->getActiveQueryId(target));
Geoff Lang37dde692014-01-31 16:34:54 -05006370 break;
6371
6372 default:
6373 return gl::error(GL_INVALID_ENUM);
Jamie Madill3641b4b2013-07-26 12:54:59 -04006374 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006375 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006376 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006377 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006378 {
6379 return gl::error(GL_OUT_OF_MEMORY);
6380 }
6381}
6382
6383void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
6384{
6385 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
6386
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006387 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006388 {
6389 gl::Context *context = gl::getNonLostContext();
6390
6391 if (context)
6392 {
6393 if (context->getClientVersion() < 3)
6394 {
6395 return gl::error(GL_INVALID_OPERATION);
6396 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006397
Geoff Lang37dde692014-01-31 16:34:54 -05006398 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
6399
6400 if (!queryObject)
6401 {
6402 return gl::error(GL_INVALID_OPERATION);
6403 }
6404
Jamie Madill45c785d2014-05-13 14:09:34 -04006405 if (context->getActiveQueryId(queryObject->getType()) == id)
Geoff Lang37dde692014-01-31 16:34:54 -05006406 {
6407 return gl::error(GL_INVALID_OPERATION);
6408 }
6409
6410 switch(pname)
6411 {
6412 case GL_QUERY_RESULT:
6413 params[0] = queryObject->getResult();
6414 break;
6415 case GL_QUERY_RESULT_AVAILABLE:
6416 params[0] = queryObject->isResultAvailable();
6417 break;
6418 default:
6419 return gl::error(GL_INVALID_ENUM);
6420 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006421 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006422 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006423 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006424 {
6425 return gl::error(GL_OUT_OF_MEMORY);
6426 }
6427}
6428
6429GLboolean __stdcall glUnmapBuffer(GLenum target)
6430{
6431 EVENT("(GLenum target = 0x%X)", target);
6432
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006433 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006434 {
6435 gl::Context *context = gl::getNonLostContext();
6436
6437 if (context)
6438 {
6439 if (context->getClientVersion() < 3)
6440 {
6441 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6442 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006443
Shannon Woodsb3801742014-03-27 14:59:19 -04006444 return glUnmapBufferOES(target);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006445 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006446 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006447 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006448 {
6449 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6450 }
6451
6452 return GL_FALSE;
6453}
6454
6455void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
6456{
6457 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
6458
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006459 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006460 {
6461 gl::Context *context = gl::getNonLostContext();
6462
6463 if (context)
6464 {
6465 if (context->getClientVersion() < 3)
6466 {
6467 return gl::error(GL_INVALID_OPERATION);
6468 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006469
Shannon Woodsb3801742014-03-27 14:59:19 -04006470 glGetBufferPointervOES(target, pname, params);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006471 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006472 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006473 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006474 {
6475 return gl::error(GL_OUT_OF_MEMORY);
6476 }
6477}
6478
6479void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
6480{
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006481 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006482 {
6483 gl::Context *context = gl::getNonLostContext();
6484
6485 if (context)
6486 {
6487 if (context->getClientVersion() < 3)
6488 {
6489 return gl::error(GL_INVALID_OPERATION);
6490 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006491
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00006492 glDrawBuffersEXT(n, bufs);
6493 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006494 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006495 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006496 {
6497 return gl::error(GL_OUT_OF_MEMORY);
6498 }
6499}
6500
6501void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6502{
6503 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6504 location, count, transpose, value);
6505
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006506 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006507 {
6508 gl::Context *context = gl::getNonLostContext();
6509
6510 if (context)
6511 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006512 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006513 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006514 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006515 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006516
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006517 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006518 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006519 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006520 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006521 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006522 {
6523 return gl::error(GL_OUT_OF_MEMORY);
6524 }
6525}
6526
6527void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6528{
6529 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6530 location, count, transpose, value);
6531
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006532 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006533 {
6534 gl::Context *context = gl::getNonLostContext();
6535
6536 if (context)
6537 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006538 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006539 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006540 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006541 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006542
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006543 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006544 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006545 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006546 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006547 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006548 {
6549 return gl::error(GL_OUT_OF_MEMORY);
6550 }
6551}
6552
6553void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6554{
6555 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6556 location, count, transpose, value);
6557
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006558 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006559 {
6560 gl::Context *context = gl::getNonLostContext();
6561
6562 if (context)
6563 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006564 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006565 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006566 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006567 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006568
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006569 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006570 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006571 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006572 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006573 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006574 {
6575 return gl::error(GL_OUT_OF_MEMORY);
6576 }
6577}
6578
6579void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6580{
6581 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6582 location, count, transpose, value);
6583
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006584 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006585 {
6586 gl::Context *context = gl::getNonLostContext();
6587
6588 if (context)
6589 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006590 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006591 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006592 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006593 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006594
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006595 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006596 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006597 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006598 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006599 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006600 {
6601 return gl::error(GL_OUT_OF_MEMORY);
6602 }
6603}
6604
6605void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6606{
6607 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6608 location, count, transpose, value);
6609
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006610 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006611 {
6612 gl::Context *context = gl::getNonLostContext();
6613
6614 if (context)
6615 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006616 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006617 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006618 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006619 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006620
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006621 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006622 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006623 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006624 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006625 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006626 {
6627 return gl::error(GL_OUT_OF_MEMORY);
6628 }
6629}
6630
6631void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6632{
6633 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6634 location, count, transpose, value);
6635
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006636 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637 {
6638 gl::Context *context = gl::getNonLostContext();
6639
6640 if (context)
6641 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006642 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006643 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006644 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006645 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006646
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006647 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006648 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006649 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006650 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006651 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006652 {
6653 return gl::error(GL_OUT_OF_MEMORY);
6654 }
6655}
6656
6657void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
6658{
6659 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
6660 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
6661 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
6662
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006663 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006664 {
6665 gl::Context *context = gl::getNonLostContext();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006666 if (context)
6667 {
6668 if (context->getClientVersion() < 3)
6669 {
6670 return gl::error(GL_INVALID_OPERATION);
6671 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006672
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006673 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
Geoff Lang758d5b22013-06-11 11:42:50 -04006674 dstX0, dstY0, dstX1, dstY1, mask, filter,
6675 false))
6676 {
6677 return;
6678 }
6679
6680 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
6681 mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006682 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006683 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006684 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006685 {
6686 return gl::error(GL_OUT_OF_MEMORY);
6687 }
6688}
6689
6690void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
6691{
6692 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6693 target, samples, internalformat, width, height);
6694
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006695 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006696 {
6697 gl::Context *context = gl::getNonLostContext();
6698
6699 if (context)
6700 {
6701 if (context->getClientVersion() < 3)
6702 {
6703 return gl::error(GL_INVALID_OPERATION);
6704 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006705
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006706 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006707 width, height, false))
6708 {
6709 return;
6710 }
6711
6712 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006713 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006714 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006715 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006716 {
6717 return gl::error(GL_OUT_OF_MEMORY);
6718 }
6719}
6720
6721void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
6722{
6723 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
6724 target, attachment, texture, level, layer);
6725
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006726 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006727 {
6728 gl::Context *context = gl::getNonLostContext();
6729
6730 if (context)
6731 {
Jamie Madill570f7c82014-07-03 10:38:54 -04006732 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
6733 level, layer))
Geoff Lang3ed0c482013-07-25 17:03:18 -04006734 {
6735 return;
6736 }
6737
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05006738 gl::Framebuffer *framebuffer = context->getTargetFramebuffer(target);
6739 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04006740
6741 gl::Texture *textureObject = context->getTexture(texture);
6742 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
6743
6744 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
6745 {
6746 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
6747 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
6748 }
6749 else
6750 {
6751 switch (attachment)
6752 {
Jamie Madill570f7c82014-07-03 10:38:54 -04006753 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
6754 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
6755 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04006756 }
6757 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006758 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006759 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006760 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006761 {
6762 return gl::error(GL_OUT_OF_MEMORY);
6763 }
6764}
6765
6766GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
6767{
6768 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
6769 target, offset, length, access);
6770
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006771 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006772 {
6773 gl::Context *context = gl::getNonLostContext();
6774
6775 if (context)
6776 {
6777 if (context->getClientVersion() < 3)
6778 {
6779 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
6780 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006781
Shannon Woods916e7692014-03-27 16:58:22 -04006782 return glMapBufferRangeEXT(target, offset, length, access);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006783 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006784 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006785 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006786 {
6787 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
6788 }
6789
6790 return NULL;
6791}
6792
6793void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
6794{
6795 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
6796
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006797 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006798 {
6799 gl::Context *context = gl::getNonLostContext();
6800
6801 if (context)
6802 {
6803 if (context->getClientVersion() < 3)
6804 {
6805 return gl::error(GL_INVALID_OPERATION);
6806 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006807
Shannon Woods916e7692014-03-27 16:58:22 -04006808 glFlushMappedBufferRangeEXT(target, offset, length);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006809 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006810 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006811 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006812 {
6813 return gl::error(GL_OUT_OF_MEMORY);
6814 }
6815}
6816
6817void __stdcall glBindVertexArray(GLuint array)
6818{
6819 EVENT("(GLuint array = %u)", array);
6820
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006821 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006822 {
6823 gl::Context *context = gl::getNonLostContext();
6824
6825 if (context)
6826 {
6827 if (context->getClientVersion() < 3)
6828 {
6829 return gl::error(GL_INVALID_OPERATION);
6830 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006831
Jamie Madilld1028542013-07-02 11:57:04 -04006832 gl::VertexArray *vao = context->getVertexArray(array);
6833
6834 if (!vao)
6835 {
6836 // The default VAO should always exist
6837 ASSERT(array != 0);
6838 return gl::error(GL_INVALID_OPERATION);
6839 }
6840
6841 context->bindVertexArray(array);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006842 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006843 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006844 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006845 {
6846 return gl::error(GL_OUT_OF_MEMORY);
6847 }
6848}
6849
6850void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
6851{
6852 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
6853
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006854 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006855 {
6856 gl::Context *context = gl::getNonLostContext();
6857
6858 if (context)
6859 {
6860 if (context->getClientVersion() < 3)
6861 {
6862 return gl::error(GL_INVALID_OPERATION);
6863 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006864
Jamie Madilld1028542013-07-02 11:57:04 -04006865 if (n < 0)
6866 {
6867 return gl::error(GL_INVALID_VALUE);
6868 }
6869
6870 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
6871 {
6872 if (arrays[arrayIndex] != 0)
6873 {
6874 context->deleteVertexArray(arrays[arrayIndex]);
6875 }
6876 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006877 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006878 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006879 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006880 {
6881 return gl::error(GL_OUT_OF_MEMORY);
6882 }
6883}
6884
6885void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
6886{
6887 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
6888
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006889 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006890 {
6891 gl::Context *context = gl::getNonLostContext();
6892
6893 if (context)
6894 {
6895 if (context->getClientVersion() < 3)
6896 {
6897 return gl::error(GL_INVALID_OPERATION);
6898 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006899
Jamie Madilld1028542013-07-02 11:57:04 -04006900 if (n < 0)
6901 {
6902 return gl::error(GL_INVALID_VALUE);
6903 }
6904
6905 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
6906 {
6907 arrays[arrayIndex] = context->createVertexArray();
6908 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006909 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006910 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006911 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006912 {
6913 return gl::error(GL_OUT_OF_MEMORY);
6914 }
6915}
6916
6917GLboolean __stdcall glIsVertexArray(GLuint array)
6918{
6919 EVENT("(GLuint array = %u)", array);
6920
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006921 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006922 {
6923 gl::Context *context = gl::getNonLostContext();
6924
6925 if (context)
6926 {
6927 if (context->getClientVersion() < 3)
6928 {
6929 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6930 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006931
Jamie Madilld1028542013-07-02 11:57:04 -04006932 if (array == 0)
6933 {
6934 return GL_FALSE;
6935 }
6936
6937 gl::VertexArray *vao = context->getVertexArray(array);
6938
6939 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006940 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006941 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006942 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006943 {
6944 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6945 }
6946
6947 return GL_FALSE;
6948}
6949
6950void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
6951{
6952 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6953 target, index, data);
6954
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006955 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006956 {
6957 gl::Context *context = gl::getNonLostContext();
6958
6959 if (context)
6960 {
6961 if (context->getClientVersion() < 3)
6962 {
6963 return gl::error(GL_INVALID_OPERATION);
6964 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006965
Shannon Woods15934d52013-08-19 14:28:49 -04006966 switch (target)
6967 {
6968 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6969 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6970 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
6971 if (index >= context->getMaxTransformFeedbackBufferBindings())
6972 return gl::error(GL_INVALID_VALUE);
6973 break;
6974 case GL_UNIFORM_BUFFER_START:
6975 case GL_UNIFORM_BUFFER_SIZE:
6976 case GL_UNIFORM_BUFFER_BINDING:
6977 if (index >= context->getMaximumCombinedUniformBufferBindings())
6978 return gl::error(GL_INVALID_VALUE);
6979 break;
6980 default:
6981 return gl::error(GL_INVALID_ENUM);
6982 }
6983
6984 if (!(context->getIndexedIntegerv(target, index, data)))
6985 {
6986 GLenum nativeType;
6987 unsigned int numParams = 0;
6988 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
6989 return gl::error(GL_INVALID_ENUM);
6990
6991 if (numParams == 0)
6992 return; // it is known that pname is valid, but there are no parameters to return
6993
6994 if (nativeType == GL_INT_64_ANGLEX)
6995 {
6996 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6997 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6998 GLint64 *int64Params = new GLint64[numParams];
6999
7000 context->getIndexedInteger64v(target, index, int64Params);
7001
7002 for (unsigned int i = 0; i < numParams; ++i)
7003 {
7004 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
7005 data[i] = static_cast<GLint>(clampedValue);
7006 }
7007
7008 delete [] int64Params;
7009 }
7010 else
7011 {
7012 UNREACHABLE();
7013 }
7014 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007015 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007016 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007017 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007018 {
7019 return gl::error(GL_OUT_OF_MEMORY);
7020 }
7021}
7022
7023void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
7024{
7025 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
7026
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007027 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007028 {
7029 gl::Context *context = gl::getNonLostContext();
7030
7031 if (context)
7032 {
7033 if (context->getClientVersion() < 3)
7034 {
7035 return gl::error(GL_INVALID_OPERATION);
7036 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007037
Geoff Langc8058452014-02-03 12:04:11 -05007038 switch (primitiveMode)
7039 {
7040 case GL_TRIANGLES:
7041 case GL_LINES:
7042 case GL_POINTS:
7043 break;
7044 default:
7045 return gl::error(GL_INVALID_ENUM);
7046 }
7047
7048 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
7049 ASSERT(transformFeedback != NULL);
7050
7051 if (transformFeedback->isStarted())
7052 {
7053 return gl::error(GL_INVALID_OPERATION);
7054 }
7055
7056 if (transformFeedback->isPaused())
7057 {
7058 transformFeedback->resume();
7059 }
7060 else
7061 {
7062 transformFeedback->start(primitiveMode);
7063 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007064 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007065 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007066 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007067 {
7068 return gl::error(GL_OUT_OF_MEMORY);
7069 }
7070}
7071
7072void __stdcall glEndTransformFeedback(void)
7073{
7074 EVENT("(void)");
7075
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007076 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007077 {
7078 gl::Context *context = gl::getNonLostContext();
7079
7080 if (context)
7081 {
7082 if (context->getClientVersion() < 3)
7083 {
7084 return gl::error(GL_INVALID_OPERATION);
7085 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007086
Geoff Langc8058452014-02-03 12:04:11 -05007087 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
7088 ASSERT(transformFeedback != NULL);
7089
7090 if (!transformFeedback->isStarted())
7091 {
7092 return gl::error(GL_INVALID_OPERATION);
7093 }
7094
7095 transformFeedback->stop();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007096 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007097 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007098 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007099 {
7100 return gl::error(GL_OUT_OF_MEMORY);
7101 }
7102}
7103
7104void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
7105{
7106 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
7107 target, index, buffer, offset, size);
7108
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007109 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007110 {
7111 gl::Context *context = gl::getNonLostContext();
7112
7113 if (context)
7114 {
7115 if (context->getClientVersion() < 3)
7116 {
7117 return gl::error(GL_INVALID_OPERATION);
7118 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007119
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007120 switch (target)
7121 {
7122 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007123 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007124 {
7125 return gl::error(GL_INVALID_VALUE);
7126 }
7127 break;
7128
7129 case GL_UNIFORM_BUFFER:
7130 if (index >= context->getMaximumCombinedUniformBufferBindings())
7131 {
7132 return gl::error(GL_INVALID_VALUE);
7133 }
7134 break;
7135
7136 default:
7137 return gl::error(GL_INVALID_ENUM);
7138 }
7139
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00007140 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007141 {
7142 return gl::error(GL_INVALID_VALUE);
7143 }
7144
7145 switch (target)
7146 {
7147 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00007148
7149 // size and offset must be a multiple of 4
7150 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
7151 {
7152 return gl::error(GL_INVALID_VALUE);
7153 }
7154
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007155 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
7156 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007157 break;
7158
7159 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00007160
7161 // it is an error to bind an offset not a multiple of the alignment
7162 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
7163 {
7164 return gl::error(GL_INVALID_VALUE);
7165 }
7166
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007167 context->bindIndexedUniformBuffer(buffer, index, offset, size);
7168 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007169 break;
7170
7171 default:
7172 UNREACHABLE();
7173 }
7174 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007175 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007176 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007177 {
7178 return gl::error(GL_OUT_OF_MEMORY);
7179 }
7180}
7181
7182void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
7183{
7184 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
7185 target, index, buffer);
7186
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007187 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007188 {
7189 gl::Context *context = gl::getNonLostContext();
7190
7191 if (context)
7192 {
7193 if (context->getClientVersion() < 3)
7194 {
7195 return gl::error(GL_INVALID_OPERATION);
7196 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007197
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007198 switch (target)
7199 {
7200 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007201 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007202 {
7203 return gl::error(GL_INVALID_VALUE);
7204 }
7205 break;
7206
7207 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007208 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007209 {
7210 return gl::error(GL_INVALID_VALUE);
7211 }
7212 break;
7213
7214 default:
7215 return gl::error(GL_INVALID_ENUM);
7216 }
7217
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007218 switch (target)
7219 {
7220 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00007221 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007222 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007223 break;
7224
7225 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00007226 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007227 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007228 break;
7229
7230 default:
7231 UNREACHABLE();
7232 }
7233 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007234 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007235 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007236 {
7237 return gl::error(GL_OUT_OF_MEMORY);
7238 }
7239}
7240
7241void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
7242{
7243 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
7244 program, count, varyings, bufferMode);
7245
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007246 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007247 {
7248 gl::Context *context = gl::getNonLostContext();
7249
7250 if (context)
7251 {
7252 if (context->getClientVersion() < 3)
7253 {
7254 return gl::error(GL_INVALID_OPERATION);
7255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007256
Geoff Lang48dcae72014-02-05 16:28:24 -05007257 if (count < 0)
7258 {
7259 return gl::error(GL_INVALID_VALUE);
7260 }
7261
7262 switch (bufferMode)
7263 {
7264 case GL_INTERLEAVED_ATTRIBS:
7265 break;
7266 case GL_SEPARATE_ATTRIBS:
7267 if (static_cast<GLuint>(count) > context->getMaxTransformFeedbackBufferBindings())
7268 {
7269 return gl::error(GL_INVALID_VALUE);
7270 }
7271 break;
7272 default:
7273 return gl::error(GL_INVALID_ENUM);
7274 }
7275
7276 if (!gl::ValidProgram(context, program))
7277 {
7278 return;
7279 }
7280
7281 gl::Program *programObject = context->getProgram(program);
7282 ASSERT(programObject);
7283
7284 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007285 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007286 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007287 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007288 {
7289 return gl::error(GL_OUT_OF_MEMORY);
7290 }
7291}
7292
7293void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
7294{
7295 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
7296 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
7297 program, index, bufSize, length, size, type, name);
7298
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007299 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007300 {
7301 gl::Context *context = gl::getNonLostContext();
7302
7303 if (context)
7304 {
7305 if (context->getClientVersion() < 3)
7306 {
7307 return gl::error(GL_INVALID_OPERATION);
7308 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007309
Geoff Lang48dcae72014-02-05 16:28:24 -05007310 if (bufSize < 0)
7311 {
7312 return gl::error(GL_INVALID_VALUE);
7313 }
7314
7315 if (!gl::ValidProgram(context, program))
7316 {
7317 return;
7318 }
7319
7320 gl::Program *programObject = context->getProgram(program);
7321 ASSERT(programObject);
7322
7323 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
7324 {
7325 return gl::error(GL_INVALID_VALUE);
7326 }
7327
7328 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007329 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007330 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007331 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007332 {
7333 return gl::error(GL_OUT_OF_MEMORY);
7334 }
7335}
7336
7337void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
7338{
7339 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
7340 index, size, type, stride, pointer);
7341
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007342 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007343 {
7344 gl::Context *context = gl::getNonLostContext();
7345
7346 if (context)
7347 {
7348 if (context->getClientVersion() < 3)
7349 {
7350 return gl::error(GL_INVALID_OPERATION);
7351 }
7352 }
7353
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007354 if (index >= gl::MAX_VERTEX_ATTRIBS)
7355 {
7356 return gl::error(GL_INVALID_VALUE);
7357 }
7358
7359 if (size < 1 || size > 4)
7360 {
7361 return gl::error(GL_INVALID_VALUE);
7362 }
7363
7364 switch (type)
7365 {
7366 case GL_BYTE:
7367 case GL_UNSIGNED_BYTE:
7368 case GL_SHORT:
7369 case GL_UNSIGNED_SHORT:
7370 case GL_INT:
7371 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007372 case GL_INT_2_10_10_10_REV:
7373 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007374 break;
7375 default:
7376 return gl::error(GL_INVALID_ENUM);
7377 }
7378
7379 if (stride < 0)
7380 {
7381 return gl::error(GL_INVALID_VALUE);
7382 }
7383
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007384 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7385 {
7386 return gl::error(GL_INVALID_OPERATION);
7387 }
7388
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007389 if (context)
7390 {
Jamie Madilld8db8662013-07-02 11:57:04 -04007391 // [OpenGL ES 3.0.2] Section 2.8 page 24:
7392 // An INVALID_OPERATION error is generated when a non-zero vertex array object
7393 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
7394 // and the pointer argument is not NULL.
7395 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL)
7396 {
7397 return gl::error(GL_INVALID_OPERATION);
7398 }
7399
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007400 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
7401 stride, pointer);
7402 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007403 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007404 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007405 {
7406 return gl::error(GL_OUT_OF_MEMORY);
7407 }
7408}
7409
7410void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
7411{
7412 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7413 index, pname, params);
7414
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007415 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007416 {
7417 gl::Context *context = gl::getNonLostContext();
7418
7419 if (context)
7420 {
7421 if (context->getClientVersion() < 3)
7422 {
7423 return gl::error(GL_INVALID_OPERATION);
7424 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007425
Jamie Madilla7d05862013-07-02 11:57:06 -04007426 if (index >= gl::MAX_VERTEX_ATTRIBS)
7427 {
7428 return gl::error(GL_INVALID_VALUE);
7429 }
7430
7431 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
7432
Geoff Lang34dbb6f2013-08-05 15:05:47 -04007433 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
Jamie Madilla7d05862013-07-02 11:57:06 -04007434 {
7435 return;
7436 }
7437
7438 if (pname == GL_CURRENT_VERTEX_ATTRIB)
7439 {
7440 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
7441 for (int i = 0; i < 4; ++i)
7442 {
7443 params[i] = currentValueData.IntValues[i];
7444 }
7445 }
7446 else
7447 {
Brandon Jones5bf98292014-06-06 17:19:38 -07007448 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
Jamie Madilla7d05862013-07-02 11:57:06 -04007449 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007450 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007451 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007452 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007453 {
7454 return gl::error(GL_OUT_OF_MEMORY);
7455 }
7456}
7457
7458void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
7459{
7460 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
7461 index, pname, params);
7462
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007463 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007464 {
7465 gl::Context *context = gl::getNonLostContext();
7466
7467 if (context)
7468 {
7469 if (context->getClientVersion() < 3)
7470 {
7471 return gl::error(GL_INVALID_OPERATION);
7472 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007473
Jamie Madilla7d05862013-07-02 11:57:06 -04007474 if (index >= gl::MAX_VERTEX_ATTRIBS)
7475 {
7476 return gl::error(GL_INVALID_VALUE);
7477 }
7478
7479 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
7480
Geoff Lang34dbb6f2013-08-05 15:05:47 -04007481 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
Jamie Madilla7d05862013-07-02 11:57:06 -04007482 {
7483 return;
7484 }
7485
7486 if (pname == GL_CURRENT_VERTEX_ATTRIB)
7487 {
7488 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
7489 for (int i = 0; i < 4; ++i)
7490 {
7491 params[i] = currentValueData.UnsignedIntValues[i];
7492 }
7493 }
7494 else
7495 {
Brandon Jones5bf98292014-06-06 17:19:38 -07007496 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
Jamie Madilla7d05862013-07-02 11:57:06 -04007497 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007498 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007499 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007500 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007501 {
7502 return gl::error(GL_OUT_OF_MEMORY);
7503 }
7504}
7505
7506void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
7507{
7508 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
7509 index, x, y, z, w);
7510
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007511 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007512 {
7513 gl::Context *context = gl::getNonLostContext();
7514
7515 if (context)
7516 {
7517 if (context->getClientVersion() < 3)
7518 {
7519 return gl::error(GL_INVALID_OPERATION);
7520 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007521
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007522 if (index >= gl::MAX_VERTEX_ATTRIBS)
7523 {
7524 return gl::error(GL_INVALID_VALUE);
7525 }
7526
7527 GLint vals[4] = { x, y, z, w };
7528 context->setVertexAttribi(index, vals);
7529 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007530 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007531 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007532 {
7533 return gl::error(GL_OUT_OF_MEMORY);
7534 }
7535}
7536
7537void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
7538{
7539 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
7540 index, x, y, z, w);
7541
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007542 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007543 {
7544 gl::Context *context = gl::getNonLostContext();
7545
7546 if (context)
7547 {
7548 if (context->getClientVersion() < 3)
7549 {
7550 return gl::error(GL_INVALID_OPERATION);
7551 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007552
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007553 if (index >= gl::MAX_VERTEX_ATTRIBS)
7554 {
7555 return gl::error(GL_INVALID_VALUE);
7556 }
7557
7558 GLuint vals[4] = { x, y, z, w };
7559 context->setVertexAttribu(index, vals);
7560 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007561 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007562 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007563 {
7564 return gl::error(GL_OUT_OF_MEMORY);
7565 }
7566}
7567
7568void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
7569{
7570 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
7571
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007572 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007573 {
7574 gl::Context *context = gl::getNonLostContext();
7575
7576 if (context)
7577 {
7578 if (context->getClientVersion() < 3)
7579 {
7580 return gl::error(GL_INVALID_OPERATION);
7581 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007582
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007583 if (index >= gl::MAX_VERTEX_ATTRIBS)
7584 {
7585 return gl::error(GL_INVALID_VALUE);
7586 }
7587
7588 context->setVertexAttribi(index, v);
7589 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007590 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007591 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007592 {
7593 return gl::error(GL_OUT_OF_MEMORY);
7594 }
7595}
7596
7597void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v)
7598{
7599 EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v);
7600
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007601 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007602 {
7603 gl::Context *context = gl::getNonLostContext();
7604
7605 if (context)
7606 {
7607 if (context->getClientVersion() < 3)
7608 {
7609 return gl::error(GL_INVALID_OPERATION);
7610 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007611
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007612 if (index >= gl::MAX_VERTEX_ATTRIBS)
7613 {
7614 return gl::error(GL_INVALID_VALUE);
7615 }
7616
7617 context->setVertexAttribu(index, v);
7618 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007619 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007620 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007621 {
7622 return gl::error(GL_OUT_OF_MEMORY);
7623 }
7624}
7625
7626void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
7627{
7628 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
7629 program, location, params);
7630
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007631 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007632 {
7633 gl::Context *context = gl::getNonLostContext();
7634
7635 if (context)
7636 {
7637 if (context->getClientVersion() < 3)
7638 {
7639 return gl::error(GL_INVALID_OPERATION);
7640 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007641
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00007642 if (program == 0)
7643 {
7644 return gl::error(GL_INVALID_VALUE);
7645 }
7646
7647 gl::Program *programObject = context->getProgram(program);
7648
7649 if (!programObject || !programObject->isLinked())
7650 {
7651 return gl::error(GL_INVALID_OPERATION);
7652 }
7653
7654 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7655 if (!programBinary)
7656 {
7657 return gl::error(GL_INVALID_OPERATION);
7658 }
7659
7660 if (!programBinary->getUniformuiv(location, NULL, params))
7661 {
7662 return gl::error(GL_INVALID_OPERATION);
7663 }
7664 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007665 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007666 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007667 {
7668 return gl::error(GL_OUT_OF_MEMORY);
7669 }
7670}
7671
7672GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
7673{
7674 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
7675 program, name);
7676
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007677 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007678 {
7679 gl::Context *context = gl::getNonLostContext();
7680
7681 if (context)
7682 {
7683 if (context->getClientVersion() < 3)
7684 {
Jamie Madilld1e78c92013-06-20 11:55:50 -04007685 return gl::error(GL_INVALID_OPERATION, -1);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007686 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007687
Jamie Madilld1e78c92013-06-20 11:55:50 -04007688 if (program == 0)
7689 {
7690 return gl::error(GL_INVALID_VALUE, -1);
7691 }
7692
7693 gl::Program *programObject = context->getProgram(program);
7694
7695 if (!programObject || !programObject->isLinked())
7696 {
7697 return gl::error(GL_INVALID_OPERATION, -1);
7698 }
7699
7700 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7701 if (!programBinary)
7702 {
7703 return gl::error(GL_INVALID_OPERATION, -1);
7704 }
7705
7706 return programBinary->getFragDataLocation(name);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007707 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007708 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007709 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007710 {
7711 return gl::error(GL_OUT_OF_MEMORY, 0);
7712 }
7713
7714 return 0;
7715}
7716
7717void __stdcall glUniform1ui(GLint location, GLuint v0)
7718{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007719 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007720}
7721
7722void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
7723{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007724 const GLuint xy[] = { v0, v1 };
7725 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007726}
7727
7728void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
7729{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007730 const GLuint xyz[] = { v0, v1, v2 };
7731 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007732}
7733
7734void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
7735{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007736 const GLuint xyzw[] = { v0, v1, v2, v3 };
7737 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007738}
7739
7740void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
7741{
7742 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7743 location, count, value);
7744
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007745 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007746 {
7747 gl::Context *context = gl::getNonLostContext();
7748
7749 if (context)
7750 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007751 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007752 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007753 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007754 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007755
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007756 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007757 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007758 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007759 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007760 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007761 {
7762 return gl::error(GL_OUT_OF_MEMORY);
7763 }
7764}
7765
7766void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
7767{
7768 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7769 location, count, value);
7770
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007771 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007772 {
7773 gl::Context *context = gl::getNonLostContext();
7774
7775 if (context)
7776 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007777 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007778 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007779 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007780 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007781
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007782 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007783 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007784 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007785 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007786 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007787 {
7788 return gl::error(GL_OUT_OF_MEMORY);
7789 }
7790}
7791
7792void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
7793{
7794 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
7795 location, count, value);
7796
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007797 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007798 {
7799 gl::Context *context = gl::getNonLostContext();
7800
7801 if (context)
7802 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007803 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007805 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007806 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007807
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007808 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007809 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007810 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007811 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007812 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007813 {
7814 return gl::error(GL_OUT_OF_MEMORY);
7815 }
7816}
7817
7818void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
7819{
7820 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7821 location, count, value);
7822
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007823 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007824 {
7825 gl::Context *context = gl::getNonLostContext();
7826
7827 if (context)
7828 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007829 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007831 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007832 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007833
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007834 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007835 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007836 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007837 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007838 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007839 {
7840 return gl::error(GL_OUT_OF_MEMORY);
7841 }
7842}
7843
7844void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
7845{
7846 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
7847 buffer, drawbuffer, value);
7848
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007849 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007850 {
7851 gl::Context *context = gl::getNonLostContext();
7852
7853 if (context)
7854 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007855 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007856 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007857 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007858 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007859
Geoff Lang42359ca2013-08-21 13:25:17 -04007860 switch (buffer)
7861 {
7862 case GL_COLOR:
7863 if (drawbuffer < 0 || drawbuffer >= static_cast<GLint>(context->getMaximumRenderTargets()))
7864 {
7865 return gl::error(GL_INVALID_VALUE);
7866 }
7867 break;
7868 case GL_STENCIL:
7869 if (drawbuffer != 0)
7870 {
7871 return gl::error(GL_INVALID_VALUE);
7872 }
Geoff Lang8d6a0022014-01-31 16:38:31 -05007873 break;
Geoff Lang42359ca2013-08-21 13:25:17 -04007874 default:
7875 return gl::error(GL_INVALID_ENUM);
7876 }
7877
7878 context->clearBufferiv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007879 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007880 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007881 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007882 {
7883 return gl::error(GL_OUT_OF_MEMORY);
7884 }
7885}
7886
7887void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
7888{
7889 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
7890 buffer, drawbuffer, value);
7891
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007892 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007893 {
7894 gl::Context *context = gl::getNonLostContext();
7895
7896 if (context)
7897 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007898 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007899 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007900 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007901 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007902
Geoff Lang42359ca2013-08-21 13:25:17 -04007903 switch (buffer)
7904 {
7905 case GL_COLOR:
7906 if (drawbuffer < 0 || drawbuffer >= static_cast<GLint>(context->getMaximumRenderTargets()))
7907 {
7908 return gl::error(GL_INVALID_VALUE);
7909 }
7910 break;
7911 default:
7912 return gl::error(GL_INVALID_ENUM);
7913 }
7914
7915 context->clearBufferuiv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007916 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007917 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007918 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007919 {
7920 return gl::error(GL_OUT_OF_MEMORY);
7921 }
7922}
7923
7924void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
7925{
7926 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
7927 buffer, drawbuffer, value);
7928
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007929 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007930 {
7931 gl::Context *context = gl::getNonLostContext();
7932
7933 if (context)
7934 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007935 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007936 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007937 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007938 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007939
Geoff Lang42359ca2013-08-21 13:25:17 -04007940 switch (buffer)
7941 {
7942 case GL_COLOR:
7943 if (drawbuffer < 0 || drawbuffer >= static_cast<GLint>(context->getMaximumRenderTargets()))
7944 {
7945 return gl::error(GL_INVALID_VALUE);
7946 }
7947 break;
7948 case GL_DEPTH:
7949 if (drawbuffer != 0)
7950 {
7951 return gl::error(GL_INVALID_VALUE);
7952 }
7953 break;
7954 default:
7955 return gl::error(GL_INVALID_ENUM);
7956 }
7957
7958 context->clearBufferfv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007959 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007960 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007961 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007962 {
7963 return gl::error(GL_OUT_OF_MEMORY);
7964 }
7965}
7966
7967void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
7968{
7969 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
7970 buffer, drawbuffer, depth, stencil);
7971
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007972 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007973 {
7974 gl::Context *context = gl::getNonLostContext();
7975
7976 if (context)
7977 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007978 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007979 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007980 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007981 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007982
Geoff Lang42359ca2013-08-21 13:25:17 -04007983 switch (buffer)
7984 {
7985 case GL_DEPTH_STENCIL:
7986 if (drawbuffer != 0)
7987 {
7988 return gl::error(GL_INVALID_VALUE);
7989 }
7990 break;
7991 default:
7992 return gl::error(GL_INVALID_ENUM);
7993 }
7994
7995 context->clearBufferfi(buffer, drawbuffer, depth, stencil);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007996 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007997 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007998 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007999 {
8000 return gl::error(GL_OUT_OF_MEMORY);
8001 }
8002}
8003
8004const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
8005{
8006 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
8007
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008008 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008009 {
8010 gl::Context *context = gl::getNonLostContext();
8011
8012 if (context)
8013 {
8014 if (context->getClientVersion() < 3)
8015 {
8016 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
8017 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008018
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00008019 if (name != GL_EXTENSIONS)
8020 {
8021 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
8022 }
8023
Geoff Langcec35902014-04-16 10:52:36 -04008024 if (index >= context->getExtensionStringCount())
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00008025 {
8026 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
8027 }
Geoff Langcec35902014-04-16 10:52:36 -04008028
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00008029 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
8030 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008031 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008032 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008033 {
8034 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
8035 }
8036
8037 return NULL;
8038}
8039
8040void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
8041{
8042 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
8043 readTarget, writeTarget, readOffset, writeOffset, size);
8044
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008045 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008046 {
8047 gl::Context *context = gl::getNonLostContext();
8048
8049 if (context)
8050 {
8051 if (context->getClientVersion() < 3)
8052 {
8053 return gl::error(GL_INVALID_OPERATION);
8054 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008055
Jamie Madill8c96d582014-03-05 15:01:23 -05008056 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008057 {
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008058 return gl::error(GL_INVALID_ENUM);
8059 }
8060
Jamie Madill8c96d582014-03-05 15:01:23 -05008061 gl::Buffer *readBuffer = context->getTargetBuffer(readTarget);
8062 gl::Buffer *writeBuffer = context->getTargetBuffer(writeTarget);
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008063
8064 if (!readBuffer || !writeBuffer)
8065 {
8066 return gl::error(GL_INVALID_OPERATION);
8067 }
8068
Brandon Jonesd38f9262014-06-18 16:26:45 -07008069 if (readBuffer->isMapped() || writeBuffer->isMapped())
Jamie Madill7a5f7382014-03-05 15:01:24 -05008070 {
8071 return gl::error(GL_INVALID_OPERATION);
8072 }
8073
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008074 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
Brandon Jonesd38f9262014-06-18 16:26:45 -07008075 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
8076 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008077 {
8078 return gl::error(GL_INVALID_VALUE);
8079 }
8080
8081 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
8082 {
8083 return gl::error(GL_INVALID_VALUE);
8084 }
8085
8086 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
8087
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00008088 // if size is zero, the copy is a successful no-op
8089 if (size > 0)
8090 {
8091 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
8092 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008093 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008094 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008095 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008096 {
8097 return gl::error(GL_OUT_OF_MEMORY);
8098 }
8099}
8100
8101void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
8102{
8103 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
8104 program, uniformCount, uniformNames, uniformIndices);
8105
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008106 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008107 {
8108 gl::Context *context = gl::getNonLostContext();
8109
8110 if (context)
8111 {
8112 if (context->getClientVersion() < 3)
8113 {
8114 return gl::error(GL_INVALID_OPERATION);
8115 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008116
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00008117 if (uniformCount < 0)
8118 {
8119 return gl::error(GL_INVALID_VALUE);
8120 }
8121
8122 gl::Program *programObject = context->getProgram(program);
8123
8124 if (!programObject)
8125 {
8126 if (context->getShader(program))
8127 {
8128 return gl::error(GL_INVALID_OPERATION);
8129 }
8130 else
8131 {
8132 return gl::error(GL_INVALID_VALUE);
8133 }
8134 }
8135
8136 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8137 if (!programObject->isLinked() || !programBinary)
8138 {
8139 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8140 {
8141 uniformIndices[uniformId] = GL_INVALID_INDEX;
8142 }
8143 }
8144 else
8145 {
8146 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8147 {
8148 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
8149 }
8150 }
8151 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008152 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008153 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008154 {
8155 return gl::error(GL_OUT_OF_MEMORY);
8156 }
8157}
8158
8159void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
8160{
8161 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
8162 program, uniformCount, uniformIndices, pname, params);
8163
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008164 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008165 {
8166 gl::Context *context = gl::getNonLostContext();
8167
8168 if (context)
8169 {
8170 if (context->getClientVersion() < 3)
8171 {
8172 return gl::error(GL_INVALID_OPERATION);
8173 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008174
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00008175 if (uniformCount < 0)
8176 {
8177 return gl::error(GL_INVALID_VALUE);
8178 }
8179
8180 gl::Program *programObject = context->getProgram(program);
8181
8182 if (!programObject)
8183 {
8184 if (context->getShader(program))
8185 {
8186 return gl::error(GL_INVALID_OPERATION);
8187 }
8188 else
8189 {
8190 return gl::error(GL_INVALID_VALUE);
8191 }
8192 }
8193
8194 switch (pname)
8195 {
8196 case GL_UNIFORM_TYPE:
8197 case GL_UNIFORM_SIZE:
8198 case GL_UNIFORM_NAME_LENGTH:
8199 case GL_UNIFORM_BLOCK_INDEX:
8200 case GL_UNIFORM_OFFSET:
8201 case GL_UNIFORM_ARRAY_STRIDE:
8202 case GL_UNIFORM_MATRIX_STRIDE:
8203 case GL_UNIFORM_IS_ROW_MAJOR:
8204 break;
8205 default:
8206 return gl::error(GL_INVALID_ENUM);
8207 }
8208
8209 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8210
8211 if (!programBinary && uniformCount > 0)
8212 {
8213 return gl::error(GL_INVALID_VALUE);
8214 }
8215
8216 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8217 {
8218 const GLuint index = uniformIndices[uniformId];
8219
8220 if (index >= (GLuint)programBinary->getActiveUniformCount())
8221 {
8222 return gl::error(GL_INVALID_VALUE);
8223 }
8224 }
8225
8226 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8227 {
8228 const GLuint index = uniformIndices[uniformId];
8229 params[uniformId] = programBinary->getActiveUniformi(index, pname);
8230 }
8231 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008232 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008233 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008234 {
8235 return gl::error(GL_OUT_OF_MEMORY);
8236 }
8237}
8238
8239GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
8240{
8241 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
8242
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008243 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008244 {
8245 gl::Context *context = gl::getNonLostContext();
8246
8247 if (context)
8248 {
8249 if (context->getClientVersion() < 3)
8250 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00008251 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008252 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008253
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00008254 gl::Program *programObject = context->getProgram(program);
8255
8256 if (!programObject)
8257 {
8258 if (context->getShader(program))
8259 {
8260 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
8261 }
8262 else
8263 {
8264 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
8265 }
8266 }
8267
8268 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8269 if (!programBinary)
8270 {
8271 return GL_INVALID_INDEX;
8272 }
8273
8274 return programBinary->getUniformBlockIndex(uniformBlockName);
8275 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008276 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008277 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008278 {
8279 return gl::error(GL_OUT_OF_MEMORY, 0);
8280 }
8281
8282 return 0;
8283}
8284
8285void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
8286{
8287 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
8288 program, uniformBlockIndex, pname, params);
8289
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008290 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008291 {
8292 gl::Context *context = gl::getNonLostContext();
8293
8294 if (context)
8295 {
8296 if (context->getClientVersion() < 3)
8297 {
8298 return gl::error(GL_INVALID_OPERATION);
8299 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00008300 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008301
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00008302 if (!programObject)
8303 {
8304 if (context->getShader(program))
8305 {
8306 return gl::error(GL_INVALID_OPERATION);
8307 }
8308 else
8309 {
8310 return gl::error(GL_INVALID_VALUE);
8311 }
8312 }
8313
8314 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8315
8316 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8317 {
8318 return gl::error(GL_INVALID_VALUE);
8319 }
8320
8321 switch (pname)
8322 {
8323 case GL_UNIFORM_BLOCK_BINDING:
8324 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
8325 break;
8326
8327 case GL_UNIFORM_BLOCK_DATA_SIZE:
8328 case GL_UNIFORM_BLOCK_NAME_LENGTH:
8329 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
8330 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
8331 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
8332 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
8333 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
8334 break;
8335
8336 default:
8337 return gl::error(GL_INVALID_ENUM);
8338 }
8339 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008340 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008341 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008342 {
8343 return gl::error(GL_OUT_OF_MEMORY);
8344 }
8345}
8346
8347void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
8348{
8349 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
8350 program, uniformBlockIndex, bufSize, length, uniformBlockName);
8351
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008352 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008353 {
8354 gl::Context *context = gl::getNonLostContext();
8355
8356 if (context)
8357 {
8358 if (context->getClientVersion() < 3)
8359 {
8360 return gl::error(GL_INVALID_OPERATION);
8361 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008362
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00008363 gl::Program *programObject = context->getProgram(program);
8364
8365 if (!programObject)
8366 {
8367 if (context->getShader(program))
8368 {
8369 return gl::error(GL_INVALID_OPERATION);
8370 }
8371 else
8372 {
8373 return gl::error(GL_INVALID_VALUE);
8374 }
8375 }
8376
8377 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8378
8379 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8380 {
8381 return gl::error(GL_INVALID_VALUE);
8382 }
8383
8384 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
8385 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008386 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008387 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008388 {
8389 return gl::error(GL_OUT_OF_MEMORY);
8390 }
8391}
8392
8393void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
8394{
8395 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
8396 program, uniformBlockIndex, uniformBlockBinding);
8397
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008398 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008399 {
8400 gl::Context *context = gl::getNonLostContext();
8401
8402 if (context)
8403 {
8404 if (context->getClientVersion() < 3)
8405 {
8406 return gl::error(GL_INVALID_OPERATION);
8407 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008408
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00008409 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
8410 {
8411 return gl::error(GL_INVALID_VALUE);
8412 }
8413
8414 gl::Program *programObject = context->getProgram(program);
8415
8416 if (!programObject)
8417 {
8418 if (context->getShader(program))
8419 {
8420 return gl::error(GL_INVALID_OPERATION);
8421 }
8422 else
8423 {
8424 return gl::error(GL_INVALID_VALUE);
8425 }
8426 }
8427
8428 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8429
8430 // if never linked, there won't be any uniform blocks
8431 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8432 {
8433 return gl::error(GL_INVALID_VALUE);
8434 }
8435
8436 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
8437 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008438 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008439 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008440 {
8441 return gl::error(GL_OUT_OF_MEMORY);
8442 }
8443}
8444
8445void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
8446{
8447 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
8448 mode, first, count, instanceCount);
8449
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008450 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008451 {
8452 gl::Context *context = gl::getNonLostContext();
8453
8454 if (context)
8455 {
8456 if (context->getClientVersion() < 3)
8457 {
8458 return gl::error(GL_INVALID_OPERATION);
8459 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008460
Jamie Madill54133512013-06-21 09:33:07 -04008461 // glDrawArraysInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008462 UNIMPLEMENTED();
8463 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008464 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008465 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008466 {
8467 return gl::error(GL_OUT_OF_MEMORY);
8468 }
8469}
8470
8471void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
8472{
8473 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
8474 mode, count, type, indices, instanceCount);
8475
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008476 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008477 {
8478 gl::Context *context = gl::getNonLostContext();
8479
8480 if (context)
8481 {
8482 if (context->getClientVersion() < 3)
8483 {
8484 return gl::error(GL_INVALID_OPERATION);
8485 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008486
Jamie Madill54133512013-06-21 09:33:07 -04008487 // glDrawElementsInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008488 UNIMPLEMENTED();
8489 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008490 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008491 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008492 {
8493 return gl::error(GL_OUT_OF_MEMORY);
8494 }
8495}
8496
8497GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
8498{
8499 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
8500
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008501 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008502 {
8503 gl::Context *context = gl::getNonLostContext();
8504
8505 if (context)
8506 {
8507 if (context->getClientVersion() < 3)
8508 {
Jamie Madill5215e1a2013-07-26 11:55:19 -04008509 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(0));
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008510 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008511
Jamie Madill5215e1a2013-07-26 11:55:19 -04008512 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
8513 {
8514 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0));
8515 }
8516
8517 if (flags != 0)
8518 {
8519 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0));
8520 }
8521
8522 return context->createFenceSync(condition);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008523 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008524 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008525 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008526 {
8527 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
8528 }
8529
8530 return NULL;
8531}
8532
8533GLboolean __stdcall glIsSync(GLsync sync)
8534{
8535 EVENT("(GLsync sync = 0x%0.8p)", sync);
8536
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008537 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008538 {
8539 gl::Context *context = gl::getNonLostContext();
8540
8541 if (context)
8542 {
8543 if (context->getClientVersion() < 3)
8544 {
8545 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8546 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008547
Jamie Madill5215e1a2013-07-26 11:55:19 -04008548 return (context->getFenceSync(sync) != NULL);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008549 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008550 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008551 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008552 {
8553 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8554 }
8555
8556 return GL_FALSE;
8557}
8558
8559void __stdcall glDeleteSync(GLsync sync)
8560{
8561 EVENT("(GLsync sync = 0x%0.8p)", sync);
8562
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008563 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008564 {
8565 gl::Context *context = gl::getNonLostContext();
8566
8567 if (context)
8568 {
8569 if (context->getClientVersion() < 3)
8570 {
8571 return gl::error(GL_INVALID_OPERATION);
8572 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008573
Jamie Madill5215e1a2013-07-26 11:55:19 -04008574 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
8575 {
8576 return gl::error(GL_INVALID_VALUE);
8577 }
8578
8579 context->deleteFenceSync(sync);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008580 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008581 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008582 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008583 {
8584 return gl::error(GL_OUT_OF_MEMORY);
8585 }
8586}
8587
8588GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
8589{
8590 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
8591 sync, flags, timeout);
8592
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008593 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008594 {
8595 gl::Context *context = gl::getNonLostContext();
8596
8597 if (context)
8598 {
8599 if (context->getClientVersion() < 3)
8600 {
Jamie Madill5215e1a2013-07-26 11:55:19 -04008601 return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008602 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008603
Jamie Madill5215e1a2013-07-26 11:55:19 -04008604 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
8605 {
8606 return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
8607 }
8608
8609 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8610
8611 if (!fenceSync)
8612 {
8613 return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
8614 }
8615
8616 return fenceSync->clientWait(flags, timeout);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008617 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008618 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008619 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008620 {
8621 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8622 }
8623
8624 return GL_FALSE;
8625}
8626
8627void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
8628{
8629 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
8630 sync, flags, timeout);
8631
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008632 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008633 {
8634 gl::Context *context = gl::getNonLostContext();
8635
8636 if (context)
8637 {
8638 if (context->getClientVersion() < 3)
8639 {
8640 return gl::error(GL_INVALID_OPERATION);
8641 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008642
Jamie Madill5215e1a2013-07-26 11:55:19 -04008643 if (flags != 0)
8644 {
8645 return gl::error(GL_INVALID_VALUE);
8646 }
8647
8648 if (timeout != GL_TIMEOUT_IGNORED)
8649 {
8650 return gl::error(GL_INVALID_VALUE);
8651 }
8652
8653 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8654
8655 if (!fenceSync)
8656 {
8657 return gl::error(GL_INVALID_VALUE);
8658 }
8659
8660 fenceSync->serverWait();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008661 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008662 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008663 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008664 {
8665 return gl::error(GL_OUT_OF_MEMORY);
8666 }
8667}
8668
8669void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
8670{
8671 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
8672 pname, params);
8673
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008674 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008675 {
8676 gl::Context *context = gl::getNonLostContext();
8677
8678 if (context)
8679 {
8680 if (context->getClientVersion() < 3)
8681 {
8682 return gl::error(GL_INVALID_OPERATION);
8683 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008684
Jamie Madill79f2f452013-12-19 11:13:02 -05008685 GLenum nativeType;
8686 unsigned int numParams = 0;
Jamie Madill893ab082014-05-16 16:56:10 -04008687 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
8688 {
Jamie Madill79f2f452013-12-19 11:13:02 -05008689 return;
Jamie Madill893ab082014-05-16 16:56:10 -04008690 }
Jamie Madill79f2f452013-12-19 11:13:02 -05008691
8692 if (nativeType == GL_INT_64_ANGLEX)
Jamie Madill71fbd602013-07-19 16:36:55 -04008693 {
Jamie Madill79f2f452013-12-19 11:13:02 -05008694 context->getInteger64v(pname, params);
8695 }
Jamie Madill55856b12014-01-02 13:59:50 -05008696 else
Jamie Madill79f2f452013-12-19 11:13:02 -05008697 {
Jamie Madill55856b12014-01-02 13:59:50 -05008698 CastStateValues(context, nativeType, pname, numParams, params);
Jamie Madill71fbd602013-07-19 16:36:55 -04008699 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008700 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008701 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008702 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008703 {
8704 return gl::error(GL_OUT_OF_MEMORY);
8705 }
8706}
8707
8708void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
8709{
8710 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
8711 sync, pname, bufSize, length, values);
8712
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008713 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008714 {
8715 gl::Context *context = gl::getNonLostContext();
8716
8717 if (context)
8718 {
8719 if (context->getClientVersion() < 3)
8720 {
8721 return gl::error(GL_INVALID_OPERATION);
8722 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008723
Jamie Madill5215e1a2013-07-26 11:55:19 -04008724 if (bufSize < 0)
8725 {
8726 return gl::error(GL_INVALID_VALUE);
8727 }
8728
8729 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8730
8731 if (!fenceSync)
8732 {
8733 return gl::error(GL_INVALID_VALUE);
8734 }
8735
8736 switch (pname)
8737 {
8738 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
8739 case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break;
8740 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
8741 case GL_SYNC_FLAGS: values[0] = 0; break;
8742
8743 default:
8744 return gl::error(GL_INVALID_ENUM);
8745 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008746 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008747 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008748 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008749 {
8750 return gl::error(GL_OUT_OF_MEMORY);
8751 }
8752}
8753
8754void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
8755{
8756 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
8757 target, index, data);
8758
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008759 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008760 {
8761 gl::Context *context = gl::getNonLostContext();
8762
8763 if (context)
8764 {
8765 if (context->getClientVersion() < 3)
8766 {
8767 return gl::error(GL_INVALID_OPERATION);
8768 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008769
Shannon Woods15934d52013-08-19 14:28:49 -04008770 switch (target)
8771 {
8772 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
8773 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
8774 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
8775 if (index >= context->getMaxTransformFeedbackBufferBindings())
8776 return gl::error(GL_INVALID_VALUE);
8777 break;
8778 case GL_UNIFORM_BUFFER_START:
8779 case GL_UNIFORM_BUFFER_SIZE:
8780 case GL_UNIFORM_BUFFER_BINDING:
8781 if (index >= context->getMaximumCombinedUniformBufferBindings())
8782 return gl::error(GL_INVALID_VALUE);
8783 break;
8784 default:
8785 return gl::error(GL_INVALID_ENUM);
8786 }
8787
8788 if (!(context->getIndexedInteger64v(target, index, data)))
8789 {
8790 GLenum nativeType;
8791 unsigned int numParams = 0;
8792 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
8793 return gl::error(GL_INVALID_ENUM);
8794
8795 if (numParams == 0)
8796 return; // it is known that pname is valid, but there are no parameters to return
8797
8798 if (nativeType == GL_INT)
8799 {
8800 GLint *intParams = new GLint[numParams];
8801
8802 context->getIndexedIntegerv(target, index, intParams);
8803
8804 for (unsigned int i = 0; i < numParams; ++i)
8805 {
8806 data[i] = static_cast<GLint64>(intParams[i]);
8807 }
8808
8809 delete [] intParams;
8810 }
8811 else
8812 {
8813 UNREACHABLE();
8814 }
8815 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008816 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008817 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008818 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008819 {
8820 return gl::error(GL_OUT_OF_MEMORY);
8821 }
8822}
8823
8824void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
8825{
8826 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
8827 target, pname, params);
8828
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008829 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008830 {
8831 gl::Context *context = gl::getNonLostContext();
8832
8833 if (context)
8834 {
8835 if (context->getClientVersion() < 3)
8836 {
8837 return gl::error(GL_INVALID_OPERATION);
8838 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008839
Jamie Madill70656a62014-03-05 15:01:26 -05008840 if (!gl::ValidBufferTarget(context, target))
8841 {
8842 return gl::error(GL_INVALID_ENUM);
8843 }
8844
8845 if (!gl::ValidBufferParameter(context, pname))
8846 {
8847 return gl::error(GL_INVALID_ENUM);
8848 }
8849
8850 gl::Buffer *buffer = context->getTargetBuffer(target);
8851
8852 if (!buffer)
8853 {
8854 // A null buffer means that "0" is bound to the requested buffer target
8855 return gl::error(GL_INVALID_OPERATION);
8856 }
8857
8858 switch (pname)
8859 {
8860 case GL_BUFFER_USAGE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008861 *params = static_cast<GLint64>(buffer->getUsage());
Jamie Madill70656a62014-03-05 15:01:26 -05008862 break;
8863 case GL_BUFFER_SIZE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008864 *params = buffer->getSize();
Jamie Madill70656a62014-03-05 15:01:26 -05008865 break;
8866 case GL_BUFFER_ACCESS_FLAGS:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008867 *params = static_cast<GLint64>(buffer->getAccessFlags());
Jamie Madill70656a62014-03-05 15:01:26 -05008868 break;
8869 case GL_BUFFER_MAPPED:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008870 *params = static_cast<GLint64>(buffer->isMapped());
Jamie Madill70656a62014-03-05 15:01:26 -05008871 break;
8872 case GL_BUFFER_MAP_OFFSET:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008873 *params = buffer->getMapOffset();
Jamie Madill70656a62014-03-05 15:01:26 -05008874 break;
8875 case GL_BUFFER_MAP_LENGTH:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008876 *params = buffer->getMapLength();
Jamie Madill70656a62014-03-05 15:01:26 -05008877 break;
8878 default: UNREACHABLE(); break;
8879 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008880 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008881 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008882 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008883 {
8884 return gl::error(GL_OUT_OF_MEMORY);
8885 }
8886}
8887
8888void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
8889{
8890 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
8891
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008892 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008893 {
8894 gl::Context *context = gl::getNonLostContext();
8895
8896 if (context)
8897 {
8898 if (context->getClientVersion() < 3)
8899 {
8900 return gl::error(GL_INVALID_OPERATION);
8901 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008902
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008903 if (count < 0)
8904 {
8905 return gl::error(GL_INVALID_VALUE);
8906 }
8907
8908 for (int i = 0; i < count; i++)
8909 {
8910 samplers[i] = context->createSampler();
8911 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008912 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008913 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008914 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008915 {
8916 return gl::error(GL_OUT_OF_MEMORY);
8917 }
8918}
8919
8920void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
8921{
8922 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
8923
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008924 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008925 {
8926 gl::Context *context = gl::getNonLostContext();
8927
8928 if (context)
8929 {
8930 if (context->getClientVersion() < 3)
8931 {
8932 return gl::error(GL_INVALID_OPERATION);
8933 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008934
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008935 if (count < 0)
8936 {
8937 return gl::error(GL_INVALID_VALUE);
8938 }
8939
8940 for (int i = 0; i < count; i++)
8941 {
8942 context->deleteSampler(samplers[i]);
8943 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008944 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008945 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008946 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008947 {
8948 return gl::error(GL_OUT_OF_MEMORY);
8949 }
8950}
8951
8952GLboolean __stdcall glIsSampler(GLuint sampler)
8953{
8954 EVENT("(GLuint sampler = %u)", sampler);
8955
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008956 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008957 {
8958 gl::Context *context = gl::getNonLostContext();
8959
8960 if (context)
8961 {
8962 if (context->getClientVersion() < 3)
8963 {
8964 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8965 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008966
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008967 return context->isSampler(sampler);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008968 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008969 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008970 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008971 {
8972 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8973 }
8974
8975 return GL_FALSE;
8976}
8977
8978void __stdcall glBindSampler(GLuint unit, GLuint sampler)
8979{
8980 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
8981
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008982 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008983 {
8984 gl::Context *context = gl::getNonLostContext();
8985
8986 if (context)
8987 {
8988 if (context->getClientVersion() < 3)
8989 {
8990 return gl::error(GL_INVALID_OPERATION);
8991 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008992
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008993 if (sampler != 0 && !context->isSampler(sampler))
8994 {
8995 return gl::error(GL_INVALID_OPERATION);
8996 }
8997
8998 if (unit >= context->getMaximumCombinedTextureImageUnits())
8999 {
9000 return gl::error(GL_INVALID_VALUE);
9001 }
9002
9003 context->bindSampler(unit, sampler);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009004 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009005 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009006 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009007 {
9008 return gl::error(GL_OUT_OF_MEMORY);
9009 }
9010}
9011
9012void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
9013{
9014 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
9015
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009016 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009017 {
9018 gl::Context *context = gl::getNonLostContext();
9019
9020 if (context)
9021 {
9022 if (context->getClientVersion() < 3)
9023 {
9024 return gl::error(GL_INVALID_OPERATION);
9025 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009026
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009027 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009028 {
9029 return;
9030 }
9031
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009032 if (!gl::ValidateTexParamParameters(context, pname, param))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009033 {
9034 return;
9035 }
9036
9037 if (!context->isSampler(sampler))
9038 {
9039 return gl::error(GL_INVALID_OPERATION);
9040 }
9041
9042 context->samplerParameteri(sampler, pname, param);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009043 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009044 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009045 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009046 {
9047 return gl::error(GL_OUT_OF_MEMORY);
9048 }
9049}
9050
9051void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
9052{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009053 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009054}
9055
9056void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
9057{
9058 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
9059
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009060 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009061 {
9062 gl::Context *context = gl::getNonLostContext();
9063
9064 if (context)
9065 {
9066 if (context->getClientVersion() < 3)
9067 {
9068 return gl::error(GL_INVALID_OPERATION);
9069 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009070
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009071 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009072 {
9073 return;
9074 }
9075
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009076 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009077 {
9078 return;
9079 }
9080
9081 if (!context->isSampler(sampler))
9082 {
9083 return gl::error(GL_INVALID_OPERATION);
9084 }
9085
9086 context->samplerParameterf(sampler, pname, param);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009087 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009088 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009089 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009090 {
9091 return gl::error(GL_OUT_OF_MEMORY);
9092 }
9093}
9094
9095void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
9096{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009097 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009098}
9099
9100void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
9101{
9102 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
9103
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009104 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009105 {
9106 gl::Context *context = gl::getNonLostContext();
9107
9108 if (context)
9109 {
9110 if (context->getClientVersion() < 3)
9111 {
9112 return gl::error(GL_INVALID_OPERATION);
9113 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009114
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009115 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009116 {
9117 return;
9118 }
9119
9120 if (!context->isSampler(sampler))
9121 {
9122 return gl::error(GL_INVALID_OPERATION);
9123 }
9124
9125 *params = context->getSamplerParameteri(sampler, pname);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009126 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009127 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009128 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009129 {
9130 return gl::error(GL_OUT_OF_MEMORY);
9131 }
9132}
9133
9134void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
9135{
9136 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
9137
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009138 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009139 {
9140 gl::Context *context = gl::getNonLostContext();
9141
9142 if (context)
9143 {
9144 if (context->getClientVersion() < 3)
9145 {
9146 return gl::error(GL_INVALID_OPERATION);
9147 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009148
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009149 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009150 {
9151 return;
9152 }
9153
9154 if (!context->isSampler(sampler))
9155 {
9156 return gl::error(GL_INVALID_OPERATION);
9157 }
9158
9159 *params = context->getSamplerParameterf(sampler, pname);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009160 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009161 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009162 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009163 {
9164 return gl::error(GL_OUT_OF_MEMORY);
9165 }
9166}
9167
9168void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
9169{
9170 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
9171
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009172 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009173 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +00009174 if (index >= gl::MAX_VERTEX_ATTRIBS)
9175 {
9176 return gl::error(GL_INVALID_VALUE);
9177 }
9178
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009179 gl::Context *context = gl::getNonLostContext();
9180
9181 if (context)
9182 {
9183 if (context->getClientVersion() < 3)
9184 {
9185 return gl::error(GL_INVALID_OPERATION);
9186 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009187
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +00009188 context->setVertexAttribDivisor(index, divisor);
9189 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009190 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009191 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009192 {
9193 return gl::error(GL_OUT_OF_MEMORY);
9194 }
9195}
9196
9197void __stdcall glBindTransformFeedback(GLenum target, GLuint id)
9198{
9199 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
9200
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009201 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009202 {
9203 gl::Context *context = gl::getNonLostContext();
9204
9205 if (context)
9206 {
9207 if (context->getClientVersion() < 3)
9208 {
9209 return gl::error(GL_INVALID_OPERATION);
9210 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009211
Geoff Langc8058452014-02-03 12:04:11 -05009212 switch (target)
9213 {
9214 case GL_TRANSFORM_FEEDBACK:
9215 {
9216 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
9217 gl::TransformFeedback *curTransformFeedback = context->getCurrentTransformFeedback();
9218 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
9219 {
9220 return gl::error(GL_INVALID_OPERATION);
9221 }
9222
9223 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
9224 if (context->getTransformFeedback(id) == NULL)
9225 {
9226 return gl::error(GL_INVALID_OPERATION);
9227 }
9228
9229 context->bindTransformFeedback(id);
9230 }
9231 break;
9232
9233 default:
9234 return gl::error(GL_INVALID_ENUM);
9235 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009236 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009237 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009238 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009239 {
9240 return gl::error(GL_OUT_OF_MEMORY);
9241 }
9242}
9243
9244void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
9245{
9246 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
9247
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009248 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009249 {
9250 gl::Context *context = gl::getNonLostContext();
9251
9252 if (context)
9253 {
9254 if (context->getClientVersion() < 3)
9255 {
9256 return gl::error(GL_INVALID_OPERATION);
9257 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009258
Geoff Langc8058452014-02-03 12:04:11 -05009259 for (int i = 0; i < n; i++)
9260 {
9261 context->deleteTransformFeedback(ids[i]);
9262 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009263 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009264 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009265 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009266 {
9267 return gl::error(GL_OUT_OF_MEMORY);
9268 }
9269}
9270
9271void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
9272{
9273 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
9274
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009275 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009276 {
9277 gl::Context *context = gl::getNonLostContext();
9278
9279 if (context)
9280 {
9281 if (context->getClientVersion() < 3)
9282 {
9283 return gl::error(GL_INVALID_OPERATION);
9284 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009285
Geoff Langc8058452014-02-03 12:04:11 -05009286 for (int i = 0; i < n; i++)
9287 {
9288 ids[i] = context->createTransformFeedback();
9289 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009290 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009291 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009292 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009293 {
9294 return gl::error(GL_OUT_OF_MEMORY);
9295 }
9296}
9297
9298GLboolean __stdcall glIsTransformFeedback(GLuint id)
9299{
9300 EVENT("(GLuint id = %u)", id);
9301
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009302 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009303 {
9304 gl::Context *context = gl::getNonLostContext();
9305
9306 if (context)
9307 {
9308 if (context->getClientVersion() < 3)
9309 {
9310 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9311 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009312
Geoff Langc8058452014-02-03 12:04:11 -05009313 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009314 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009315 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009316 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009317 {
9318 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9319 }
9320
9321 return GL_FALSE;
9322}
9323
9324void __stdcall glPauseTransformFeedback(void)
9325{
9326 EVENT("(void)");
9327
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009328 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009329 {
9330 gl::Context *context = gl::getNonLostContext();
9331
9332 if (context)
9333 {
9334 if (context->getClientVersion() < 3)
9335 {
9336 return gl::error(GL_INVALID_OPERATION);
9337 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009338
Geoff Langc8058452014-02-03 12:04:11 -05009339 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
9340 ASSERT(transformFeedback != NULL);
9341
9342 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
9343 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
9344 {
9345 return gl::error(GL_INVALID_OPERATION);
9346 }
9347
9348 transformFeedback->pause();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009349 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009350 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009351 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009352 {
9353 return gl::error(GL_OUT_OF_MEMORY);
9354 }
9355}
9356
9357void __stdcall glResumeTransformFeedback(void)
9358{
9359 EVENT("(void)");
9360
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009361 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009362 {
9363 gl::Context *context = gl::getNonLostContext();
9364
9365 if (context)
9366 {
9367 if (context->getClientVersion() < 3)
9368 {
9369 return gl::error(GL_INVALID_OPERATION);
9370 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009371
Geoff Langc8058452014-02-03 12:04:11 -05009372 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
9373 ASSERT(transformFeedback != NULL);
9374
9375 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
9376 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
9377 {
9378 return gl::error(GL_INVALID_OPERATION);
9379 }
9380
9381 transformFeedback->resume();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009382 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009383 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009384 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009385 {
9386 return gl::error(GL_OUT_OF_MEMORY);
9387 }
9388}
9389
9390void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
9391{
9392 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
9393 program, bufSize, length, binaryFormat, binary);
9394
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009395 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009396 {
9397 gl::Context *context = gl::getNonLostContext();
9398
9399 if (context)
9400 {
9401 if (context->getClientVersion() < 3)
9402 {
9403 return gl::error(GL_INVALID_OPERATION);
9404 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009405
Jamie Madill54133512013-06-21 09:33:07 -04009406 // glGetProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009407 UNIMPLEMENTED();
9408 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009409 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009410 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009411 {
9412 return gl::error(GL_OUT_OF_MEMORY);
9413 }
9414}
9415
9416void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
9417{
9418 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
9419 program, binaryFormat, binary, length);
9420
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009421 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009422 {
9423 gl::Context *context = gl::getNonLostContext();
9424
9425 if (context)
9426 {
9427 if (context->getClientVersion() < 3)
9428 {
9429 return gl::error(GL_INVALID_OPERATION);
9430 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009431
Jamie Madill54133512013-06-21 09:33:07 -04009432 // glProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009433 UNIMPLEMENTED();
9434 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009435 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009436 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009437 {
9438 return gl::error(GL_OUT_OF_MEMORY);
9439 }
9440}
9441
9442void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
9443{
9444 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
9445 program, pname, value);
9446
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009447 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009448 {
9449 gl::Context *context = gl::getNonLostContext();
9450
9451 if (context)
9452 {
9453 if (context->getClientVersion() < 3)
9454 {
9455 return gl::error(GL_INVALID_OPERATION);
9456 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009457
Jamie Madill54133512013-06-21 09:33:07 -04009458 // glProgramParameteri
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009459 UNIMPLEMENTED();
9460 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009461 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009462 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009463 {
9464 return gl::error(GL_OUT_OF_MEMORY);
9465 }
9466}
9467
9468void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
9469{
9470 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
9471 target, numAttachments, attachments);
9472
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009473 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009474 {
9475 gl::Context *context = gl::getNonLostContext();
9476
9477 if (context)
9478 {
9479 if (context->getClientVersion() < 3)
9480 {
9481 return gl::error(GL_INVALID_OPERATION);
9482 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009483
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009484 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00009485 {
9486 return;
9487 }
9488
9489 int maxDimension = context->getMaximumRenderbufferDimension();
9490 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
9491 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009492 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009493 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009494 {
9495 return gl::error(GL_OUT_OF_MEMORY);
9496 }
9497}
9498
9499void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
9500{
9501 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
9502 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
9503 target, numAttachments, attachments, x, y, width, height);
9504
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009505 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009506 {
9507 gl::Context *context = gl::getNonLostContext();
9508
9509 if (context)
9510 {
9511 if (context->getClientVersion() < 3)
9512 {
9513 return gl::error(GL_INVALID_OPERATION);
9514 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009515
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009516 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00009517 {
9518 return;
9519 }
9520
9521 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
9522 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009523 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009524 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009525 {
9526 return gl::error(GL_OUT_OF_MEMORY);
9527 }
9528}
9529
9530void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
9531{
9532 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
9533 target, levels, internalformat, width, height);
9534
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009535 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009536 {
9537 gl::Context *context = gl::getNonLostContext();
9538
9539 if (context)
9540 {
9541 if (context->getClientVersion() < 3)
9542 {
9543 return gl::error(GL_INVALID_OPERATION);
9544 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009545
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009546 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009547 {
9548 return;
9549 }
9550
9551 switch (target)
9552 {
9553 case GL_TEXTURE_2D:
9554 {
9555 gl::Texture2D *texture2d = context->getTexture2D();
9556 texture2d->storage(levels, internalformat, width, height);
9557 }
9558 break;
9559
Geoff Lang01c21d22013-09-24 11:52:16 -04009560 case GL_TEXTURE_CUBE_MAP:
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009561 {
9562 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
9563 textureCube->storage(levels, internalformat, width);
9564 }
9565 break;
9566
9567 default:
9568 return gl::error(GL_INVALID_ENUM);
9569 }
9570 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009571 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009572 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009573 {
9574 return gl::error(GL_OUT_OF_MEMORY);
9575 }
9576}
9577
9578void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
9579{
9580 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
9581 "GLsizei height = %d, GLsizei depth = %d)",
9582 target, levels, internalformat, width, height, depth);
9583
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009584 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009585 {
9586 gl::Context *context = gl::getNonLostContext();
9587
9588 if (context)
9589 {
9590 if (context->getClientVersion() < 3)
9591 {
9592 return gl::error(GL_INVALID_OPERATION);
9593 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009594
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009595 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009596 {
9597 return;
9598 }
9599
9600 switch (target)
9601 {
9602 case GL_TEXTURE_3D:
9603 {
9604 gl::Texture3D *texture3d = context->getTexture3D();
9605 texture3d->storage(levels, internalformat, width, height, depth);
9606 }
9607 break;
9608
9609 case GL_TEXTURE_2D_ARRAY:
9610 {
9611 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
9612 texture2darray->storage(levels, internalformat, width, height, depth);
9613 }
9614 break;
9615
9616 default:
Geoff Lang01c21d22013-09-24 11:52:16 -04009617 UNREACHABLE();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009618 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00009619 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009620 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009621 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009622 {
9623 return gl::error(GL_OUT_OF_MEMORY);
9624 }
9625}
9626
9627void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
9628{
9629 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
9630 "GLint* params = 0x%0.8p)",
9631 target, internalformat, pname, bufSize, params);
9632
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009633 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009634 {
9635 gl::Context *context = gl::getNonLostContext();
9636
9637 if (context)
9638 {
9639 if (context->getClientVersion() < 3)
9640 {
9641 return gl::error(GL_INVALID_OPERATION);
9642 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009643
Geoff Langcec35902014-04-16 10:52:36 -04009644 const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(internalformat);
9645 if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering)
Shannon Woods809d2502013-07-08 10:32:18 -04009646 {
9647 return gl::error(GL_INVALID_ENUM);
9648 }
9649
9650 if (target != GL_RENDERBUFFER)
9651 {
9652 return gl::error(GL_INVALID_ENUM);
9653 }
9654
9655 if (bufSize < 0)
9656 {
9657 return gl::error(GL_INVALID_VALUE);
9658 }
9659
9660 switch (pname)
9661 {
9662 case GL_NUM_SAMPLE_COUNTS:
9663 if (bufSize != 0)
9664 *params = context->getNumSampleCounts(internalformat);
9665 break;
9666 case GL_SAMPLES:
9667 context->getSampleCounts(internalformat, bufSize, params);
9668 break;
9669 default:
9670 return gl::error(GL_INVALID_ENUM);
9671 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009672 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009673 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009674 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009675 {
9676 return gl::error(GL_OUT_OF_MEMORY);
9677 }
9678}
9679
9680// Extension functions
9681
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009682void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
9683 GLbitfield mask, GLenum filter)
9684{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00009685 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009686 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
9687 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
9688 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
9689
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009690 ANGLE_TRY
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009691 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00009692 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009693
9694 if (context)
9695 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009696 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
Geoff Lang758d5b22013-06-11 11:42:50 -04009697 dstX0, dstY0, dstX1, dstY1, mask, filter,
9698 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009699 {
Geoff Lang758d5b22013-06-11 11:42:50 -04009700 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009701 }
9702
Geoff Lang758d5b22013-06-11 11:42:50 -04009703 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
9704 mask, filter);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009705 }
9706 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009707 ANGLE_CATCH_ALL
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009708 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009709 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009710 }
9711}
9712
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00009713void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
9714 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009715{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00009716 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00009717 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00009718 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009719 target, level, internalformat, width, height, depth, border, format, type, pixels);
9720
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009721 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009722 {
9723 UNIMPLEMENTED(); // FIXME
9724 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009725 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009726 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009727 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009728 }
9729}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00009730
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009731void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
9732 GLenum *binaryFormat, void *binary)
9733{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009734 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 +00009735 program, bufSize, length, binaryFormat, binary);
9736
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009737 ANGLE_TRY
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009738 {
9739 gl::Context *context = gl::getNonLostContext();
9740
9741 if (context)
9742 {
9743 gl::Program *programObject = context->getProgram(program);
9744
daniel@transgaming.com716056c2012-07-24 18:38:59 +00009745 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009746 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009747 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009748 }
9749
9750 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9751
9752 if (!programBinary)
9753 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009754 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009755 }
9756
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009757 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009758 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009759 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009760 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009761
9762 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009763 }
9764 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009765 ANGLE_CATCH_ALL
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009766 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009767 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009768 }
9769}
9770
9771void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
9772 const void *binary, GLint length)
9773{
9774 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
9775 program, binaryFormat, binary, length);
9776
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009777 ANGLE_TRY
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009778 {
9779 gl::Context *context = gl::getNonLostContext();
9780
9781 if (context)
9782 {
9783 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
9784 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009785 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009786 }
9787
9788 gl::Program *programObject = context->getProgram(program);
9789
9790 if (!programObject)
9791 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009792 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009793 }
9794
daniel@transgaming.com95d29422012-07-24 18:36:10 +00009795 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009796 }
9797 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009798 ANGLE_CATCH_ALL
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009799 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009800 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009801 }
9802}
9803
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009804void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
9805{
9806 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
9807
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009808 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009809 {
9810 gl::Context *context = gl::getNonLostContext();
9811
9812 if (context)
9813 {
9814 if (n < 0 || (unsigned int)n > context->getMaximumRenderTargets())
9815 {
9816 return gl::error(GL_INVALID_VALUE);
9817 }
9818
9819 if (context->getDrawFramebufferHandle() == 0)
9820 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009821 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009822 {
9823 return gl::error(GL_INVALID_OPERATION);
9824 }
9825
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009826 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009827 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009828 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009829 }
9830 }
9831 else
9832 {
9833 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
9834 {
9835 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
9836 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
9837 {
9838 return gl::error(GL_INVALID_OPERATION);
9839 }
9840 }
9841 }
9842
9843 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
9844
9845 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
9846 {
9847 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
9848 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009849
9850 for (int colorAttachment = n; colorAttachment < (int)context->getMaximumRenderTargets(); colorAttachment++)
9851 {
9852 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
9853 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009854 }
9855 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009856 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009857 {
9858 return gl::error(GL_OUT_OF_MEMORY);
9859 }
9860}
9861
Shannon Woodsb3801742014-03-27 14:59:19 -04009862void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
9863{
9864 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
9865
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009866 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009867 {
9868 gl::Context *context = gl::getNonLostContext();
9869
9870 if (context)
9871 {
Shannon Woodsb3801742014-03-27 14:59:19 -04009872 if (!gl::ValidBufferTarget(context, target))
9873 {
9874 return gl::error(GL_INVALID_ENUM);
9875 }
9876
9877 if (pname != GL_BUFFER_MAP_POINTER)
9878 {
9879 return gl::error(GL_INVALID_ENUM);
9880 }
9881
9882 gl::Buffer *buffer = context->getTargetBuffer(target);
9883
Brandon Jonesd38f9262014-06-18 16:26:45 -07009884 if (!buffer || !buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009885 {
9886 *params = NULL;
9887 }
Shannon Woods6dc7f362014-06-25 21:12:02 -04009888 else
9889 {
9890 *params = buffer->getMapPointer();
9891 }
Shannon Woodsb3801742014-03-27 14:59:19 -04009892 }
9893 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009894 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009895 {
9896 return gl::error(GL_OUT_OF_MEMORY);
9897 }
9898}
9899
9900void * __stdcall glMapBufferOES(GLenum target, GLenum access)
9901{
9902 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
9903
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009904 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009905 {
9906 gl::Context *context = gl::getNonLostContext();
9907
9908 if (context)
9909 {
9910 if (!gl::ValidBufferTarget(context, target))
9911 {
9912 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9913 }
9914
9915 gl::Buffer *buffer = context->getTargetBuffer(target);
9916
9917 if (buffer == NULL)
9918 {
9919 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9920 }
9921
9922 if (access != GL_WRITE_ONLY_OES)
9923 {
9924 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9925 }
9926
Brandon Jonesd38f9262014-06-18 16:26:45 -07009927 if (buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009928 {
9929 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9930 }
9931
Brandon Jonesd38f9262014-06-18 16:26:45 -07009932 return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
Shannon Woodsb3801742014-03-27 14:59:19 -04009933 }
9934 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009935 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009936 {
9937 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
9938 }
9939
9940 return NULL;
9941}
9942
9943GLboolean __stdcall glUnmapBufferOES(GLenum target)
9944{
9945 EVENT("(GLenum target = 0x%X)", target);
9946
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009947 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009948 {
9949 gl::Context *context = gl::getNonLostContext();
9950
9951 if (context)
9952 {
9953 if (!gl::ValidBufferTarget(context, target))
9954 {
9955 return gl::error(GL_INVALID_ENUM, GL_FALSE);
9956 }
9957
9958 gl::Buffer *buffer = context->getTargetBuffer(target);
9959
Brandon Jonesd38f9262014-06-18 16:26:45 -07009960 if (buffer == NULL || !buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009961 {
9962 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9963 }
9964
9965 // TODO: detect if we had corruption. if so, throw an error and return false.
9966
9967 buffer->unmap();
9968
9969 return GL_TRUE;
9970 }
9971 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009972 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009973 {
9974 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9975 }
9976
9977 return GL_FALSE;
9978}
9979
Shannon Woods916e7692014-03-27 16:58:22 -04009980void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
9981{
9982 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
9983 target, offset, length, access);
9984
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009985 ANGLE_TRY
Shannon Woods916e7692014-03-27 16:58:22 -04009986 {
9987 gl::Context *context = gl::getNonLostContext();
9988
9989 if (context)
9990 {
9991 if (!gl::ValidBufferTarget(context, target))
9992 {
9993 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9994 }
9995
9996 if (offset < 0 || length < 0)
9997 {
9998 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
9999 }
10000
10001 gl::Buffer *buffer = context->getTargetBuffer(target);
10002
10003 if (buffer == NULL)
10004 {
10005 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10006 }
10007
10008 // Check for buffer overflow
10009 size_t offsetSize = static_cast<size_t>(offset);
10010 size_t lengthSize = static_cast<size_t>(length);
10011
10012 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
Brandon Jonesd38f9262014-06-18 16:26:45 -070010013 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
Shannon Woods916e7692014-03-27 16:58:22 -040010014 {
10015 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
10016 }
10017
10018 // Check for invalid bits in the mask
10019 GLbitfield allAccessBits = GL_MAP_READ_BIT |
10020 GL_MAP_WRITE_BIT |
10021 GL_MAP_INVALIDATE_RANGE_BIT |
10022 GL_MAP_INVALIDATE_BUFFER_BIT |
10023 GL_MAP_FLUSH_EXPLICIT_BIT |
10024 GL_MAP_UNSYNCHRONIZED_BIT;
10025
10026 if (access & ~(allAccessBits))
10027 {
10028 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
10029 }
10030
Brandon Jonesd38f9262014-06-18 16:26:45 -070010031 if (length == 0 || buffer->isMapped())
Shannon Woods916e7692014-03-27 16:58:22 -040010032 {
10033 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10034 }
10035
10036 // Check for invalid bit combinations
10037 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
10038 {
10039 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10040 }
10041
10042 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
10043 GL_MAP_INVALIDATE_BUFFER_BIT |
10044 GL_MAP_UNSYNCHRONIZED_BIT;
10045
10046 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
10047 {
10048 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10049 }
10050
10051 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
10052 {
10053 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10054 }
10055
10056 return buffer->mapRange(offset, length, access);
10057 }
10058 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010059 ANGLE_CATCH_ALL
Shannon Woods916e7692014-03-27 16:58:22 -040010060 {
10061 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
10062 }
10063
10064 return NULL;
10065}
10066
10067void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
10068{
10069 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
10070
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010071 ANGLE_TRY
Shannon Woods916e7692014-03-27 16:58:22 -040010072 {
10073 gl::Context *context = gl::getNonLostContext();
10074
10075 if (context)
10076 {
10077 if (offset < 0 || length < 0)
10078 {
10079 return gl::error(GL_INVALID_VALUE);
10080 }
10081
10082 if (!gl::ValidBufferTarget(context, target))
10083 {
10084 return gl::error(GL_INVALID_ENUM);
10085 }
10086
10087 gl::Buffer *buffer = context->getTargetBuffer(target);
10088
10089 if (buffer == NULL)
10090 {
10091 return gl::error(GL_INVALID_OPERATION);
10092 }
10093
Brandon Jonesd38f9262014-06-18 16:26:45 -070010094 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
Shannon Woods916e7692014-03-27 16:58:22 -040010095 {
10096 return gl::error(GL_INVALID_OPERATION);
10097 }
10098
10099 // Check for buffer overflow
10100 size_t offsetSize = static_cast<size_t>(offset);
10101 size_t lengthSize = static_cast<size_t>(length);
10102
10103 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
Brandon Jonesd38f9262014-06-18 16:26:45 -070010104 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
Shannon Woods916e7692014-03-27 16:58:22 -040010105 {
10106 return gl::error(GL_INVALID_VALUE);
10107 }
10108
10109 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
10110 }
10111 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010112 ANGLE_CATCH_ALL
Shannon Woods916e7692014-03-27 16:58:22 -040010113 {
10114 return gl::error(GL_OUT_OF_MEMORY);
10115 }
10116}
10117
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010118__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
10119{
10120 struct Extension
10121 {
10122 const char *name;
10123 __eglMustCastToProperFunctionPointerType address;
10124 };
10125
10126 static const Extension glExtensions[] =
10127 {
10128 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000010129 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000010130 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000010131 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
10132 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
10133 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
10134 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
10135 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
10136 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
10137 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000010138 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000010139 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000010140 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
10141 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
10142 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
10143 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000010144 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
10145 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
10146 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
10147 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
10148 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
10149 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
10150 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000010151 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000010152 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
10153 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
10154 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000010155 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -040010156 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
10157 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
10158 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -040010159 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
10160 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
10161 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010162
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000010163 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010164 {
10165 if (strcmp(procname, glExtensions[ext].name) == 0)
10166 {
10167 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
10168 }
10169 }
10170
10171 return NULL;
10172}
10173
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000010174// Non-public functions used by EGL
10175
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010176bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010177{
10178 EVENT("(egl::Surface* surface = 0x%0.8p)",
10179 surface);
10180
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010181 ANGLE_TRY
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010182 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000010183 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010184
10185 if (context)
10186 {
10187 gl::Texture2D *textureObject = context->getTexture2D();
Geoff Lang32d508e2014-02-11 09:39:48 -050010188 ASSERT(textureObject != NULL);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010189
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010190 if (textureObject->isImmutable())
10191 {
10192 return false;
10193 }
10194
Geoff Lang32d508e2014-02-11 09:39:48 -050010195 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010196 }
10197 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010198 ANGLE_CATCH_ALL
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010199 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000010200 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010201 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010202
10203 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010204}
10205
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000010206}