blob: f5cf7c3304b8dfcf231f3c63fa873fb219dcbf1d [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 ||
Geoff Langaae65a42014-05-26 12:43:44 -04002598 (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments)
Geoff Lang646559f2013-08-15 11:08:15 -04002599 {
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
Jamie Madill3c7fa222014-06-05 13:08:51 -04002609 if (framebufferHandle == 0)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002610 {
Jamie Madill1e3fa742014-06-16 10:34:00 -04002611 if (clientVersion < 3)
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002612 {
Geoff Lang646559f2013-08-15 11:08:15 -04002613 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002614 }
2615
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002616 switch (attachment)
2617 {
Geoff Lang646559f2013-08-15 11:08:15 -04002618 case GL_BACK:
Geoff Lang646559f2013-08-15 11:08:15 -04002619 case GL_DEPTH:
Geoff Lang646559f2013-08-15 11:08:15 -04002620 case GL_STENCIL:
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002621 break;
Geoff Lang646559f2013-08-15 11:08:15 -04002622 default:
2623 return gl::error(GL_INVALID_OPERATION);
2624 }
2625 }
2626 else
2627 {
2628 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
2629 {
Jamie Madille92a3542014-07-03 10:38:58 -04002630 // Valid attachment query
Geoff Lang646559f2013-08-15 11:08:15 -04002631 }
2632 else
2633 {
2634 switch (attachment)
Geoff Lang55ba29c2013-07-11 16:57:53 -04002635 {
Geoff Lang646559f2013-08-15 11:08:15 -04002636 case GL_DEPTH_ATTACHMENT:
Geoff Lang646559f2013-08-15 11:08:15 -04002637 case GL_STENCIL_ATTACHMENT:
Geoff Lang646559f2013-08-15 11:08:15 -04002638 break;
2639 case GL_DEPTH_STENCIL_ATTACHMENT:
Jamie Madille92a3542014-07-03 10:38:58 -04002640 if (framebuffer->hasValidDepthStencil())
Geoff Lang646559f2013-08-15 11:08:15 -04002641 {
2642 return gl::error(GL_INVALID_OPERATION);
2643 }
Geoff Lang646559f2013-08-15 11:08:15 -04002644 break;
2645 default:
Geoff Lang55ba29c2013-07-11 16:57:53 -04002646 return gl::error(GL_INVALID_OPERATION);
2647 }
shannon.woods%transgaming.com@gtempaccount.com89ae1132013-04-13 03:28:43 +00002648 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002649 }
2650
Jamie Madille92a3542014-07-03 10:38:58 -04002651 GLenum attachmentType = GL_NONE;
2652 GLuint attachmentHandle = 0;
2653 GLuint attachmentLevel = 0;
2654 GLuint attachmentLayer = 0;
2655
2656 const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment);
2657
2658 if (attachmentObject)
2659 {
2660 attachmentType = attachmentObject->type();
2661 attachmentHandle = attachmentObject->id();
2662 attachmentLevel = attachmentObject->mipLevel();
2663 attachmentLayer = attachmentObject->layer();
2664 }
2665
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002666 GLenum attachmentObjectType; // Type category
Geoff Lang646559f2013-08-15 11:08:15 -04002667 if (framebufferHandle == 0)
2668 {
2669 attachmentObjectType = GL_FRAMEBUFFER_DEFAULT;
2670 }
2671 else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002672 {
2673 attachmentObjectType = attachmentType;
2674 }
Jamie Madillbb94f342014-06-23 15:23:02 -04002675 else if (gl::ValidTexture2DDestinationTarget(context, attachmentType))
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002676 {
2677 attachmentObjectType = GL_TEXTURE;
2678 }
apatrick@chromium.orga1d80592012-01-25 21:52:10 +00002679 else
2680 {
2681 UNREACHABLE();
2682 return;
2683 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002684
Geoff Lang646559f2013-08-15 11:08:15 -04002685 if (attachmentObjectType == GL_NONE)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002686 {
Geoff Lang646559f2013-08-15 11:08:15 -04002687 // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
2688 // is NONE, then querying any other pname will generate INVALID_ENUM.
2689
2690 // ES 3.0.2 spec pg 235 states that if the attachment type is none,
2691 // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an
2692 // INVALID_OPERATION for all other pnames
2693
2694 switch (pname)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002695 {
Geoff Lang646559f2013-08-15 11:08:15 -04002696 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2697 *params = attachmentObjectType;
2698 break;
2699
2700 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002701 if (clientVersion < 3)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002702 {
Geoff Lang646559f2013-08-15 11:08:15 -04002703 return gl::error(GL_INVALID_ENUM);
2704 }
2705 *params = 0;
2706 break;
2707
2708 default:
Jamie Madill1e3fa742014-06-16 10:34:00 -04002709 if (clientVersion < 3)
Geoff Lang646559f2013-08-15 11:08:15 -04002710 {
2711 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002712 }
2713 else
2714 {
Geoff Lang646559f2013-08-15 11:08:15 -04002715 gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002716 }
2717 }
Geoff Lang646559f2013-08-15 11:08:15 -04002718 }
2719 else
2720 {
2721 ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE ||
2722 attachmentObjectType == GL_FRAMEBUFFER_DEFAULT);
Jamie Madill3c7fa222014-06-05 13:08:51 -04002723 ASSERT(attachmentObject != NULL);
Geoff Lang646559f2013-08-15 11:08:15 -04002724
2725 switch (pname)
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002726 {
Geoff Lang646559f2013-08-15 11:08:15 -04002727 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2728 *params = attachmentObjectType;
2729 break;
2730
2731 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2732 if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE)
2733 {
2734 return gl::error(GL_INVALID_ENUM);
2735 }
2736 *params = attachmentHandle;
2737 break;
2738
2739 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2740 if (attachmentObjectType != GL_TEXTURE)
2741 {
2742 return gl::error(GL_INVALID_ENUM);
2743 }
2744 *params = attachmentLevel;
2745 break;
2746
2747 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2748 if (attachmentObjectType != GL_TEXTURE)
2749 {
2750 return gl::error(GL_INVALID_ENUM);
2751 }
2752 *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0;
2753 break;
2754
2755 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002756 *params = attachmentObject->getRedSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002757 break;
2758
2759 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002760 *params = attachmentObject->getGreenSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002761 break;
2762
2763 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002764 *params = attachmentObject->getBlueSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002765 break;
2766
2767 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002768 *params = attachmentObject->getAlphaSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002769 break;
2770
2771 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002772 *params = attachmentObject->getDepthSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002773 break;
2774
2775 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:
Geoff Lange4a492b2014-06-19 14:14:41 -04002776 *params = attachmentObject->getStencilSize();
Geoff Lang646559f2013-08-15 11:08:15 -04002777 break;
2778
2779 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:
2780 if (attachment == GL_DEPTH_STENCIL)
2781 {
2782 gl::error(GL_INVALID_OPERATION);
2783 }
Geoff Lange4a492b2014-06-19 14:14:41 -04002784 *params = attachmentObject->getComponentType();
Geoff Lang646559f2013-08-15 11:08:15 -04002785 break;
2786
2787 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:
Geoff Lange4a492b2014-06-19 14:14:41 -04002788 *params = attachmentObject->getColorEncoding();
Geoff Lang646559f2013-08-15 11:08:15 -04002789 break;
2790
2791 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:
2792 if (attachmentObjectType != GL_TEXTURE)
2793 {
2794 return gl::error(GL_INVALID_ENUM);
2795 }
2796 *params = attachmentLayer;
2797 break;
2798
2799 default:
2800 UNREACHABLE();
2801 break;
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002802 }
daniel@transgaming.comc46c9c02010-04-23 18:34:55 +00002803 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002804 }
2805 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002806 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002807 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002808 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002809 }
2810}
2811
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002812GLenum __stdcall glGetGraphicsResetStatusEXT(void)
2813{
2814 EVENT("()");
2815
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002816 ANGLE_TRY
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002817 {
2818 gl::Context *context = gl::getContext();
2819
2820 if (context)
2821 {
2822 return context->getResetStatus();
2823 }
2824
2825 return GL_NO_ERROR;
2826 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002827 ANGLE_CATCH_ALL
daniel@transgaming.com17f548c2011-11-09 17:47:02 +00002828 {
2829 return GL_OUT_OF_MEMORY;
2830 }
2831}
2832
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002833void __stdcall glGetIntegerv(GLenum pname, GLint* params)
2834{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002835 EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002836
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002837 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002838 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002839 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002840
2841 if (context)
2842 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002843 GLenum nativeType;
2844 unsigned int numParams = 0;
Jamie Madill79f2f452013-12-19 11:13:02 -05002845
Jamie Madill893ab082014-05-16 16:56:10 -04002846 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
2847 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002848 return;
Jamie Madill893ab082014-05-16 16:56:10 -04002849 }
Jamie Madill79f2f452013-12-19 11:13:02 -05002850
2851 if (nativeType == GL_INT)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002852 {
Jamie Madill79f2f452013-12-19 11:13:02 -05002853 context->getIntegerv(pname, params);
2854 }
Jamie Madill55856b12014-01-02 13:59:50 -05002855 else
Jamie Madill79f2f452013-12-19 11:13:02 -05002856 {
Jamie Madill55856b12014-01-02 13:59:50 -05002857 CastStateValues(context, nativeType, pname, numParams, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002858 }
2859 }
2860 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002861 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002862 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002863 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002864 }
2865}
2866
2867void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params)
2868{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002869 EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002870
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002871 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002872 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002873 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002874
2875 if (context)
2876 {
2877 gl::Program *programObject = context->getProgram(program);
2878
2879 if (!programObject)
2880 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002881 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002882 }
2883
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002884 if (context->getClientVersion() < 3)
2885 {
2886 switch (pname)
2887 {
2888 case GL_ACTIVE_UNIFORM_BLOCKS:
2889 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002890 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2891 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2892 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002893 return gl::error(GL_INVALID_ENUM);
2894 }
2895 }
2896
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002897 switch (pname)
2898 {
2899 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002900 *params = programObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002901 return;
2902 case GL_LINK_STATUS:
daniel@transgaming.com716056c2012-07-24 18:38:59 +00002903 *params = programObject->isLinked();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002904 return;
2905 case GL_VALIDATE_STATUS:
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00002906 *params = programObject->isValidated();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002907 return;
2908 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002909 *params = programObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002910 return;
2911 case GL_ATTACHED_SHADERS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002912 *params = programObject->getAttachedShadersCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002913 return;
2914 case GL_ACTIVE_ATTRIBUTES:
daniel@transgaming.com85423182010-04-22 13:35:27 +00002915 *params = programObject->getActiveAttributeCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002916 return;
2917 case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
daniel@transgaming.com85423182010-04-22 13:35:27 +00002918 *params = programObject->getActiveAttributeMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002919 return;
2920 case GL_ACTIVE_UNIFORMS:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002921 *params = programObject->getActiveUniformCount();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002922 return;
2923 case GL_ACTIVE_UNIFORM_MAX_LENGTH:
daniel@transgaming.com09fbfef2010-04-22 13:35:31 +00002924 *params = programObject->getActiveUniformMaxLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002925 return;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00002926 case GL_PROGRAM_BINARY_LENGTH_OES:
apatrick@chromium.org90080e32012-07-09 22:15:33 +00002927 *params = programObject->getProgramBinaryLength();
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00002928 return;
shannonwoods@chromium.orge684b582013-05-30 00:07:42 +00002929 case GL_ACTIVE_UNIFORM_BLOCKS:
2930 *params = programObject->getActiveUniformBlockCount();
2931 return;
2932 case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH:
2933 *params = programObject->getActiveUniformBlockMaxLength();
2934 break;
Geoff Lang1b6edcb2014-02-03 14:27:56 -05002935 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
2936 *params = programObject->getTransformFeedbackBufferMode();
2937 break;
2938 case GL_TRANSFORM_FEEDBACK_VARYINGS:
2939 *params = programObject->getTransformFeedbackVaryingCount();
2940 break;
2941 case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
2942 *params = programObject->getTransformFeedbackVaryingMaxLength();
2943 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002944 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002945 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002946 }
2947 }
2948 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002949 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002950 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002951 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002952 }
2953}
2954
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00002955void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002956{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00002957 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 +00002958 program, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002959
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002960 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002961 {
2962 if (bufsize < 0)
2963 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002964 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002965 }
2966
daniel@transgaming.com9d788502011-11-09 17:46:55 +00002967 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002968
2969 if (context)
2970 {
2971 gl::Program *programObject = context->getProgram(program);
2972
2973 if (!programObject)
2974 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002975 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00002976 }
2977
2978 programObject->getInfoLog(bufsize, length, infolog);
2979 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002980 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002981 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002982 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00002983 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00002984 }
2985}
2986
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002987void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
2988{
2989 EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
2990
Ehsan Akhgari10530c32014-07-02 20:37:53 -04002991 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002992 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00002993 gl::Context *context = gl::getNonLostContext();
2994
2995 if (context)
2996 {
Geoff Lang37dde692014-01-31 16:34:54 -05002997 if (!ValidQueryType(context, target))
2998 {
2999 return gl::error(GL_INVALID_ENUM);
3000 }
3001
3002 switch (pname)
3003 {
3004 case GL_CURRENT_QUERY_EXT:
Jamie Madill45c785d2014-05-13 14:09:34 -04003005 params[0] = context->getActiveQueryId(target);
Geoff Lang37dde692014-01-31 16:34:54 -05003006 break;
3007
3008 default:
3009 return gl::error(GL_INVALID_ENUM);
3010 }
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003011 }
3012 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003013 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003014 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003015 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003016 }
3017}
3018
3019void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
3020{
3021 EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
3022
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003023 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003024 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003025 gl::Context *context = gl::getNonLostContext();
3026
3027 if (context)
3028 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003029 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
3030
3031 if (!queryObject)
3032 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003033 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003034 }
3035
Jamie Madill45c785d2014-05-13 14:09:34 -04003036 if (context->getActiveQueryId(queryObject->getType()) == id)
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003037 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003038 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003039 }
3040
3041 switch(pname)
3042 {
3043 case GL_QUERY_RESULT_EXT:
3044 params[0] = queryObject->getResult();
3045 break;
3046 case GL_QUERY_RESULT_AVAILABLE_EXT:
3047 params[0] = queryObject->isResultAvailable();
3048 break;
3049 default:
Geoff Lang37dde692014-01-31 16:34:54 -05003050 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003051 }
3052 }
3053 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003054 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003055 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003056 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00003057 }
3058}
3059
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003060void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
3061{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003062 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 +00003063
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003064 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003065 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003066 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003067
3068 if (context)
3069 {
3070 if (target != GL_RENDERBUFFER)
3071 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003072 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003073 }
3074
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003075 if (context->getRenderbufferHandle() == 0)
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003076 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003077 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003078 }
3079
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003080 gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003081
3082 switch (pname)
3083 {
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003084 case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
3085 case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
3086 case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break;
3087 case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
3088 case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
3089 case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
3090 case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
3091 case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
3092 case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003093 case GL_RENDERBUFFER_SAMPLES_ANGLE:
Geoff Langcec35902014-04-16 10:52:36 -04003094 if (!context->getCaps().extensions.framebufferMultisample)
daniel@transgaming.comd2fd4f22011-02-01 18:49:11 +00003095 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003096 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003097 }
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04003098 *params = renderbuffer->getSamples();
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00003099 break;
daniel@transgaming.com4901fca2010-04-20 18:52:41 +00003100 default:
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.com4f39fd92010-03-08 20:26:45 +00003104 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003105 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003106 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003107 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003108 }
3109}
3110
3111void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
3112{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003113 EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003114
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003115 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003116 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003117 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003118
3119 if (context)
3120 {
3121 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00003122
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003123 if (!shaderObject)
3124 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003125 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003126 }
3127
3128 switch (pname)
3129 {
3130 case GL_SHADER_TYPE:
3131 *params = shaderObject->getType();
3132 return;
3133 case GL_DELETE_STATUS:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003134 *params = shaderObject->isFlaggedForDeletion();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003135 return;
3136 case GL_COMPILE_STATUS:
3137 *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
3138 return;
3139 case GL_INFO_LOG_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003140 *params = shaderObject->getInfoLogLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003141 return;
3142 case GL_SHADER_SOURCE_LENGTH:
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003143 *params = shaderObject->getSourceLength();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003144 return;
zmo@google.coma574f782011-10-03 21:45:23 +00003145 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
3146 *params = shaderObject->getTranslatedSourceLength();
3147 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003148 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003149 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003150 }
3151 }
3152 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003153 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003154 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003155 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003156 }
3157}
3158
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003159void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003160{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003161 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 +00003162 shader, bufsize, length, infolog);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003163
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003164 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003165 {
3166 if (bufsize < 0)
3167 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003168 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003169 }
3170
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003171 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003172
3173 if (context)
3174 {
3175 gl::Shader *shaderObject = context->getShader(shader);
3176
3177 if (!shaderObject)
3178 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003179 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003180 }
3181
3182 shaderObject->getInfoLog(bufsize, length, infolog);
3183 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003184 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003185 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003186 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003187 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003188 }
3189}
3190
3191void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
3192{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003193 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 +00003194 shadertype, precisiontype, range, precision);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003195
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003196 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003197 {
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003198 switch (shadertype)
3199 {
3200 case GL_VERTEX_SHADER:
3201 case GL_FRAGMENT_SHADER:
3202 break;
3203 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003204 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003205 }
3206
3207 switch (precisiontype)
3208 {
3209 case GL_LOW_FLOAT:
3210 case GL_MEDIUM_FLOAT:
3211 case GL_HIGH_FLOAT:
3212 // Assume IEEE 754 precision
3213 range[0] = 127;
3214 range[1] = 127;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00003215 *precision = 23;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003216 break;
3217 case GL_LOW_INT:
3218 case GL_MEDIUM_INT:
3219 case GL_HIGH_INT:
3220 // Some (most) hardware only supports single-precision floating-point numbers,
3221 // which can accurately represent integers up to +/-16777216
3222 range[0] = 24;
3223 range[1] = 24;
daniel@transgaming.comc5c15382010-04-23 18:34:49 +00003224 *precision = 0;
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003225 break;
3226 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003227 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com6c785212010-03-30 03:36:17 +00003228 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003229 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003230 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003231 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003232 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003233 }
3234}
3235
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003236void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003237{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003238 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 +00003239 shader, bufsize, length, source);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003240
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003241 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003242 {
3243 if (bufsize < 0)
3244 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003245 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003246 }
3247
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003248 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003249
3250 if (context)
3251 {
3252 gl::Shader *shaderObject = context->getShader(shader);
3253
3254 if (!shaderObject)
3255 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003256 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comcba50572010-03-28 19:36:09 +00003257 }
3258
3259 shaderObject->getSource(bufsize, length, source);
3260 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003261 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003262 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003263 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003264 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003265 }
3266}
3267
zmo@google.coma574f782011-10-03 21:45:23 +00003268void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
3269{
3270 EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
3271 shader, bufsize, length, source);
3272
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003273 ANGLE_TRY
zmo@google.coma574f782011-10-03 21:45:23 +00003274 {
3275 if (bufsize < 0)
3276 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003277 return gl::error(GL_INVALID_VALUE);
zmo@google.coma574f782011-10-03 21:45:23 +00003278 }
3279
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003280 gl::Context *context = gl::getNonLostContext();
zmo@google.coma574f782011-10-03 21:45:23 +00003281
3282 if (context)
3283 {
3284 gl::Shader *shaderObject = context->getShader(shader);
3285
3286 if (!shaderObject)
3287 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003288 return gl::error(GL_INVALID_OPERATION);
zmo@google.coma574f782011-10-03 21:45:23 +00003289 }
3290
3291 shaderObject->getTranslatedSource(bufsize, length, source);
3292 }
3293 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003294 ANGLE_CATCH_ALL
zmo@google.coma574f782011-10-03 21:45:23 +00003295 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003296 return gl::error(GL_OUT_OF_MEMORY);
zmo@google.coma574f782011-10-03 21:45:23 +00003297 }
3298}
3299
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003300const GLubyte* __stdcall glGetString(GLenum name)
3301{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003302 EVENT("(GLenum name = 0x%X)", name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003303
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003304 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003305 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003306 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3e4c6002010-05-05 18:50:13 +00003307
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003308 switch (name)
3309 {
3310 case GL_VENDOR:
daniel@transgaming.coma0ce7e62011-01-25 14:47:16 +00003311 return (GLubyte*)"Google Inc.";
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003312 case GL_RENDERER:
daniel@transgaming.comc23ff642011-08-16 20:28:45 +00003313 return (GLubyte*)((context != NULL) ? context->getRendererString() : "ANGLE");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003314 case GL_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003315 if (context->getClientVersion() == 2)
3316 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003317 return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003318 }
3319 else
3320 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003321 return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003322 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003323 case GL_SHADING_LANGUAGE_VERSION:
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003324 if (context->getClientVersion() == 2)
3325 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003326 return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003327 }
3328 else
3329 {
Jamie Madill0aa84f62014-02-13 13:17:23 -05003330 return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")";
shannonwoods@chromium.orge2865d02013-05-30 00:06:01 +00003331 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003332 case GL_EXTENSIONS:
Geoff Langcec35902014-04-16 10:52:36 -04003333 return (GLubyte*)((context != NULL) ? context->getExtensionString() : "");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003334 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003335 return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003336 }
3337 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003338 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003339 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003340 return gl::error(GL_OUT_OF_MEMORY, (GLubyte*)NULL);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003341 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003342}
3343
3344void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
3345{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003346 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 +00003347
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003348 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003349 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003350 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003351
3352 if (context)
3353 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05003354 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003355
Jamie Madillfb8a8302013-07-03 14:24:12 -04003356 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003357 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003358 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003359 }
3360
3361 switch (pname)
3362 {
3363 case GL_TEXTURE_MAG_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003364 *params = (GLfloat)texture->getSamplerState().magFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003365 break;
3366 case GL_TEXTURE_MIN_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003367 *params = (GLfloat)texture->getSamplerState().minFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003368 break;
3369 case GL_TEXTURE_WRAP_S:
Brandon Jonesa328d562014-07-01 13:52:40 -07003370 *params = (GLfloat)texture->getSamplerState().wrapS;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003371 break;
3372 case GL_TEXTURE_WRAP_T:
Brandon Jonesa328d562014-07-01 13:52:40 -07003373 *params = (GLfloat)texture->getSamplerState().wrapT;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003374 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003375 case GL_TEXTURE_WRAP_R:
3376 if (context->getClientVersion() < 3)
3377 {
3378 return gl::error(GL_INVALID_ENUM);
3379 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003380 *params = (GLfloat)texture->getSamplerState().wrapR;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003381 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003382 case GL_TEXTURE_IMMUTABLE_FORMAT:
3383 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00003384 *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE);
3385 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003386 case GL_TEXTURE_IMMUTABLE_LEVELS:
3387 if (context->getClientVersion() < 3)
3388 {
3389 return gl::error(GL_INVALID_ENUM);
3390 }
Jamie Madill51a94372013-10-24 17:49:43 -04003391 *params = (GLfloat)texture->immutableLevelCount();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003392 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00003393 case GL_TEXTURE_USAGE_ANGLE:
3394 *params = (GLfloat)texture->getUsage();
3395 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003396 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
Geoff Langcec35902014-04-16 10:52:36 -04003397 if (!context->getCaps().extensions.textureFilterAnisotropic)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003398 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003399 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003400 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003401 *params = (GLfloat)texture->getSamplerState().maxAnisotropy;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003402 break;
Geoff Langbc90a482013-09-17 16:51:27 -04003403 case GL_TEXTURE_SWIZZLE_R:
3404 if (context->getClientVersion() < 3)
3405 {
3406 return gl::error(GL_INVALID_ENUM);
3407 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003408 *params = (GLfloat)texture->getSamplerState().swizzleRed;
Geoff Langbc90a482013-09-17 16:51:27 -04003409 break;
3410 case GL_TEXTURE_SWIZZLE_G:
3411 if (context->getClientVersion() < 3)
3412 {
3413 return gl::error(GL_INVALID_ENUM);
3414 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003415 *params = (GLfloat)texture->getSamplerState().swizzleGreen;
Geoff Langbc90a482013-09-17 16:51:27 -04003416 break;
3417 case GL_TEXTURE_SWIZZLE_B:
3418 if (context->getClientVersion() < 3)
3419 {
3420 return gl::error(GL_INVALID_ENUM);
3421 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003422 *params = (GLfloat)texture->getSamplerState().swizzleBlue;
Geoff Langbc90a482013-09-17 16:51:27 -04003423 break;
3424 case GL_TEXTURE_SWIZZLE_A:
3425 if (context->getClientVersion() < 3)
3426 {
3427 return gl::error(GL_INVALID_ENUM);
3428 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003429 *params = (GLfloat)texture->getSamplerState().swizzleAlpha;
Geoff Langbc90a482013-09-17 16:51:27 -04003430 break;
Nicolas Capens8de68282014-04-04 11:10:27 -04003431 case GL_TEXTURE_BASE_LEVEL:
3432 if (context->getClientVersion() < 3)
3433 {
3434 return gl::error(GL_INVALID_ENUM);
3435 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003436 *params = (GLfloat)texture->getSamplerState().baseLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003437 break;
3438 case GL_TEXTURE_MAX_LEVEL:
3439 if (context->getClientVersion() < 3)
3440 {
3441 return gl::error(GL_INVALID_ENUM);
3442 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003443 *params = (GLfloat)texture->getSamplerState().maxLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003444 break;
3445 case GL_TEXTURE_MIN_LOD:
3446 if (context->getClientVersion() < 3)
3447 {
3448 return gl::error(GL_INVALID_ENUM);
3449 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003450 *params = texture->getSamplerState().minLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003451 break;
3452 case GL_TEXTURE_MAX_LOD:
3453 if (context->getClientVersion() < 3)
3454 {
3455 return gl::error(GL_INVALID_ENUM);
3456 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003457 *params = texture->getSamplerState().maxLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003458 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003459 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003460 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003461 }
3462 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003463 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003464 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003465 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003466 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003467 }
3468}
3469
3470void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params)
3471{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003472 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 +00003473
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003474 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003475 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003476 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003477
3478 if (context)
3479 {
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05003480 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003481
Jamie Madillfb8a8302013-07-03 14:24:12 -04003482 if (!texture)
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003483 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003484 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003485 }
3486
3487 switch (pname)
3488 {
3489 case GL_TEXTURE_MAG_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003490 *params = texture->getSamplerState().magFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003491 break;
3492 case GL_TEXTURE_MIN_FILTER:
Brandon Jonesa328d562014-07-01 13:52:40 -07003493 *params = texture->getSamplerState().minFilter;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003494 break;
3495 case GL_TEXTURE_WRAP_S:
Brandon Jonesa328d562014-07-01 13:52:40 -07003496 *params = texture->getSamplerState().wrapS;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003497 break;
3498 case GL_TEXTURE_WRAP_T:
Brandon Jonesa328d562014-07-01 13:52:40 -07003499 *params = texture->getSamplerState().wrapT;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003500 break;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003501 case GL_TEXTURE_WRAP_R:
3502 if (context->getClientVersion() < 3)
3503 {
3504 return gl::error(GL_INVALID_ENUM);
3505 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003506 *params = texture->getSamplerState().wrapR;
shannon.woods%transgaming.com@gtempaccount.com0b3a8df2013-04-13 03:44:51 +00003507 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003508 case GL_TEXTURE_IMMUTABLE_FORMAT:
3509 // Exposed to ES2.0 through EXT_texture_storage, no client version validation.
daniel@transgaming.comd30bd0a2011-11-11 04:10:34 +00003510 *params = texture->isImmutable() ? GL_TRUE : GL_FALSE;
3511 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003512 case GL_TEXTURE_IMMUTABLE_LEVELS:
3513 if (context->getClientVersion() < 3)
3514 {
3515 return gl::error(GL_INVALID_ENUM);
3516 }
Jamie Madill51a94372013-10-24 17:49:43 -04003517 *params = texture->immutableLevelCount();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00003518 break;
daniel@transgaming.com7d18c172011-11-11 04:18:21 +00003519 case GL_TEXTURE_USAGE_ANGLE:
3520 *params = texture->getUsage();
3521 break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003522 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
Geoff Langcec35902014-04-16 10:52:36 -04003523 if (!context->getCaps().extensions.textureFilterAnisotropic)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003524 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003525 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003526 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003527 *params = (GLint)texture->getSamplerState().maxAnisotropy;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00003528 break;
Geoff Langbc90a482013-09-17 16:51:27 -04003529 case GL_TEXTURE_SWIZZLE_R:
3530 if (context->getClientVersion() < 3)
3531 {
3532 return gl::error(GL_INVALID_ENUM);
3533 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003534 *params = texture->getSamplerState().swizzleRed;
Geoff Langbc90a482013-09-17 16:51:27 -04003535 break;
3536 case GL_TEXTURE_SWIZZLE_G:
3537 if (context->getClientVersion() < 3)
3538 {
3539 return gl::error(GL_INVALID_ENUM);
3540 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003541 *params = texture->getSamplerState().swizzleGreen;
Geoff Langbc90a482013-09-17 16:51:27 -04003542 break;
3543 case GL_TEXTURE_SWIZZLE_B:
3544 if (context->getClientVersion() < 3)
3545 {
3546 return gl::error(GL_INVALID_ENUM);
3547 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003548 *params = texture->getSamplerState().swizzleBlue;
Geoff Langbc90a482013-09-17 16:51:27 -04003549 break;
3550 case GL_TEXTURE_SWIZZLE_A:
3551 if (context->getClientVersion() < 3)
3552 {
3553 return gl::error(GL_INVALID_ENUM);
3554 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003555 *params = texture->getSamplerState().swizzleAlpha;
Geoff Langbc90a482013-09-17 16:51:27 -04003556 break;
Nicolas Capens8de68282014-04-04 11:10:27 -04003557 case GL_TEXTURE_BASE_LEVEL:
3558 if (context->getClientVersion() < 3)
3559 {
3560 return gl::error(GL_INVALID_ENUM);
3561 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003562 *params = texture->getSamplerState().baseLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003563 break;
3564 case GL_TEXTURE_MAX_LEVEL:
3565 if (context->getClientVersion() < 3)
3566 {
3567 return gl::error(GL_INVALID_ENUM);
3568 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003569 *params = texture->getSamplerState().maxLevel;
Nicolas Capens8de68282014-04-04 11:10:27 -04003570 break;
3571 case GL_TEXTURE_MIN_LOD:
3572 if (context->getClientVersion() < 3)
3573 {
3574 return gl::error(GL_INVALID_ENUM);
3575 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003576 *params = (GLint)texture->getSamplerState().minLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003577 break;
3578 case GL_TEXTURE_MAX_LOD:
3579 if (context->getClientVersion() < 3)
3580 {
3581 return gl::error(GL_INVALID_ENUM);
3582 }
Brandon Jonesa328d562014-07-01 13:52:40 -07003583 *params = (GLint)texture->getSamplerState().maxLod;
Nicolas Capens8de68282014-04-04 11:10:27 -04003584 break;
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003585 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003586 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5d2bee92010-04-20 18:51:56 +00003587 }
3588 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003589 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003590 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003591 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003592 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003593 }
3594}
3595
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003596void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
3597{
3598 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
3599 program, location, bufSize, params);
3600
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003601 ANGLE_TRY
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003602 {
3603 if (bufSize < 0)
3604 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003605 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003606 }
3607
3608 gl::Context *context = gl::getNonLostContext();
3609
3610 if (context)
3611 {
3612 if (program == 0)
3613 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003614 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003615 }
3616
3617 gl::Program *programObject = context->getProgram(program);
3618
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003619 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003620 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003621 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003622 }
3623
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003624 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3625 if (!programBinary)
3626 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003627 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003628 }
3629
3630 if (!programBinary->getUniformfv(location, &bufSize, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003631 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003632 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003633 }
3634 }
3635 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003636 ANGLE_CATCH_ALL
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003637 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003638 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003639 }
3640}
3641
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003642void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
3643{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003644 EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003645
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003646 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003647 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003648 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003649
3650 if (context)
3651 {
3652 if (program == 0)
3653 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003654 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003655 }
3656
3657 gl::Program *programObject = context->getProgram(program);
3658
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003659 if (!programObject || !programObject->isLinked())
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003660 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003661 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003662 }
3663
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003664 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3665 if (!programBinary)
3666 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003667 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003668 }
3669
3670 if (!programBinary->getUniformfv(location, NULL, params))
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003671 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003672 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003673 }
3674 }
3675 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003676 ANGLE_CATCH_ALL
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003677 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003678 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003679 }
3680}
3681
3682void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
3683{
3684 EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
3685 program, location, bufSize, params);
3686
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003687 ANGLE_TRY
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003688 {
3689 if (bufSize < 0)
3690 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003691 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003692 }
3693
3694 gl::Context *context = gl::getNonLostContext();
3695
3696 if (context)
3697 {
3698 if (program == 0)
3699 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003700 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003701 }
3702
3703 gl::Program *programObject = context->getProgram(program);
3704
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003705 if (!programObject || !programObject->isLinked())
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003706 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003707 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com9a849122011-11-12 03:18:00 +00003708 }
3709
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003710 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3711 if (!programBinary)
3712 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003713 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003714 }
3715
3716 if (!programBinary->getUniformiv(location, &bufSize, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003718 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003719 }
3720 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003721 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003722 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003723 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003724 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003725 }
3726}
3727
3728void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
3729{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003730 EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003731
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003732 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003733 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003734 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003735
3736 if (context)
3737 {
3738 if (program == 0)
3739 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003740 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003741 }
3742
3743 gl::Program *programObject = context->getProgram(program);
3744
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003745 if (!programObject || !programObject->isLinked())
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
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003750 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
3751 if (!programBinary)
3752 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003753 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003754 }
3755
3756 if (!programBinary->getUniformiv(location, NULL, params))
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003757 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003758 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.combb3d9d02010-04-13 03:26:06 +00003759 }
3760 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003761 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003762 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003763 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003764 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003765 }
3766}
3767
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003768int __stdcall glGetUniformLocation(GLuint program, const GLchar* name)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003769{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003770 EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003771
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003772 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003773 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003774 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003775
3776 if (strstr(name, "gl_") == name)
3777 {
3778 return -1;
3779 }
3780
3781 if (context)
3782 {
3783 gl::Program *programObject = context->getProgram(program);
3784
3785 if (!programObject)
3786 {
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003787 if (context->getShader(program))
3788 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003789 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003790 }
3791 else
3792 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003793 return gl::error(GL_INVALID_VALUE, -1);
daniel@transgaming.comd1abe5b2010-04-13 19:53:33 +00003794 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003795 }
3796
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003797 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
daniel@transgaming.com716056c2012-07-24 18:38:59 +00003798 if (!programObject->isLinked() || !programBinary)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003799 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003800 return gl::error(GL_INVALID_OPERATION, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003801 }
3802
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00003803 return programBinary->getUniformLocation(name);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003804 }
3805 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003806 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003807 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003808 return gl::error(GL_OUT_OF_MEMORY, -1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003809 }
3810
3811 return -1;
3812}
3813
3814void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
3815{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003816 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003817
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003818 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003819 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003820 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003821
daniel@transgaming.come0078962010-04-15 20:45:08 +00003822 if (context)
3823 {
3824 if (index >= gl::MAX_VERTEX_ATTRIBS)
3825 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003826 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003827 }
3828
daniel@transgaming.com83921382011-01-08 05:46:00 +00003829 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003830
Geoff Lang34dbb6f2013-08-05 15:05:47 -04003831 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00003832 {
Jamie Madillaff71502013-07-02 11:57:05 -04003833 return;
3834 }
3835
3836 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3837 {
3838 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
3839 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003840 {
Jamie Madillaff71502013-07-02 11:57:05 -04003841 params[i] = currentValueData.FloatValues[i];
daniel@transgaming.come0078962010-04-15 20:45:08 +00003842 }
Jamie Madillaff71502013-07-02 11:57:05 -04003843 }
3844 else
3845 {
Brandon Jones5bf98292014-06-06 17:19:38 -07003846 *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003847 }
3848 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003849 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003850 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003851 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003852 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003853 }
3854}
3855
3856void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
3857{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003858 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003859
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003860 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003861 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003862 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003863
daniel@transgaming.come0078962010-04-15 20:45:08 +00003864 if (context)
3865 {
3866 if (index >= gl::MAX_VERTEX_ATTRIBS)
3867 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003868 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003869 }
3870
daniel@transgaming.com83921382011-01-08 05:46:00 +00003871 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003872
Geoff Lang34dbb6f2013-08-05 15:05:47 -04003873 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
daniel@transgaming.come0078962010-04-15 20:45:08 +00003874 {
Jamie Madillaff71502013-07-02 11:57:05 -04003875 return;
3876 }
3877
3878 if (pname == GL_CURRENT_VERTEX_ATTRIB)
3879 {
3880 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
3881 for (int i = 0; i < 4; ++i)
daniel@transgaming.come0078962010-04-15 20:45:08 +00003882 {
Jamie Madillaff71502013-07-02 11:57:05 -04003883 float currentValue = currentValueData.FloatValues[i];
Jamie Madillaf496912013-07-19 16:36:54 -04003884 params[i] = gl::iround<GLint>(currentValue);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003885 }
Jamie Madillaff71502013-07-02 11:57:05 -04003886 }
3887 else
3888 {
Brandon Jones5bf98292014-06-06 17:19:38 -07003889 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003890 }
3891 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003892 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003893 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003894 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003895 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003896 }
3897}
3898
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00003899void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003900{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003901 EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003902
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003903 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003904 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003905 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003906
daniel@transgaming.come0078962010-04-15 20:45:08 +00003907 if (context)
3908 {
3909 if (index >= gl::MAX_VERTEX_ATTRIBS)
3910 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003911 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003912 }
3913
3914 if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
3915 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003916 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.come0078962010-04-15 20:45:08 +00003917 }
3918
daniel@transgaming.com428d1582010-05-04 03:35:25 +00003919 *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
daniel@transgaming.come0078962010-04-15 20:45:08 +00003920 }
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
3928void __stdcall glHint(GLenum target, GLenum mode)
3929{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003930 EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode);
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 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003934 switch (mode)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003935 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003936 case GL_FASTEST:
3937 case GL_NICEST:
3938 case GL_DONT_CARE:
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003939 break;
3940 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003941 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003942 }
3943
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003944 gl::Context *context = gl::getNonLostContext();
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003945 switch (target)
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003946 {
alokp@chromium.orgd303ef92010-09-09 17:30:15 +00003947 case GL_GENERATE_MIPMAP_HINT:
3948 if (context) context->setGenerateMipmapHint(mode);
3949 break;
3950 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
3951 if (context) context->setFragmentShaderDerivativeHint(mode);
3952 break;
3953 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003954 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com5949aa12010-03-21 04:31:15 +00003955 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003956 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003957 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003958 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003959 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003960 }
3961}
3962
3963GLboolean __stdcall glIsBuffer(GLuint buffer)
3964{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003965 EVENT("(GLuint buffer = %d)", buffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003966
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003967 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003968 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003969 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003970
3971 if (context && buffer)
3972 {
3973 gl::Buffer *bufferObject = context->getBuffer(buffer);
3974
3975 if (bufferObject)
3976 {
3977 return GL_TRUE;
3978 }
3979 }
3980 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003981 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003982 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00003983 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003984 }
3985
3986 return GL_FALSE;
3987}
3988
3989GLboolean __stdcall glIsEnabled(GLenum cap)
3990{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00003991 EVENT("(GLenum cap = 0x%X)", cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003992
Ehsan Akhgari10530c32014-07-02 20:37:53 -04003993 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003994 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00003995 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003996
3997 if (context)
3998 {
Geoff Lang0550d032014-01-30 11:29:07 -05003999 if (!ValidCap(context, cap))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004000 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004001 return gl::error(GL_INVALID_ENUM, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004002 }
Geoff Lang0550d032014-01-30 11:29:07 -05004003
4004 return context->getCap(cap);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004005 }
4006 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004007 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004008 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004009 return gl::error(GL_OUT_OF_MEMORY, false);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004010 }
4011
4012 return false;
4013}
4014
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004015GLboolean __stdcall glIsFenceNV(GLuint fence)
4016{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004017 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004018
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004019 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004020 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004021 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004022
4023 if (context)
4024 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004025 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004026
4027 if (fenceObject == NULL)
4028 {
4029 return GL_FALSE;
4030 }
4031
4032 return fenceObject->isFence();
4033 }
4034 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004035 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004036 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004037 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004038 }
4039
4040 return GL_FALSE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004041}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004042
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004043GLboolean __stdcall glIsFramebuffer(GLuint framebuffer)
4044{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004045 EVENT("(GLuint framebuffer = %d)", framebuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004046
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004047 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004048 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004049 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004050
4051 if (context && framebuffer)
4052 {
4053 gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer);
4054
4055 if (framebufferObject)
4056 {
4057 return GL_TRUE;
4058 }
4059 }
4060 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004061 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004062 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004063 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004064 }
4065
4066 return GL_FALSE;
4067}
4068
4069GLboolean __stdcall glIsProgram(GLuint program)
4070{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004071 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004072
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004073 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004074 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004075 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004076
4077 if (context && program)
4078 {
4079 gl::Program *programObject = context->getProgram(program);
4080
4081 if (programObject)
4082 {
4083 return GL_TRUE;
4084 }
4085 }
4086 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004087 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004088 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004089 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004090 }
4091
4092 return GL_FALSE;
4093}
4094
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004095GLboolean __stdcall glIsQueryEXT(GLuint id)
4096{
4097 EVENT("(GLuint id = %d)", id);
4098
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004099 ANGLE_TRY
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004100 {
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004101 gl::Context *context = gl::getNonLostContext();
4102
4103 if (context)
4104 {
Geoff Lang37dde692014-01-31 16:34:54 -05004105 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004106 }
4107 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004108 ANGLE_CATCH_ALL
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004109 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004110 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com86bdb822012-01-20 18:24:39 +00004111 }
4112
4113 return GL_FALSE;
4114}
4115
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004116GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer)
4117{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004118 EVENT("(GLuint renderbuffer = %d)", renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004119
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004120 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004121 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004122 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004123
4124 if (context && renderbuffer)
4125 {
Jamie Madill6c7b4ad2014-06-16 10:33:59 -04004126 gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004127
4128 if (renderbufferObject)
4129 {
4130 return GL_TRUE;
4131 }
4132 }
4133 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004134 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004135 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004136 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004137 }
4138
4139 return GL_FALSE;
4140}
4141
4142GLboolean __stdcall glIsShader(GLuint shader)
4143{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004144 EVENT("(GLuint shader = %d)", shader);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004145
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004146 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004147 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004148 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004149
4150 if (context && shader)
4151 {
4152 gl::Shader *shaderObject = context->getShader(shader);
4153
4154 if (shaderObject)
4155 {
4156 return GL_TRUE;
4157 }
4158 }
4159 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004160 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004161 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004162 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004163 }
4164
4165 return GL_FALSE;
4166}
4167
4168GLboolean __stdcall glIsTexture(GLuint texture)
4169{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004170 EVENT("(GLuint texture = %d)", texture);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004171
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004172 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004173 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004174 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004175
4176 if (context && texture)
4177 {
4178 gl::Texture *textureObject = context->getTexture(texture);
4179
4180 if (textureObject)
4181 {
4182 return GL_TRUE;
4183 }
4184 }
4185 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004186 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004187 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004188 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004189 }
4190
4191 return GL_FALSE;
4192}
4193
4194void __stdcall glLineWidth(GLfloat width)
4195{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004196 EVENT("(GLfloat width = %f)", width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004197
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004198 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004199 {
4200 if (width <= 0.0f)
4201 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004202 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004203 }
4204
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004205 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com32e58cd2010-03-24 09:44:10 +00004206
4207 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004208 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004209 context->setLineWidth(width);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004210 }
4211 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004212 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004213 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004214 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004215 }
4216}
4217
4218void __stdcall glLinkProgram(GLuint program)
4219{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004220 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004221
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004222 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004223 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004224 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004225
4226 if (context)
4227 {
4228 gl::Program *programObject = context->getProgram(program);
4229
4230 if (!programObject)
4231 {
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004232 if (context->getShader(program))
4233 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004234 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004235 }
4236 else
4237 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004238 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com277b7142010-04-13 03:26:44 +00004239 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004240 }
4241
daniel@transgaming.com95d29422012-07-24 18:36:10 +00004242 context->linkProgram(program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004243 }
4244 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004245 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004246 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004247 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004248 }
4249}
4250
4251void __stdcall glPixelStorei(GLenum pname, GLint param)
4252{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004253 EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004254
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004255 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004256 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004257 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004258
4259 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004260 {
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004261 switch (pname)
4262 {
4263 case GL_UNPACK_ALIGNMENT:
4264 if (param != 1 && param != 2 && param != 4 && param != 8)
4265 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004266 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004267 }
4268
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004269 context->setUnpackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004270 break;
4271
4272 case GL_PACK_ALIGNMENT:
4273 if (param != 1 && param != 2 && param != 4 && param != 8)
4274 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004275 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004276 }
4277
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004278 context->setPackAlignment(param);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004279 break;
4280
bsalomon@google.com56d46ab2011-11-23 14:53:10 +00004281 case GL_PACK_REVERSE_ROW_ORDER_ANGLE:
4282 context->setPackReverseRowOrder(param != 0);
4283 break;
4284
shannonwoods@chromium.orgabf14cc2013-05-30 00:20:58 +00004285 case GL_UNPACK_IMAGE_HEIGHT:
4286 case GL_UNPACK_SKIP_IMAGES:
4287 case GL_UNPACK_ROW_LENGTH:
4288 case GL_UNPACK_SKIP_ROWS:
4289 case GL_UNPACK_SKIP_PIXELS:
4290 case GL_PACK_ROW_LENGTH:
4291 case GL_PACK_SKIP_ROWS:
4292 case GL_PACK_SKIP_PIXELS:
4293 if (context->getClientVersion() < 3)
4294 {
4295 return gl::error(GL_INVALID_ENUM);
4296 }
4297 UNIMPLEMENTED();
4298 break;
4299
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004300 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004301 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com3489e3a2010-03-21 04:31:11 +00004302 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004303 }
4304 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004305 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004306 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004307 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004308 }
4309}
4310
4311void __stdcall glPolygonOffset(GLfloat factor, GLfloat units)
4312{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004313 EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004314
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004315 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004316 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004317 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.comaede6302010-04-29 03:35:48 +00004318
4319 if (context)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004320 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004321 context->setPolygonOffsetParams(factor, units);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004322 }
4323 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004324 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004325 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004326 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004327 }
4328}
4329
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004330void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
4331 GLenum format, GLenum type, GLsizei bufSize,
4332 GLvoid *data)
4333{
4334 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
4335 "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
4336 x, y, width, height, format, type, bufSize, data);
4337
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004338 ANGLE_TRY
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004339 {
4340 if (width < 0 || height < 0 || bufSize < 0)
4341 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004342 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004343 }
4344
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004345 gl::Context *context = gl::getNonLostContext();
4346
4347 if (context)
4348 {
Jamie Madill26e91952014-03-05 15:01:27 -05004349 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
4350 format, type, &bufSize, data))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004351 {
Jamie Madill26e91952014-03-05 15:01:27 -05004352 return;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004353 }
4354
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004355 context->readPixels(x, y, width, height, format, type, &bufSize, data);
4356 }
4357 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004358 ANGLE_CATCH_ALL
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004359 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004360 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004361 }
4362}
4363
4364void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
4365 GLenum format, GLenum type, GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004366{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004367 EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004368 "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004369 x, y, width, height, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004370
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004371 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004372 {
4373 if (width < 0 || height < 0)
4374 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004375 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004376 }
4377
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004378 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004379
4380 if (context)
4381 {
Jamie Madill26e91952014-03-05 15:01:27 -05004382 if (!gl::ValidateReadPixelsParameters(context, x, y, width, height,
4383 format, type, NULL, pixels))
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004384 {
Jamie Madill26e91952014-03-05 15:01:27 -05004385 return;
daniel@transgaming.com42944b02012-09-27 17:45:57 +00004386 }
4387
daniel@transgaming.comb7915a52011-11-12 03:14:20 +00004388 context->readPixels(x, y, width, height, format, type, NULL, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004389 }
4390 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004391 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004392 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004393 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004394 }
4395}
4396
4397void __stdcall glReleaseShaderCompiler(void)
4398{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004399 EVENT("()");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004400
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004401 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004402 {
4403 gl::Shader::releaseCompiler();
4404 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004405 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004406 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004407 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004408 }
4409}
4410
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004411void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004412{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004413 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 +00004414 target, samples, internalformat, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004415
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004416 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004417 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004418 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004419
4420 if (context)
4421 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004422 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
Geoff Lang2e1dcd52013-05-29 10:34:08 -04004423 width, height, true))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00004424 {
Geoff Lang2e1dcd52013-05-29 10:34:08 -04004425 return;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004426 }
shannon.woods%transgaming.com@gtempaccount.com8dce6512013-04-13 03:42:19 +00004427
4428 context->setRenderbufferStorage(width, height, internalformat, samples);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004429 }
4430 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004431 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004432 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004433 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004434 }
4435}
4436
daniel@transgaming.com1f135d82010-08-24 19:20:36 +00004437void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
4438{
4439 glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
4440}
4441
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004442void __stdcall glSampleCoverage(GLclampf value, GLboolean invert)
4443{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00004444 EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004445
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004446 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004447 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004448 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004449
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004450 if (context)
4451 {
daniel@transgaming.coma36f98e2010-05-18 18:51:09 +00004452 context->setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004453 }
4454 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004455 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004456 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004457 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004458 }
4459}
4460
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004461void __stdcall glSetFenceNV(GLuint fence, GLenum condition)
4462{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004463 EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004464
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004465 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004466 {
4467 if (condition != GL_ALL_COMPLETED_NV)
4468 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004469 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004470 }
4471
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004472 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004473
4474 if (context)
4475 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004476 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004477
4478 if (fenceObject == NULL)
4479 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004480 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004481 }
4482
4483 fenceObject->setFence(condition);
4484 }
4485 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004486 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004487 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004488 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004489 }
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004490}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004491
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004492void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
4493{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004494 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 +00004495
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004496 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004497 {
4498 if (width < 0 || height < 0)
4499 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004500 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004501 }
4502
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004503 gl::Context* context = gl::getNonLostContext();
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004504
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004505 if (context)
4506 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004507 context->setScissorParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004508 }
4509 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004510 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004511 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004512 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004513 }
4514}
4515
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004516void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004517{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004518 EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004519 "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00004520 n, shaders, binaryformat, binary, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004521
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004522 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004523 {
daniel@transgaming.comd1f667f2010-04-29 03:38:52 +00004524 // No binary shader formats are supported.
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004525 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004526 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004527 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004528 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004529 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004530 }
4531}
4532
shannon.woods%transgaming.com@gtempaccount.com5f339332013-04-13 03:29:02 +00004533void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004534{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004535 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 +00004536 shader, count, string, length);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004537
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004538 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004539 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004540 if (count < 0)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004541 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004542 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004543 }
4544
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004545 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004546
4547 if (context)
4548 {
4549 gl::Shader *shaderObject = context->getShader(shader);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004550
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004551 if (!shaderObject)
4552 {
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004553 if (context->getProgram(shader))
4554 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004555 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004556 }
4557 else
4558 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004559 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com8e6a6be2010-04-13 03:26:41 +00004560 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004561 }
4562
4563 shaderObject->setSource(count, string, length);
4564 }
4565 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004566 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004567 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004568 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004569 }
4570}
4571
4572void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask)
4573{
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004574 glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004575}
4576
4577void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
4578{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004579 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 +00004580
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004581 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004582 {
4583 switch (face)
4584 {
4585 case GL_FRONT:
4586 case GL_BACK:
4587 case GL_FRONT_AND_BACK:
4588 break;
4589 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004590 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004591 }
4592
4593 switch (func)
4594 {
4595 case GL_NEVER:
4596 case GL_ALWAYS:
4597 case GL_LESS:
4598 case GL_LEQUAL:
4599 case GL_EQUAL:
4600 case GL_GEQUAL:
4601 case GL_GREATER:
4602 case GL_NOTEQUAL:
4603 break;
4604 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004605 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004606 }
4607
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004608 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004609
4610 if (context)
4611 {
4612 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4613 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004614 context->setStencilParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004615 }
4616
4617 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4618 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004619 context->setStencilBackParams(func, ref, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004620 }
4621 }
4622 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004623 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004624 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004625 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004626 }
4627}
4628
4629void __stdcall glStencilMask(GLuint mask)
4630{
4631 glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
4632}
4633
4634void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask)
4635{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004636 EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004637
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004638 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004639 {
4640 switch (face)
4641 {
4642 case GL_FRONT:
4643 case GL_BACK:
4644 case GL_FRONT_AND_BACK:
4645 break;
4646 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004647 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004648 }
4649
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004650 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004651
4652 if (context)
4653 {
4654 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4655 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004656 context->setStencilWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004657 }
4658
4659 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4660 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004661 context->setStencilBackWritemask(mask);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004662 }
4663 }
4664 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004665 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004666 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004667 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004668 }
4669}
4670
4671void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
4672{
4673 glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
4674}
4675
4676void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
4677{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004678 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 +00004679 face, fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004680
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004681 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004682 {
4683 switch (face)
4684 {
4685 case GL_FRONT:
4686 case GL_BACK:
4687 case GL_FRONT_AND_BACK:
4688 break;
4689 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004690 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004691 }
4692
4693 switch (fail)
4694 {
4695 case GL_ZERO:
4696 case GL_KEEP:
4697 case GL_REPLACE:
4698 case GL_INCR:
4699 case GL_DECR:
4700 case GL_INVERT:
4701 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004702 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004703 break;
4704 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004705 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004706 }
4707
4708 switch (zfail)
4709 {
4710 case GL_ZERO:
4711 case GL_KEEP:
4712 case GL_REPLACE:
4713 case GL_INCR:
4714 case GL_DECR:
4715 case GL_INVERT:
4716 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004717 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004718 break;
4719 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004720 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004721 }
4722
4723 switch (zpass)
4724 {
4725 case GL_ZERO:
4726 case GL_KEEP:
4727 case GL_REPLACE:
4728 case GL_INCR:
4729 case GL_DECR:
4730 case GL_INVERT:
4731 case GL_INCR_WRAP:
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +00004732 case GL_DECR_WRAP:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004733 break;
4734 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004735 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004736 }
4737
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004738 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004739
4740 if (context)
4741 {
4742 if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
4743 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004744 context->setStencilOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004745 }
4746
4747 if (face == GL_BACK || face == GL_FRONT_AND_BACK)
4748 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00004749 context->setStencilBackOperations(fail, zfail, zpass);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004750 }
4751 }
4752 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004753 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004754 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004755 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004756 }
4757}
4758
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004759GLboolean __stdcall glTestFenceNV(GLuint fence)
4760{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004761 EVENT("(GLuint fence = %d)", fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004762
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004763 ANGLE_TRY
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004764 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004765 gl::Context *context = gl::getNonLostContext();
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004766
4767 if (context)
4768 {
Jamie Madill33dc8432013-07-26 11:55:05 -04004769 gl::FenceNV *fenceObject = context->getFenceNV(fence);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004770
4771 if (fenceObject == NULL)
4772 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004773 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004774 }
4775
Jamie Madillfb9a7402013-07-26 11:55:01 -04004776 if (fenceObject->isFence() != GL_TRUE)
4777 {
4778 return gl::error(GL_INVALID_OPERATION, GL_TRUE);
4779 }
4780
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004781 return fenceObject->testFence();
4782 }
4783 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004784 ANGLE_CATCH_ALL
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004785 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004786 gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004787 }
4788
4789 return GL_TRUE;
daniel@transgaming.comfe208882010-09-01 15:47:57 +00004790}
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +00004791
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00004792void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
4793 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004794{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004795 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, "
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004796 "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 +00004797 target, level, internalformat, width, height, border, format, type, pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004798
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004799 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004800 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004801 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004802
4803 if (context)
4804 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004805 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004806 !ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004807 0, 0, width, height, border, format, type, pixels))
daniel@transgaming.com32b11442011-11-19 02:42:48 +00004808 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004809 return;
4810 }
4811
4812 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004813 !ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04004814 0, 0, 0, width, height, 1, border, format, type, pixels))
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004815 {
4816 return;
daniel@transgaming.com32b11442011-11-19 02:42:48 +00004817 }
4818
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004819 switch (target)
4820 {
4821 case GL_TEXTURE_2D:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004822 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004823 gl::Texture2D *texture = context->getTexture2D();
Jamie Madill88f18f42013-09-18 14:36:19 -04004824 texture->setImage(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004825 }
4826 break;
4827 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
daniel@transgaming.com5d752f22010-10-07 13:37:20 +00004828 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004829 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004830 texture->setImagePosX(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004831 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004832 break;
4833 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
4834 {
4835 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004836 texture->setImageNegX(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004837 }
4838 break;
4839 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
4840 {
4841 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004842 texture->setImagePosY(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004843 }
4844 break;
4845 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
4846 {
4847 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004848 texture->setImageNegY(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004849 }
4850 break;
4851 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
4852 {
4853 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004854 texture->setImagePosZ(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004855 }
4856 break;
4857 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
4858 {
4859 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04004860 texture->setImageNegZ(level, width, height, internalformat, format, type, context->getUnpackState(), pixels);
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00004861 }
4862 break;
4863 default: UNREACHABLE();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004864 }
4865 }
4866 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004867 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004868 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004869 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004870 }
4871}
4872
4873void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param)
4874{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004875 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param);
4876
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004877 ANGLE_TRY
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004878 {
4879 gl::Context *context = gl::getNonLostContext();
4880
4881 if (context)
4882 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004883 if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
Jamie Madill478fdb22013-07-19 16:36:59 -04004884 {
4885 return;
4886 }
4887
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004888 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004889
Jamie Madillfb8a8302013-07-03 14:24:12 -04004890 if (!texture)
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004891 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004892 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004893 }
4894
4895 switch (pname)
4896 {
Brandon Jonesa328d562014-07-01 13:52:40 -07004897 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break;
4898 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break;
4899 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break;
4900 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break;
4901 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break;
4902 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break;
4903 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getCaps().extensions.maxTextureAnisotropy); break;
4904 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break;
4905 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break;
4906 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break;
4907 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break;
4908 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break;
4909 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break;
4910 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break;
4911 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break;
4912 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break;
4913 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break;
Jamie Madill478fdb22013-07-19 16:36:59 -04004914 default: UNREACHABLE(); break;
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004915 }
4916 }
4917 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004918 ANGLE_CATCH_ALL
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004919 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004920 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004921 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004922}
4923
4924void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params)
4925{
daniel@transgaming.com07ab8412012-07-12 15:17:09 +00004926 glTexParameterf(target, pname, (GLfloat)*params);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004927}
4928
4929void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param)
4930{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00004931 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004932
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004933 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004934 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00004935 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004936
4937 if (context)
4938 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04004939 if (!ValidateTexParamParameters(context, pname, param))
Jamie Madill478fdb22013-07-19 16:36:59 -04004940 {
4941 return;
4942 }
4943
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05004944 gl::Texture *texture = context->getTargetTexture(target);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004945
Jamie Madillfb8a8302013-07-03 14:24:12 -04004946 if (!texture)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004947 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004948 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004949 }
4950
4951 switch (pname)
4952 {
Brandon Jonesa328d562014-07-01 13:52:40 -07004953 case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break;
4954 case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break;
4955 case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break;
4956 case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break;
4957 case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break;
4958 case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break;
4959 case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getCaps().extensions.maxTextureAnisotropy); break;
4960 case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break;
4961 case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break;
4962 case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break;
4963 case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break;
4964 case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break;
4965 case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break;
4966 case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break;
4967 case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break;
4968 case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break;
4969 case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break;
Jamie Madill478fdb22013-07-19 16:36:59 -04004970 default: UNREACHABLE(); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004971 }
4972 }
4973 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004974 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004975 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00004976 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00004977 }
4978}
4979
4980void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params)
4981{
4982 glTexParameteri(target, pname, *params);
4983}
4984
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004985void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
4986{
4987 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
4988 target, levels, internalformat, width, height);
4989
Ehsan Akhgari10530c32014-07-02 20:37:53 -04004990 ANGLE_TRY
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004991 {
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00004992 gl::Context *context = gl::getNonLostContext();
4993
4994 if (context)
4995 {
Geoff Langcec35902014-04-16 10:52:36 -04004996 if (!context->getCaps().extensions.textureStorage)
4997 {
4998 return gl::error(GL_INVALID_OPERATION);
4999 }
5000
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005001 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005002 !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005003 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005004 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005005 }
5006
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005007 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005008 !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005009 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005010 return;
shannonwoods@chromium.org8dcfc6a2013-05-30 00:09:48 +00005011 }
5012
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005013 switch (target)
5014 {
5015 case GL_TEXTURE_2D:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005016 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005017 gl::Texture2D *texture2d = context->getTexture2D();
5018 texture2d->storage(levels, internalformat, width, height);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005019 }
5020 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005021
Geoff Lang01c21d22013-09-24 11:52:16 -04005022 case GL_TEXTURE_CUBE_MAP:
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005023 {
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005024 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
5025 textureCube->storage(levels, internalformat, width);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005026 }
5027 break;
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00005028
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005029 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005030 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com21f05d72011-11-29 19:42:28 +00005031 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005032 }
5033 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005034 ANGLE_CATCH_ALL
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005035 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005036 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +00005037 }
5038}
5039
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005040void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
5041 GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005042{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005043 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005044 "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005045 "const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005046 target, level, xoffset, yoffset, width, height, format, type, pixels);
5047
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005048 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005049 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005050 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005051
5052 if (context)
5053 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005054 if (context->getClientVersion() < 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005055 !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true,
Jamie Madillf67115c2014-04-22 13:14:05 -04005056 xoffset, yoffset, width, height, 0, format, type, pixels))
daniel@transgaming.com1d2d3c42012-05-31 01:14:15 +00005057 {
5058 return;
5059 }
5060
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005061 if (context->getClientVersion() >= 3 &&
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005062 !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
Jamie Madillf67115c2014-04-22 13:14:05 -04005063 xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels))
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005064 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005065 return;
5066 }
5067
Geoff Langc41e42d2014-04-28 10:58:16 -04005068 // Zero sized uploads are valid but no-ops
5069 if (width == 0 || height == 0)
5070 {
5071 return;
5072 }
5073
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005074 switch (target)
5075 {
5076 case GL_TEXTURE_2D:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005077 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005078 gl::Texture2D *texture = context->getTexture2D();
Jamie Madill88f18f42013-09-18 14:36:19 -04005079 texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005080 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005081 break;
5082
5083 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
5084 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
5085 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
5086 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
5087 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
5088 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005089 {
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005090 gl::TextureCubeMap *texture = context->getTextureCubeMap();
Jamie Madill88f18f42013-09-18 14:36:19 -04005091 texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackState(), pixels);
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005092 }
shannonwoods@chromium.orgf3a3eda2013-05-30 00:13:42 +00005093 break;
5094
5095 default:
Geoff Lang01c21d22013-09-24 11:52:16 -04005096 UNREACHABLE();
daniel@transgaming.com00c75962010-03-11 20:36:15 +00005097 }
5098 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005099 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005100 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005101 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005102 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005103 }
5104}
5105
5106void __stdcall glUniform1f(GLint location, GLfloat x)
5107{
5108 glUniform1fv(location, 1, &x);
5109}
5110
5111void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
5112{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005113 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005114
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005115 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005116 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005117 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005118
5119 if (context)
5120 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005121 if (!ValidateUniform(context, GL_FLOAT, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005122 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005123 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005124 }
5125
Jamie Madillaa981bd2014-05-20 10:55:55 -04005126 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005127 programBinary->setUniform1fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005128 }
5129 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005130 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005131 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005132 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005133 }
5134}
5135
5136void __stdcall glUniform1i(GLint location, GLint x)
5137{
5138 glUniform1iv(location, 1, &x);
5139}
5140
5141void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
5142{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005143 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005144
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005145 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005146 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005147 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005148
5149 if (context)
5150 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005151 if (!ValidateUniform(context, GL_INT, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005152 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005153 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005154 }
5155
Jamie Madillaa981bd2014-05-20 10:55:55 -04005156 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005157 programBinary->setUniform1iv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005158 }
5159 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005160 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005161 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005162 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005163 }
5164}
5165
5166void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y)
5167{
5168 GLfloat xy[2] = {x, y};
5169
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005170 glUniform2fv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005171}
5172
5173void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
5174{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005175 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005176
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005177 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005178 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005179 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005180
5181 if (context)
5182 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005183 if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005184 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005185 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005186 }
5187
Jamie Madillaa981bd2014-05-20 10:55:55 -04005188 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005189 programBinary->setUniform2fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005190 }
5191 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005192 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005193 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005194 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005195 }
5196}
5197
5198void __stdcall glUniform2i(GLint location, GLint x, GLint y)
5199{
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005200 GLint xy[2] = {x, y};
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005201
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005202 glUniform2iv(location, 1, xy);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005203}
5204
5205void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
5206{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005207 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005208
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005209 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005210 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005211 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005212
5213 if (context)
5214 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005215 if (!ValidateUniform(context, GL_INT_VEC2, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005216 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005217 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005218 }
5219
Jamie Madillaa981bd2014-05-20 10:55:55 -04005220 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005221 programBinary->setUniform2iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005222 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005223 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005224 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005225 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005226 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005227 }
5228}
5229
5230void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
5231{
5232 GLfloat xyz[3] = {x, y, z};
5233
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005234 glUniform3fv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005235}
5236
5237void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
5238{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005239 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005240
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005241 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005242 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005243 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005244
5245 if (context)
5246 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005247 if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005248 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005249 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005250 }
5251
Jamie Madillaa981bd2014-05-20 10:55:55 -04005252 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005253 programBinary->setUniform3fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005254 }
5255 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005256 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005257 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005258 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005259 }
5260}
5261
5262void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z)
5263{
5264 GLint xyz[3] = {x, y, z};
5265
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005266 glUniform3iv(location, 1, xyz);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005267}
5268
5269void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
5270{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005271 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005272
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005273 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005274 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005275 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005276
5277 if (context)
5278 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005279 if (!ValidateUniform(context, GL_INT_VEC3, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005280 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005281 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005282 }
5283
Jamie Madillaa981bd2014-05-20 10:55:55 -04005284 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005285 programBinary->setUniform3iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005286 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005287 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005288 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005289 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005290 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005291 }
5292}
5293
5294void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5295{
5296 GLfloat xyzw[4] = {x, y, z, w};
5297
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005298 glUniform4fv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005299}
5300
5301void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
5302{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005303 EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005304
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005305 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005306 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005307 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005308
5309 if (context)
5310 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005311 if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005312 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005313 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005314 }
5315
Jamie Madillaa981bd2014-05-20 10:55:55 -04005316 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005317 programBinary->setUniform4fv(location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005318 }
5319 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005320 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005321 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005322 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005323 }
5324}
5325
5326void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
5327{
5328 GLint xyzw[4] = {x, y, z, w};
5329
Geoff Lang3b3ad1f2014-03-05 14:35:01 -05005330 glUniform4iv(location, 1, xyzw);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005331}
5332
5333void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
5334{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005335 EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005336
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005337 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005338 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005339 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005340
5341 if (context)
5342 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005343 if (!ValidateUniform(context, GL_INT_VEC4, location, count))
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005344 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04005345 return;
apatrick@chromium.orge2a59bb2012-06-07 21:09:53 +00005346 }
5347
Jamie Madillaa981bd2014-05-20 10:55:55 -04005348 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005349 programBinary->setUniform4iv(location, count, v);
daniel@transgaming.com9a95e2b2010-04-13 03:26:03 +00005350 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005351 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005352 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005353 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005354 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005355 }
5356}
5357
5358void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5359{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005360 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005361 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005362
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005363 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005364 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005365 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005366
5367 if (context)
5368 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005369 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005370 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005371 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005372 }
5373
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005374 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005375 programBinary->setUniformMatrix2fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005376 }
5377 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005378 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005379 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005380 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005381 }
5382}
5383
5384void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5385{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005386 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005387 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005388
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005389 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005390 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005391 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005392
5393 if (context)
5394 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005395 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005396 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005397 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005398 }
5399
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005400 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005401 programBinary->setUniformMatrix3fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005402 }
5403 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005404 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005405 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005406 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005407 }
5408}
5409
5410void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
5411{
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005412 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005413 location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005414
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005415 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005416 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005417 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005418
5419 if (context)
5420 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005421 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005422 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04005423 return;
shannon.woods%transgaming.com@gtempaccount.coma741b642013-04-13 03:40:10 +00005424 }
5425
daniel@transgaming.com62a28462012-07-24 18:33:59 +00005426 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04005427 programBinary->setUniformMatrix4fv(location, count, transpose, value);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005428 }
5429 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005430 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005431 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005432 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005433 }
5434}
5435
5436void __stdcall glUseProgram(GLuint program)
5437{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005438 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005439
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005440 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005441 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005442 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005443
5444 if (context)
5445 {
5446 gl::Program *programObject = context->getProgram(program);
5447
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005448 if (!programObject && program != 0)
5449 {
5450 if (context->getShader(program))
5451 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005452 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005453 }
5454 else
5455 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005456 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comc8478202010-04-13 19:53:35 +00005457 }
5458 }
5459
daniel@transgaming.com716056c2012-07-24 18:38:59 +00005460 if (program != 0 && !programObject->isLinked())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005461 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005462 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005463 }
5464
5465 context->useProgram(program);
5466 }
5467 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005468 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005469 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005470 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005471 }
5472}
5473
5474void __stdcall glValidateProgram(GLuint program)
5475{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005476 EVENT("(GLuint program = %d)", program);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005477
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005478 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005479 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005480 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005481
5482 if (context)
5483 {
5484 gl::Program *programObject = context->getProgram(program);
5485
5486 if (!programObject)
5487 {
5488 if (context->getShader(program))
5489 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005490 return gl::error(GL_INVALID_OPERATION);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005491 }
5492 else
5493 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005494 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005495 }
5496 }
5497
apatrick@chromium.org253b8d22012-06-22 19:27:21 +00005498 programObject->validate();
daniel@transgaming.com86a7a132010-04-29 03:32:32 +00005499 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005500 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005501 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005502 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005503 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005504 }
5505}
5506
5507void __stdcall glVertexAttrib1f(GLuint index, GLfloat x)
5508{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005509 EVENT("(GLuint index = %d, GLfloat x = %f)", index, x);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005510
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005511 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005512 {
5513 if (index >= gl::MAX_VERTEX_ATTRIBS)
5514 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005515 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005516 }
5517
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005518 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005519
5520 if (context)
5521 {
5522 GLfloat vals[4] = { x, 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005523 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005524 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005525 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005526 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005527 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005528 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005529 }
5530}
5531
5532void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values)
5533{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005534 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005535
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005536 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005537 {
5538 if (index >= gl::MAX_VERTEX_ATTRIBS)
5539 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005540 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005541 }
5542
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005543 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005544
5545 if (context)
5546 {
5547 GLfloat vals[4] = { values[0], 0, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005548 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005549 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005550 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005551 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005552 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005553 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005554 }
5555}
5556
5557void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
5558{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005559 EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005560
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005561 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005562 {
5563 if (index >= gl::MAX_VERTEX_ATTRIBS)
5564 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005565 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005566 }
5567
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005568 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005569
5570 if (context)
5571 {
5572 GLfloat vals[4] = { x, y, 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005573 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005574 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005575 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005576 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005577 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005578 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005579 }
5580}
5581
5582void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values)
5583{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005584 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005585
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005586 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005587 {
5588 if (index >= gl::MAX_VERTEX_ATTRIBS)
5589 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005590 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005591 }
5592
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005593 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005594
5595 if (context)
5596 {
5597 GLfloat vals[4] = { values[0], values[1], 0, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005598 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005599 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005600 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005601 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005602 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005603 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005604 }
5605}
5606
5607void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
5608{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005609 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 +00005610
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005611 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005612 {
5613 if (index >= gl::MAX_VERTEX_ATTRIBS)
5614 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005615 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005616 }
5617
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005618 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005619
5620 if (context)
5621 {
5622 GLfloat vals[4] = { x, y, z, 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005623 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005624 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005625 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005626 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005627 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005628 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005629 }
5630}
5631
5632void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values)
5633{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005634 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005635
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005636 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005637 {
5638 if (index >= gl::MAX_VERTEX_ATTRIBS)
5639 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005640 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005641 }
5642
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005643 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005644
5645 if (context)
5646 {
5647 GLfloat vals[4] = { values[0], values[1], values[2], 1 };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005648 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005649 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005650 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005651 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005652 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005653 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005654 }
5655}
5656
5657void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
5658{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005659 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 +00005660
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005661 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005662 {
5663 if (index >= gl::MAX_VERTEX_ATTRIBS)
5664 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005665 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005666 }
5667
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005668 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005669
5670 if (context)
5671 {
5672 GLfloat vals[4] = { x, y, z, w };
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005673 context->setVertexAttribf(index, vals);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005674 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005675 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005676 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005677 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005678 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005679 }
5680}
5681
5682void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values)
5683{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005684 EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005685
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005686 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005687 {
5688 if (index >= gl::MAX_VERTEX_ATTRIBS)
5689 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005690 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005691 }
5692
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005693 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005694
5695 if (context)
5696 {
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005697 context->setVertexAttribf(index, values);
daniel@transgaming.come4b08c82010-04-20 18:53:06 +00005698 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005699 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005700 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005701 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005702 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005703 }
5704}
5705
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005706void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor)
5707{
5708 EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
5709
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005710 ANGLE_TRY
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005711 {
5712 if (index >= gl::MAX_VERTEX_ATTRIBS)
5713 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005714 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005715 }
5716
5717 gl::Context *context = gl::getNonLostContext();
5718
5719 if (context)
5720 {
5721 context->setVertexAttribDivisor(index, divisor);
5722 }
5723 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005724 ANGLE_CATCH_ALL
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005725 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005726 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.comd2820bf2012-01-27 15:38:48 +00005727 }
5728}
5729
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00005730void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005731{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005732 EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005733 "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00005734 index, size, type, normalized, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005735
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005736 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005737 {
5738 if (index >= gl::MAX_VERTEX_ATTRIBS)
5739 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005740 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005741 }
5742
5743 if (size < 1 || size > 4)
5744 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005745 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005746 }
5747
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005748 gl::Context *context = gl::getNonLostContext();
5749
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005750 switch (type)
5751 {
5752 case GL_BYTE:
5753 case GL_UNSIGNED_BYTE:
5754 case GL_SHORT:
5755 case GL_UNSIGNED_SHORT:
5756 case GL_FIXED:
5757 case GL_FLOAT:
5758 break;
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005759 case GL_HALF_FLOAT:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00005760 case GL_INT:
5761 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005762 case GL_INT_2_10_10_10_REV:
5763 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.com1a4e09a2013-04-13 03:33:30 +00005764 if (context && context->getClientVersion() < 3)
5765 {
5766 return gl::error(GL_INVALID_ENUM);
5767 }
5768 else
5769 {
5770 break;
5771 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005772 default:
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005773 return gl::error(GL_INVALID_ENUM);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005774 }
5775
5776 if (stride < 0)
5777 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005778 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005779 }
5780
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00005781 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
5782 {
5783 return gl::error(GL_INVALID_OPERATION);
5784 }
5785
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005786 if (context)
5787 {
Jamie Madilld8db8662013-07-02 11:57:04 -04005788 // [OpenGL ES 3.0.2] Section 2.8 page 24:
5789 // An INVALID_OPERATION error is generated when a non-zero vertex array object
5790 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
5791 // and the pointer argument is not NULL.
5792 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && ptr != NULL)
5793 {
5794 return gl::error(GL_INVALID_OPERATION);
5795 }
5796
shannon.woods%transgaming.com@gtempaccount.com8de4e6a2013-04-13 03:37:44 +00005797 context->setVertexAttribState(index, context->getArrayBuffer(), size, type,
5798 normalized == GL_TRUE, false, stride, ptr);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005799 }
5800 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005801 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005802 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005803 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005804 }
5805}
5806
5807void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
5808{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00005809 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 +00005810
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005811 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005812 {
5813 if (width < 0 || height < 0)
5814 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005815 return gl::error(GL_INVALID_VALUE);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005816 }
5817
daniel@transgaming.com9d788502011-11-09 17:46:55 +00005818 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005819
5820 if (context)
5821 {
daniel@transgaming.com428d1582010-05-04 03:35:25 +00005822 context->setViewportParams(x, y, width, height);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005823 }
5824 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005825 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005826 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00005827 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00005828 }
5829}
5830
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005831// OpenGL ES 3.0 functions
5832
5833void __stdcall glReadBuffer(GLenum mode)
5834{
5835 EVENT("(GLenum mode = 0x%X)", mode);
5836
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005837 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005838 {
5839 gl::Context *context = gl::getNonLostContext();
5840
5841 if (context)
5842 {
5843 if (context->getClientVersion() < 3)
5844 {
5845 return gl::error(GL_INVALID_OPERATION);
5846 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005847
Jamie Madill54133512013-06-21 09:33:07 -04005848 // glReadBuffer
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005849 UNIMPLEMENTED();
5850 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005851 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005852 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005853 {
5854 return gl::error(GL_OUT_OF_MEMORY);
5855 }
5856}
5857
5858void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices)
5859{
5860 EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, "
5861 "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices);
5862
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005863 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005864 {
5865 gl::Context *context = gl::getNonLostContext();
5866
5867 if (context)
5868 {
5869 if (context->getClientVersion() < 3)
5870 {
5871 return gl::error(GL_INVALID_OPERATION);
5872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005873
Jamie Madill54133512013-06-21 09:33:07 -04005874 // glDrawRangeElements
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00005875 UNIMPLEMENTED();
5876 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005877 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005878 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005879 {
5880 return gl::error(GL_OUT_OF_MEMORY);
5881 }
5882}
5883
5884void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels)
5885{
5886 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, "
5887 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, "
5888 "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5889 target, level, internalformat, width, height, depth, border, format, type, pixels);
5890
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005891 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005892 {
5893 gl::Context *context = gl::getNonLostContext();
5894
5895 if (context)
5896 {
5897 if (context->getClientVersion() < 3)
5898 {
5899 return gl::error(GL_INVALID_OPERATION);
5900 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005901
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005902 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005903 if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04005904 0, 0, 0, width, height, depth, border, format, type, pixels))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005905 {
5906 return;
5907 }
5908
5909 switch(target)
5910 {
5911 case GL_TEXTURE_3D:
5912 {
5913 gl::Texture3D *texture = context->getTexture3D();
Jamie Madill88f18f42013-09-18 14:36:19 -04005914 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005915 }
5916 break;
5917
5918 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00005919 {
5920 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madill88f18f42013-09-18 14:36:19 -04005921 texture->setImage(level, width, height, depth, internalformat, format, type, context->getUnpackState(), pixels);
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00005922 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005923 break;
5924
5925 default:
5926 return gl::error(GL_INVALID_ENUM);
5927 }
5928 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005929 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005930 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005931 {
5932 return gl::error(GL_OUT_OF_MEMORY);
5933 }
5934}
5935
5936void __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)
5937{
5938 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5939 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
5940 "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)",
5941 target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
5942
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005943 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005944 {
5945 gl::Context *context = gl::getNonLostContext();
5946
5947 if (context)
5948 {
5949 if (context->getClientVersion() < 3)
5950 {
5951 return gl::error(GL_INVALID_OPERATION);
5952 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005953
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005954 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04005955 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true,
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005956 xoffset, yoffset, zoffset, width, height, depth, 0,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04005957 format, type, pixels))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005958 {
5959 return;
5960 }
5961
Geoff Langc41e42d2014-04-28 10:58:16 -04005962 // Zero sized uploads are valid but no-ops
5963 if (width == 0 || height == 0 || depth == 0)
5964 {
5965 return;
5966 }
5967
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005968 switch(target)
5969 {
5970 case GL_TEXTURE_3D:
5971 {
5972 gl::Texture3D *texture = context->getTexture3D();
Jamie Madill88f18f42013-09-18 14:36:19 -04005973 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 +00005974 }
5975 break;
5976
5977 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00005978 {
5979 gl::Texture2DArray *texture = context->getTexture2DArray();
Jamie Madill88f18f42013-09-18 14:36:19 -04005980 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 +00005981 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00005982 break;
5983
5984 default:
5985 return gl::error(GL_INVALID_ENUM);
5986 }
5987 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005988 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04005989 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00005990 {
5991 return gl::error(GL_OUT_OF_MEMORY);
5992 }
5993}
5994
5995void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
5996{
5997 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
5998 "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
5999 target, level, xoffset, yoffset, zoffset, x, y, width, height);
6000
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006001 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006002 {
6003 gl::Context *context = gl::getNonLostContext();
6004
6005 if (context)
6006 {
6007 if (context->getClientVersion() < 3)
6008 {
6009 return gl::error(GL_INVALID_OPERATION);
6010 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006011
Jamie Madill6f38f822014-06-06 17:12:20 -04006012 if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset,
shannonwoods@chromium.org6cf2b0e2013-05-30 00:13:36 +00006013 x, y, width, height, 0))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006014 {
6015 return;
6016 }
6017
6018 gl::Framebuffer *framebuffer = context->getReadFramebuffer();
6019 gl::Texture *texture = NULL;
6020 switch (target)
6021 {
6022 case GL_TEXTURE_3D:
6023 texture = context->getTexture3D();
6024 break;
6025
6026 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006027 texture = context->getTexture2DArray();
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006028 break;
6029
6030 default:
6031 return gl::error(GL_INVALID_ENUM);
6032 }
6033
6034 texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer);
6035 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006036 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006037 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006038 {
6039 return gl::error(GL_OUT_OF_MEMORY);
6040 }
6041}
6042
6043void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data)
6044{
Geoff Langeef52cc2013-10-16 15:07:39 -04006045 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 +00006046 "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, "
6047 "const GLvoid* data = 0x%0.8p)",
6048 target, level, internalformat, width, height, depth, border, imageSize, data);
6049
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006050 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006051 {
6052 gl::Context *context = gl::getNonLostContext();
6053
6054 if (context)
6055 {
6056 if (context->getClientVersion() < 3)
6057 {
6058 return gl::error(GL_INVALID_OPERATION);
6059 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006060
Geoff Lange4a492b2014-06-19 14:14:41 -04006061 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(internalformat, GL_UNSIGNED_BYTE, width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006062 {
6063 return gl::error(GL_INVALID_VALUE);
6064 }
6065
6066 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006067 if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04006068 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006069 {
6070 return;
6071 }
6072
6073 switch(target)
6074 {
6075 case GL_TEXTURE_3D:
6076 {
6077 gl::Texture3D *texture = context->getTexture3D();
6078 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
6079 }
6080 break;
6081
6082 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006083 {
6084 gl::Texture2DArray *texture = context->getTexture2DArray();
6085 texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data);
6086 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006087 break;
6088
6089 default:
6090 return gl::error(GL_INVALID_ENUM);
6091 }
6092 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006093 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006094 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006095 {
6096 return gl::error(GL_OUT_OF_MEMORY);
6097 }
6098}
6099
6100void __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)
6101{
6102 EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, "
6103 "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, "
6104 "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)",
6105 target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
6106
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006107 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006108 {
6109 gl::Context *context = gl::getNonLostContext();
6110
6111 if (context)
6112 {
6113 if (context->getClientVersion() < 3)
6114 {
6115 return gl::error(GL_INVALID_OPERATION);
6116 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006117
Geoff Lange4a492b2014-06-19 14:14:41 -04006118 if (imageSize < 0 || imageSize != (GLsizei)gl::GetBlockSize(format, GL_UNSIGNED_BYTE, width, height))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006119 {
6120 return gl::error(GL_INVALID_VALUE);
6121 }
6122
6123 if (!data)
6124 {
6125 return gl::error(GL_INVALID_VALUE);
6126 }
6127
6128 // validateES3TexImageFormat sets the error code if there is an error
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006129 if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true,
Jamie Madillefb2a6f2013-09-24 10:22:42 -04006130 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data))
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006131 {
6132 return;
6133 }
6134
Geoff Langc41e42d2014-04-28 10:58:16 -04006135 // Zero sized uploads are valid but no-ops
6136 if (width == 0 || height == 0)
6137 {
6138 return;
6139 }
6140
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006141 switch(target)
6142 {
6143 case GL_TEXTURE_3D:
6144 {
6145 gl::Texture3D *texture = context->getTexture3D();
6146 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
6147 format, imageSize, data);
6148 }
6149 break;
6150
6151 case GL_TEXTURE_2D_ARRAY:
shannon.woods%transgaming.com@gtempaccount.com14e8f592013-04-13 03:46:21 +00006152 {
6153 gl::Texture2DArray *texture = context->getTexture2DArray();
6154 texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth,
6155 format, imageSize, data);
6156 }
shannon.woods%transgaming.com@gtempaccount.com875994b2013-04-13 03:45:17 +00006157 break;
6158
6159 default:
6160 return gl::error(GL_INVALID_ENUM);
6161 }
6162 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006163 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006164 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006165 {
6166 return gl::error(GL_OUT_OF_MEMORY);
6167 }
6168}
6169
6170void __stdcall glGenQueries(GLsizei n, GLuint* ids)
6171{
6172 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
6173
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006174 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006175 {
6176 gl::Context *context = gl::getNonLostContext();
6177
6178 if (context)
6179 {
6180 if (context->getClientVersion() < 3)
6181 {
6182 return gl::error(GL_INVALID_OPERATION);
6183 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006184
Geoff Lang37dde692014-01-31 16:34:54 -05006185 if (n < 0)
6186 {
6187 return gl::error(GL_INVALID_VALUE);
6188 }
6189
6190 for (GLsizei i = 0; i < n; i++)
6191 {
6192 ids[i] = context->createQuery();
6193 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006194 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006195 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006196 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006197 {
6198 return gl::error(GL_OUT_OF_MEMORY);
6199 }
6200}
6201
6202void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids)
6203{
6204 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
6205
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006206 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006207 {
6208 gl::Context *context = gl::getNonLostContext();
6209
6210 if (context)
6211 {
6212 if (context->getClientVersion() < 3)
6213 {
6214 return gl::error(GL_INVALID_OPERATION);
6215 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006216
Geoff Lang37dde692014-01-31 16:34:54 -05006217 if (n < 0)
6218 {
6219 return gl::error(GL_INVALID_VALUE);
6220 }
6221
6222 for (GLsizei i = 0; i < n; i++)
6223 {
6224 context->deleteQuery(ids[i]);
6225 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006226 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006227 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006228 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006229 {
6230 return gl::error(GL_OUT_OF_MEMORY);
6231 }
6232}
6233
6234GLboolean __stdcall glIsQuery(GLuint id)
6235{
6236 EVENT("(GLuint id = %u)", id);
6237
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006238 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006239 {
6240 gl::Context *context = gl::getNonLostContext();
6241
6242 if (context)
6243 {
6244 if (context->getClientVersion() < 3)
6245 {
6246 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6247 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006248
Geoff Lang37dde692014-01-31 16:34:54 -05006249 return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE;
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006250 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006251 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006252 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006253 {
6254 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6255 }
6256
6257 return GL_FALSE;
6258}
6259
6260void __stdcall glBeginQuery(GLenum target, GLuint id)
6261{
6262 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
6263
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006264 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006265 {
6266 gl::Context *context = gl::getNonLostContext();
6267
6268 if (context)
6269 {
6270 if (context->getClientVersion() < 3)
6271 {
6272 return gl::error(GL_INVALID_OPERATION);
6273 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006274
Jamie Madilldb2f14c2014-05-13 13:56:30 -04006275 if (!ValidateBeginQuery(context, target, id))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006276 {
Jamie Madilldb2f14c2014-05-13 13:56:30 -04006277 return;
Jamie Madill3641b4b2013-07-26 12:54:59 -04006278 }
Geoff Lang37dde692014-01-31 16:34:54 -05006279 context->beginQuery(target, id);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006280 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006281 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006282 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006283 {
6284 return gl::error(GL_OUT_OF_MEMORY);
6285 }
6286}
6287
6288void __stdcall glEndQuery(GLenum target)
6289{
6290 EVENT("(GLenum target = 0x%X)", target);
6291
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006292 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006293 {
6294 gl::Context *context = gl::getNonLostContext();
6295
6296 if (context)
6297 {
6298 if (context->getClientVersion() < 3)
6299 {
6300 return gl::error(GL_INVALID_OPERATION);
6301 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006302
Jamie Madill45c785d2014-05-13 14:09:34 -04006303 if (!ValidateEndQuery(context, target))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006304 {
Jamie Madill45c785d2014-05-13 14:09:34 -04006305 return;
Jamie Madill3641b4b2013-07-26 12:54:59 -04006306 }
Geoff Lang37dde692014-01-31 16:34:54 -05006307
6308 context->endQuery(target);
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 glGetQueryiv(GLenum target, GLenum pname, GLint* params)
6318{
6319 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
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
Geoff Lang37dde692014-01-31 16:34:54 -05006332 if (!ValidQueryType(context, target))
Jamie Madill3641b4b2013-07-26 12:54:59 -04006333 {
Geoff Lang37dde692014-01-31 16:34:54 -05006334 return gl::error(GL_INVALID_ENUM);
Jamie Madill3641b4b2013-07-26 12:54:59 -04006335 }
Geoff Lang37dde692014-01-31 16:34:54 -05006336
6337 switch (pname)
Jamie Madill3641b4b2013-07-26 12:54:59 -04006338 {
Geoff Lang37dde692014-01-31 16:34:54 -05006339 case GL_CURRENT_QUERY:
Jamie Madill45c785d2014-05-13 14:09:34 -04006340 params[0] = static_cast<GLint>(context->getActiveQueryId(target));
Geoff Lang37dde692014-01-31 16:34:54 -05006341 break;
6342
6343 default:
6344 return gl::error(GL_INVALID_ENUM);
Jamie Madill3641b4b2013-07-26 12:54:59 -04006345 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006346 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006347 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006348 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006349 {
6350 return gl::error(GL_OUT_OF_MEMORY);
6351 }
6352}
6353
6354void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params)
6355{
6356 EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params);
6357
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006358 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006359 {
6360 gl::Context *context = gl::getNonLostContext();
6361
6362 if (context)
6363 {
6364 if (context->getClientVersion() < 3)
6365 {
6366 return gl::error(GL_INVALID_OPERATION);
6367 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006368
Geoff Lang37dde692014-01-31 16:34:54 -05006369 gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
6370
6371 if (!queryObject)
6372 {
6373 return gl::error(GL_INVALID_OPERATION);
6374 }
6375
Jamie Madill45c785d2014-05-13 14:09:34 -04006376 if (context->getActiveQueryId(queryObject->getType()) == id)
Geoff Lang37dde692014-01-31 16:34:54 -05006377 {
6378 return gl::error(GL_INVALID_OPERATION);
6379 }
6380
6381 switch(pname)
6382 {
6383 case GL_QUERY_RESULT:
6384 params[0] = queryObject->getResult();
6385 break;
6386 case GL_QUERY_RESULT_AVAILABLE:
6387 params[0] = queryObject->isResultAvailable();
6388 break;
6389 default:
6390 return gl::error(GL_INVALID_ENUM);
6391 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006392 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006393 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006394 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006395 {
6396 return gl::error(GL_OUT_OF_MEMORY);
6397 }
6398}
6399
6400GLboolean __stdcall glUnmapBuffer(GLenum target)
6401{
6402 EVENT("(GLenum target = 0x%X)", target);
6403
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006404 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006405 {
6406 gl::Context *context = gl::getNonLostContext();
6407
6408 if (context)
6409 {
6410 if (context->getClientVersion() < 3)
6411 {
6412 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6413 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006414
Shannon Woodsb3801742014-03-27 14:59:19 -04006415 return glUnmapBufferOES(target);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006416 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006417 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006418 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006419 {
6420 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6421 }
6422
6423 return GL_FALSE;
6424}
6425
6426void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params)
6427{
6428 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
6429
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006430 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006431 {
6432 gl::Context *context = gl::getNonLostContext();
6433
6434 if (context)
6435 {
6436 if (context->getClientVersion() < 3)
6437 {
6438 return gl::error(GL_INVALID_OPERATION);
6439 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006440
Shannon Woodsb3801742014-03-27 14:59:19 -04006441 glGetBufferPointervOES(target, pname, params);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006442 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006443 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006444 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006445 {
6446 return gl::error(GL_OUT_OF_MEMORY);
6447 }
6448}
6449
6450void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs)
6451{
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006452 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006453 {
6454 gl::Context *context = gl::getNonLostContext();
6455
6456 if (context)
6457 {
6458 if (context->getClientVersion() < 3)
6459 {
6460 return gl::error(GL_INVALID_OPERATION);
6461 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006462
shannon.woods%transgaming.com@gtempaccount.com7948c5f2013-04-13 03:38:58 +00006463 glDrawBuffersEXT(n, bufs);
6464 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006465 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006466 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006467 {
6468 return gl::error(GL_OUT_OF_MEMORY);
6469 }
6470}
6471
6472void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6473{
6474 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6475 location, count, transpose, value);
6476
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006477 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006478 {
6479 gl::Context *context = gl::getNonLostContext();
6480
6481 if (context)
6482 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006483 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006484 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006485 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006486 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006487
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006488 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006489 programBinary->setUniformMatrix2x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006490 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006491 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006492 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006493 {
6494 return gl::error(GL_OUT_OF_MEMORY);
6495 }
6496}
6497
6498void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6499{
6500 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6501 location, count, transpose, value);
6502
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006503 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006504 {
6505 gl::Context *context = gl::getNonLostContext();
6506
6507 if (context)
6508 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006509 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006510 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006511 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006512 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006513
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006514 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006515 programBinary->setUniformMatrix3x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006516 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006517 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006518 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006519 {
6520 return gl::error(GL_OUT_OF_MEMORY);
6521 }
6522}
6523
6524void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6525{
6526 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6527 location, count, transpose, value);
6528
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006529 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006530 {
6531 gl::Context *context = gl::getNonLostContext();
6532
6533 if (context)
6534 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006535 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006536 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006537 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006538 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006539
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006540 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006541 programBinary->setUniformMatrix2x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006542 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006543 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006544 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006545 {
6546 return gl::error(GL_OUT_OF_MEMORY);
6547 }
6548}
6549
6550void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6551{
6552 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6553 location, count, transpose, value);
6554
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006555 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006556 {
6557 gl::Context *context = gl::getNonLostContext();
6558
6559 if (context)
6560 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006561 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006562 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006563 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006564 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006565
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006566 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006567 programBinary->setUniformMatrix4x2fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006568 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006569 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006570 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006571 {
6572 return gl::error(GL_OUT_OF_MEMORY);
6573 }
6574}
6575
6576void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6577{
6578 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6579 location, count, transpose, value);
6580
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006581 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006582 {
6583 gl::Context *context = gl::getNonLostContext();
6584
6585 if (context)
6586 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006587 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006588 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006589 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006590 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006591
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006592 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006593 programBinary->setUniformMatrix3x4fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006594 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006595 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006596 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006597 {
6598 return gl::error(GL_OUT_OF_MEMORY);
6599 }
6600}
6601
6602void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
6603{
6604 EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)",
6605 location, count, transpose, value);
6606
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006607 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006608 {
6609 gl::Context *context = gl::getNonLostContext();
6610
6611 if (context)
6612 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006613 if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006614 {
Jamie Madilld7c7bb22014-05-20 10:55:54 -04006615 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006616 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006617
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006618 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04006619 programBinary->setUniformMatrix4x3fv(location, count, transpose, value);
shannon.woods%transgaming.com@gtempaccount.comf1306162013-04-13 03:40:04 +00006620 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006621 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006622 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006623 {
6624 return gl::error(GL_OUT_OF_MEMORY);
6625 }
6626}
6627
6628void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
6629{
6630 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, "
6631 "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
6632 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
6633
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006634 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006635 {
6636 gl::Context *context = gl::getNonLostContext();
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006637 if (context)
6638 {
6639 if (context->getClientVersion() < 3)
6640 {
6641 return gl::error(GL_INVALID_OPERATION);
6642 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006643
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006644 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
Geoff Lang758d5b22013-06-11 11:42:50 -04006645 dstX0, dstY0, dstX1, dstY1, mask, filter,
6646 false))
6647 {
6648 return;
6649 }
6650
6651 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
6652 mask, filter);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006653 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006654 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006655 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006656 {
6657 return gl::error(GL_OUT_OF_MEMORY);
6658 }
6659}
6660
6661void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
6662{
6663 EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
6664 target, samples, internalformat, width, height);
6665
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006666 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006667 {
6668 gl::Context *context = gl::getNonLostContext();
6669
6670 if (context)
6671 {
6672 if (context->getClientVersion() < 3)
6673 {
6674 return gl::error(GL_INVALID_OPERATION);
6675 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006676
Geoff Lang34dbb6f2013-08-05 15:05:47 -04006677 if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat,
Geoff Lang2e1dcd52013-05-29 10:34:08 -04006678 width, height, false))
6679 {
6680 return;
6681 }
6682
6683 context->setRenderbufferStorage(width, height, internalformat, samples);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006684 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006685 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006686 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006687 {
6688 return gl::error(GL_OUT_OF_MEMORY);
6689 }
6690}
6691
6692void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer)
6693{
6694 EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)",
6695 target, attachment, texture, level, layer);
6696
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006697 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006698 {
6699 gl::Context *context = gl::getNonLostContext();
6700
6701 if (context)
6702 {
Jamie Madill570f7c82014-07-03 10:38:54 -04006703 if (!ValidateFramebufferTextureLayer(context, target, attachment, texture,
6704 level, layer))
Geoff Lang3ed0c482013-07-25 17:03:18 -04006705 {
6706 return;
6707 }
6708
Jamie Madill1fc7e2c2014-01-21 16:47:10 -05006709 gl::Framebuffer *framebuffer = context->getTargetFramebuffer(target);
6710 ASSERT(framebuffer);
Geoff Lang3ed0c482013-07-25 17:03:18 -04006711
6712 gl::Texture *textureObject = context->getTexture(texture);
6713 GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE;
6714
6715 if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT)
6716 {
6717 const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT);
6718 framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer);
6719 }
6720 else
6721 {
6722 switch (attachment)
6723 {
Jamie Madill570f7c82014-07-03 10:38:54 -04006724 case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break;
6725 case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break;
6726 case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break;
Geoff Lang3ed0c482013-07-25 17:03:18 -04006727 }
6728 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006729 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006730 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006731 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006732 {
6733 return gl::error(GL_OUT_OF_MEMORY);
6734 }
6735}
6736
6737GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
6738{
6739 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
6740 target, offset, length, access);
6741
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006742 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006743 {
6744 gl::Context *context = gl::getNonLostContext();
6745
6746 if (context)
6747 {
6748 if (context->getClientVersion() < 3)
6749 {
6750 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
6751 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006752
Shannon Woods916e7692014-03-27 16:58:22 -04006753 return glMapBufferRangeEXT(target, offset, length, access);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006754 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006755 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006756 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006757 {
6758 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
6759 }
6760
6761 return NULL;
6762}
6763
6764void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
6765{
6766 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
6767
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006768 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006769 {
6770 gl::Context *context = gl::getNonLostContext();
6771
6772 if (context)
6773 {
6774 if (context->getClientVersion() < 3)
6775 {
6776 return gl::error(GL_INVALID_OPERATION);
6777 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006778
Shannon Woods916e7692014-03-27 16:58:22 -04006779 glFlushMappedBufferRangeEXT(target, offset, length);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006780 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006781 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006782 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006783 {
6784 return gl::error(GL_OUT_OF_MEMORY);
6785 }
6786}
6787
6788void __stdcall glBindVertexArray(GLuint array)
6789{
6790 EVENT("(GLuint array = %u)", array);
6791
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006792 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006793 {
6794 gl::Context *context = gl::getNonLostContext();
6795
6796 if (context)
6797 {
6798 if (context->getClientVersion() < 3)
6799 {
6800 return gl::error(GL_INVALID_OPERATION);
6801 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006802
Jamie Madilld1028542013-07-02 11:57:04 -04006803 gl::VertexArray *vao = context->getVertexArray(array);
6804
6805 if (!vao)
6806 {
6807 // The default VAO should always exist
6808 ASSERT(array != 0);
6809 return gl::error(GL_INVALID_OPERATION);
6810 }
6811
6812 context->bindVertexArray(array);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006813 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006814 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006815 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006816 {
6817 return gl::error(GL_OUT_OF_MEMORY);
6818 }
6819}
6820
6821void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays)
6822{
6823 EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays);
6824
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006825 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006826 {
6827 gl::Context *context = gl::getNonLostContext();
6828
6829 if (context)
6830 {
6831 if (context->getClientVersion() < 3)
6832 {
6833 return gl::error(GL_INVALID_OPERATION);
6834 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006835
Jamie Madilld1028542013-07-02 11:57:04 -04006836 if (n < 0)
6837 {
6838 return gl::error(GL_INVALID_VALUE);
6839 }
6840
6841 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
6842 {
6843 if (arrays[arrayIndex] != 0)
6844 {
6845 context->deleteVertexArray(arrays[arrayIndex]);
6846 }
6847 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006848 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006849 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006850 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006851 {
6852 return gl::error(GL_OUT_OF_MEMORY);
6853 }
6854}
6855
6856void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays)
6857{
6858 EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays);
6859
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006860 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006861 {
6862 gl::Context *context = gl::getNonLostContext();
6863
6864 if (context)
6865 {
6866 if (context->getClientVersion() < 3)
6867 {
6868 return gl::error(GL_INVALID_OPERATION);
6869 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006870
Jamie Madilld1028542013-07-02 11:57:04 -04006871 if (n < 0)
6872 {
6873 return gl::error(GL_INVALID_VALUE);
6874 }
6875
6876 for (int arrayIndex = 0; arrayIndex < n; arrayIndex++)
6877 {
6878 arrays[arrayIndex] = context->createVertexArray();
6879 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006880 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006881 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006882 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006883 {
6884 return gl::error(GL_OUT_OF_MEMORY);
6885 }
6886}
6887
6888GLboolean __stdcall glIsVertexArray(GLuint array)
6889{
6890 EVENT("(GLuint array = %u)", array);
6891
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006892 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006893 {
6894 gl::Context *context = gl::getNonLostContext();
6895
6896 if (context)
6897 {
6898 if (context->getClientVersion() < 3)
6899 {
6900 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
6901 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006902
Jamie Madilld1028542013-07-02 11:57:04 -04006903 if (array == 0)
6904 {
6905 return GL_FALSE;
6906 }
6907
6908 gl::VertexArray *vao = context->getVertexArray(array);
6909
6910 return (vao != NULL ? GL_TRUE : GL_FALSE);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006911 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006912 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006913 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006914 {
6915 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
6916 }
6917
6918 return GL_FALSE;
6919}
6920
6921void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data)
6922{
6923 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)",
6924 target, index, data);
6925
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006926 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006927 {
6928 gl::Context *context = gl::getNonLostContext();
6929
6930 if (context)
6931 {
6932 if (context->getClientVersion() < 3)
6933 {
6934 return gl::error(GL_INVALID_OPERATION);
6935 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006936
Shannon Woods15934d52013-08-19 14:28:49 -04006937 switch (target)
6938 {
6939 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
6940 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
6941 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
6942 if (index >= context->getMaxTransformFeedbackBufferBindings())
6943 return gl::error(GL_INVALID_VALUE);
6944 break;
6945 case GL_UNIFORM_BUFFER_START:
6946 case GL_UNIFORM_BUFFER_SIZE:
6947 case GL_UNIFORM_BUFFER_BINDING:
6948 if (index >= context->getMaximumCombinedUniformBufferBindings())
6949 return gl::error(GL_INVALID_VALUE);
6950 break;
6951 default:
6952 return gl::error(GL_INVALID_ENUM);
6953 }
6954
6955 if (!(context->getIndexedIntegerv(target, index, data)))
6956 {
6957 GLenum nativeType;
6958 unsigned int numParams = 0;
6959 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
6960 return gl::error(GL_INVALID_ENUM);
6961
6962 if (numParams == 0)
6963 return; // it is known that pname is valid, but there are no parameters to return
6964
6965 if (nativeType == GL_INT_64_ANGLEX)
6966 {
6967 GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min());
6968 GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max());
6969 GLint64 *int64Params = new GLint64[numParams];
6970
6971 context->getIndexedInteger64v(target, index, int64Params);
6972
6973 for (unsigned int i = 0; i < numParams; ++i)
6974 {
6975 GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue);
6976 data[i] = static_cast<GLint>(clampedValue);
6977 }
6978
6979 delete [] int64Params;
6980 }
6981 else
6982 {
6983 UNREACHABLE();
6984 }
6985 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00006986 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006987 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006988 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006989 {
6990 return gl::error(GL_OUT_OF_MEMORY);
6991 }
6992}
6993
6994void __stdcall glBeginTransformFeedback(GLenum primitiveMode)
6995{
6996 EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode);
6997
Ehsan Akhgari10530c32014-07-02 20:37:53 -04006998 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00006999 {
7000 gl::Context *context = gl::getNonLostContext();
7001
7002 if (context)
7003 {
7004 if (context->getClientVersion() < 3)
7005 {
7006 return gl::error(GL_INVALID_OPERATION);
7007 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007008
Geoff Langc8058452014-02-03 12:04:11 -05007009 switch (primitiveMode)
7010 {
7011 case GL_TRIANGLES:
7012 case GL_LINES:
7013 case GL_POINTS:
7014 break;
7015 default:
7016 return gl::error(GL_INVALID_ENUM);
7017 }
7018
7019 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
7020 ASSERT(transformFeedback != NULL);
7021
7022 if (transformFeedback->isStarted())
7023 {
7024 return gl::error(GL_INVALID_OPERATION);
7025 }
7026
7027 if (transformFeedback->isPaused())
7028 {
7029 transformFeedback->resume();
7030 }
7031 else
7032 {
7033 transformFeedback->start(primitiveMode);
7034 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007035 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007036 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007037 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007038 {
7039 return gl::error(GL_OUT_OF_MEMORY);
7040 }
7041}
7042
7043void __stdcall glEndTransformFeedback(void)
7044{
7045 EVENT("(void)");
7046
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007047 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007048 {
7049 gl::Context *context = gl::getNonLostContext();
7050
7051 if (context)
7052 {
7053 if (context->getClientVersion() < 3)
7054 {
7055 return gl::error(GL_INVALID_OPERATION);
7056 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007057
Geoff Langc8058452014-02-03 12:04:11 -05007058 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
7059 ASSERT(transformFeedback != NULL);
7060
7061 if (!transformFeedback->isStarted())
7062 {
7063 return gl::error(GL_INVALID_OPERATION);
7064 }
7065
7066 transformFeedback->stop();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007067 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007068 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007069 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007070 {
7071 return gl::error(GL_OUT_OF_MEMORY);
7072 }
7073}
7074
7075void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size)
7076{
7077 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)",
7078 target, index, buffer, offset, size);
7079
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007080 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007081 {
7082 gl::Context *context = gl::getNonLostContext();
7083
7084 if (context)
7085 {
7086 if (context->getClientVersion() < 3)
7087 {
7088 return gl::error(GL_INVALID_OPERATION);
7089 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007090
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007091 switch (target)
7092 {
7093 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007094 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007095 {
7096 return gl::error(GL_INVALID_VALUE);
7097 }
7098 break;
7099
7100 case GL_UNIFORM_BUFFER:
7101 if (index >= context->getMaximumCombinedUniformBufferBindings())
7102 {
7103 return gl::error(GL_INVALID_VALUE);
7104 }
7105 break;
7106
7107 default:
7108 return gl::error(GL_INVALID_ENUM);
7109 }
7110
shannonwoods@chromium.orge6e00792013-05-30 00:06:07 +00007111 if (buffer != 0 && size <= 0)
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007112 {
7113 return gl::error(GL_INVALID_VALUE);
7114 }
7115
7116 switch (target)
7117 {
7118 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orga26aeaf2013-05-30 00:06:13 +00007119
7120 // size and offset must be a multiple of 4
7121 if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0))
7122 {
7123 return gl::error(GL_INVALID_VALUE);
7124 }
7125
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007126 context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size);
7127 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007128 break;
7129
7130 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org97c3d502013-05-30 00:04:34 +00007131
7132 // it is an error to bind an offset not a multiple of the alignment
7133 if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0)
7134 {
7135 return gl::error(GL_INVALID_VALUE);
7136 }
7137
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007138 context->bindIndexedUniformBuffer(buffer, index, offset, size);
7139 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007140 break;
7141
7142 default:
7143 UNREACHABLE();
7144 }
7145 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007146 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007147 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007148 {
7149 return gl::error(GL_OUT_OF_MEMORY);
7150 }
7151}
7152
7153void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
7154{
7155 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)",
7156 target, index, buffer);
7157
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007158 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007159 {
7160 gl::Context *context = gl::getNonLostContext();
7161
7162 if (context)
7163 {
7164 if (context->getClientVersion() < 3)
7165 {
7166 return gl::error(GL_INVALID_OPERATION);
7167 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007168
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007169 switch (target)
7170 {
7171 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007172 if (index >= context->getMaxTransformFeedbackBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007173 {
7174 return gl::error(GL_INVALID_VALUE);
7175 }
7176 break;
7177
7178 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.orgd11158f2013-05-30 00:06:19 +00007179 if (index >= context->getMaximumCombinedUniformBufferBindings())
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007180 {
7181 return gl::error(GL_INVALID_VALUE);
7182 }
7183 break;
7184
7185 default:
7186 return gl::error(GL_INVALID_ENUM);
7187 }
7188
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007189 switch (target)
7190 {
7191 case GL_TRANSFORM_FEEDBACK_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00007192 context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007193 context->bindGenericTransformFeedbackBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007194 break;
7195
7196 case GL_UNIFORM_BUFFER:
shannonwoods@chromium.org3eeca1e2013-05-30 00:04:28 +00007197 context->bindIndexedUniformBuffer(buffer, index, 0, 0);
shannon.woods%transgaming.com@gtempaccount.com667a29c2013-04-13 03:39:04 +00007198 context->bindGenericUniformBuffer(buffer);
shannon.woods%transgaming.com@gtempaccount.comd4e61972013-04-13 03:37:04 +00007199 break;
7200
7201 default:
7202 UNREACHABLE();
7203 }
7204 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007205 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007206 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007207 {
7208 return gl::error(GL_OUT_OF_MEMORY);
7209 }
7210}
7211
7212void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode)
7213{
7214 EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)",
7215 program, count, varyings, bufferMode);
7216
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007217 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007218 {
7219 gl::Context *context = gl::getNonLostContext();
7220
7221 if (context)
7222 {
7223 if (context->getClientVersion() < 3)
7224 {
7225 return gl::error(GL_INVALID_OPERATION);
7226 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007227
Geoff Lang48dcae72014-02-05 16:28:24 -05007228 if (count < 0)
7229 {
7230 return gl::error(GL_INVALID_VALUE);
7231 }
7232
7233 switch (bufferMode)
7234 {
7235 case GL_INTERLEAVED_ATTRIBS:
7236 break;
7237 case GL_SEPARATE_ATTRIBS:
7238 if (static_cast<GLuint>(count) > context->getMaxTransformFeedbackBufferBindings())
7239 {
7240 return gl::error(GL_INVALID_VALUE);
7241 }
7242 break;
7243 default:
7244 return gl::error(GL_INVALID_ENUM);
7245 }
7246
7247 if (!gl::ValidProgram(context, program))
7248 {
7249 return;
7250 }
7251
7252 gl::Program *programObject = context->getProgram(program);
7253 ASSERT(programObject);
7254
7255 programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007256 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007257 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007258 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007259 {
7260 return gl::error(GL_OUT_OF_MEMORY);
7261 }
7262}
7263
7264void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name)
7265{
7266 EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, "
7267 "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
7268 program, index, bufSize, length, size, type, name);
7269
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007270 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007271 {
7272 gl::Context *context = gl::getNonLostContext();
7273
7274 if (context)
7275 {
7276 if (context->getClientVersion() < 3)
7277 {
7278 return gl::error(GL_INVALID_OPERATION);
7279 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007280
Geoff Lang48dcae72014-02-05 16:28:24 -05007281 if (bufSize < 0)
7282 {
7283 return gl::error(GL_INVALID_VALUE);
7284 }
7285
7286 if (!gl::ValidProgram(context, program))
7287 {
7288 return;
7289 }
7290
7291 gl::Program *programObject = context->getProgram(program);
7292 ASSERT(programObject);
7293
7294 if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
7295 {
7296 return gl::error(GL_INVALID_VALUE);
7297 }
7298
7299 programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007300 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007301 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007302 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007303 {
7304 return gl::error(GL_OUT_OF_MEMORY);
7305 }
7306}
7307
7308void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
7309{
7310 EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)",
7311 index, size, type, stride, pointer);
7312
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007313 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007314 {
7315 gl::Context *context = gl::getNonLostContext();
7316
7317 if (context)
7318 {
7319 if (context->getClientVersion() < 3)
7320 {
7321 return gl::error(GL_INVALID_OPERATION);
7322 }
7323 }
7324
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007325 if (index >= gl::MAX_VERTEX_ATTRIBS)
7326 {
7327 return gl::error(GL_INVALID_VALUE);
7328 }
7329
7330 if (size < 1 || size > 4)
7331 {
7332 return gl::error(GL_INVALID_VALUE);
7333 }
7334
7335 switch (type)
7336 {
7337 case GL_BYTE:
7338 case GL_UNSIGNED_BYTE:
7339 case GL_SHORT:
7340 case GL_UNSIGNED_SHORT:
7341 case GL_INT:
7342 case GL_UNSIGNED_INT:
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007343 case GL_INT_2_10_10_10_REV:
7344 case GL_UNSIGNED_INT_2_10_10_10_REV:
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007345 break;
7346 default:
7347 return gl::error(GL_INVALID_ENUM);
7348 }
7349
7350 if (stride < 0)
7351 {
7352 return gl::error(GL_INVALID_VALUE);
7353 }
7354
shannon.woods%transgaming.com@gtempaccount.com1ab57be2013-04-13 03:38:39 +00007355 if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4)
7356 {
7357 return gl::error(GL_INVALID_OPERATION);
7358 }
7359
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007360 if (context)
7361 {
Jamie Madilld8db8662013-07-02 11:57:04 -04007362 // [OpenGL ES 3.0.2] Section 2.8 page 24:
7363 // An INVALID_OPERATION error is generated when a non-zero vertex array object
7364 // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
7365 // and the pointer argument is not NULL.
7366 if (context->getVertexArrayHandle() != 0 && context->getArrayBufferHandle() == 0 && pointer != NULL)
7367 {
7368 return gl::error(GL_INVALID_OPERATION);
7369 }
7370
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007371 context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, true,
7372 stride, pointer);
7373 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007374 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007375 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007376 {
7377 return gl::error(GL_OUT_OF_MEMORY);
7378 }
7379}
7380
7381void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params)
7382{
7383 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
7384 index, pname, params);
7385
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007386 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007387 {
7388 gl::Context *context = gl::getNonLostContext();
7389
7390 if (context)
7391 {
7392 if (context->getClientVersion() < 3)
7393 {
7394 return gl::error(GL_INVALID_OPERATION);
7395 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007396
Jamie Madilla7d05862013-07-02 11:57:06 -04007397 if (index >= gl::MAX_VERTEX_ATTRIBS)
7398 {
7399 return gl::error(GL_INVALID_VALUE);
7400 }
7401
7402 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
7403
Geoff Lang34dbb6f2013-08-05 15:05:47 -04007404 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
Jamie Madilla7d05862013-07-02 11:57:06 -04007405 {
7406 return;
7407 }
7408
7409 if (pname == GL_CURRENT_VERTEX_ATTRIB)
7410 {
7411 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
7412 for (int i = 0; i < 4; ++i)
7413 {
7414 params[i] = currentValueData.IntValues[i];
7415 }
7416 }
7417 else
7418 {
Brandon Jones5bf98292014-06-06 17:19:38 -07007419 *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname);
Jamie Madilla7d05862013-07-02 11:57:06 -04007420 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007421 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007422 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007423 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007424 {
7425 return gl::error(GL_OUT_OF_MEMORY);
7426 }
7427}
7428
7429void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params)
7430{
7431 EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)",
7432 index, pname, params);
7433
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007434 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007435 {
7436 gl::Context *context = gl::getNonLostContext();
7437
7438 if (context)
7439 {
7440 if (context->getClientVersion() < 3)
7441 {
7442 return gl::error(GL_INVALID_OPERATION);
7443 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007444
Jamie Madilla7d05862013-07-02 11:57:06 -04007445 if (index >= gl::MAX_VERTEX_ATTRIBS)
7446 {
7447 return gl::error(GL_INVALID_VALUE);
7448 }
7449
7450 const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
7451
Geoff Lang34dbb6f2013-08-05 15:05:47 -04007452 if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion()))
Jamie Madilla7d05862013-07-02 11:57:06 -04007453 {
7454 return;
7455 }
7456
7457 if (pname == GL_CURRENT_VERTEX_ATTRIB)
7458 {
7459 const gl::VertexAttribCurrentValueData &currentValueData = context->getVertexAttribCurrentValue(index);
7460 for (int i = 0; i < 4; ++i)
7461 {
7462 params[i] = currentValueData.UnsignedIntValues[i];
7463 }
7464 }
7465 else
7466 {
Brandon Jones5bf98292014-06-06 17:19:38 -07007467 *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname);
Jamie Madilla7d05862013-07-02 11:57:06 -04007468 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007469 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007470 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007471 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007472 {
7473 return gl::error(GL_OUT_OF_MEMORY);
7474 }
7475}
7476
7477void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
7478{
7479 EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)",
7480 index, x, y, z, w);
7481
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007482 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007483 {
7484 gl::Context *context = gl::getNonLostContext();
7485
7486 if (context)
7487 {
7488 if (context->getClientVersion() < 3)
7489 {
7490 return gl::error(GL_INVALID_OPERATION);
7491 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007492
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007493 if (index >= gl::MAX_VERTEX_ATTRIBS)
7494 {
7495 return gl::error(GL_INVALID_VALUE);
7496 }
7497
7498 GLint vals[4] = { x, y, z, w };
7499 context->setVertexAttribi(index, vals);
7500 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007501 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007502 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007503 {
7504 return gl::error(GL_OUT_OF_MEMORY);
7505 }
7506}
7507
7508void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
7509{
7510 EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)",
7511 index, x, y, z, w);
7512
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007513 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007514 {
7515 gl::Context *context = gl::getNonLostContext();
7516
7517 if (context)
7518 {
7519 if (context->getClientVersion() < 3)
7520 {
7521 return gl::error(GL_INVALID_OPERATION);
7522 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007523
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007524 if (index >= gl::MAX_VERTEX_ATTRIBS)
7525 {
7526 return gl::error(GL_INVALID_VALUE);
7527 }
7528
7529 GLuint vals[4] = { x, y, z, w };
7530 context->setVertexAttribu(index, vals);
7531 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007532 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007533 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007534 {
7535 return gl::error(GL_OUT_OF_MEMORY);
7536 }
7537}
7538
7539void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v)
7540{
7541 EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v);
7542
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007543 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007544 {
7545 gl::Context *context = gl::getNonLostContext();
7546
7547 if (context)
7548 {
7549 if (context->getClientVersion() < 3)
7550 {
7551 return gl::error(GL_INVALID_OPERATION);
7552 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007553
shannon.woods%transgaming.com@gtempaccount.coma8885862013-04-13 03:37:53 +00007554 if (index >= gl::MAX_VERTEX_ATTRIBS)
7555 {
7556 return gl::error(GL_INVALID_VALUE);
7557 }
7558
7559 context->setVertexAttribi(index, v);
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 glVertexAttribI4uiv(GLuint index, const GLuint* v)
7569{
7570 EVENT("(GLuint index = %u, const GLuint* 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->setVertexAttribu(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 glGetUniformuiv(GLuint program, GLint location, GLuint* params)
7598{
7599 EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)",
7600 program, location, params);
7601
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007602 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007603 {
7604 gl::Context *context = gl::getNonLostContext();
7605
7606 if (context)
7607 {
7608 if (context->getClientVersion() < 3)
7609 {
7610 return gl::error(GL_INVALID_OPERATION);
7611 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007612
shannon.woods%transgaming.com@gtempaccount.come2290122013-04-13 03:41:07 +00007613 if (program == 0)
7614 {
7615 return gl::error(GL_INVALID_VALUE);
7616 }
7617
7618 gl::Program *programObject = context->getProgram(program);
7619
7620 if (!programObject || !programObject->isLinked())
7621 {
7622 return gl::error(GL_INVALID_OPERATION);
7623 }
7624
7625 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7626 if (!programBinary)
7627 {
7628 return gl::error(GL_INVALID_OPERATION);
7629 }
7630
7631 if (!programBinary->getUniformuiv(location, NULL, params))
7632 {
7633 return gl::error(GL_INVALID_OPERATION);
7634 }
7635 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007636 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007637 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007638 {
7639 return gl::error(GL_OUT_OF_MEMORY);
7640 }
7641}
7642
7643GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name)
7644{
7645 EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)",
7646 program, name);
7647
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007648 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007649 {
7650 gl::Context *context = gl::getNonLostContext();
7651
7652 if (context)
7653 {
7654 if (context->getClientVersion() < 3)
7655 {
Jamie Madilld1e78c92013-06-20 11:55:50 -04007656 return gl::error(GL_INVALID_OPERATION, -1);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007657 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007658
Jamie Madilld1e78c92013-06-20 11:55:50 -04007659 if (program == 0)
7660 {
7661 return gl::error(GL_INVALID_VALUE, -1);
7662 }
7663
7664 gl::Program *programObject = context->getProgram(program);
7665
7666 if (!programObject || !programObject->isLinked())
7667 {
7668 return gl::error(GL_INVALID_OPERATION, -1);
7669 }
7670
7671 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
7672 if (!programBinary)
7673 {
7674 return gl::error(GL_INVALID_OPERATION, -1);
7675 }
7676
7677 return programBinary->getFragDataLocation(name);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007678 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007679 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007680 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007681 {
7682 return gl::error(GL_OUT_OF_MEMORY, 0);
7683 }
7684
7685 return 0;
7686}
7687
7688void __stdcall glUniform1ui(GLint location, GLuint v0)
7689{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007690 glUniform1uiv(location, 1, &v0);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007691}
7692
7693void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1)
7694{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007695 const GLuint xy[] = { v0, v1 };
7696 glUniform2uiv(location, 1, xy);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007697}
7698
7699void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
7700{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007701 const GLuint xyz[] = { v0, v1, v2 };
7702 glUniform3uiv(location, 1, xyz);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007703}
7704
7705void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
7706{
shannon.woods%transgaming.com@gtempaccount.com8431b9c2013-04-13 03:40:17 +00007707 const GLuint xyzw[] = { v0, v1, v2, v3 };
7708 glUniform4uiv(location, 1, xyzw);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007709}
7710
7711void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
7712{
7713 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7714 location, count, value);
7715
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007716 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007717 {
7718 gl::Context *context = gl::getNonLostContext();
7719
7720 if (context)
7721 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007722 if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007723 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007724 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007725 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007726
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007727 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007728 programBinary->setUniform1uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007729 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007730 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007731 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007732 {
7733 return gl::error(GL_OUT_OF_MEMORY);
7734 }
7735}
7736
7737void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
7738{
7739 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7740 location, count, value);
7741
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007742 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007743 {
7744 gl::Context *context = gl::getNonLostContext();
7745
7746 if (context)
7747 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007748 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007749 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007750 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007751 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007752
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007753 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007754 programBinary->setUniform2uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007755 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007756 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007757 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007758 {
7759 return gl::error(GL_OUT_OF_MEMORY);
7760 }
7761}
7762
7763void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
7764{
7765 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)",
7766 location, count, value);
7767
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007768 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007769 {
7770 gl::Context *context = gl::getNonLostContext();
7771
7772 if (context)
7773 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007774 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007775 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007776 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007777 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007778
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007779 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007780 programBinary->setUniform3uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007781 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007782 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007783 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007784 {
7785 return gl::error(GL_OUT_OF_MEMORY);
7786 }
7787}
7788
7789void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
7790{
7791 EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)",
7792 location, count, value);
7793
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007794 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007795 {
7796 gl::Context *context = gl::getNonLostContext();
7797
7798 if (context)
7799 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007800 if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007801 {
Jamie Madillaa981bd2014-05-20 10:55:55 -04007802 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007803 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007804
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007805 gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
Jamie Madill36398922014-05-20 14:51:53 -04007806 programBinary->setUniform4uiv(location, count, value);
shannon.woods%transgaming.com@gtempaccount.com50ea4ab2013-04-13 03:40:36 +00007807 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007808 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007809 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007810 {
7811 return gl::error(GL_OUT_OF_MEMORY);
7812 }
7813}
7814
7815void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value)
7816{
7817 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)",
7818 buffer, drawbuffer, value);
7819
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007820 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007821 {
7822 gl::Context *context = gl::getNonLostContext();
7823
7824 if (context)
7825 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007826 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007827 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007828 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007829 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007830
Geoff Lang42359ca2013-08-21 13:25:17 -04007831 switch (buffer)
7832 {
7833 case GL_COLOR:
Geoff Langaae65a42014-05-26 12:43:44 -04007834 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
Geoff Lang42359ca2013-08-21 13:25:17 -04007835 {
7836 return gl::error(GL_INVALID_VALUE);
7837 }
7838 break;
7839 case GL_STENCIL:
7840 if (drawbuffer != 0)
7841 {
7842 return gl::error(GL_INVALID_VALUE);
7843 }
Geoff Lang8d6a0022014-01-31 16:38:31 -05007844 break;
Geoff Lang42359ca2013-08-21 13:25:17 -04007845 default:
7846 return gl::error(GL_INVALID_ENUM);
7847 }
7848
7849 context->clearBufferiv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007850 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007851 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007852 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007853 {
7854 return gl::error(GL_OUT_OF_MEMORY);
7855 }
7856}
7857
7858void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value)
7859{
7860 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)",
7861 buffer, drawbuffer, value);
7862
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007863 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007864 {
7865 gl::Context *context = gl::getNonLostContext();
7866
7867 if (context)
7868 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007869 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007870 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007871 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007873
Geoff Lang42359ca2013-08-21 13:25:17 -04007874 switch (buffer)
7875 {
7876 case GL_COLOR:
Geoff Langaae65a42014-05-26 12:43:44 -04007877 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
Geoff Lang42359ca2013-08-21 13:25:17 -04007878 {
7879 return gl::error(GL_INVALID_VALUE);
7880 }
7881 break;
7882 default:
7883 return gl::error(GL_INVALID_ENUM);
7884 }
7885
7886 context->clearBufferuiv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007887 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007888 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007889 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007890 {
7891 return gl::error(GL_OUT_OF_MEMORY);
7892 }
7893}
7894
7895void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value)
7896{
7897 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)",
7898 buffer, drawbuffer, value);
7899
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007900 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007901 {
7902 gl::Context *context = gl::getNonLostContext();
7903
7904 if (context)
7905 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007906 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007907 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007908 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007909 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007910
Geoff Lang42359ca2013-08-21 13:25:17 -04007911 switch (buffer)
7912 {
7913 case GL_COLOR:
Geoff Langaae65a42014-05-26 12:43:44 -04007914 if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers)
Geoff Lang42359ca2013-08-21 13:25:17 -04007915 {
7916 return gl::error(GL_INVALID_VALUE);
7917 }
7918 break;
7919 case GL_DEPTH:
7920 if (drawbuffer != 0)
7921 {
7922 return gl::error(GL_INVALID_VALUE);
7923 }
7924 break;
7925 default:
7926 return gl::error(GL_INVALID_ENUM);
7927 }
7928
7929 context->clearBufferfv(buffer, drawbuffer, value);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007930 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007931 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007932 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007933 {
7934 return gl::error(GL_OUT_OF_MEMORY);
7935 }
7936}
7937
7938void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil)
7939{
7940 EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)",
7941 buffer, drawbuffer, depth, stencil);
7942
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007943 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007944 {
7945 gl::Context *context = gl::getNonLostContext();
7946
7947 if (context)
7948 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007949 if (!ValidateClearBuffer(context))
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007950 {
Jamie Madill13f7d7d2014-06-20 13:21:27 -04007951 return;
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007952 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007953
Geoff Lang42359ca2013-08-21 13:25:17 -04007954 switch (buffer)
7955 {
7956 case GL_DEPTH_STENCIL:
7957 if (drawbuffer != 0)
7958 {
7959 return gl::error(GL_INVALID_VALUE);
7960 }
7961 break;
7962 default:
7963 return gl::error(GL_INVALID_ENUM);
7964 }
7965
7966 context->clearBufferfi(buffer, drawbuffer, depth, stencil);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00007967 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007968 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007969 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007970 {
7971 return gl::error(GL_OUT_OF_MEMORY);
7972 }
7973}
7974
7975const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index)
7976{
7977 EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index);
7978
Ehsan Akhgari10530c32014-07-02 20:37:53 -04007979 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007980 {
7981 gl::Context *context = gl::getNonLostContext();
7982
7983 if (context)
7984 {
7985 if (context->getClientVersion() < 3)
7986 {
7987 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL));
7988 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00007989
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00007990 if (name != GL_EXTENSIONS)
7991 {
7992 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL));
7993 }
7994
Geoff Langcec35902014-04-16 10:52:36 -04007995 if (index >= context->getExtensionStringCount())
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00007996 {
7997 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL));
7998 }
Geoff Langcec35902014-04-16 10:52:36 -04007999
shannonwoods@chromium.org302df742013-05-30 00:05:54 +00008000 return reinterpret_cast<const GLubyte*>(context->getExtensionString(index));
8001 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008002 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008003 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008004 {
8005 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLubyte*>(NULL));
8006 }
8007
8008 return NULL;
8009}
8010
8011void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
8012{
8013 EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)",
8014 readTarget, writeTarget, readOffset, writeOffset, size);
8015
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008016 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008017 {
8018 gl::Context *context = gl::getNonLostContext();
8019
8020 if (context)
8021 {
8022 if (context->getClientVersion() < 3)
8023 {
8024 return gl::error(GL_INVALID_OPERATION);
8025 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008026
Jamie Madill8c96d582014-03-05 15:01:23 -05008027 if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget))
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008028 {
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008029 return gl::error(GL_INVALID_ENUM);
8030 }
8031
Jamie Madill8c96d582014-03-05 15:01:23 -05008032 gl::Buffer *readBuffer = context->getTargetBuffer(readTarget);
8033 gl::Buffer *writeBuffer = context->getTargetBuffer(writeTarget);
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008034
8035 if (!readBuffer || !writeBuffer)
8036 {
8037 return gl::error(GL_INVALID_OPERATION);
8038 }
8039
Brandon Jonesd38f9262014-06-18 16:26:45 -07008040 if (readBuffer->isMapped() || writeBuffer->isMapped())
Jamie Madill7a5f7382014-03-05 15:01:24 -05008041 {
8042 return gl::error(GL_INVALID_OPERATION);
8043 }
8044
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008045 if (readOffset < 0 || writeOffset < 0 || size < 0 ||
Brandon Jonesd38f9262014-06-18 16:26:45 -07008046 static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() ||
8047 static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize())
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008048 {
8049 return gl::error(GL_INVALID_VALUE);
8050 }
8051
8052 if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size)
8053 {
8054 return gl::error(GL_INVALID_VALUE);
8055 }
8056
8057 // TODO: Verify that readBuffer and writeBuffer are not currently mapped (GL_INVALID_OPERATION)
8058
shannon.woods%transgaming.com@gtempaccount.comc53376a2013-04-13 03:41:23 +00008059 // if size is zero, the copy is a successful no-op
8060 if (size > 0)
8061 {
8062 writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size);
8063 }
shannon.woods%transgaming.com@gtempaccount.com296c3f22013-04-13 03:39:39 +00008064 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008065 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008066 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008067 {
8068 return gl::error(GL_OUT_OF_MEMORY);
8069 }
8070}
8071
8072void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices)
8073{
8074 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)",
8075 program, uniformCount, uniformNames, uniformIndices);
8076
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008077 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008078 {
8079 gl::Context *context = gl::getNonLostContext();
8080
8081 if (context)
8082 {
8083 if (context->getClientVersion() < 3)
8084 {
8085 return gl::error(GL_INVALID_OPERATION);
8086 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008087
shannonwoods@chromium.orgc2ed9912013-05-30 00:05:33 +00008088 if (uniformCount < 0)
8089 {
8090 return gl::error(GL_INVALID_VALUE);
8091 }
8092
8093 gl::Program *programObject = context->getProgram(program);
8094
8095 if (!programObject)
8096 {
8097 if (context->getShader(program))
8098 {
8099 return gl::error(GL_INVALID_OPERATION);
8100 }
8101 else
8102 {
8103 return gl::error(GL_INVALID_VALUE);
8104 }
8105 }
8106
8107 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8108 if (!programObject->isLinked() || !programBinary)
8109 {
8110 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8111 {
8112 uniformIndices[uniformId] = GL_INVALID_INDEX;
8113 }
8114 }
8115 else
8116 {
8117 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8118 {
8119 uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]);
8120 }
8121 }
8122 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008123 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008124 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008125 {
8126 return gl::error(GL_OUT_OF_MEMORY);
8127 }
8128}
8129
8130void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params)
8131{
8132 EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
8133 program, uniformCount, uniformIndices, pname, params);
8134
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008135 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008136 {
8137 gl::Context *context = gl::getNonLostContext();
8138
8139 if (context)
8140 {
8141 if (context->getClientVersion() < 3)
8142 {
8143 return gl::error(GL_INVALID_OPERATION);
8144 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008145
shannonwoods@chromium.org2a9a9d22013-05-30 00:05:40 +00008146 if (uniformCount < 0)
8147 {
8148 return gl::error(GL_INVALID_VALUE);
8149 }
8150
8151 gl::Program *programObject = context->getProgram(program);
8152
8153 if (!programObject)
8154 {
8155 if (context->getShader(program))
8156 {
8157 return gl::error(GL_INVALID_OPERATION);
8158 }
8159 else
8160 {
8161 return gl::error(GL_INVALID_VALUE);
8162 }
8163 }
8164
8165 switch (pname)
8166 {
8167 case GL_UNIFORM_TYPE:
8168 case GL_UNIFORM_SIZE:
8169 case GL_UNIFORM_NAME_LENGTH:
8170 case GL_UNIFORM_BLOCK_INDEX:
8171 case GL_UNIFORM_OFFSET:
8172 case GL_UNIFORM_ARRAY_STRIDE:
8173 case GL_UNIFORM_MATRIX_STRIDE:
8174 case GL_UNIFORM_IS_ROW_MAJOR:
8175 break;
8176 default:
8177 return gl::error(GL_INVALID_ENUM);
8178 }
8179
8180 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8181
8182 if (!programBinary && uniformCount > 0)
8183 {
8184 return gl::error(GL_INVALID_VALUE);
8185 }
8186
8187 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8188 {
8189 const GLuint index = uniformIndices[uniformId];
8190
8191 if (index >= (GLuint)programBinary->getActiveUniformCount())
8192 {
8193 return gl::error(GL_INVALID_VALUE);
8194 }
8195 }
8196
8197 for (int uniformId = 0; uniformId < uniformCount; uniformId++)
8198 {
8199 const GLuint index = uniformIndices[uniformId];
8200 params[uniformId] = programBinary->getActiveUniformi(index, pname);
8201 }
8202 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008203 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008204 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008205 {
8206 return gl::error(GL_OUT_OF_MEMORY);
8207 }
8208}
8209
8210GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName)
8211{
8212 EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName);
8213
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008214 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008215 {
8216 gl::Context *context = gl::getNonLostContext();
8217
8218 if (context)
8219 {
8220 if (context->getClientVersion() < 3)
8221 {
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00008222 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008223 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008224
shannonwoods@chromium.org42766252013-05-30 00:07:12 +00008225 gl::Program *programObject = context->getProgram(program);
8226
8227 if (!programObject)
8228 {
8229 if (context->getShader(program))
8230 {
8231 return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX);
8232 }
8233 else
8234 {
8235 return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX);
8236 }
8237 }
8238
8239 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8240 if (!programBinary)
8241 {
8242 return GL_INVALID_INDEX;
8243 }
8244
8245 return programBinary->getUniformBlockIndex(uniformBlockName);
8246 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008247 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008248 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008249 {
8250 return gl::error(GL_OUT_OF_MEMORY, 0);
8251 }
8252
8253 return 0;
8254}
8255
8256void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params)
8257{
8258 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
8259 program, uniformBlockIndex, pname, params);
8260
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008261 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008262 {
8263 gl::Context *context = gl::getNonLostContext();
8264
8265 if (context)
8266 {
8267 if (context->getClientVersion() < 3)
8268 {
8269 return gl::error(GL_INVALID_OPERATION);
8270 }
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00008271 gl::Program *programObject = context->getProgram(program);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008272
shannonwoods@chromium.orge7317ca2013-05-30 00:07:35 +00008273 if (!programObject)
8274 {
8275 if (context->getShader(program))
8276 {
8277 return gl::error(GL_INVALID_OPERATION);
8278 }
8279 else
8280 {
8281 return gl::error(GL_INVALID_VALUE);
8282 }
8283 }
8284
8285 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8286
8287 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8288 {
8289 return gl::error(GL_INVALID_VALUE);
8290 }
8291
8292 switch (pname)
8293 {
8294 case GL_UNIFORM_BLOCK_BINDING:
8295 *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex));
8296 break;
8297
8298 case GL_UNIFORM_BLOCK_DATA_SIZE:
8299 case GL_UNIFORM_BLOCK_NAME_LENGTH:
8300 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
8301 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
8302 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
8303 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
8304 programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params);
8305 break;
8306
8307 default:
8308 return gl::error(GL_INVALID_ENUM);
8309 }
8310 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008311 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008312 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008313 {
8314 return gl::error(GL_OUT_OF_MEMORY);
8315 }
8316}
8317
8318void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName)
8319{
8320 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)",
8321 program, uniformBlockIndex, bufSize, length, uniformBlockName);
8322
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008323 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008324 {
8325 gl::Context *context = gl::getNonLostContext();
8326
8327 if (context)
8328 {
8329 if (context->getClientVersion() < 3)
8330 {
8331 return gl::error(GL_INVALID_OPERATION);
8332 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008333
shannonwoods@chromium.orgbeb02782013-05-30 00:07:28 +00008334 gl::Program *programObject = context->getProgram(program);
8335
8336 if (!programObject)
8337 {
8338 if (context->getShader(program))
8339 {
8340 return gl::error(GL_INVALID_OPERATION);
8341 }
8342 else
8343 {
8344 return gl::error(GL_INVALID_VALUE);
8345 }
8346 }
8347
8348 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8349
8350 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8351 {
8352 return gl::error(GL_INVALID_VALUE);
8353 }
8354
8355 programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName);
8356 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008357 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008358 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008359 {
8360 return gl::error(GL_OUT_OF_MEMORY);
8361 }
8362}
8363
8364void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
8365{
8366 EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)",
8367 program, uniformBlockIndex, uniformBlockBinding);
8368
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008369 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008370 {
8371 gl::Context *context = gl::getNonLostContext();
8372
8373 if (context)
8374 {
8375 if (context->getClientVersion() < 3)
8376 {
8377 return gl::error(GL_INVALID_OPERATION);
8378 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008379
shannonwoods@chromium.org70eb1ea2013-05-30 00:07:20 +00008380 if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings())
8381 {
8382 return gl::error(GL_INVALID_VALUE);
8383 }
8384
8385 gl::Program *programObject = context->getProgram(program);
8386
8387 if (!programObject)
8388 {
8389 if (context->getShader(program))
8390 {
8391 return gl::error(GL_INVALID_OPERATION);
8392 }
8393 else
8394 {
8395 return gl::error(GL_INVALID_VALUE);
8396 }
8397 }
8398
8399 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
8400
8401 // if never linked, there won't be any uniform blocks
8402 if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount())
8403 {
8404 return gl::error(GL_INVALID_VALUE);
8405 }
8406
8407 programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
8408 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008409 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008410 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008411 {
8412 return gl::error(GL_OUT_OF_MEMORY);
8413 }
8414}
8415
8416void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount)
8417{
8418 EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)",
8419 mode, first, count, instanceCount);
8420
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008421 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008422 {
8423 gl::Context *context = gl::getNonLostContext();
8424
8425 if (context)
8426 {
8427 if (context->getClientVersion() < 3)
8428 {
8429 return gl::error(GL_INVALID_OPERATION);
8430 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008431
Jamie Madill54133512013-06-21 09:33:07 -04008432 // glDrawArraysInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008433 UNIMPLEMENTED();
8434 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008435 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008436 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008437 {
8438 return gl::error(GL_OUT_OF_MEMORY);
8439 }
8440}
8441
8442void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount)
8443{
8444 EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)",
8445 mode, count, type, indices, instanceCount);
8446
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008447 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008448 {
8449 gl::Context *context = gl::getNonLostContext();
8450
8451 if (context)
8452 {
8453 if (context->getClientVersion() < 3)
8454 {
8455 return gl::error(GL_INVALID_OPERATION);
8456 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008457
Jamie Madill54133512013-06-21 09:33:07 -04008458 // glDrawElementsInstanced
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008459 UNIMPLEMENTED();
8460 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008461 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008462 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008463 {
8464 return gl::error(GL_OUT_OF_MEMORY);
8465 }
8466}
8467
8468GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags)
8469{
8470 EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags);
8471
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008472 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008473 {
8474 gl::Context *context = gl::getNonLostContext();
8475
8476 if (context)
8477 {
8478 if (context->getClientVersion() < 3)
8479 {
Jamie Madill5215e1a2013-07-26 11:55:19 -04008480 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(0));
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008481 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008482
Jamie Madill5215e1a2013-07-26 11:55:19 -04008483 if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
8484 {
8485 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0));
8486 }
8487
8488 if (flags != 0)
8489 {
8490 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0));
8491 }
8492
8493 return context->createFenceSync(condition);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008494 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008495 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008496 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008497 {
8498 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLsync>(NULL));
8499 }
8500
8501 return NULL;
8502}
8503
8504GLboolean __stdcall glIsSync(GLsync sync)
8505{
8506 EVENT("(GLsync sync = 0x%0.8p)", sync);
8507
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008508 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008509 {
8510 gl::Context *context = gl::getNonLostContext();
8511
8512 if (context)
8513 {
8514 if (context->getClientVersion() < 3)
8515 {
8516 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8517 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008518
Jamie Madill5215e1a2013-07-26 11:55:19 -04008519 return (context->getFenceSync(sync) != NULL);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008520 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008521 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008522 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008523 {
8524 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8525 }
8526
8527 return GL_FALSE;
8528}
8529
8530void __stdcall glDeleteSync(GLsync sync)
8531{
8532 EVENT("(GLsync sync = 0x%0.8p)", sync);
8533
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008534 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008535 {
8536 gl::Context *context = gl::getNonLostContext();
8537
8538 if (context)
8539 {
8540 if (context->getClientVersion() < 3)
8541 {
8542 return gl::error(GL_INVALID_OPERATION);
8543 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008544
Jamie Madill5215e1a2013-07-26 11:55:19 -04008545 if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
8546 {
8547 return gl::error(GL_INVALID_VALUE);
8548 }
8549
8550 context->deleteFenceSync(sync);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008551 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008552 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008553 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008554 {
8555 return gl::error(GL_OUT_OF_MEMORY);
8556 }
8557}
8558
8559GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
8560{
8561 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
8562 sync, flags, timeout);
8563
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008564 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008565 {
8566 gl::Context *context = gl::getNonLostContext();
8567
8568 if (context)
8569 {
8570 if (context->getClientVersion() < 3)
8571 {
Jamie Madill5215e1a2013-07-26 11:55:19 -04008572 return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008573 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008574
Jamie Madill5215e1a2013-07-26 11:55:19 -04008575 if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
8576 {
8577 return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
8578 }
8579
8580 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8581
8582 if (!fenceSync)
8583 {
8584 return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED);
8585 }
8586
8587 return fenceSync->clientWait(flags, timeout);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008588 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008589 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008590 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008591 {
8592 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8593 }
8594
8595 return GL_FALSE;
8596}
8597
8598void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
8599{
8600 EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)",
8601 sync, flags, timeout);
8602
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008603 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008604 {
8605 gl::Context *context = gl::getNonLostContext();
8606
8607 if (context)
8608 {
8609 if (context->getClientVersion() < 3)
8610 {
8611 return gl::error(GL_INVALID_OPERATION);
8612 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008613
Jamie Madill5215e1a2013-07-26 11:55:19 -04008614 if (flags != 0)
8615 {
8616 return gl::error(GL_INVALID_VALUE);
8617 }
8618
8619 if (timeout != GL_TIMEOUT_IGNORED)
8620 {
8621 return gl::error(GL_INVALID_VALUE);
8622 }
8623
8624 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8625
8626 if (!fenceSync)
8627 {
8628 return gl::error(GL_INVALID_VALUE);
8629 }
8630
8631 fenceSync->serverWait();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008632 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008633 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008634 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008635 {
8636 return gl::error(GL_OUT_OF_MEMORY);
8637 }
8638}
8639
8640void __stdcall glGetInteger64v(GLenum pname, GLint64* params)
8641{
8642 EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
8643 pname, params);
8644
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008645 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008646 {
8647 gl::Context *context = gl::getNonLostContext();
8648
8649 if (context)
8650 {
8651 if (context->getClientVersion() < 3)
8652 {
8653 return gl::error(GL_INVALID_OPERATION);
8654 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008655
Jamie Madill79f2f452013-12-19 11:13:02 -05008656 GLenum nativeType;
8657 unsigned int numParams = 0;
Jamie Madill893ab082014-05-16 16:56:10 -04008658 if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
8659 {
Jamie Madill79f2f452013-12-19 11:13:02 -05008660 return;
Jamie Madill893ab082014-05-16 16:56:10 -04008661 }
Jamie Madill79f2f452013-12-19 11:13:02 -05008662
8663 if (nativeType == GL_INT_64_ANGLEX)
Jamie Madill71fbd602013-07-19 16:36:55 -04008664 {
Jamie Madill79f2f452013-12-19 11:13:02 -05008665 context->getInteger64v(pname, params);
8666 }
Jamie Madill55856b12014-01-02 13:59:50 -05008667 else
Jamie Madill79f2f452013-12-19 11:13:02 -05008668 {
Jamie Madill55856b12014-01-02 13:59:50 -05008669 CastStateValues(context, nativeType, pname, numParams, params);
Jamie Madill71fbd602013-07-19 16:36:55 -04008670 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008671 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008672 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008673 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008674 {
8675 return gl::error(GL_OUT_OF_MEMORY);
8676 }
8677}
8678
8679void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values)
8680{
8681 EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)",
8682 sync, pname, bufSize, length, values);
8683
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008684 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008685 {
8686 gl::Context *context = gl::getNonLostContext();
8687
8688 if (context)
8689 {
8690 if (context->getClientVersion() < 3)
8691 {
8692 return gl::error(GL_INVALID_OPERATION);
8693 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008694
Jamie Madill5215e1a2013-07-26 11:55:19 -04008695 if (bufSize < 0)
8696 {
8697 return gl::error(GL_INVALID_VALUE);
8698 }
8699
8700 gl::FenceSync *fenceSync = context->getFenceSync(sync);
8701
8702 if (!fenceSync)
8703 {
8704 return gl::error(GL_INVALID_VALUE);
8705 }
8706
8707 switch (pname)
8708 {
8709 case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
8710 case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break;
8711 case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
8712 case GL_SYNC_FLAGS: values[0] = 0; break;
8713
8714 default:
8715 return gl::error(GL_INVALID_ENUM);
8716 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008717 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008718 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008719 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008720 {
8721 return gl::error(GL_OUT_OF_MEMORY);
8722 }
8723}
8724
8725void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data)
8726{
8727 EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)",
8728 target, index, data);
8729
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008730 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008731 {
8732 gl::Context *context = gl::getNonLostContext();
8733
8734 if (context)
8735 {
8736 if (context->getClientVersion() < 3)
8737 {
8738 return gl::error(GL_INVALID_OPERATION);
8739 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008740
Shannon Woods15934d52013-08-19 14:28:49 -04008741 switch (target)
8742 {
8743 case GL_TRANSFORM_FEEDBACK_BUFFER_START:
8744 case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
8745 case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
8746 if (index >= context->getMaxTransformFeedbackBufferBindings())
8747 return gl::error(GL_INVALID_VALUE);
8748 break;
8749 case GL_UNIFORM_BUFFER_START:
8750 case GL_UNIFORM_BUFFER_SIZE:
8751 case GL_UNIFORM_BUFFER_BINDING:
8752 if (index >= context->getMaximumCombinedUniformBufferBindings())
8753 return gl::error(GL_INVALID_VALUE);
8754 break;
8755 default:
8756 return gl::error(GL_INVALID_ENUM);
8757 }
8758
8759 if (!(context->getIndexedInteger64v(target, index, data)))
8760 {
8761 GLenum nativeType;
8762 unsigned int numParams = 0;
8763 if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams))
8764 return gl::error(GL_INVALID_ENUM);
8765
8766 if (numParams == 0)
8767 return; // it is known that pname is valid, but there are no parameters to return
8768
8769 if (nativeType == GL_INT)
8770 {
8771 GLint *intParams = new GLint[numParams];
8772
8773 context->getIndexedIntegerv(target, index, intParams);
8774
8775 for (unsigned int i = 0; i < numParams; ++i)
8776 {
8777 data[i] = static_cast<GLint64>(intParams[i]);
8778 }
8779
8780 delete [] intParams;
8781 }
8782 else
8783 {
8784 UNREACHABLE();
8785 }
8786 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008787 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008788 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008789 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008790 {
8791 return gl::error(GL_OUT_OF_MEMORY);
8792 }
8793}
8794
8795void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params)
8796{
8797 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)",
8798 target, pname, params);
8799
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008800 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008801 {
8802 gl::Context *context = gl::getNonLostContext();
8803
8804 if (context)
8805 {
8806 if (context->getClientVersion() < 3)
8807 {
8808 return gl::error(GL_INVALID_OPERATION);
8809 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008810
Jamie Madill70656a62014-03-05 15:01:26 -05008811 if (!gl::ValidBufferTarget(context, target))
8812 {
8813 return gl::error(GL_INVALID_ENUM);
8814 }
8815
8816 if (!gl::ValidBufferParameter(context, pname))
8817 {
8818 return gl::error(GL_INVALID_ENUM);
8819 }
8820
8821 gl::Buffer *buffer = context->getTargetBuffer(target);
8822
8823 if (!buffer)
8824 {
8825 // A null buffer means that "0" is bound to the requested buffer target
8826 return gl::error(GL_INVALID_OPERATION);
8827 }
8828
8829 switch (pname)
8830 {
8831 case GL_BUFFER_USAGE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008832 *params = static_cast<GLint64>(buffer->getUsage());
Jamie Madill70656a62014-03-05 15:01:26 -05008833 break;
8834 case GL_BUFFER_SIZE:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008835 *params = buffer->getSize();
Jamie Madill70656a62014-03-05 15:01:26 -05008836 break;
8837 case GL_BUFFER_ACCESS_FLAGS:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008838 *params = static_cast<GLint64>(buffer->getAccessFlags());
Jamie Madill70656a62014-03-05 15:01:26 -05008839 break;
8840 case GL_BUFFER_MAPPED:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008841 *params = static_cast<GLint64>(buffer->isMapped());
Jamie Madill70656a62014-03-05 15:01:26 -05008842 break;
8843 case GL_BUFFER_MAP_OFFSET:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008844 *params = buffer->getMapOffset();
Jamie Madill70656a62014-03-05 15:01:26 -05008845 break;
8846 case GL_BUFFER_MAP_LENGTH:
Brandon Jonesd38f9262014-06-18 16:26:45 -07008847 *params = buffer->getMapLength();
Jamie Madill70656a62014-03-05 15:01:26 -05008848 break;
8849 default: UNREACHABLE(); break;
8850 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008851 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008852 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008853 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008854 {
8855 return gl::error(GL_OUT_OF_MEMORY);
8856 }
8857}
8858
8859void __stdcall glGenSamplers(GLsizei count, GLuint* samplers)
8860{
8861 EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers);
8862
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008863 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008864 {
8865 gl::Context *context = gl::getNonLostContext();
8866
8867 if (context)
8868 {
8869 if (context->getClientVersion() < 3)
8870 {
8871 return gl::error(GL_INVALID_OPERATION);
8872 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008873
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008874 if (count < 0)
8875 {
8876 return gl::error(GL_INVALID_VALUE);
8877 }
8878
8879 for (int i = 0; i < count; i++)
8880 {
8881 samplers[i] = context->createSampler();
8882 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008883 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008884 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008885 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008886 {
8887 return gl::error(GL_OUT_OF_MEMORY);
8888 }
8889}
8890
8891void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers)
8892{
8893 EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers);
8894
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008895 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008896 {
8897 gl::Context *context = gl::getNonLostContext();
8898
8899 if (context)
8900 {
8901 if (context->getClientVersion() < 3)
8902 {
8903 return gl::error(GL_INVALID_OPERATION);
8904 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008905
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008906 if (count < 0)
8907 {
8908 return gl::error(GL_INVALID_VALUE);
8909 }
8910
8911 for (int i = 0; i < count; i++)
8912 {
8913 context->deleteSampler(samplers[i]);
8914 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008915 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008916 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008917 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008918 {
8919 return gl::error(GL_OUT_OF_MEMORY);
8920 }
8921}
8922
8923GLboolean __stdcall glIsSampler(GLuint sampler)
8924{
8925 EVENT("(GLuint sampler = %u)", sampler);
8926
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008927 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008928 {
8929 gl::Context *context = gl::getNonLostContext();
8930
8931 if (context)
8932 {
8933 if (context->getClientVersion() < 3)
8934 {
8935 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
8936 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008937
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008938 return context->isSampler(sampler);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008939 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008940 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008941 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008942 {
8943 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
8944 }
8945
8946 return GL_FALSE;
8947}
8948
8949void __stdcall glBindSampler(GLuint unit, GLuint sampler)
8950{
8951 EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler);
8952
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008953 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008954 {
8955 gl::Context *context = gl::getNonLostContext();
8956
8957 if (context)
8958 {
8959 if (context->getClientVersion() < 3)
8960 {
8961 return gl::error(GL_INVALID_OPERATION);
8962 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008963
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008964 if (sampler != 0 && !context->isSampler(sampler))
8965 {
8966 return gl::error(GL_INVALID_OPERATION);
8967 }
8968
8969 if (unit >= context->getMaximumCombinedTextureImageUnits())
8970 {
8971 return gl::error(GL_INVALID_VALUE);
8972 }
8973
8974 context->bindSampler(unit, sampler);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00008975 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008976 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008977 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008978 {
8979 return gl::error(GL_OUT_OF_MEMORY);
8980 }
8981}
8982
8983void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param)
8984{
8985 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param);
8986
Ehsan Akhgari10530c32014-07-02 20:37:53 -04008987 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008988 {
8989 gl::Context *context = gl::getNonLostContext();
8990
8991 if (context)
8992 {
8993 if (context->getClientVersion() < 3)
8994 {
8995 return gl::error(GL_INVALID_OPERATION);
8996 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00008997
Geoff Lang34dbb6f2013-08-05 15:05:47 -04008998 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04008999 {
9000 return;
9001 }
9002
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009003 if (!gl::ValidateTexParamParameters(context, pname, param))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009004 {
9005 return;
9006 }
9007
9008 if (!context->isSampler(sampler))
9009 {
9010 return gl::error(GL_INVALID_OPERATION);
9011 }
9012
9013 context->samplerParameteri(sampler, pname, param);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009014 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009015 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009016 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009017 {
9018 return gl::error(GL_OUT_OF_MEMORY);
9019 }
9020}
9021
9022void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param)
9023{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009024 glSamplerParameteri(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009025}
9026
9027void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param)
9028{
9029 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param);
9030
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009031 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009032 {
9033 gl::Context *context = gl::getNonLostContext();
9034
9035 if (context)
9036 {
9037 if (context->getClientVersion() < 3)
9038 {
9039 return gl::error(GL_INVALID_OPERATION);
9040 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009041
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009042 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009043 {
9044 return;
9045 }
9046
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009047 if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param)))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009048 {
9049 return;
9050 }
9051
9052 if (!context->isSampler(sampler))
9053 {
9054 return gl::error(GL_INVALID_OPERATION);
9055 }
9056
9057 context->samplerParameterf(sampler, pname, param);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009058 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009059 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009060 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009061 {
9062 return gl::error(GL_OUT_OF_MEMORY);
9063 }
9064}
9065
9066void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param)
9067{
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009068 glSamplerParameterf(sampler, pname, *param);
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009069}
9070
9071void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params)
9072{
9073 EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params);
9074
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009075 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009076 {
9077 gl::Context *context = gl::getNonLostContext();
9078
9079 if (context)
9080 {
9081 if (context->getClientVersion() < 3)
9082 {
9083 return gl::error(GL_INVALID_OPERATION);
9084 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009085
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009086 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009087 {
9088 return;
9089 }
9090
9091 if (!context->isSampler(sampler))
9092 {
9093 return gl::error(GL_INVALID_OPERATION);
9094 }
9095
9096 *params = context->getSamplerParameteri(sampler, pname);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009097 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009098 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009099 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009100 {
9101 return gl::error(GL_OUT_OF_MEMORY);
9102 }
9103}
9104
9105void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params)
9106{
9107 EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params);
9108
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009109 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009110 {
9111 gl::Context *context = gl::getNonLostContext();
9112
9113 if (context)
9114 {
9115 if (context->getClientVersion() < 3)
9116 {
9117 return gl::error(GL_INVALID_OPERATION);
9118 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009119
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009120 if (!gl::ValidateSamplerObjectParameter(pname))
Jamie Madillf6cc8cc2013-07-03 12:44:15 -04009121 {
9122 return;
9123 }
9124
9125 if (!context->isSampler(sampler))
9126 {
9127 return gl::error(GL_INVALID_OPERATION);
9128 }
9129
9130 *params = context->getSamplerParameterf(sampler, pname);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009131 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009132 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009133 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009134 {
9135 return gl::error(GL_OUT_OF_MEMORY);
9136 }
9137}
9138
9139void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor)
9140{
9141 EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor);
9142
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009143 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009144 {
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +00009145 if (index >= gl::MAX_VERTEX_ATTRIBS)
9146 {
9147 return gl::error(GL_INVALID_VALUE);
9148 }
9149
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009150 gl::Context *context = gl::getNonLostContext();
9151
9152 if (context)
9153 {
9154 if (context->getClientVersion() < 3)
9155 {
9156 return gl::error(GL_INVALID_OPERATION);
9157 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009158
shannon.woods%transgaming.com@gtempaccount.com8736bd62013-04-13 03:35:41 +00009159 context->setVertexAttribDivisor(index, divisor);
9160 }
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 glBindTransformFeedback(GLenum target, GLuint id)
9169{
9170 EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id);
9171
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009172 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009173 {
9174 gl::Context *context = gl::getNonLostContext();
9175
9176 if (context)
9177 {
9178 if (context->getClientVersion() < 3)
9179 {
9180 return gl::error(GL_INVALID_OPERATION);
9181 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009182
Geoff Langc8058452014-02-03 12:04:11 -05009183 switch (target)
9184 {
9185 case GL_TRANSFORM_FEEDBACK:
9186 {
9187 // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1)
9188 gl::TransformFeedback *curTransformFeedback = context->getCurrentTransformFeedback();
9189 if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused())
9190 {
9191 return gl::error(GL_INVALID_OPERATION);
9192 }
9193
9194 // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1)
9195 if (context->getTransformFeedback(id) == NULL)
9196 {
9197 return gl::error(GL_INVALID_OPERATION);
9198 }
9199
9200 context->bindTransformFeedback(id);
9201 }
9202 break;
9203
9204 default:
9205 return gl::error(GL_INVALID_ENUM);
9206 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009207 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009208 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009209 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009210 {
9211 return gl::error(GL_OUT_OF_MEMORY);
9212 }
9213}
9214
9215void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids)
9216{
9217 EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids);
9218
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009219 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009220 {
9221 gl::Context *context = gl::getNonLostContext();
9222
9223 if (context)
9224 {
9225 if (context->getClientVersion() < 3)
9226 {
9227 return gl::error(GL_INVALID_OPERATION);
9228 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009229
Geoff Langc8058452014-02-03 12:04:11 -05009230 for (int i = 0; i < n; i++)
9231 {
9232 context->deleteTransformFeedback(ids[i]);
9233 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009234 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009235 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009236 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009237 {
9238 return gl::error(GL_OUT_OF_MEMORY);
9239 }
9240}
9241
9242void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids)
9243{
9244 EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
9245
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009246 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009247 {
9248 gl::Context *context = gl::getNonLostContext();
9249
9250 if (context)
9251 {
9252 if (context->getClientVersion() < 3)
9253 {
9254 return gl::error(GL_INVALID_OPERATION);
9255 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009256
Geoff Langc8058452014-02-03 12:04:11 -05009257 for (int i = 0; i < n; i++)
9258 {
9259 ids[i] = context->createTransformFeedback();
9260 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009261 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009262 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009263 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009264 {
9265 return gl::error(GL_OUT_OF_MEMORY);
9266 }
9267}
9268
9269GLboolean __stdcall glIsTransformFeedback(GLuint id)
9270{
9271 EVENT("(GLuint id = %u)", id);
9272
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009273 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009274 {
9275 gl::Context *context = gl::getNonLostContext();
9276
9277 if (context)
9278 {
9279 if (context->getClientVersion() < 3)
9280 {
9281 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9282 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009283
Geoff Langc8058452014-02-03 12:04:11 -05009284 return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE);
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009285 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009286 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009287 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009288 {
9289 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9290 }
9291
9292 return GL_FALSE;
9293}
9294
9295void __stdcall glPauseTransformFeedback(void)
9296{
9297 EVENT("(void)");
9298
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009299 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009300 {
9301 gl::Context *context = gl::getNonLostContext();
9302
9303 if (context)
9304 {
9305 if (context->getClientVersion() < 3)
9306 {
9307 return gl::error(GL_INVALID_OPERATION);
9308 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009309
Geoff Langc8058452014-02-03 12:04:11 -05009310 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
9311 ASSERT(transformFeedback != NULL);
9312
9313 // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86)
9314 if (!transformFeedback->isStarted() || transformFeedback->isPaused())
9315 {
9316 return gl::error(GL_INVALID_OPERATION);
9317 }
9318
9319 transformFeedback->pause();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009320 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009321 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009322 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009323 {
9324 return gl::error(GL_OUT_OF_MEMORY);
9325 }
9326}
9327
9328void __stdcall glResumeTransformFeedback(void)
9329{
9330 EVENT("(void)");
9331
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009332 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009333 {
9334 gl::Context *context = gl::getNonLostContext();
9335
9336 if (context)
9337 {
9338 if (context->getClientVersion() < 3)
9339 {
9340 return gl::error(GL_INVALID_OPERATION);
9341 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009342
Geoff Langc8058452014-02-03 12:04:11 -05009343 gl::TransformFeedback *transformFeedback = context->getCurrentTransformFeedback();
9344 ASSERT(transformFeedback != NULL);
9345
9346 // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86)
9347 if (!transformFeedback->isStarted() || !transformFeedback->isPaused())
9348 {
9349 return gl::error(GL_INVALID_OPERATION);
9350 }
9351
9352 transformFeedback->resume();
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009353 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009354 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009355 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009356 {
9357 return gl::error(GL_OUT_OF_MEMORY);
9358 }
9359}
9360
9361void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary)
9362{
9363 EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)",
9364 program, bufSize, length, binaryFormat, binary);
9365
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009366 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009367 {
9368 gl::Context *context = gl::getNonLostContext();
9369
9370 if (context)
9371 {
9372 if (context->getClientVersion() < 3)
9373 {
9374 return gl::error(GL_INVALID_OPERATION);
9375 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009376
Jamie Madill54133512013-06-21 09:33:07 -04009377 // glGetProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009378 UNIMPLEMENTED();
9379 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009380 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009381 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009382 {
9383 return gl::error(GL_OUT_OF_MEMORY);
9384 }
9385}
9386
9387void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length)
9388{
9389 EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
9390 program, binaryFormat, binary, length);
9391
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009392 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009393 {
9394 gl::Context *context = gl::getNonLostContext();
9395
9396 if (context)
9397 {
9398 if (context->getClientVersion() < 3)
9399 {
9400 return gl::error(GL_INVALID_OPERATION);
9401 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009402
Jamie Madill54133512013-06-21 09:33:07 -04009403 // glProgramBinary
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009404 UNIMPLEMENTED();
9405 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009406 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009407 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009408 {
9409 return gl::error(GL_OUT_OF_MEMORY);
9410 }
9411}
9412
9413void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value)
9414{
9415 EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)",
9416 program, pname, value);
9417
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009418 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009419 {
9420 gl::Context *context = gl::getNonLostContext();
9421
9422 if (context)
9423 {
9424 if (context->getClientVersion() < 3)
9425 {
9426 return gl::error(GL_INVALID_OPERATION);
9427 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009428
Jamie Madill54133512013-06-21 09:33:07 -04009429 // glProgramParameteri
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009430 UNIMPLEMENTED();
9431 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009432 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009433 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009434 {
9435 return gl::error(GL_OUT_OF_MEMORY);
9436 }
9437}
9438
9439void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments)
9440{
9441 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)",
9442 target, numAttachments, attachments);
9443
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009444 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009445 {
9446 gl::Context *context = gl::getNonLostContext();
9447
9448 if (context)
9449 {
9450 if (context->getClientVersion() < 3)
9451 {
9452 return gl::error(GL_INVALID_OPERATION);
9453 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009454
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009455 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00009456 {
9457 return;
9458 }
9459
Geoff Langaae65a42014-05-26 12:43:44 -04009460 GLuint maxDimension = context->getCaps().maxRenderbufferSize;
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00009461 context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension);
9462 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009463 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009464 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009465 {
9466 return gl::error(GL_OUT_OF_MEMORY);
9467 }
9468}
9469
9470void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height)
9471{
9472 EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, "
9473 "GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
9474 target, numAttachments, attachments, x, y, width, height);
9475
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009476 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009477 {
9478 gl::Context *context = gl::getNonLostContext();
9479
9480 if (context)
9481 {
9482 if (context->getClientVersion() < 3)
9483 {
9484 return gl::error(GL_INVALID_OPERATION);
9485 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009486
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009487 if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments))
shannonwoods@chromium.orgd63ef892013-05-30 00:10:56 +00009488 {
9489 return;
9490 }
9491
9492 context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height);
9493 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009494 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009495 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009496 {
9497 return gl::error(GL_OUT_OF_MEMORY);
9498 }
9499}
9500
9501void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
9502{
9503 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
9504 target, levels, internalformat, width, height);
9505
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009506 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009507 {
9508 gl::Context *context = gl::getNonLostContext();
9509
9510 if (context)
9511 {
9512 if (context->getClientVersion() < 3)
9513 {
9514 return gl::error(GL_INVALID_OPERATION);
9515 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009516
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009517 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1))
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009518 {
9519 return;
9520 }
9521
9522 switch (target)
9523 {
9524 case GL_TEXTURE_2D:
9525 {
9526 gl::Texture2D *texture2d = context->getTexture2D();
9527 texture2d->storage(levels, internalformat, width, height);
9528 }
9529 break;
9530
Geoff Lang01c21d22013-09-24 11:52:16 -04009531 case GL_TEXTURE_CUBE_MAP:
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009532 {
9533 gl::TextureCubeMap *textureCube = context->getTextureCubeMap();
9534 textureCube->storage(levels, internalformat, width);
9535 }
9536 break;
9537
9538 default:
9539 return gl::error(GL_INVALID_ENUM);
9540 }
9541 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009542 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009543 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009544 {
9545 return gl::error(GL_OUT_OF_MEMORY);
9546 }
9547}
9548
9549void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
9550{
9551 EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, "
9552 "GLsizei height = %d, GLsizei depth = %d)",
9553 target, levels, internalformat, width, height, depth);
9554
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009555 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009556 {
9557 gl::Context *context = gl::getNonLostContext();
9558
9559 if (context)
9560 {
9561 if (context->getClientVersion() < 3)
9562 {
9563 return gl::error(GL_INVALID_OPERATION);
9564 }
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009565
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009566 if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth))
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009567 {
9568 return;
9569 }
9570
9571 switch (target)
9572 {
9573 case GL_TEXTURE_3D:
9574 {
9575 gl::Texture3D *texture3d = context->getTexture3D();
9576 texture3d->storage(levels, internalformat, width, height, depth);
9577 }
9578 break;
9579
9580 case GL_TEXTURE_2D_ARRAY:
9581 {
9582 gl::Texture2DArray *texture2darray = context->getTexture2DArray();
9583 texture2darray->storage(levels, internalformat, width, height, depth);
9584 }
9585 break;
9586
9587 default:
Geoff Lang01c21d22013-09-24 11:52:16 -04009588 UNREACHABLE();
shannonwoods@chromium.org8757c062013-05-30 00:14:24 +00009589 }
shannon.woods%transgaming.com@gtempaccount.com14eb55e2013-04-13 03:35:06 +00009590 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009591 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009592 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009593 {
9594 return gl::error(GL_OUT_OF_MEMORY);
9595 }
9596}
9597
9598void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params)
9599{
9600 EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, "
9601 "GLint* params = 0x%0.8p)",
9602 target, internalformat, pname, bufSize, params);
9603
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009604 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009605 {
9606 gl::Context *context = gl::getNonLostContext();
9607
9608 if (context)
9609 {
9610 if (context->getClientVersion() < 3)
9611 {
9612 return gl::error(GL_INVALID_OPERATION);
9613 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009614
Geoff Langcec35902014-04-16 10:52:36 -04009615 const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(internalformat);
9616 if (!formatCaps.colorRendering && !formatCaps.depthRendering && !formatCaps.stencilRendering)
Shannon Woods809d2502013-07-08 10:32:18 -04009617 {
9618 return gl::error(GL_INVALID_ENUM);
9619 }
9620
9621 if (target != GL_RENDERBUFFER)
9622 {
9623 return gl::error(GL_INVALID_ENUM);
9624 }
9625
9626 if (bufSize < 0)
9627 {
9628 return gl::error(GL_INVALID_VALUE);
9629 }
9630
9631 switch (pname)
9632 {
9633 case GL_NUM_SAMPLE_COUNTS:
9634 if (bufSize != 0)
9635 *params = context->getNumSampleCounts(internalformat);
9636 break;
9637 case GL_SAMPLES:
9638 context->getSampleCounts(internalformat, bufSize, params);
9639 break;
9640 default:
9641 return gl::error(GL_INVALID_ENUM);
9642 }
shannonwoods@chromium.org705fc2f2013-05-30 00:17:14 +00009643 }
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009644 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009645 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.coma8171752013-04-13 03:29:28 +00009646 {
9647 return gl::error(GL_OUT_OF_MEMORY);
9648 }
9649}
9650
9651// Extension functions
9652
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009653void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
9654 GLbitfield mask, GLenum filter)
9655{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00009656 EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009657 "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
9658 "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
9659 srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
9660
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009661 ANGLE_TRY
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009662 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +00009663 gl::Context *context = gl::getNonLostContext();
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009664
9665 if (context)
9666 {
Geoff Lang34dbb6f2013-08-05 15:05:47 -04009667 if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
Geoff Lang758d5b22013-06-11 11:42:50 -04009668 dstX0, dstY0, dstX1, dstY1, mask, filter,
9669 true))
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009670 {
Geoff Lang758d5b22013-06-11 11:42:50 -04009671 return;
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009672 }
9673
Geoff Lang758d5b22013-06-11 11:42:50 -04009674 context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1,
9675 mask, filter);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009676 }
9677 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009678 ANGLE_CATCH_ALL
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009679 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009680 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4cbc5902010-08-24 19:20:26 +00009681 }
9682}
9683
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00009684void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
9685 GLint border, GLenum format, GLenum type, const GLvoid* pixels)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009686{
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +00009687 EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
daniel@transgaming.comb5b06162010-03-21 04:31:32 +00009688 "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
daniel@transgaming.comfe4b8272010-04-08 03:51:20 +00009689 "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009690 target, level, internalformat, width, height, depth, border, format, type, pixels);
9691
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009692 ANGLE_TRY
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009693 {
9694 UNIMPLEMENTED(); // FIXME
9695 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009696 ANGLE_CATCH_ALL
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009697 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009698 return gl::error(GL_OUT_OF_MEMORY);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009699 }
9700}
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +00009701
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009702void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length,
9703 GLenum *binaryFormat, void *binary)
9704{
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009705 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 +00009706 program, bufSize, length, binaryFormat, binary);
9707
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009708 ANGLE_TRY
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009709 {
9710 gl::Context *context = gl::getNonLostContext();
9711
9712 if (context)
9713 {
9714 gl::Program *programObject = context->getProgram(program);
9715
daniel@transgaming.com716056c2012-07-24 18:38:59 +00009716 if (!programObject || !programObject->isLinked())
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009717 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009718 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009719 }
9720
9721 gl::ProgramBinary *programBinary = programObject->getProgramBinary();
9722
9723 if (!programBinary)
9724 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009725 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009726 }
9727
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009728 if (!programBinary->save(binary, bufSize, length))
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009729 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009730 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009731 }
apatrick@chromium.org90080e32012-07-09 22:15:33 +00009732
9733 *binaryFormat = GL_PROGRAM_BINARY_ANGLE;
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009734 }
9735 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009736 ANGLE_CATCH_ALL
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009737 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009738 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009739 }
9740}
9741
9742void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat,
9743 const void *binary, GLint length)
9744{
9745 EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)",
9746 program, binaryFormat, binary, length);
9747
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009748 ANGLE_TRY
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009749 {
9750 gl::Context *context = gl::getNonLostContext();
9751
9752 if (context)
9753 {
9754 if (binaryFormat != GL_PROGRAM_BINARY_ANGLE)
9755 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009756 return gl::error(GL_INVALID_ENUM);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009757 }
9758
9759 gl::Program *programObject = context->getProgram(program);
9760
9761 if (!programObject)
9762 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009763 return gl::error(GL_INVALID_OPERATION);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009764 }
9765
daniel@transgaming.com95d29422012-07-24 18:36:10 +00009766 context->setProgramBinary(program, binary, length);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009767 }
9768 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009769 ANGLE_CATCH_ALL
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009770 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +00009771 return gl::error(GL_OUT_OF_MEMORY);
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +00009772 }
9773}
9774
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009775void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs)
9776{
9777 EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
9778
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009779 ANGLE_TRY
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009780 {
9781 gl::Context *context = gl::getNonLostContext();
9782
9783 if (context)
9784 {
Geoff Langaae65a42014-05-26 12:43:44 -04009785 if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009786 {
9787 return gl::error(GL_INVALID_VALUE);
9788 }
9789
9790 if (context->getDrawFramebufferHandle() == 0)
9791 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009792 if (n != 1)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009793 {
9794 return gl::error(GL_INVALID_OPERATION);
9795 }
9796
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009797 if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009798 {
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009799 return gl::error(GL_INVALID_OPERATION);
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009800 }
9801 }
9802 else
9803 {
9804 for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
9805 {
9806 const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
9807 if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
9808 {
9809 return gl::error(GL_INVALID_OPERATION);
9810 }
9811 }
9812 }
9813
9814 gl::Framebuffer *framebuffer = context->getDrawFramebuffer();
9815
Geoff Langaae65a42014-05-26 12:43:44 -04009816 for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++)
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009817 {
9818 framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]);
9819 }
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009820
Geoff Langaae65a42014-05-26 12:43:44 -04009821 for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++)
shannon.woods%transgaming.com@gtempaccount.com2fa73c52013-04-13 03:37:20 +00009822 {
9823 framebuffer->setDrawBufferState(colorAttachment, GL_NONE);
9824 }
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009825 }
9826 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009827 ANGLE_CATCH_ALL
shannon.woods%transgaming.com@gtempaccount.com4059a382013-04-13 03:31:16 +00009828 {
9829 return gl::error(GL_OUT_OF_MEMORY);
9830 }
9831}
9832
Shannon Woodsb3801742014-03-27 14:59:19 -04009833void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params)
9834{
9835 EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params);
9836
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009837 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009838 {
9839 gl::Context *context = gl::getNonLostContext();
9840
9841 if (context)
9842 {
Shannon Woodsb3801742014-03-27 14:59:19 -04009843 if (!gl::ValidBufferTarget(context, target))
9844 {
9845 return gl::error(GL_INVALID_ENUM);
9846 }
9847
9848 if (pname != GL_BUFFER_MAP_POINTER)
9849 {
9850 return gl::error(GL_INVALID_ENUM);
9851 }
9852
9853 gl::Buffer *buffer = context->getTargetBuffer(target);
9854
Brandon Jonesd38f9262014-06-18 16:26:45 -07009855 if (!buffer || !buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009856 {
9857 *params = NULL;
9858 }
Shannon Woods6dc7f362014-06-25 21:12:02 -04009859 else
9860 {
9861 *params = buffer->getMapPointer();
9862 }
Shannon Woodsb3801742014-03-27 14:59:19 -04009863 }
9864 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009865 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009866 {
9867 return gl::error(GL_OUT_OF_MEMORY);
9868 }
9869}
9870
9871void * __stdcall glMapBufferOES(GLenum target, GLenum access)
9872{
9873 EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access);
9874
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009875 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009876 {
9877 gl::Context *context = gl::getNonLostContext();
9878
9879 if (context)
9880 {
9881 if (!gl::ValidBufferTarget(context, target))
9882 {
9883 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9884 }
9885
9886 gl::Buffer *buffer = context->getTargetBuffer(target);
9887
9888 if (buffer == NULL)
9889 {
9890 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9891 }
9892
9893 if (access != GL_WRITE_ONLY_OES)
9894 {
9895 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9896 }
9897
Brandon Jonesd38f9262014-06-18 16:26:45 -07009898 if (buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009899 {
9900 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9901 }
9902
Brandon Jonesd38f9262014-06-18 16:26:45 -07009903 return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT);
Shannon Woodsb3801742014-03-27 14:59:19 -04009904 }
9905 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009906 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009907 {
9908 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
9909 }
9910
9911 return NULL;
9912}
9913
9914GLboolean __stdcall glUnmapBufferOES(GLenum target)
9915{
9916 EVENT("(GLenum target = 0x%X)", target);
9917
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009918 ANGLE_TRY
Shannon Woodsb3801742014-03-27 14:59:19 -04009919 {
9920 gl::Context *context = gl::getNonLostContext();
9921
9922 if (context)
9923 {
9924 if (!gl::ValidBufferTarget(context, target))
9925 {
9926 return gl::error(GL_INVALID_ENUM, GL_FALSE);
9927 }
9928
9929 gl::Buffer *buffer = context->getTargetBuffer(target);
9930
Brandon Jonesd38f9262014-06-18 16:26:45 -07009931 if (buffer == NULL || !buffer->isMapped())
Shannon Woodsb3801742014-03-27 14:59:19 -04009932 {
9933 return gl::error(GL_INVALID_OPERATION, GL_FALSE);
9934 }
9935
9936 // TODO: detect if we had corruption. if so, throw an error and return false.
9937
9938 buffer->unmap();
9939
9940 return GL_TRUE;
9941 }
9942 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009943 ANGLE_CATCH_ALL
Shannon Woodsb3801742014-03-27 14:59:19 -04009944 {
9945 return gl::error(GL_OUT_OF_MEMORY, GL_FALSE);
9946 }
9947
9948 return GL_FALSE;
9949}
9950
Shannon Woods916e7692014-03-27 16:58:22 -04009951void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
9952{
9953 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
9954 target, offset, length, access);
9955
Ehsan Akhgari10530c32014-07-02 20:37:53 -04009956 ANGLE_TRY
Shannon Woods916e7692014-03-27 16:58:22 -04009957 {
9958 gl::Context *context = gl::getNonLostContext();
9959
9960 if (context)
9961 {
9962 if (!gl::ValidBufferTarget(context, target))
9963 {
9964 return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL));
9965 }
9966
9967 if (offset < 0 || length < 0)
9968 {
9969 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
9970 }
9971
9972 gl::Buffer *buffer = context->getTargetBuffer(target);
9973
9974 if (buffer == NULL)
9975 {
9976 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
9977 }
9978
9979 // Check for buffer overflow
9980 size_t offsetSize = static_cast<size_t>(offset);
9981 size_t lengthSize = static_cast<size_t>(length);
9982
9983 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
Brandon Jonesd38f9262014-06-18 16:26:45 -07009984 offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
Shannon Woods916e7692014-03-27 16:58:22 -04009985 {
9986 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
9987 }
9988
9989 // Check for invalid bits in the mask
9990 GLbitfield allAccessBits = GL_MAP_READ_BIT |
9991 GL_MAP_WRITE_BIT |
9992 GL_MAP_INVALIDATE_RANGE_BIT |
9993 GL_MAP_INVALIDATE_BUFFER_BIT |
9994 GL_MAP_FLUSH_EXPLICIT_BIT |
9995 GL_MAP_UNSYNCHRONIZED_BIT;
9996
9997 if (access & ~(allAccessBits))
9998 {
9999 return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL));
10000 }
10001
Brandon Jonesd38f9262014-06-18 16:26:45 -070010002 if (length == 0 || buffer->isMapped())
Shannon Woods916e7692014-03-27 16:58:22 -040010003 {
10004 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10005 }
10006
10007 // Check for invalid bit combinations
10008 if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
10009 {
10010 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10011 }
10012
10013 GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
10014 GL_MAP_INVALIDATE_BUFFER_BIT |
10015 GL_MAP_UNSYNCHRONIZED_BIT;
10016
10017 if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
10018 {
10019 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10020 }
10021
10022 if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
10023 {
10024 return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL));
10025 }
10026
10027 return buffer->mapRange(offset, length, access);
10028 }
10029 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010030 ANGLE_CATCH_ALL
Shannon Woods916e7692014-03-27 16:58:22 -040010031 {
10032 return gl::error(GL_OUT_OF_MEMORY, reinterpret_cast<GLvoid*>(NULL));
10033 }
10034
10035 return NULL;
10036}
10037
10038void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length)
10039{
10040 EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length);
10041
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010042 ANGLE_TRY
Shannon Woods916e7692014-03-27 16:58:22 -040010043 {
10044 gl::Context *context = gl::getNonLostContext();
10045
10046 if (context)
10047 {
10048 if (offset < 0 || length < 0)
10049 {
10050 return gl::error(GL_INVALID_VALUE);
10051 }
10052
10053 if (!gl::ValidBufferTarget(context, target))
10054 {
10055 return gl::error(GL_INVALID_ENUM);
10056 }
10057
10058 gl::Buffer *buffer = context->getTargetBuffer(target);
10059
10060 if (buffer == NULL)
10061 {
10062 return gl::error(GL_INVALID_OPERATION);
10063 }
10064
Brandon Jonesd38f9262014-06-18 16:26:45 -070010065 if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0)
Shannon Woods916e7692014-03-27 16:58:22 -040010066 {
10067 return gl::error(GL_INVALID_OPERATION);
10068 }
10069
10070 // Check for buffer overflow
10071 size_t offsetSize = static_cast<size_t>(offset);
10072 size_t lengthSize = static_cast<size_t>(length);
10073
10074 if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
Brandon Jonesd38f9262014-06-18 16:26:45 -070010075 offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength()))
Shannon Woods916e7692014-03-27 16:58:22 -040010076 {
10077 return gl::error(GL_INVALID_VALUE);
10078 }
10079
10080 // We do not currently support a non-trivial implementation of FlushMappedBufferRange
10081 }
10082 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010083 ANGLE_CATCH_ALL
Shannon Woods916e7692014-03-27 16:58:22 -040010084 {
10085 return gl::error(GL_OUT_OF_MEMORY);
10086 }
10087}
10088
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010089__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname)
10090{
10091 struct Extension
10092 {
10093 const char *name;
10094 __eglMustCastToProperFunctionPointerType address;
10095 };
10096
10097 static const Extension glExtensions[] =
10098 {
10099 {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
daniel@transgaming.com01868132010-08-24 19:21:17 +000010100 {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
daniel@transgaming.com1fe96c92011-01-14 15:08:44 +000010101 {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
apatrick@chromium.orgd3bd0ad2010-08-30 18:55:36 +000010102 {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
10103 {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
10104 {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
10105 {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
10106 {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
10107 {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
10108 {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
zmo@google.coma574f782011-10-03 21:45:23 +000010109 {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE},
daniel@transgaming.com0bd1f2f2011-11-11 04:19:03 +000010110 {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT},
daniel@transgaming.com709ed112011-11-12 03:18:10 +000010111 {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
10112 {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
10113 {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
10114 {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
daniel@transgaming.com86bdb822012-01-20 18:24:39 +000010115 {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
10116 {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
10117 {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
10118 {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
10119 {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
10120 {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
10121 {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
shannon.woods%transgaming.com@gtempaccount.com77d94722013-04-13 03:34:22 +000010122 {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT},
daniel@transgaming.comdce02fd2012-01-27 15:39:51 +000010123 {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE},
10124 {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE},
10125 {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE},
apatrick@chromium.org3ce8dbc2012-06-08 17:52:30 +000010126 {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES},
Shannon Woodsb3801742014-03-27 14:59:19 -040010127 {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES},
10128 {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES},
10129 {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES},
Shannon Woods916e7692014-03-27 16:58:22 -040010130 {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES},
10131 {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT},
10132 {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, };
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010133
shannon.woods@transgaming.comd438fd42013-02-28 23:17:45 +000010134 for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++)
daniel@transgaming.comce3d0f22010-05-04 03:35:14 +000010135 {
10136 if (strcmp(procname, glExtensions[ext].name) == 0)
10137 {
10138 return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address;
10139 }
10140 }
10141
10142 return NULL;
10143}
10144
daniel@transgaming.com17f548c2011-11-09 17:47:02 +000010145// Non-public functions used by EGL
10146
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010147bool __stdcall glBindTexImage(egl::Surface *surface)
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010148{
10149 EVENT("(egl::Surface* surface = 0x%0.8p)",
10150 surface);
10151
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010152 ANGLE_TRY
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010153 {
daniel@transgaming.com9d788502011-11-09 17:46:55 +000010154 gl::Context *context = gl::getNonLostContext();
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010155
10156 if (context)
10157 {
10158 gl::Texture2D *textureObject = context->getTexture2D();
Geoff Lang32d508e2014-02-11 09:39:48 -050010159 ASSERT(textureObject != NULL);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010160
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010161 if (textureObject->isImmutable())
10162 {
10163 return false;
10164 }
10165
Geoff Lang32d508e2014-02-11 09:39:48 -050010166 textureObject->bindTexImage(surface);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010167 }
10168 }
Ehsan Akhgari10530c32014-07-02 20:37:53 -040010169 ANGLE_CATCH_ALL
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010170 {
shannon.woods@transgaming.com779aa262013-02-28 23:04:58 +000010171 return gl::error(GL_OUT_OF_MEMORY, false);
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010172 }
daniel@transgaming.com64a0fb22011-11-11 04:10:40 +000010173
10174 return true;
jbauman@chromium.orgae345802011-03-30 22:04:25 +000010175}
10176
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000010177}