shannon.woods@transgaming.com | bdf2d80 | 2013-02-28 23:16:20 +0000 | [diff] [blame] | 1 | #include "precompiled.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2 | // |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 3 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4 | // 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.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 10 | #include "common/version.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | |
| 12 | #include "libGLESv2/main.h" |
shannonwoods@chromium.org | a2ecfcc | 2013-05-30 00:11:59 +0000 | [diff] [blame] | 13 | #include "common/utilities.h" |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 14 | #include "libGLESv2/formatutils.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 15 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Fence.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 17 | #include "libGLESv2/Framebuffer.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 18 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 19 | #include "libGLESv2/Program.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 20 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 21 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 22 | #include "libGLESv2/Query.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 23 | #include "libGLESv2/Context.h" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 24 | #include "libGLESv2/VertexArray.h" |
Brandon Jones | 5bf9829 | 2014-06-06 17:19:38 -0700 | [diff] [blame] | 25 | #include "libGLESv2/VertexAttribute.h" |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 26 | #include "libGLESv2/TransformFeedback.h" |
Jamie Madill | e261b44 | 2014-06-25 12:42:21 -0400 | [diff] [blame] | 27 | #include "libGLESv2/FramebufferAttachment.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 28 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 29 | #include "libGLESv2/validationES.h" |
| 30 | #include "libGLESv2/validationES2.h" |
| 31 | #include "libGLESv2/validationES3.h" |
Jamie Madill | 55856b1 | 2014-01-02 13:59:50 -0500 | [diff] [blame] | 32 | #include "libGLESv2/queryconversions.h" |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 33 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 34 | extern "C" |
| 35 | { |
| 36 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 37 | // OpenGL ES 2.0 functions |
| 38 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 39 | void __stdcall glActiveTexture(GLenum texture) |
| 40 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 41 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 43 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 44 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 45 | if (context) |
| 46 | { |
| 47 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getMaximumCombinedTextureImageUnits() - 1) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 48 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 49 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 50 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 51 | |
| 52 | context->getState().setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 57 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 58 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 59 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 60 | gl::Context *context = gl::getNonLostContext(); |
| 61 | |
| 62 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 63 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 64 | gl::Program *programObject = context->getProgram(program); |
| 65 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 67 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 68 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 69 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 70 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 71 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 72 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 73 | else |
| 74 | { |
| 75 | return gl::error(GL_INVALID_VALUE); |
| 76 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 77 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 78 | |
| 79 | if (!shaderObject) |
| 80 | { |
| 81 | if (context->getProgram(shader)) |
| 82 | { |
| 83 | return gl::error(GL_INVALID_OPERATION); |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | return gl::error(GL_INVALID_VALUE); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if (!programObject->attachShader(shaderObject)) |
| 92 | { |
| 93 | return gl::error(GL_INVALID_OPERATION); |
| 94 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 95 | } |
| 96 | } |
| 97 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 98 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 99 | { |
| 100 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 101 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 102 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 103 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 104 | if (context) |
| 105 | { |
| 106 | if (!ValidateBeginQuery(context, target, id)) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 107 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 108 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 109 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 110 | |
| 111 | context->beginQuery(target, id); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 115 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 116 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 117 | EVENT("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 118 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 119 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 120 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 121 | return gl::error(GL_INVALID_VALUE); |
| 122 | } |
| 123 | |
| 124 | gl::Context *context = gl::getNonLostContext(); |
| 125 | |
| 126 | if (context) |
| 127 | { |
| 128 | gl::Program *programObject = context->getProgram(program); |
| 129 | |
| 130 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 131 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 132 | if (context->getShader(program)) |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 133 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 134 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 135 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 136 | else |
| 137 | { |
| 138 | return gl::error(GL_INVALID_VALUE); |
| 139 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 140 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 141 | |
| 142 | if (strncmp(name, "gl_", 3) == 0) |
| 143 | { |
| 144 | return gl::error(GL_INVALID_OPERATION); |
| 145 | } |
| 146 | |
| 147 | programObject->bindAttributeLocation(index, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | |
| 151 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 152 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 153 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 154 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 155 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 156 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 157 | if (context) |
| 158 | { |
| 159 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 160 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 161 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 162 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 163 | |
| 164 | switch (target) |
| 165 | { |
| 166 | case GL_ARRAY_BUFFER: |
| 167 | context->bindArrayBuffer(buffer); |
| 168 | return; |
| 169 | case GL_ELEMENT_ARRAY_BUFFER: |
| 170 | context->bindElementArrayBuffer(buffer); |
| 171 | return; |
| 172 | case GL_COPY_READ_BUFFER: |
| 173 | context->bindCopyReadBuffer(buffer); |
| 174 | return; |
| 175 | case GL_COPY_WRITE_BUFFER: |
| 176 | context->bindCopyWriteBuffer(buffer); |
| 177 | return; |
| 178 | case GL_PIXEL_PACK_BUFFER: |
| 179 | context->bindPixelPackBuffer(buffer); |
| 180 | return; |
| 181 | case GL_PIXEL_UNPACK_BUFFER: |
| 182 | context->bindPixelUnpackBuffer(buffer); |
| 183 | return; |
| 184 | case GL_UNIFORM_BUFFER: |
| 185 | context->bindGenericUniformBuffer(buffer); |
| 186 | return; |
| 187 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 188 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 189 | return; |
| 190 | default: |
| 191 | return gl::error(GL_INVALID_ENUM); |
| 192 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 197 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 198 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 199 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 200 | if (!gl::ValidFramebufferTarget(target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 201 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 202 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 203 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 204 | |
| 205 | gl::Context *context = gl::getNonLostContext(); |
| 206 | |
| 207 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 208 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 209 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 210 | { |
| 211 | context->bindReadFramebuffer(framebuffer); |
| 212 | } |
| 213 | |
| 214 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 215 | { |
| 216 | context->bindDrawFramebuffer(framebuffer); |
| 217 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | |
| 221 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 222 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 223 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 224 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 225 | if (target != GL_RENDERBUFFER) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 226 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 227 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 228 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 229 | |
| 230 | gl::Context *context = gl::getNonLostContext(); |
| 231 | |
| 232 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 233 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 234 | context->bindRenderbuffer(renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
| 238 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 239 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 240 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 241 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 242 | gl::Context *context = gl::getNonLostContext(); |
| 243 | |
| 244 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 245 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 246 | gl::Texture *textureObject = context->getTexture(texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 247 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 248 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 249 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 250 | return gl::error(GL_INVALID_OPERATION); |
| 251 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 252 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 253 | switch (target) |
| 254 | { |
| 255 | case GL_TEXTURE_2D: |
| 256 | context->bindTexture2D(texture); |
| 257 | return; |
| 258 | case GL_TEXTURE_CUBE_MAP: |
| 259 | context->bindTextureCubeMap(texture); |
| 260 | return; |
| 261 | case GL_TEXTURE_3D: |
| 262 | if (context->getClientVersion() < 3) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 263 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 264 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 265 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 266 | context->bindTexture3D(texture); |
| 267 | return; |
| 268 | case GL_TEXTURE_2D_ARRAY: |
| 269 | if (context->getClientVersion() < 3) |
| 270 | { |
| 271 | return gl::error(GL_INVALID_ENUM); |
| 272 | } |
| 273 | context->bindTexture2DArray(texture); |
| 274 | return; |
| 275 | default: |
| 276 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 277 | } |
| 278 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 282 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 283 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 284 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 285 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 286 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 287 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 288 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 289 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 290 | context->getState().setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
| 294 | void __stdcall glBlendEquation(GLenum mode) |
| 295 | { |
| 296 | glBlendEquationSeparate(mode, mode); |
| 297 | } |
| 298 | |
| 299 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 300 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 301 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 302 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 303 | gl::Context *context = gl::getNonLostContext(); |
| 304 | |
| 305 | switch (modeRGB) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 306 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 307 | case GL_FUNC_ADD: |
| 308 | case GL_FUNC_SUBTRACT: |
| 309 | case GL_FUNC_REVERSE_SUBTRACT: |
| 310 | case GL_MIN: |
| 311 | case GL_MAX: |
| 312 | break; |
shannon.woods%transgaming.com@gtempaccount.com | 00b6a0e | 2013-04-13 03:38:00 +0000 | [diff] [blame] | 313 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 314 | default: |
| 315 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 316 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 317 | |
| 318 | switch (modeAlpha) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 319 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 320 | case GL_FUNC_ADD: |
| 321 | case GL_FUNC_SUBTRACT: |
| 322 | case GL_FUNC_REVERSE_SUBTRACT: |
| 323 | case GL_MIN: |
| 324 | case GL_MAX: |
| 325 | break; |
| 326 | |
| 327 | default: |
| 328 | return gl::error(GL_INVALID_ENUM); |
| 329 | } |
| 330 | |
| 331 | if (context) |
| 332 | { |
| 333 | context->getState().setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
| 337 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 338 | { |
| 339 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 340 | } |
| 341 | |
| 342 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 343 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 344 | EVENT("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 345 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 346 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 347 | gl::Context *context = gl::getNonLostContext(); |
| 348 | |
| 349 | switch (srcRGB) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 350 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 351 | case GL_ZERO: |
| 352 | case GL_ONE: |
| 353 | case GL_SRC_COLOR: |
| 354 | case GL_ONE_MINUS_SRC_COLOR: |
| 355 | case GL_DST_COLOR: |
| 356 | case GL_ONE_MINUS_DST_COLOR: |
| 357 | case GL_SRC_ALPHA: |
| 358 | case GL_ONE_MINUS_SRC_ALPHA: |
| 359 | case GL_DST_ALPHA: |
| 360 | case GL_ONE_MINUS_DST_ALPHA: |
| 361 | case GL_CONSTANT_COLOR: |
| 362 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 363 | case GL_CONSTANT_ALPHA: |
| 364 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 365 | case GL_SRC_ALPHA_SATURATE: |
| 366 | break; |
| 367 | default: |
| 368 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 369 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 370 | |
| 371 | switch (dstRGB) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 372 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 373 | case GL_ZERO: |
| 374 | case GL_ONE: |
| 375 | case GL_SRC_COLOR: |
| 376 | case GL_ONE_MINUS_SRC_COLOR: |
| 377 | case GL_DST_COLOR: |
| 378 | case GL_ONE_MINUS_DST_COLOR: |
| 379 | case GL_SRC_ALPHA: |
| 380 | case GL_ONE_MINUS_SRC_ALPHA: |
| 381 | case GL_DST_ALPHA: |
| 382 | case GL_ONE_MINUS_DST_ALPHA: |
| 383 | case GL_CONSTANT_COLOR: |
| 384 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 385 | case GL_CONSTANT_ALPHA: |
| 386 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 387 | break; |
| 388 | |
| 389 | case GL_SRC_ALPHA_SATURATE: |
| 390 | if (!context || context->getClientVersion() < 3) |
| 391 | { |
| 392 | return gl::error(GL_INVALID_ENUM); |
| 393 | } |
| 394 | break; |
| 395 | |
| 396 | default: |
| 397 | return gl::error(GL_INVALID_ENUM); |
| 398 | } |
| 399 | |
| 400 | switch (srcAlpha) |
| 401 | { |
| 402 | case GL_ZERO: |
| 403 | case GL_ONE: |
| 404 | case GL_SRC_COLOR: |
| 405 | case GL_ONE_MINUS_SRC_COLOR: |
| 406 | case GL_DST_COLOR: |
| 407 | case GL_ONE_MINUS_DST_COLOR: |
| 408 | case GL_SRC_ALPHA: |
| 409 | case GL_ONE_MINUS_SRC_ALPHA: |
| 410 | case GL_DST_ALPHA: |
| 411 | case GL_ONE_MINUS_DST_ALPHA: |
| 412 | case GL_CONSTANT_COLOR: |
| 413 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 414 | case GL_CONSTANT_ALPHA: |
| 415 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 416 | case GL_SRC_ALPHA_SATURATE: |
| 417 | break; |
| 418 | default: |
| 419 | return gl::error(GL_INVALID_ENUM); |
| 420 | } |
| 421 | |
| 422 | switch (dstAlpha) |
| 423 | { |
| 424 | case GL_ZERO: |
| 425 | case GL_ONE: |
| 426 | case GL_SRC_COLOR: |
| 427 | case GL_ONE_MINUS_SRC_COLOR: |
| 428 | case GL_DST_COLOR: |
| 429 | case GL_ONE_MINUS_DST_COLOR: |
| 430 | case GL_SRC_ALPHA: |
| 431 | case GL_ONE_MINUS_SRC_ALPHA: |
| 432 | case GL_DST_ALPHA: |
| 433 | case GL_ONE_MINUS_DST_ALPHA: |
| 434 | case GL_CONSTANT_COLOR: |
| 435 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 436 | case GL_CONSTANT_ALPHA: |
| 437 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 438 | break; |
| 439 | |
| 440 | case GL_SRC_ALPHA_SATURATE: |
| 441 | if (!context || context->getClientVersion() < 3) |
| 442 | { |
| 443 | return gl::error(GL_INVALID_ENUM); |
| 444 | } |
| 445 | break; |
| 446 | |
| 447 | default: |
| 448 | return gl::error(GL_INVALID_ENUM); |
| 449 | } |
| 450 | |
| 451 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 452 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 453 | |
| 454 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 455 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 456 | |
| 457 | if (constantColorUsed && constantAlphaUsed) |
| 458 | { |
| 459 | ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL"); |
| 460 | return gl::error(GL_INVALID_OPERATION); |
| 461 | } |
| 462 | |
| 463 | if (context) |
| 464 | { |
| 465 | context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 466 | } |
| 467 | } |
| 468 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 469 | void __stdcall glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 470 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 471 | EVENT("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 472 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 473 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 474 | if (size < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 475 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 476 | return gl::error(GL_INVALID_VALUE); |
| 477 | } |
| 478 | |
| 479 | gl::Context *context = gl::getNonLostContext(); |
| 480 | |
| 481 | switch (usage) |
| 482 | { |
| 483 | case GL_STREAM_DRAW: |
| 484 | case GL_STATIC_DRAW: |
| 485 | case GL_DYNAMIC_DRAW: |
| 486 | break; |
| 487 | |
| 488 | case GL_STREAM_READ: |
| 489 | case GL_STREAM_COPY: |
| 490 | case GL_STATIC_READ: |
| 491 | case GL_STATIC_COPY: |
| 492 | case GL_DYNAMIC_READ: |
| 493 | case GL_DYNAMIC_COPY: |
| 494 | if (context && context->getClientVersion() < 3) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 495 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 496 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 497 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 498 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 499 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 500 | default: |
| 501 | return gl::error(GL_INVALID_ENUM); |
| 502 | } |
shannon.woods%transgaming.com@gtempaccount.com | f2db40b | 2013-04-13 03:37:09 +0000 | [diff] [blame] | 503 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 504 | if (context) |
| 505 | { |
| 506 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 507 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 508 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 511 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 512 | |
| 513 | if (!buffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 514 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 515 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 516 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 517 | |
| 518 | buffer->bufferData(data, size, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 519 | } |
| 520 | } |
| 521 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 522 | void __stdcall glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 523 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 524 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 525 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 526 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 527 | if (size < 0 || offset < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 528 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 529 | return gl::error(GL_INVALID_VALUE); |
| 530 | } |
| 531 | |
| 532 | if (data == NULL) |
| 533 | { |
| 534 | return; |
| 535 | } |
| 536 | |
| 537 | gl::Context *context = gl::getNonLostContext(); |
| 538 | |
| 539 | if (context) |
| 540 | { |
| 541 | if (!gl::ValidBufferTarget(context, target)) |
| 542 | { |
| 543 | return gl::error(GL_INVALID_ENUM); |
| 544 | } |
| 545 | |
| 546 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 547 | |
| 548 | if (!buffer) |
| 549 | { |
| 550 | return gl::error(GL_INVALID_OPERATION); |
| 551 | } |
| 552 | |
| 553 | if (buffer->isMapped()) |
| 554 | { |
| 555 | return gl::error(GL_INVALID_OPERATION); |
| 556 | } |
| 557 | |
| 558 | // Check for possible overflow of size + offset |
| 559 | if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset)) |
| 560 | { |
| 561 | return gl::error(GL_OUT_OF_MEMORY); |
| 562 | } |
| 563 | |
| 564 | if (size + offset > buffer->getSize()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 565 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 566 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 567 | } |
| 568 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 569 | buffer->bufferSubData(data, size, offset); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
| 573 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 574 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 575 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 576 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 577 | if (!gl::ValidFramebufferTarget(target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 578 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 579 | return gl::error(GL_INVALID_ENUM, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 580 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 581 | |
| 582 | gl::Context *context = gl::getNonLostContext(); |
| 583 | |
| 584 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 585 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 586 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 587 | ASSERT(framebuffer); |
| 588 | return framebuffer->completeness(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | void __stdcall glClear(GLbitfield mask) |
| 595 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 596 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 597 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 598 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 599 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 600 | if (context) |
| 601 | { |
| 602 | gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer(); |
| 603 | |
| 604 | if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 605 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 606 | return gl::error(GL_INVALID_FRAMEBUFFER_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 607 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 608 | |
| 609 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) |
| 610 | { |
| 611 | return gl::error(GL_INVALID_VALUE); |
| 612 | } |
| 613 | |
| 614 | context->clear(mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | |
| 618 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 619 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 620 | EVENT("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 621 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 622 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 623 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 624 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 625 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 626 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 627 | context->getState().setClearColor(red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 628 | } |
| 629 | } |
| 630 | |
| 631 | void __stdcall glClearDepthf(GLclampf depth) |
| 632 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 633 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 634 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 635 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 636 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 637 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 638 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 639 | context->getState().setClearDepth(depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
| 643 | void __stdcall glClearStencil(GLint s) |
| 644 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 645 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 646 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 647 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 648 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 649 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 650 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 651 | context->getState().setClearStencil(s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 652 | } |
| 653 | } |
| 654 | |
| 655 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 656 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 657 | EVENT("(GLboolean red = %d, GLboolean green = %u, GLboolean blue = %u, GLboolean alpha = %u)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 658 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 659 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 660 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 661 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 662 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 663 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 664 | context->getState().setColorMask(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 665 | } |
| 666 | } |
| 667 | |
| 668 | void __stdcall glCompileShader(GLuint shader) |
| 669 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 670 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 671 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 672 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 673 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 674 | if (context) |
| 675 | { |
| 676 | gl::Shader *shaderObject = context->getShader(shader); |
| 677 | |
| 678 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 679 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 680 | if (context->getProgram(shader)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 681 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 682 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 683 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 684 | else |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 685 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 686 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 687 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 688 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 689 | |
| 690 | shaderObject->compile(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 691 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 695 | GLint border, GLsizei imageSize, const GLvoid* data) |
| 696 | { |
| 697 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 698 | "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 699 | target, level, internalformat, width, height, border, imageSize, data); |
| 700 | |
| 701 | gl::Context *context = gl::getNonLostContext(); |
| 702 | |
| 703 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 704 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 705 | if (context->getClientVersion() < 3 && |
| 706 | !ValidateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 707 | 0, 0, width, height, border, GL_NONE, GL_NONE, data)) |
| 708 | { |
| 709 | return; |
| 710 | } |
| 711 | |
| 712 | if (context->getClientVersion() >= 3 && |
| 713 | !ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 714 | 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data)) |
| 715 | { |
| 716 | return; |
| 717 | } |
| 718 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 719 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
| 720 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 721 | { |
| 722 | return gl::error(GL_INVALID_VALUE); |
| 723 | } |
| 724 | |
| 725 | switch (target) |
| 726 | { |
| 727 | case GL_TEXTURE_2D: |
| 728 | { |
| 729 | gl::Texture2D *texture = context->getTexture2D(); |
| 730 | texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
| 731 | } |
| 732 | break; |
| 733 | |
| 734 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 735 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 736 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 737 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 738 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 739 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 740 | { |
| 741 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 742 | texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
| 743 | } |
| 744 | break; |
| 745 | |
| 746 | default: |
| 747 | return gl::error(GL_INVALID_ENUM); |
| 748 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 749 | } |
| 750 | } |
| 751 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 752 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 753 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 754 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 755 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 756 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 757 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 758 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 759 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 760 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 761 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 762 | if (context) |
| 763 | { |
| 764 | if (context->getClientVersion() < 3 && |
| 765 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 766 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 767 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 768 | return; |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 769 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 770 | |
| 771 | if (context->getClientVersion() >= 3 && |
| 772 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 773 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data)) |
| 774 | { |
| 775 | return; |
| 776 | } |
| 777 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 778 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format); |
| 779 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 780 | { |
| 781 | return gl::error(GL_INVALID_VALUE); |
| 782 | } |
| 783 | |
| 784 | switch (target) |
| 785 | { |
| 786 | case GL_TEXTURE_2D: |
| 787 | { |
| 788 | gl::Texture2D *texture = context->getTexture2D(); |
| 789 | texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
| 790 | } |
| 791 | break; |
| 792 | |
| 793 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 794 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 795 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 796 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 797 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 798 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 799 | { |
| 800 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 801 | texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 802 | } |
| 803 | break; |
| 804 | |
| 805 | default: |
| 806 | return gl::error(GL_INVALID_ENUM); |
| 807 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | |
| 811 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 812 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 813 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 814 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, GLint border = %d)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 815 | target, level, internalformat, x, y, width, height, border); |
| 816 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 817 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 818 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 819 | if (context) |
| 820 | { |
| 821 | if (context->getClientVersion() < 3 && |
| 822 | !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 823 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 824 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 825 | return; |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 826 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 827 | |
| 828 | if (context->getClientVersion() >= 3 && |
| 829 | !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 830 | 0, 0, 0, x, y, width, height, border)) |
| 831 | { |
| 832 | return; |
| 833 | } |
| 834 | |
| 835 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 836 | |
| 837 | switch (target) |
| 838 | { |
| 839 | case GL_TEXTURE_2D: |
| 840 | { |
| 841 | gl::Texture2D *texture = context->getTexture2D(); |
| 842 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
| 843 | } |
| 844 | break; |
| 845 | |
| 846 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 847 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 848 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 849 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 850 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 851 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 852 | { |
| 853 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 854 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
| 855 | } |
| 856 | break; |
| 857 | |
| 858 | default: |
| 859 | return gl::error(GL_INVALID_ENUM); |
| 860 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 861 | } |
| 862 | } |
| 863 | |
| 864 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 865 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 866 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 867 | "GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 868 | target, level, xoffset, yoffset, x, y, width, height); |
| 869 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 870 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 871 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 872 | if (context) |
| 873 | { |
| 874 | if (context->getClientVersion() < 3 && |
| 875 | !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 876 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 877 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 878 | return; |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 879 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 880 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 881 | if (context->getClientVersion() >= 3 && |
| 882 | !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 883 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 884 | { |
| 885 | return; |
| 886 | } |
| 887 | |
| 888 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 889 | |
| 890 | switch (target) |
| 891 | { |
| 892 | case GL_TEXTURE_2D: |
| 893 | { |
| 894 | gl::Texture2D *texture = context->getTexture2D(); |
| 895 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
| 896 | } |
| 897 | break; |
| 898 | |
| 899 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 900 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 901 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 902 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 903 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 904 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 905 | { |
| 906 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 907 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
| 908 | } |
| 909 | break; |
| 910 | |
| 911 | default: |
| 912 | return gl::error(GL_INVALID_ENUM); |
| 913 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 914 | } |
| 915 | } |
| 916 | |
| 917 | GLuint __stdcall glCreateProgram(void) |
| 918 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 919 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 920 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 921 | gl::Context *context = gl::getNonLostContext(); |
| 922 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 923 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 924 | return context->createProgram(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | return 0; |
| 928 | } |
| 929 | |
| 930 | GLuint __stdcall glCreateShader(GLenum type) |
| 931 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 932 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 933 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 934 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 935 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 936 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 937 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 938 | switch (type) |
| 939 | { |
| 940 | case GL_FRAGMENT_SHADER: |
| 941 | case GL_VERTEX_SHADER: |
| 942 | return context->createShader(type); |
| 943 | default: |
| 944 | return gl::error(GL_INVALID_ENUM, 0); |
| 945 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | return 0; |
| 949 | } |
| 950 | |
| 951 | void __stdcall glCullFace(GLenum mode) |
| 952 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 953 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 954 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 955 | switch (mode) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 956 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 957 | case GL_FRONT: |
| 958 | case GL_BACK: |
| 959 | case GL_FRONT_AND_BACK: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 960 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 961 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 962 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 963 | if (context) |
| 964 | { |
| 965 | context->getState().setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 966 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 967 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 968 | break; |
| 969 | default: |
| 970 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 971 | } |
| 972 | } |
| 973 | |
| 974 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 975 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 976 | EVENT("(GLsizei n = %d, const GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 977 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 978 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 979 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 980 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 981 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 982 | |
| 983 | gl::Context *context = gl::getNonLostContext(); |
| 984 | |
| 985 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 986 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 987 | for (int i = 0; i < n; i++) |
| 988 | { |
| 989 | context->deleteBuffer(buffers[i]); |
| 990 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 991 | } |
| 992 | } |
| 993 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 994 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 995 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 996 | EVENT("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 997 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 998 | if (n < 0) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 999 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1000 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1001 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1002 | |
| 1003 | gl::Context *context = gl::getNonLostContext(); |
| 1004 | |
| 1005 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1006 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1007 | for (int i = 0; i < n; i++) |
| 1008 | { |
| 1009 | context->deleteFenceNV(fences[i]); |
| 1010 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1011 | } |
| 1012 | } |
| 1013 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1014 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 1015 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1016 | EVENT("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1017 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1018 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1019 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1020 | return gl::error(GL_INVALID_VALUE); |
| 1021 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1022 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1023 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1024 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1025 | if (context) |
| 1026 | { |
| 1027 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1028 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1029 | if (framebuffers[i] != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1030 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1031 | context->deleteFramebuffer(framebuffers[i]); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1032 | } |
| 1033 | } |
| 1034 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | void __stdcall glDeleteProgram(GLuint program) |
| 1038 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1039 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1040 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1041 | if (program == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1042 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1043 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1044 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1045 | |
| 1046 | gl::Context *context = gl::getNonLostContext(); |
| 1047 | |
| 1048 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1049 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1050 | if (!context->getProgram(program)) |
| 1051 | { |
| 1052 | if(context->getShader(program)) |
| 1053 | { |
| 1054 | return gl::error(GL_INVALID_OPERATION); |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | return gl::error(GL_INVALID_VALUE); |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | context->deleteProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1063 | } |
| 1064 | } |
| 1065 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1066 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 1067 | { |
| 1068 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 1069 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1070 | if (n < 0) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1071 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1072 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1073 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1074 | |
| 1075 | gl::Context *context = gl::getNonLostContext(); |
| 1076 | |
| 1077 | if (context) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1078 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1079 | for (int i = 0; i < n; i++) |
| 1080 | { |
| 1081 | context->deleteQuery(ids[i]); |
| 1082 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1083 | } |
| 1084 | } |
| 1085 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1086 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 1087 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1088 | EVENT("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1089 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1090 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1091 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1092 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1093 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1094 | |
| 1095 | gl::Context *context = gl::getNonLostContext(); |
| 1096 | |
| 1097 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1098 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1099 | for (int i = 0; i < n; i++) |
| 1100 | { |
| 1101 | context->deleteRenderbuffer(renderbuffers[i]); |
| 1102 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1103 | } |
| 1104 | } |
| 1105 | |
| 1106 | void __stdcall glDeleteShader(GLuint shader) |
| 1107 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1108 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1109 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1110 | if (shader == 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1111 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1112 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1113 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1114 | |
| 1115 | gl::Context *context = gl::getNonLostContext(); |
| 1116 | |
| 1117 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1118 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1119 | if (!context->getShader(shader)) |
| 1120 | { |
| 1121 | if(context->getProgram(shader)) |
| 1122 | { |
| 1123 | return gl::error(GL_INVALID_OPERATION); |
| 1124 | } |
| 1125 | else |
| 1126 | { |
| 1127 | return gl::error(GL_INVALID_VALUE); |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | context->deleteShader(shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 1136 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1137 | EVENT("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1138 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1139 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1140 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1141 | return gl::error(GL_INVALID_VALUE); |
| 1142 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1143 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1144 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1145 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1146 | if (context) |
| 1147 | { |
| 1148 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1149 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1150 | if (textures[i] != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1151 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1152 | context->deleteTexture(textures[i]); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1153 | } |
| 1154 | } |
| 1155 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | void __stdcall glDepthFunc(GLenum func) |
| 1159 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1160 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1161 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1162 | switch (func) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1163 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1164 | case GL_NEVER: |
| 1165 | case GL_ALWAYS: |
| 1166 | case GL_LESS: |
| 1167 | case GL_LEQUAL: |
| 1168 | case GL_EQUAL: |
| 1169 | case GL_GREATER: |
| 1170 | case GL_GEQUAL: |
| 1171 | case GL_NOTEQUAL: |
| 1172 | break; |
| 1173 | default: |
| 1174 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1175 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1176 | |
| 1177 | gl::Context *context = gl::getNonLostContext(); |
| 1178 | |
| 1179 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1180 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1181 | context->getState().setDepthFunc(func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | void __stdcall glDepthMask(GLboolean flag) |
| 1186 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1187 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1188 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1189 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1190 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1191 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1192 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1193 | context->getState().setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 1198 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1199 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1200 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1201 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1202 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1203 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1204 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1205 | context->getState().setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 1210 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1211 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1212 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1213 | gl::Context *context = gl::getNonLostContext(); |
| 1214 | |
| 1215 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1216 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1217 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1218 | gl::Program *programObject = context->getProgram(program); |
| 1219 | gl::Shader *shaderObject = context->getShader(shader); |
| 1220 | |
| 1221 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1222 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1223 | gl::Shader *shaderByProgramHandle; |
| 1224 | shaderByProgramHandle = context->getShader(program); |
| 1225 | if (!shaderByProgramHandle) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1226 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1227 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1228 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1229 | else |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1230 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1231 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1232 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1233 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1234 | |
| 1235 | if (!shaderObject) |
| 1236 | { |
| 1237 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 1238 | if (!programByShaderHandle) |
| 1239 | { |
| 1240 | return gl::error(GL_INVALID_VALUE); |
| 1241 | } |
| 1242 | else |
| 1243 | { |
| 1244 | return gl::error(GL_INVALID_OPERATION); |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | if (!programObject->detachShader(shaderObject)) |
| 1249 | { |
| 1250 | return gl::error(GL_INVALID_OPERATION); |
| 1251 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | void __stdcall glDisable(GLenum cap) |
| 1256 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1257 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1258 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1259 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1260 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1261 | if (context) |
| 1262 | { |
| 1263 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1264 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1265 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1266 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1267 | |
| 1268 | context->getState().setEnableFeature(cap, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 1273 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1274 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1275 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1276 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1277 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1278 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1279 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1280 | |
| 1281 | gl::Context *context = gl::getNonLostContext(); |
| 1282 | |
| 1283 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1284 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1285 | context->getState().setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1286 | } |
| 1287 | } |
| 1288 | |
| 1289 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 1290 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1291 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d)", mode, first, count); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1292 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1293 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1294 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1295 | if (context) |
| 1296 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1297 | if (!ValidateDrawArrays(context, mode, first, count, 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1298 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1299 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1300 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1301 | |
| 1302 | context->drawArrays(mode, first, count, 0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1303 | } |
| 1304 | } |
| 1305 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1306 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 1307 | { |
| 1308 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 1309 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1310 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1311 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1312 | if (context) |
| 1313 | { |
| 1314 | if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount)) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1315 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1316 | return; |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1317 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1318 | |
| 1319 | context->drawArrays(mode, first, count, primcount); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1323 | void __stdcall glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1324 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1325 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1326 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1327 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1328 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1329 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1330 | if (context) |
| 1331 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1332 | rx::RangeUI indexRange; |
| 1333 | if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1334 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1335 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1336 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1337 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1338 | context->drawElements(mode, count, type, indices, 0, indexRange); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1339 | } |
| 1340 | } |
| 1341 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1342 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 1343 | { |
| 1344 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 1345 | mode, count, type, indices, primcount); |
| 1346 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1347 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1348 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1349 | if (context) |
| 1350 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1351 | rx::RangeUI indexRange; |
| 1352 | if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, &indexRange)) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1353 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1354 | return; |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1355 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1356 | |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1357 | context->drawElements(mode, count, type, indices, primcount, indexRange); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1358 | } |
| 1359 | } |
| 1360 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1361 | void __stdcall glEnable(GLenum cap) |
| 1362 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1363 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1364 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1365 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1366 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1367 | if (context) |
| 1368 | { |
| 1369 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1370 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1371 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1372 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1373 | |
| 1374 | context->getState().setEnableFeature(cap, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 1379 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1380 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1381 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1382 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1383 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1384 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1385 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1386 | |
| 1387 | gl::Context *context = gl::getNonLostContext(); |
| 1388 | |
| 1389 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1390 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1391 | context->getState().setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1392 | } |
| 1393 | } |
| 1394 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1395 | void __stdcall glEndQueryEXT(GLenum target) |
| 1396 | { |
| 1397 | EVENT("GLenum target = 0x%X)", target); |
| 1398 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1399 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1400 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1401 | if (context) |
| 1402 | { |
| 1403 | if (!ValidateEndQuery(context, target)) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1404 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1405 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1406 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1407 | |
| 1408 | context->endQuery(target); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1409 | } |
| 1410 | } |
| 1411 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1412 | void __stdcall glFinishFenceNV(GLuint fence) |
| 1413 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1414 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1415 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1416 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1417 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1418 | if (context) |
| 1419 | { |
| 1420 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 1421 | |
| 1422 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1423 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1424 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1425 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1426 | |
| 1427 | if (fenceObject->isFence() != GL_TRUE) |
| 1428 | { |
| 1429 | return gl::error(GL_INVALID_OPERATION); |
| 1430 | } |
| 1431 | |
| 1432 | fenceObject->finishFence(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1433 | } |
| 1434 | } |
| 1435 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1436 | void __stdcall glFinish(void) |
| 1437 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1438 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1439 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1440 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1441 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1442 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1443 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1444 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | void __stdcall glFlush(void) |
| 1449 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1450 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1451 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1452 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1453 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1454 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1455 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1456 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 1461 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1462 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1463 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1464 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1465 | if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1466 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1467 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1468 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1469 | |
| 1470 | gl::Context *context = gl::getNonLostContext(); |
| 1471 | |
| 1472 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1473 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1474 | if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer)) |
| 1475 | { |
| 1476 | return; |
| 1477 | } |
| 1478 | |
| 1479 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 1480 | ASSERT(framebuffer); |
| 1481 | |
| 1482 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 1483 | { |
| 1484 | unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 1485 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1486 | } |
| 1487 | else |
| 1488 | { |
| 1489 | switch (attachment) |
| 1490 | { |
| 1491 | case GL_DEPTH_ATTACHMENT: |
| 1492 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1493 | break; |
| 1494 | case GL_STENCIL_ATTACHMENT: |
| 1495 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1496 | break; |
| 1497 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1498 | framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1499 | break; |
| 1500 | default: |
| 1501 | UNREACHABLE(); |
| 1502 | break; |
| 1503 | } |
| 1504 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 1509 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1510 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1511 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1512 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1513 | gl::Context *context = gl::getNonLostContext(); |
| 1514 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1515 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1516 | if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1517 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1518 | return; |
| 1519 | } |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 1520 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1521 | if (texture == 0) |
| 1522 | { |
| 1523 | textarget = GL_NONE; |
| 1524 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1525 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1526 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1527 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1528 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 1529 | { |
| 1530 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 1531 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0); |
| 1532 | } |
| 1533 | else |
| 1534 | { |
| 1535 | switch (attachment) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 1536 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1537 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break; |
| 1538 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break; |
| 1539 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, 0); break; |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 1540 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1541 | } |
| 1542 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1543 | } |
| 1544 | |
| 1545 | void __stdcall glFrontFace(GLenum mode) |
| 1546 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1547 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1548 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1549 | switch (mode) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1550 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1551 | case GL_CW: |
| 1552 | case GL_CCW: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1553 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1554 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1555 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1556 | if (context) |
| 1557 | { |
| 1558 | context->getState().setFrontFace(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1559 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1560 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1561 | break; |
| 1562 | default: |
| 1563 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 1568 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1569 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1570 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1571 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1572 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1573 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1574 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1575 | |
| 1576 | gl::Context *context = gl::getNonLostContext(); |
| 1577 | |
| 1578 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1579 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1580 | for (int i = 0; i < n; i++) |
| 1581 | { |
| 1582 | buffers[i] = context->createBuffer(); |
| 1583 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1584 | } |
| 1585 | } |
| 1586 | |
| 1587 | void __stdcall glGenerateMipmap(GLenum target) |
| 1588 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1589 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1590 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1591 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 1592 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1593 | if (context) |
| 1594 | { |
| 1595 | if (!ValidTextureTarget(context, target)) |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 1596 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1597 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 1598 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1599 | |
| 1600 | gl::Texture *texture = context->getTargetTexture(target); |
| 1601 | |
| 1602 | if (texture == NULL) |
| 1603 | { |
| 1604 | return gl::error(GL_INVALID_OPERATION); |
| 1605 | } |
| 1606 | |
| 1607 | GLenum internalFormat = texture->getBaseLevelInternalFormat(); |
| 1608 | const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1609 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1610 | |
| 1611 | // GenerateMipmap should not generate an INVALID_OPERATION for textures created with |
| 1612 | // unsized formats or that are color renderable and filterable. Since we do not track if |
| 1613 | // the texture was created with sized or unsized format (only sized formats are stored), |
| 1614 | // it is not possible to make sure the the LUMA formats can generate mipmaps (they should |
| 1615 | // be able to) because they aren't color renderable. Simply do a special case for LUMA |
| 1616 | // textures since they're the only texture format that can be created with unsized formats |
| 1617 | // that is not color renderable. New unsized formats are unlikely to be added, since ES2 |
| 1618 | // was the last version to use add them. |
| 1619 | bool isLUMA = internalFormat == GL_LUMINANCE8_EXT || |
| 1620 | internalFormat == GL_LUMINANCE8_ALPHA8_EXT || |
| 1621 | internalFormat == GL_ALPHA8_EXT; |
| 1622 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1623 | if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable || |
| 1624 | (!formatCaps.renderable && !isLUMA) || formatInfo.compressed) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1625 | { |
| 1626 | return gl::error(GL_INVALID_OPERATION); |
| 1627 | } |
| 1628 | |
| 1629 | // GL_EXT_sRGB does not support mipmap generation on sRGB textures |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1630 | if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1631 | { |
| 1632 | return gl::error(GL_INVALID_OPERATION); |
| 1633 | } |
| 1634 | |
| 1635 | // Non-power of 2 ES2 check |
| 1636 | if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight()))) |
| 1637 | { |
| 1638 | ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP)); |
| 1639 | return gl::error(GL_INVALID_OPERATION); |
| 1640 | } |
| 1641 | |
| 1642 | // Cube completeness check |
| 1643 | if (target == GL_TEXTURE_CUBE_MAP) |
| 1644 | { |
| 1645 | gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture); |
| 1646 | if (!textureCube->isCubeComplete()) |
| 1647 | { |
| 1648 | return gl::error(GL_INVALID_OPERATION); |
| 1649 | } |
| 1650 | } |
| 1651 | |
| 1652 | texture->generateMipmaps(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1653 | } |
| 1654 | } |
| 1655 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1656 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 1657 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1658 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1659 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1660 | if (n < 0) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1661 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1662 | return gl::error(GL_INVALID_VALUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1663 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1664 | |
| 1665 | gl::Context *context = gl::getNonLostContext(); |
| 1666 | |
| 1667 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1668 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1669 | for (int i = 0; i < n; i++) |
| 1670 | { |
| 1671 | fences[i] = context->createFenceNV(); |
| 1672 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1673 | } |
| 1674 | } |
| 1675 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1676 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 1677 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1678 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1679 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1680 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1681 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1682 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1683 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1684 | |
| 1685 | gl::Context *context = gl::getNonLostContext(); |
| 1686 | |
| 1687 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1688 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1689 | for (int i = 0; i < n; i++) |
| 1690 | { |
| 1691 | framebuffers[i] = context->createFramebuffer(); |
| 1692 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1693 | } |
| 1694 | } |
| 1695 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1696 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 1697 | { |
| 1698 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 1699 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1700 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1701 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1702 | if (context) |
| 1703 | { |
| 1704 | if (n < 0) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1705 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1706 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1707 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1708 | |
| 1709 | for (GLsizei i = 0; i < n; i++) |
| 1710 | { |
| 1711 | ids[i] = context->createQuery(); |
| 1712 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1713 | } |
| 1714 | } |
| 1715 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1716 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 1717 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1718 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1719 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1720 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1721 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1722 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1723 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1724 | |
| 1725 | gl::Context *context = gl::getNonLostContext(); |
| 1726 | |
| 1727 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1728 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1729 | for (int i = 0; i < n; i++) |
| 1730 | { |
| 1731 | renderbuffers[i] = context->createRenderbuffer(); |
| 1732 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1733 | } |
| 1734 | } |
| 1735 | |
| 1736 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 1737 | { |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1738 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1739 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1740 | if (n < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1741 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1742 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1743 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1744 | |
| 1745 | gl::Context *context = gl::getNonLostContext(); |
| 1746 | |
| 1747 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1748 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1749 | for (int i = 0; i < n; i++) |
| 1750 | { |
| 1751 | textures[i] = context->createTexture(); |
| 1752 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1753 | } |
| 1754 | } |
| 1755 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 1756 | void __stdcall glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1757 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1758 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, " |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 1759 | "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1760 | program, index, bufsize, length, size, type, name); |
| 1761 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1762 | if (bufsize < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1763 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1764 | return gl::error(GL_INVALID_VALUE); |
| 1765 | } |
| 1766 | |
| 1767 | gl::Context *context = gl::getNonLostContext(); |
| 1768 | |
| 1769 | if (context) |
| 1770 | { |
| 1771 | gl::Program *programObject = context->getProgram(program); |
| 1772 | |
| 1773 | if (!programObject) |
| 1774 | { |
| 1775 | if (context->getShader(program)) |
| 1776 | { |
| 1777 | return gl::error(GL_INVALID_OPERATION); |
| 1778 | } |
| 1779 | else |
| 1780 | { |
| 1781 | return gl::error(GL_INVALID_VALUE); |
| 1782 | } |
| 1783 | } |
| 1784 | |
| 1785 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1786 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1787 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1788 | } |
| 1789 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1790 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1791 | } |
| 1792 | } |
| 1793 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1794 | void __stdcall glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1795 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1796 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1797 | "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1798 | program, index, bufsize, length, size, type, name); |
| 1799 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1800 | if (bufsize < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1801 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1802 | return gl::error(GL_INVALID_VALUE); |
| 1803 | } |
| 1804 | |
| 1805 | gl::Context *context = gl::getNonLostContext(); |
| 1806 | |
| 1807 | if (context) |
| 1808 | { |
| 1809 | gl::Program *programObject = context->getProgram(program); |
| 1810 | |
| 1811 | if (!programObject) |
| 1812 | { |
| 1813 | if (context->getShader(program)) |
| 1814 | { |
| 1815 | return gl::error(GL_INVALID_OPERATION); |
| 1816 | } |
| 1817 | else |
| 1818 | { |
| 1819 | return gl::error(GL_INVALID_VALUE); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1824 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1825 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1826 | } |
| 1827 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1828 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1829 | } |
| 1830 | } |
| 1831 | |
| 1832 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 1833 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1834 | EVENT("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 1835 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1836 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1837 | if (maxcount < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1838 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1839 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1840 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1841 | |
| 1842 | gl::Context *context = gl::getNonLostContext(); |
| 1843 | |
| 1844 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1845 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1846 | gl::Program *programObject = context->getProgram(program); |
| 1847 | |
| 1848 | if (!programObject) |
| 1849 | { |
| 1850 | if (context->getShader(program)) |
| 1851 | { |
| 1852 | return gl::error(GL_INVALID_OPERATION); |
| 1853 | } |
| 1854 | else |
| 1855 | { |
| 1856 | return gl::error(GL_INVALID_VALUE); |
| 1857 | } |
| 1858 | } |
| 1859 | |
| 1860 | return programObject->getAttachedShaders(maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1861 | } |
| 1862 | } |
| 1863 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1864 | int __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1865 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1866 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1867 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1868 | gl::Context *context = gl::getNonLostContext(); |
| 1869 | |
| 1870 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1871 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1872 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1873 | gl::Program *programObject = context->getProgram(program); |
| 1874 | |
| 1875 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1876 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1877 | if (context->getShader(program)) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 1878 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 1879 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 1880 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1881 | else |
| 1882 | { |
| 1883 | return gl::error(GL_INVALID_VALUE, -1); |
| 1884 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1885 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1886 | |
| 1887 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 1888 | if (!programObject->isLinked() || !programBinary) |
| 1889 | { |
| 1890 | return gl::error(GL_INVALID_OPERATION, -1); |
| 1891 | } |
| 1892 | |
| 1893 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1894 | } |
| 1895 | |
| 1896 | return -1; |
| 1897 | } |
| 1898 | |
| 1899 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 1900 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1901 | EVENT("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1902 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1903 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 777f267 | 2010-04-07 03:25:16 +0000 | [diff] [blame] | 1904 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1905 | if (context) |
| 1906 | { |
| 1907 | GLenum nativeType; |
| 1908 | unsigned int numParams = 0; |
| 1909 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1910 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1911 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1912 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1913 | |
| 1914 | if (nativeType == GL_BOOL) |
| 1915 | { |
| 1916 | context->getBooleanv(pname, params); |
| 1917 | } |
| 1918 | else |
| 1919 | { |
| 1920 | CastStateValues(context, nativeType, pname, numParams, params); |
| 1921 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 1926 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1927 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1928 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1929 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 1930 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1931 | if (context) |
| 1932 | { |
| 1933 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 1934 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1935 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 1936 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1937 | |
| 1938 | if (!gl::ValidBufferParameter(context, pname)) |
| 1939 | { |
| 1940 | return gl::error(GL_INVALID_ENUM); |
| 1941 | } |
| 1942 | |
| 1943 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 1944 | |
| 1945 | if (!buffer) |
| 1946 | { |
| 1947 | // A null buffer means that "0" is bound to the requested buffer target |
| 1948 | return gl::error(GL_INVALID_OPERATION); |
| 1949 | } |
| 1950 | |
| 1951 | switch (pname) |
| 1952 | { |
| 1953 | case GL_BUFFER_USAGE: |
| 1954 | *params = static_cast<GLint>(buffer->getUsage()); |
| 1955 | break; |
| 1956 | case GL_BUFFER_SIZE: |
| 1957 | *params = gl::clampCast<GLint>(buffer->getSize()); |
| 1958 | break; |
| 1959 | case GL_BUFFER_ACCESS_FLAGS: |
| 1960 | *params = buffer->getAccessFlags(); |
| 1961 | break; |
| 1962 | case GL_BUFFER_MAPPED: |
| 1963 | *params = static_cast<GLint>(buffer->isMapped()); |
| 1964 | break; |
| 1965 | case GL_BUFFER_MAP_OFFSET: |
| 1966 | *params = gl::clampCast<GLint>(buffer->getMapOffset()); |
| 1967 | break; |
| 1968 | case GL_BUFFER_MAP_LENGTH: |
| 1969 | *params = gl::clampCast<GLint>(buffer->getMapLength()); |
| 1970 | break; |
| 1971 | default: UNREACHABLE(); break; |
| 1972 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | GLenum __stdcall glGetError(void) |
| 1977 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1978 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1979 | |
| 1980 | gl::Context *context = gl::getContext(); |
| 1981 | |
| 1982 | if (context) |
| 1983 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 1984 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1985 | } |
| 1986 | |
| 1987 | return GL_NO_ERROR; |
| 1988 | } |
| 1989 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1990 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 1991 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1992 | EVENT("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1993 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1994 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1995 | gl::Context *context = gl::getNonLostContext(); |
| 1996 | |
| 1997 | if (context) |
| 1998 | { |
| 1999 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 2000 | |
| 2001 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2002 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2003 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2004 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2005 | |
| 2006 | if (fenceObject->isFence() != GL_TRUE) |
| 2007 | { |
| 2008 | return gl::error(GL_INVALID_OPERATION); |
| 2009 | } |
| 2010 | |
| 2011 | switch (pname) |
| 2012 | { |
| 2013 | case GL_FENCE_STATUS_NV: |
| 2014 | case GL_FENCE_CONDITION_NV: |
| 2015 | break; |
| 2016 | |
| 2017 | default: return gl::error(GL_INVALID_ENUM); |
| 2018 | } |
| 2019 | |
| 2020 | params[0] = fenceObject->getFencei(pname); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2021 | } |
| 2022 | } |
| 2023 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2024 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 2025 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2026 | EVENT("(GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2027 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2028 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2029 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2030 | if (context) |
| 2031 | { |
| 2032 | GLenum nativeType; |
| 2033 | unsigned int numParams = 0; |
| 2034 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2035 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2036 | return; |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2037 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2038 | |
| 2039 | if (nativeType == GL_FLOAT) |
| 2040 | { |
| 2041 | context->getFloatv(pname, params); |
| 2042 | } |
| 2043 | else |
| 2044 | { |
| 2045 | CastStateValues(context, nativeType, pname, numParams, params); |
| 2046 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2047 | } |
| 2048 | } |
| 2049 | |
| 2050 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 2051 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2052 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2053 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2054 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2055 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2056 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2057 | if (context) |
| 2058 | { |
| 2059 | if (!gl::ValidFramebufferTarget(target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2060 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2061 | return gl::error(GL_INVALID_ENUM); |
| 2062 | } |
| 2063 | |
| 2064 | int clientVersion = context->getClientVersion(); |
| 2065 | |
| 2066 | switch (pname) |
| 2067 | { |
| 2068 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2069 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2070 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2071 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2072 | break; |
| 2073 | case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: |
| 2074 | if (clientVersion < 3 && !context->getExtensions().sRGB) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2075 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2076 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2077 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2078 | break; |
| 2079 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
| 2080 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
| 2081 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
| 2082 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
| 2083 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
| 2084 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
| 2085 | case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: |
| 2086 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 2087 | if (clientVersion < 3) |
| 2088 | { |
| 2089 | return gl::error(GL_INVALID_ENUM); |
| 2090 | } |
| 2091 | break; |
| 2092 | default: |
| 2093 | return gl::error(GL_INVALID_ENUM); |
| 2094 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2095 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2096 | // Determine if the attachment is a valid enum |
| 2097 | switch (attachment) |
| 2098 | { |
| 2099 | case GL_BACK: |
| 2100 | case GL_FRONT: |
| 2101 | case GL_DEPTH: |
| 2102 | case GL_STENCIL: |
| 2103 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2104 | if (clientVersion < 3) |
| 2105 | { |
| 2106 | return gl::error(GL_INVALID_ENUM); |
| 2107 | } |
| 2108 | break; |
| 2109 | |
| 2110 | case GL_DEPTH_ATTACHMENT: |
| 2111 | case GL_STENCIL_ATTACHMENT: |
| 2112 | break; |
| 2113 | |
| 2114 | default: |
| 2115 | if (attachment < GL_COLOR_ATTACHMENT0_EXT || |
| 2116 | (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments) |
| 2117 | { |
| 2118 | return gl::error(GL_INVALID_ENUM); |
| 2119 | } |
| 2120 | break; |
| 2121 | } |
| 2122 | |
| 2123 | GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id(); |
| 2124 | gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle); |
| 2125 | |
| 2126 | if (framebufferHandle == 0) |
| 2127 | { |
| 2128 | if (clientVersion < 3) |
| 2129 | { |
| 2130 | return gl::error(GL_INVALID_OPERATION); |
| 2131 | } |
| 2132 | |
| 2133 | switch (attachment) |
| 2134 | { |
| 2135 | case GL_BACK: |
| 2136 | case GL_DEPTH: |
| 2137 | case GL_STENCIL: |
| 2138 | break; |
| 2139 | default: |
| 2140 | return gl::error(GL_INVALID_OPERATION); |
| 2141 | } |
| 2142 | } |
| 2143 | else |
| 2144 | { |
| 2145 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 2146 | { |
| 2147 | // Valid attachment query |
| 2148 | } |
| 2149 | else |
| 2150 | { |
| 2151 | switch (attachment) |
| 2152 | { |
| 2153 | case GL_DEPTH_ATTACHMENT: |
| 2154 | case GL_STENCIL_ATTACHMENT: |
| 2155 | break; |
| 2156 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2157 | if (framebuffer->hasValidDepthStencil()) |
| 2158 | { |
| 2159 | return gl::error(GL_INVALID_OPERATION); |
| 2160 | } |
| 2161 | break; |
| 2162 | default: |
| 2163 | return gl::error(GL_INVALID_OPERATION); |
| 2164 | } |
| 2165 | } |
| 2166 | } |
| 2167 | |
| 2168 | GLenum attachmentType = GL_NONE; |
| 2169 | GLuint attachmentHandle = 0; |
| 2170 | GLuint attachmentLevel = 0; |
| 2171 | GLuint attachmentLayer = 0; |
| 2172 | |
| 2173 | const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); |
| 2174 | |
| 2175 | if (attachmentObject) |
| 2176 | { |
| 2177 | attachmentType = attachmentObject->type(); |
| 2178 | attachmentHandle = attachmentObject->id(); |
| 2179 | attachmentLevel = attachmentObject->mipLevel(); |
| 2180 | attachmentLayer = attachmentObject->layer(); |
| 2181 | } |
| 2182 | |
| 2183 | GLenum attachmentObjectType; // Type category |
| 2184 | if (framebufferHandle == 0) |
| 2185 | { |
| 2186 | attachmentObjectType = GL_FRAMEBUFFER_DEFAULT; |
| 2187 | } |
| 2188 | else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
| 2189 | { |
| 2190 | attachmentObjectType = attachmentType; |
| 2191 | } |
| 2192 | else if (gl::ValidTexture2DDestinationTarget(context, attachmentType)) |
| 2193 | { |
| 2194 | attachmentObjectType = GL_TEXTURE; |
| 2195 | } |
| 2196 | else |
| 2197 | { |
| 2198 | UNREACHABLE(); |
| 2199 | return; |
| 2200 | } |
| 2201 | |
| 2202 | if (attachmentObjectType == GL_NONE) |
| 2203 | { |
| 2204 | // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
| 2205 | // is NONE, then querying any other pname will generate INVALID_ENUM. |
| 2206 | |
| 2207 | // ES 3.0.2 spec pg 235 states that if the attachment type is none, |
| 2208 | // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an |
| 2209 | // INVALID_OPERATION for all other pnames |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 2210 | |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2211 | switch (pname) |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2212 | { |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2213 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2214 | *params = attachmentObjectType; |
| 2215 | break; |
| 2216 | |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2217 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
Geoff Lang | 05b0502 | 2014-06-11 15:31:45 -0400 | [diff] [blame] | 2218 | if (clientVersion < 3) |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2219 | { |
Geoff Lang | 05b0502 | 2014-06-11 15:31:45 -0400 | [diff] [blame] | 2220 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2221 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2222 | *params = 0; |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2223 | break; |
| 2224 | |
| 2225 | default: |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 2226 | if (clientVersion < 3) |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2227 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2228 | return gl::error(GL_INVALID_ENUM); |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2229 | } |
| 2230 | else |
| 2231 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2232 | gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2233 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2234 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2235 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2236 | else |
| 2237 | { |
| 2238 | ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE || |
| 2239 | attachmentObjectType == GL_FRAMEBUFFER_DEFAULT); |
| 2240 | ASSERT(attachmentObject != NULL); |
| 2241 | |
| 2242 | switch (pname) |
| 2243 | { |
| 2244 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2245 | *params = attachmentObjectType; |
| 2246 | break; |
| 2247 | |
| 2248 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2249 | if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE) |
| 2250 | { |
| 2251 | return gl::error(GL_INVALID_ENUM); |
| 2252 | } |
| 2253 | *params = attachmentHandle; |
| 2254 | break; |
| 2255 | |
| 2256 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2257 | if (attachmentObjectType != GL_TEXTURE) |
| 2258 | { |
| 2259 | return gl::error(GL_INVALID_ENUM); |
| 2260 | } |
| 2261 | *params = attachmentLevel; |
| 2262 | break; |
| 2263 | |
| 2264 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2265 | if (attachmentObjectType != GL_TEXTURE) |
| 2266 | { |
| 2267 | return gl::error(GL_INVALID_ENUM); |
| 2268 | } |
| 2269 | *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0; |
| 2270 | break; |
| 2271 | |
| 2272 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
| 2273 | *params = attachmentObject->getRedSize(); |
| 2274 | break; |
| 2275 | |
| 2276 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
| 2277 | *params = attachmentObject->getGreenSize(); |
| 2278 | break; |
| 2279 | |
| 2280 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
| 2281 | *params = attachmentObject->getBlueSize(); |
| 2282 | break; |
| 2283 | |
| 2284 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
| 2285 | *params = attachmentObject->getAlphaSize(); |
| 2286 | break; |
| 2287 | |
| 2288 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
| 2289 | *params = attachmentObject->getDepthSize(); |
| 2290 | break; |
| 2291 | |
| 2292 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
| 2293 | *params = attachmentObject->getStencilSize(); |
| 2294 | break; |
| 2295 | |
| 2296 | case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: |
| 2297 | if (attachment == GL_DEPTH_STENCIL) |
| 2298 | { |
| 2299 | gl::error(GL_INVALID_OPERATION); |
| 2300 | } |
| 2301 | *params = attachmentObject->getComponentType(); |
| 2302 | break; |
| 2303 | |
| 2304 | case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: |
| 2305 | *params = attachmentObject->getColorEncoding(); |
| 2306 | break; |
| 2307 | |
| 2308 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 2309 | if (attachmentObjectType != GL_TEXTURE) |
| 2310 | { |
| 2311 | return gl::error(GL_INVALID_ENUM); |
| 2312 | } |
| 2313 | *params = attachmentLayer; |
| 2314 | break; |
| 2315 | |
| 2316 | default: |
| 2317 | UNREACHABLE(); |
| 2318 | break; |
| 2319 | } |
| 2320 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2321 | } |
| 2322 | } |
| 2323 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2324 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 2325 | { |
| 2326 | EVENT("()"); |
| 2327 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2328 | gl::Context *context = gl::getContext(); |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2329 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2330 | if (context) |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2331 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2332 | return context->getResetStatus(); |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2333 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2334 | |
| 2335 | return GL_NO_ERROR; |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2336 | } |
| 2337 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2338 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 2339 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2340 | EVENT("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2341 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2342 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2343 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2344 | if (context) |
| 2345 | { |
| 2346 | GLenum nativeType; |
| 2347 | unsigned int numParams = 0; |
| 2348 | |
| 2349 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2350 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2351 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2352 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2353 | |
| 2354 | if (nativeType == GL_INT) |
| 2355 | { |
| 2356 | context->getIntegerv(pname, params); |
| 2357 | } |
| 2358 | else |
| 2359 | { |
| 2360 | CastStateValues(context, nativeType, pname, numParams, params); |
| 2361 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 2366 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2367 | EVENT("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2368 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2369 | gl::Context *context = gl::getNonLostContext(); |
| 2370 | |
| 2371 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2372 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2373 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2374 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2375 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2376 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2377 | return gl::error(GL_INVALID_VALUE); |
| 2378 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2379 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2380 | if (context->getClientVersion() < 3) |
| 2381 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2382 | switch (pname) |
| 2383 | { |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 2384 | case GL_ACTIVE_UNIFORM_BLOCKS: |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 2385 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2386 | case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2387 | case GL_TRANSFORM_FEEDBACK_VARYINGS: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2388 | case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2389 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2390 | } |
| 2391 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2392 | |
| 2393 | switch (pname) |
| 2394 | { |
| 2395 | case GL_DELETE_STATUS: |
| 2396 | *params = programObject->isFlaggedForDeletion(); |
| 2397 | return; |
| 2398 | case GL_LINK_STATUS: |
| 2399 | *params = programObject->isLinked(); |
| 2400 | return; |
| 2401 | case GL_VALIDATE_STATUS: |
| 2402 | *params = programObject->isValidated(); |
| 2403 | return; |
| 2404 | case GL_INFO_LOG_LENGTH: |
| 2405 | *params = programObject->getInfoLogLength(); |
| 2406 | return; |
| 2407 | case GL_ATTACHED_SHADERS: |
| 2408 | *params = programObject->getAttachedShadersCount(); |
| 2409 | return; |
| 2410 | case GL_ACTIVE_ATTRIBUTES: |
| 2411 | *params = programObject->getActiveAttributeCount(); |
| 2412 | return; |
| 2413 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
| 2414 | *params = programObject->getActiveAttributeMaxLength(); |
| 2415 | return; |
| 2416 | case GL_ACTIVE_UNIFORMS: |
| 2417 | *params = programObject->getActiveUniformCount(); |
| 2418 | return; |
| 2419 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
| 2420 | *params = programObject->getActiveUniformMaxLength(); |
| 2421 | return; |
| 2422 | case GL_PROGRAM_BINARY_LENGTH_OES: |
| 2423 | *params = programObject->getProgramBinaryLength(); |
| 2424 | return; |
| 2425 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 2426 | *params = programObject->getActiveUniformBlockCount(); |
| 2427 | return; |
| 2428 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 2429 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 2430 | break; |
| 2431 | case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: |
| 2432 | *params = programObject->getTransformFeedbackBufferMode(); |
| 2433 | break; |
| 2434 | case GL_TRANSFORM_FEEDBACK_VARYINGS: |
| 2435 | *params = programObject->getTransformFeedbackVaryingCount(); |
| 2436 | break; |
| 2437 | case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: |
| 2438 | *params = programObject->getTransformFeedbackVaryingMaxLength(); |
| 2439 | break; |
| 2440 | default: |
| 2441 | return gl::error(GL_INVALID_ENUM); |
| 2442 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2443 | } |
| 2444 | } |
| 2445 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2446 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2447 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2448 | EVENT("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2449 | program, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2450 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2451 | if (bufsize < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2452 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2453 | return gl::error(GL_INVALID_VALUE); |
| 2454 | } |
| 2455 | |
| 2456 | gl::Context *context = gl::getNonLostContext(); |
| 2457 | |
| 2458 | if (context) |
| 2459 | { |
| 2460 | gl::Program *programObject = context->getProgram(program); |
| 2461 | |
| 2462 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2463 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2464 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2465 | } |
| 2466 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2467 | programObject->getInfoLog(bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2468 | } |
| 2469 | } |
| 2470 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2471 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 2472 | { |
| 2473 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 2474 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2475 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2476 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2477 | if (context) |
| 2478 | { |
| 2479 | if (!ValidQueryType(context, target)) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2480 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2481 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2482 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2483 | |
| 2484 | switch (pname) |
| 2485 | { |
| 2486 | case GL_CURRENT_QUERY_EXT: |
| 2487 | params[0] = context->getState().getActiveQueryId(target); |
| 2488 | break; |
| 2489 | |
| 2490 | default: |
| 2491 | return gl::error(GL_INVALID_ENUM); |
| 2492 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2493 | } |
| 2494 | } |
| 2495 | |
| 2496 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 2497 | { |
| 2498 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 2499 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2500 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2501 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2502 | if (context) |
| 2503 | { |
| 2504 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 2505 | |
| 2506 | if (!queryObject) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2507 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2508 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2509 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2510 | |
| 2511 | if (context->getState().getActiveQueryId(queryObject->getType()) == id) |
| 2512 | { |
| 2513 | return gl::error(GL_INVALID_OPERATION); |
| 2514 | } |
| 2515 | |
| 2516 | switch(pname) |
| 2517 | { |
| 2518 | case GL_QUERY_RESULT_EXT: |
| 2519 | params[0] = queryObject->getResult(); |
| 2520 | break; |
| 2521 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 2522 | params[0] = queryObject->isResultAvailable(); |
| 2523 | break; |
| 2524 | default: |
| 2525 | return gl::error(GL_INVALID_ENUM); |
| 2526 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2527 | } |
| 2528 | } |
| 2529 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2530 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2531 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2532 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2533 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2534 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 2535 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2536 | if (context) |
| 2537 | { |
| 2538 | if (target != GL_RENDERBUFFER) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 2539 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2540 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 2541 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2542 | |
| 2543 | if (context->getState().getRenderbufferId() == 0) |
| 2544 | { |
| 2545 | return gl::error(GL_INVALID_OPERATION); |
| 2546 | } |
| 2547 | |
| 2548 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId()); |
| 2549 | |
| 2550 | switch (pname) |
| 2551 | { |
| 2552 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 2553 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 2554 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 2555 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 2556 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 2557 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 2558 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 2559 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 2560 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
| 2561 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
| 2562 | if (!context->getExtensions().framebufferMultisample) |
| 2563 | { |
| 2564 | return gl::error(GL_INVALID_ENUM); |
| 2565 | } |
| 2566 | *params = renderbuffer->getSamples(); |
| 2567 | break; |
| 2568 | default: |
| 2569 | return gl::error(GL_INVALID_ENUM); |
| 2570 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 2575 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2576 | EVENT("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2577 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2578 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2579 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2580 | if (context) |
| 2581 | { |
| 2582 | gl::Shader *shaderObject = context->getShader(shader); |
| 2583 | |
| 2584 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2585 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2586 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2587 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2588 | |
| 2589 | switch (pname) |
| 2590 | { |
| 2591 | case GL_SHADER_TYPE: |
| 2592 | *params = shaderObject->getType(); |
| 2593 | return; |
| 2594 | case GL_DELETE_STATUS: |
| 2595 | *params = shaderObject->isFlaggedForDeletion(); |
| 2596 | return; |
| 2597 | case GL_COMPILE_STATUS: |
| 2598 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 2599 | return; |
| 2600 | case GL_INFO_LOG_LENGTH: |
| 2601 | *params = shaderObject->getInfoLogLength(); |
| 2602 | return; |
| 2603 | case GL_SHADER_SOURCE_LENGTH: |
| 2604 | *params = shaderObject->getSourceLength(); |
| 2605 | return; |
| 2606 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 2607 | *params = shaderObject->getTranslatedSourceLength(); |
| 2608 | return; |
| 2609 | default: |
| 2610 | return gl::error(GL_INVALID_ENUM); |
| 2611 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2612 | } |
| 2613 | } |
| 2614 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2615 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2616 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2617 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2618 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2619 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2620 | if (bufsize < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2621 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2622 | return gl::error(GL_INVALID_VALUE); |
| 2623 | } |
| 2624 | |
| 2625 | gl::Context *context = gl::getNonLostContext(); |
| 2626 | |
| 2627 | if (context) |
| 2628 | { |
| 2629 | gl::Shader *shaderObject = context->getShader(shader); |
| 2630 | |
| 2631 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2632 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 2633 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2634 | } |
| 2635 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2636 | shaderObject->getInfoLog(bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 2641 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2642 | EVENT("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2643 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2644 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2645 | switch (shadertype) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2646 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2647 | case GL_VERTEX_SHADER: |
| 2648 | case GL_FRAGMENT_SHADER: |
| 2649 | break; |
| 2650 | default: |
| 2651 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2652 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2653 | |
| 2654 | switch (precisiontype) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2655 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2656 | case GL_LOW_FLOAT: |
| 2657 | case GL_MEDIUM_FLOAT: |
| 2658 | case GL_HIGH_FLOAT: |
| 2659 | // Assume IEEE 754 precision |
| 2660 | range[0] = 127; |
| 2661 | range[1] = 127; |
| 2662 | *precision = 23; |
| 2663 | break; |
| 2664 | case GL_LOW_INT: |
| 2665 | case GL_MEDIUM_INT: |
| 2666 | case GL_HIGH_INT: |
| 2667 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 2668 | // which can accurately represent integers up to +/-16777216 |
| 2669 | range[0] = 24; |
| 2670 | range[1] = 24; |
| 2671 | *precision = 0; |
| 2672 | break; |
| 2673 | default: |
| 2674 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2675 | } |
| 2676 | } |
| 2677 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2678 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2679 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2680 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 2681 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2682 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2683 | if (bufsize < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2684 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2685 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2686 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2687 | |
| 2688 | gl::Context *context = gl::getNonLostContext(); |
| 2689 | |
| 2690 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2691 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2692 | gl::Shader *shaderObject = context->getShader(shader); |
| 2693 | |
| 2694 | if (!shaderObject) |
| 2695 | { |
| 2696 | return gl::error(GL_INVALID_OPERATION); |
| 2697 | } |
| 2698 | |
| 2699 | shaderObject->getSource(bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2700 | } |
| 2701 | } |
| 2702 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2703 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 2704 | { |
| 2705 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 2706 | shader, bufsize, length, source); |
| 2707 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2708 | if (bufsize < 0) |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2709 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2710 | return gl::error(GL_INVALID_VALUE); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2711 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2712 | |
| 2713 | gl::Context *context = gl::getNonLostContext(); |
| 2714 | |
| 2715 | if (context) |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2716 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2717 | gl::Shader *shaderObject = context->getShader(shader); |
| 2718 | |
| 2719 | if (!shaderObject) |
| 2720 | { |
| 2721 | return gl::error(GL_INVALID_OPERATION); |
| 2722 | } |
| 2723 | |
| 2724 | shaderObject->getTranslatedSource(bufsize, length, source); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2725 | } |
| 2726 | } |
| 2727 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2728 | const GLubyte* __stdcall glGetString(GLenum name) |
| 2729 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2730 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2731 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2732 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 2733 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2734 | switch (name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2735 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2736 | case GL_VENDOR: |
| 2737 | return (GLubyte*)"Google Inc."; |
| 2738 | case GL_RENDERER: |
| 2739 | return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE"); |
| 2740 | case GL_VERSION: |
| 2741 | if (context->getClientVersion() == 2) |
| 2742 | { |
| 2743 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2744 | } |
| 2745 | else |
| 2746 | { |
| 2747 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2748 | } |
| 2749 | case GL_SHADING_LANGUAGE_VERSION: |
| 2750 | if (context->getClientVersion() == 2) |
| 2751 | { |
| 2752 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2753 | } |
| 2754 | else |
| 2755 | { |
| 2756 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2757 | } |
| 2758 | case GL_EXTENSIONS: |
| 2759 | return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : ""); |
| 2760 | default: |
| 2761 | return gl::error(GL_INVALID_ENUM, (GLubyte*)NULL); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2762 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2763 | } |
| 2764 | |
| 2765 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 2766 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2767 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", target, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2768 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2769 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2770 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2771 | if (context) |
| 2772 | { |
| 2773 | gl::Texture *texture = context->getTargetTexture(target); |
| 2774 | |
| 2775 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2776 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2777 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2778 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2779 | |
| 2780 | switch (pname) |
| 2781 | { |
| 2782 | case GL_TEXTURE_MAG_FILTER: |
| 2783 | *params = (GLfloat)texture->getSamplerState().magFilter; |
| 2784 | break; |
| 2785 | case GL_TEXTURE_MIN_FILTER: |
| 2786 | *params = (GLfloat)texture->getSamplerState().minFilter; |
| 2787 | break; |
| 2788 | case GL_TEXTURE_WRAP_S: |
| 2789 | *params = (GLfloat)texture->getSamplerState().wrapS; |
| 2790 | break; |
| 2791 | case GL_TEXTURE_WRAP_T: |
| 2792 | *params = (GLfloat)texture->getSamplerState().wrapT; |
| 2793 | break; |
| 2794 | case GL_TEXTURE_WRAP_R: |
| 2795 | if (context->getClientVersion() < 3) |
| 2796 | { |
| 2797 | return gl::error(GL_INVALID_ENUM); |
| 2798 | } |
| 2799 | *params = (GLfloat)texture->getSamplerState().wrapR; |
| 2800 | break; |
| 2801 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 2802 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
| 2803 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 2804 | break; |
| 2805 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 2806 | if (context->getClientVersion() < 3) |
| 2807 | { |
| 2808 | return gl::error(GL_INVALID_ENUM); |
| 2809 | } |
| 2810 | *params = (GLfloat)texture->immutableLevelCount(); |
| 2811 | break; |
| 2812 | case GL_TEXTURE_USAGE_ANGLE: |
| 2813 | *params = (GLfloat)texture->getUsage(); |
| 2814 | break; |
| 2815 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 2816 | if (!context->getExtensions().textureFilterAnisotropic) |
| 2817 | { |
| 2818 | return gl::error(GL_INVALID_ENUM); |
| 2819 | } |
| 2820 | *params = (GLfloat)texture->getSamplerState().maxAnisotropy; |
| 2821 | break; |
| 2822 | case GL_TEXTURE_SWIZZLE_R: |
| 2823 | if (context->getClientVersion() < 3) |
| 2824 | { |
| 2825 | return gl::error(GL_INVALID_ENUM); |
| 2826 | } |
| 2827 | *params = (GLfloat)texture->getSamplerState().swizzleRed; |
| 2828 | break; |
| 2829 | case GL_TEXTURE_SWIZZLE_G: |
| 2830 | if (context->getClientVersion() < 3) |
| 2831 | { |
| 2832 | return gl::error(GL_INVALID_ENUM); |
| 2833 | } |
| 2834 | *params = (GLfloat)texture->getSamplerState().swizzleGreen; |
| 2835 | break; |
| 2836 | case GL_TEXTURE_SWIZZLE_B: |
| 2837 | if (context->getClientVersion() < 3) |
| 2838 | { |
| 2839 | return gl::error(GL_INVALID_ENUM); |
| 2840 | } |
| 2841 | *params = (GLfloat)texture->getSamplerState().swizzleBlue; |
| 2842 | break; |
| 2843 | case GL_TEXTURE_SWIZZLE_A: |
| 2844 | if (context->getClientVersion() < 3) |
| 2845 | { |
| 2846 | return gl::error(GL_INVALID_ENUM); |
| 2847 | } |
| 2848 | *params = (GLfloat)texture->getSamplerState().swizzleAlpha; |
| 2849 | break; |
| 2850 | case GL_TEXTURE_BASE_LEVEL: |
| 2851 | if (context->getClientVersion() < 3) |
| 2852 | { |
| 2853 | return gl::error(GL_INVALID_ENUM); |
| 2854 | } |
| 2855 | *params = (GLfloat)texture->getSamplerState().baseLevel; |
| 2856 | break; |
| 2857 | case GL_TEXTURE_MAX_LEVEL: |
| 2858 | if (context->getClientVersion() < 3) |
| 2859 | { |
| 2860 | return gl::error(GL_INVALID_ENUM); |
| 2861 | } |
| 2862 | *params = (GLfloat)texture->getSamplerState().maxLevel; |
| 2863 | break; |
| 2864 | case GL_TEXTURE_MIN_LOD: |
| 2865 | if (context->getClientVersion() < 3) |
| 2866 | { |
| 2867 | return gl::error(GL_INVALID_ENUM); |
| 2868 | } |
| 2869 | *params = texture->getSamplerState().minLod; |
| 2870 | break; |
| 2871 | case GL_TEXTURE_MAX_LOD: |
| 2872 | if (context->getClientVersion() < 3) |
| 2873 | { |
| 2874 | return gl::error(GL_INVALID_ENUM); |
| 2875 | } |
| 2876 | *params = texture->getSamplerState().maxLod; |
| 2877 | break; |
| 2878 | default: |
| 2879 | return gl::error(GL_INVALID_ENUM); |
| 2880 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2881 | } |
| 2882 | } |
| 2883 | |
| 2884 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2885 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2886 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2887 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2888 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2889 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2890 | if (context) |
| 2891 | { |
| 2892 | gl::Texture *texture = context->getTargetTexture(target); |
| 2893 | |
| 2894 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2895 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2896 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2897 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2898 | |
| 2899 | switch (pname) |
| 2900 | { |
| 2901 | case GL_TEXTURE_MAG_FILTER: |
| 2902 | *params = texture->getSamplerState().magFilter; |
| 2903 | break; |
| 2904 | case GL_TEXTURE_MIN_FILTER: |
| 2905 | *params = texture->getSamplerState().minFilter; |
| 2906 | break; |
| 2907 | case GL_TEXTURE_WRAP_S: |
| 2908 | *params = texture->getSamplerState().wrapS; |
| 2909 | break; |
| 2910 | case GL_TEXTURE_WRAP_T: |
| 2911 | *params = texture->getSamplerState().wrapT; |
| 2912 | break; |
| 2913 | case GL_TEXTURE_WRAP_R: |
| 2914 | if (context->getClientVersion() < 3) |
| 2915 | { |
| 2916 | return gl::error(GL_INVALID_ENUM); |
| 2917 | } |
| 2918 | *params = texture->getSamplerState().wrapR; |
| 2919 | break; |
| 2920 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 2921 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
| 2922 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 2923 | break; |
| 2924 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 2925 | if (context->getClientVersion() < 3) |
| 2926 | { |
| 2927 | return gl::error(GL_INVALID_ENUM); |
| 2928 | } |
| 2929 | *params = texture->immutableLevelCount(); |
| 2930 | break; |
| 2931 | case GL_TEXTURE_USAGE_ANGLE: |
| 2932 | *params = texture->getUsage(); |
| 2933 | break; |
| 2934 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 2935 | if (!context->getExtensions().textureFilterAnisotropic) |
| 2936 | { |
| 2937 | return gl::error(GL_INVALID_ENUM); |
| 2938 | } |
| 2939 | *params = (GLint)texture->getSamplerState().maxAnisotropy; |
| 2940 | break; |
| 2941 | case GL_TEXTURE_SWIZZLE_R: |
| 2942 | if (context->getClientVersion() < 3) |
| 2943 | { |
| 2944 | return gl::error(GL_INVALID_ENUM); |
| 2945 | } |
| 2946 | *params = texture->getSamplerState().swizzleRed; |
| 2947 | break; |
| 2948 | case GL_TEXTURE_SWIZZLE_G: |
| 2949 | if (context->getClientVersion() < 3) |
| 2950 | { |
| 2951 | return gl::error(GL_INVALID_ENUM); |
| 2952 | } |
| 2953 | *params = texture->getSamplerState().swizzleGreen; |
| 2954 | break; |
| 2955 | case GL_TEXTURE_SWIZZLE_B: |
| 2956 | if (context->getClientVersion() < 3) |
| 2957 | { |
| 2958 | return gl::error(GL_INVALID_ENUM); |
| 2959 | } |
| 2960 | *params = texture->getSamplerState().swizzleBlue; |
| 2961 | break; |
| 2962 | case GL_TEXTURE_SWIZZLE_A: |
| 2963 | if (context->getClientVersion() < 3) |
| 2964 | { |
| 2965 | return gl::error(GL_INVALID_ENUM); |
| 2966 | } |
| 2967 | *params = texture->getSamplerState().swizzleAlpha; |
| 2968 | break; |
| 2969 | case GL_TEXTURE_BASE_LEVEL: |
| 2970 | if (context->getClientVersion() < 3) |
| 2971 | { |
| 2972 | return gl::error(GL_INVALID_ENUM); |
| 2973 | } |
| 2974 | *params = texture->getSamplerState().baseLevel; |
| 2975 | break; |
| 2976 | case GL_TEXTURE_MAX_LEVEL: |
| 2977 | if (context->getClientVersion() < 3) |
| 2978 | { |
| 2979 | return gl::error(GL_INVALID_ENUM); |
| 2980 | } |
| 2981 | *params = texture->getSamplerState().maxLevel; |
| 2982 | break; |
| 2983 | case GL_TEXTURE_MIN_LOD: |
| 2984 | if (context->getClientVersion() < 3) |
| 2985 | { |
| 2986 | return gl::error(GL_INVALID_ENUM); |
| 2987 | } |
| 2988 | *params = (GLint)texture->getSamplerState().minLod; |
| 2989 | break; |
| 2990 | case GL_TEXTURE_MAX_LOD: |
| 2991 | if (context->getClientVersion() < 3) |
| 2992 | { |
| 2993 | return gl::error(GL_INVALID_ENUM); |
| 2994 | } |
| 2995 | *params = (GLint)texture->getSamplerState().maxLod; |
| 2996 | break; |
| 2997 | default: |
| 2998 | return gl::error(GL_INVALID_ENUM); |
| 2999 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3000 | } |
| 3001 | } |
| 3002 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3003 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 3004 | { |
| 3005 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 3006 | program, location, bufSize, params); |
| 3007 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3008 | if (bufSize < 0) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3009 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3010 | return gl::error(GL_INVALID_VALUE); |
| 3011 | } |
| 3012 | |
| 3013 | gl::Context *context = gl::getNonLostContext(); |
| 3014 | |
| 3015 | if (context) |
| 3016 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3017 | if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3018 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3019 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3020 | } |
| 3021 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3022 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 3023 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3024 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3025 | programBinary->getUniformfv(location, params); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3026 | } |
| 3027 | } |
| 3028 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3029 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 3030 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3031 | EVENT("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3032 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3033 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3034 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3035 | if (context) |
| 3036 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3037 | if (!ValidateGetUniformfv(context, program, location, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3038 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3039 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3040 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3041 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3042 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 3043 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3044 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3045 | programBinary->getUniformfv(location, params); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3046 | } |
| 3047 | } |
| 3048 | |
| 3049 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 3050 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3051 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)", |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3052 | program, location, bufSize, params); |
| 3053 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3054 | if (bufSize < 0) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3055 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3056 | return gl::error(GL_INVALID_VALUE); |
| 3057 | } |
| 3058 | |
| 3059 | gl::Context *context = gl::getNonLostContext(); |
| 3060 | |
| 3061 | if (context) |
| 3062 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3063 | if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3064 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3065 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3066 | } |
| 3067 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3068 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 3069 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3070 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3071 | programBinary->getUniformiv(location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3072 | } |
| 3073 | } |
| 3074 | |
| 3075 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 3076 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3077 | EVENT("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3078 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3079 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3080 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3081 | if (context) |
| 3082 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3083 | if (!ValidateGetUniformiv(context, program, location, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3084 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3085 | return; |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3086 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3087 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3088 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 3089 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3090 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3091 | programBinary->getUniformiv(location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3092 | } |
| 3093 | } |
| 3094 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3095 | int __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3096 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3097 | EVENT("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3098 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3099 | gl::Context *context = gl::getNonLostContext(); |
| 3100 | |
| 3101 | if (strstr(name, "gl_") == name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3102 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3103 | return -1; |
| 3104 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3105 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3106 | if (context) |
| 3107 | { |
| 3108 | gl::Program *programObject = context->getProgram(program); |
| 3109 | |
| 3110 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3111 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3112 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3113 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3114 | return gl::error(GL_INVALID_OPERATION, -1); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3115 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3116 | else |
| 3117 | { |
| 3118 | return gl::error(GL_INVALID_VALUE, -1); |
| 3119 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3120 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3121 | |
| 3122 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3123 | if (!programObject->isLinked() || !programBinary) |
| 3124 | { |
| 3125 | return gl::error(GL_INVALID_OPERATION, -1); |
| 3126 | } |
| 3127 | |
| 3128 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3129 | } |
| 3130 | |
| 3131 | return -1; |
| 3132 | } |
| 3133 | |
| 3134 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 3135 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3136 | EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3137 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3138 | gl::Context *context = gl::getNonLostContext(); |
| 3139 | |
| 3140 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3141 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3142 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3143 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3144 | return gl::error(GL_INVALID_VALUE); |
| 3145 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3146 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3147 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
| 3148 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 3149 | { |
| 3150 | return; |
| 3151 | } |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3152 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3153 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 3154 | { |
| 3155 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 3156 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3157 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3158 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3159 | } |
| 3160 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3161 | else |
| 3162 | { |
| 3163 | *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname); |
| 3164 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3165 | } |
| 3166 | } |
| 3167 | |
| 3168 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 3169 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3170 | EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3171 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3172 | gl::Context *context = gl::getNonLostContext(); |
| 3173 | |
| 3174 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3175 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3176 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3177 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3178 | return gl::error(GL_INVALID_VALUE); |
| 3179 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3180 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3181 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3182 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3183 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 3184 | { |
| 3185 | return; |
| 3186 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3187 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3188 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 3189 | { |
| 3190 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 3191 | for (int i = 0; i < 4; ++i) |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3192 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3193 | float currentValue = currentValueData.FloatValues[i]; |
| 3194 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3195 | } |
| 3196 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3197 | else |
| 3198 | { |
| 3199 | *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname); |
| 3200 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3201 | } |
| 3202 | } |
| 3203 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3204 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3205 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3206 | EVENT("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3207 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3208 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3209 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3210 | if (context) |
| 3211 | { |
| 3212 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3213 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3214 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3215 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3216 | |
| 3217 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 3218 | { |
| 3219 | return gl::error(GL_INVALID_ENUM); |
| 3220 | } |
| 3221 | |
| 3222 | *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3223 | } |
| 3224 | } |
| 3225 | |
| 3226 | void __stdcall glHint(GLenum target, GLenum mode) |
| 3227 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3228 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3229 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3230 | switch (mode) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3231 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3232 | case GL_FASTEST: |
| 3233 | case GL_NICEST: |
| 3234 | case GL_DONT_CARE: |
| 3235 | break; |
| 3236 | default: |
| 3237 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3238 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3239 | |
| 3240 | gl::Context *context = gl::getNonLostContext(); |
| 3241 | switch (target) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3242 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3243 | case GL_GENERATE_MIPMAP_HINT: |
| 3244 | if (context) context->getState().setGenerateMipmapHint(mode); |
| 3245 | break; |
| 3246 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 3247 | if (context) context->getState().setFragmentShaderDerivativeHint(mode); |
| 3248 | break; |
| 3249 | default: |
| 3250 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3251 | } |
| 3252 | } |
| 3253 | |
| 3254 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 3255 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3256 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3257 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3258 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3259 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3260 | if (context && buffer) |
| 3261 | { |
| 3262 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 3263 | |
| 3264 | if (bufferObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3265 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3266 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3267 | } |
| 3268 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3269 | |
| 3270 | return GL_FALSE; |
| 3271 | } |
| 3272 | |
| 3273 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 3274 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3275 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3276 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3277 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3278 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3279 | if (context) |
| 3280 | { |
| 3281 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3282 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3283 | return gl::error(GL_INVALID_ENUM, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3284 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3285 | |
| 3286 | return context->getState().getEnableFeature(cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3287 | } |
| 3288 | |
| 3289 | return false; |
| 3290 | } |
| 3291 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3292 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 3293 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3294 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3295 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3296 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3297 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3298 | if (context) |
| 3299 | { |
| 3300 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 3301 | |
| 3302 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3303 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3304 | return GL_FALSE; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3305 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3306 | |
| 3307 | return fenceObject->isFence(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3308 | } |
| 3309 | |
| 3310 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3311 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3312 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3313 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 3314 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3315 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3316 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3317 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3318 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3319 | if (context && framebuffer) |
| 3320 | { |
| 3321 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 3322 | |
| 3323 | if (framebufferObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3324 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3325 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3326 | } |
| 3327 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | |
| 3329 | return GL_FALSE; |
| 3330 | } |
| 3331 | |
| 3332 | GLboolean __stdcall glIsProgram(GLuint program) |
| 3333 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3334 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3335 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3336 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3337 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3338 | if (context && program) |
| 3339 | { |
| 3340 | gl::Program *programObject = context->getProgram(program); |
| 3341 | |
| 3342 | if (programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3343 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3344 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3345 | } |
| 3346 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3347 | |
| 3348 | return GL_FALSE; |
| 3349 | } |
| 3350 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3351 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 3352 | { |
| 3353 | EVENT("(GLuint id = %d)", id); |
| 3354 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3355 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3356 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3357 | if (context) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3358 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3359 | return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3360 | } |
| 3361 | |
| 3362 | return GL_FALSE; |
| 3363 | } |
| 3364 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3365 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 3366 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3367 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3368 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3369 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3370 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3371 | if (context && renderbuffer) |
| 3372 | { |
| 3373 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 3374 | |
| 3375 | if (renderbufferObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3376 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3377 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3378 | } |
| 3379 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3380 | |
| 3381 | return GL_FALSE; |
| 3382 | } |
| 3383 | |
| 3384 | GLboolean __stdcall glIsShader(GLuint shader) |
| 3385 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3386 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3387 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3388 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3389 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3390 | if (context && shader) |
| 3391 | { |
| 3392 | gl::Shader *shaderObject = context->getShader(shader); |
| 3393 | |
| 3394 | if (shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3395 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3396 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3397 | } |
| 3398 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3399 | |
| 3400 | return GL_FALSE; |
| 3401 | } |
| 3402 | |
| 3403 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 3404 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3405 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3406 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3407 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3408 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3409 | if (context && texture) |
| 3410 | { |
| 3411 | gl::Texture *textureObject = context->getTexture(texture); |
| 3412 | |
| 3413 | if (textureObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3414 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3415 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3416 | } |
| 3417 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3418 | |
| 3419 | return GL_FALSE; |
| 3420 | } |
| 3421 | |
| 3422 | void __stdcall glLineWidth(GLfloat width) |
| 3423 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3424 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3425 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3426 | if (width <= 0.0f) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3427 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3428 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3429 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3430 | |
| 3431 | gl::Context *context = gl::getNonLostContext(); |
| 3432 | |
| 3433 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3434 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3435 | context->getState().setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3436 | } |
| 3437 | } |
| 3438 | |
| 3439 | void __stdcall glLinkProgram(GLuint program) |
| 3440 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3441 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3442 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3443 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3444 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3445 | if (context) |
| 3446 | { |
| 3447 | gl::Program *programObject = context->getProgram(program); |
| 3448 | |
| 3449 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3450 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3451 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3452 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3453 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3454 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3455 | else |
| 3456 | { |
| 3457 | return gl::error(GL_INVALID_VALUE); |
| 3458 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3459 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3460 | |
| 3461 | context->linkProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3462 | } |
| 3463 | } |
| 3464 | |
| 3465 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 3466 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3467 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3468 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3469 | gl::Context *context = gl::getNonLostContext(); |
| 3470 | |
| 3471 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3472 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3473 | switch (pname) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3474 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3475 | case GL_UNPACK_ALIGNMENT: |
| 3476 | if (param != 1 && param != 2 && param != 4 && param != 8) |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3477 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3478 | return gl::error(GL_INVALID_VALUE); |
| 3479 | } |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3480 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3481 | context->getState().setUnpackAlignment(param); |
| 3482 | break; |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3483 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3484 | case GL_PACK_ALIGNMENT: |
| 3485 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 3486 | { |
| 3487 | return gl::error(GL_INVALID_VALUE); |
| 3488 | } |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3489 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3490 | context->getState().setPackAlignment(param); |
| 3491 | break; |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3492 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3493 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 3494 | context->getState().setPackReverseRowOrder(param != 0); |
| 3495 | break; |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 3496 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3497 | case GL_UNPACK_IMAGE_HEIGHT: |
| 3498 | case GL_UNPACK_SKIP_IMAGES: |
| 3499 | case GL_UNPACK_ROW_LENGTH: |
| 3500 | case GL_UNPACK_SKIP_ROWS: |
| 3501 | case GL_UNPACK_SKIP_PIXELS: |
| 3502 | case GL_PACK_ROW_LENGTH: |
| 3503 | case GL_PACK_SKIP_ROWS: |
| 3504 | case GL_PACK_SKIP_PIXELS: |
| 3505 | if (context->getClientVersion() < 3) |
| 3506 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 3507 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3508 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3509 | UNIMPLEMENTED(); |
| 3510 | break; |
| 3511 | |
| 3512 | default: |
| 3513 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3514 | } |
| 3515 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3516 | } |
| 3517 | |
| 3518 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 3519 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3520 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3521 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3522 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | aede630 | 2010-04-29 03:35:48 +0000 | [diff] [blame] | 3523 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3524 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3525 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3526 | context->getState().setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3527 | } |
| 3528 | } |
| 3529 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3530 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 3531 | GLenum format, GLenum type, GLsizei bufSize, |
| 3532 | GLvoid *data) |
| 3533 | { |
| 3534 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 3535 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 3536 | x, y, width, height, format, type, bufSize, data); |
| 3537 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3538 | if (width < 0 || height < 0 || bufSize < 0) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3539 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3540 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3541 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3542 | |
| 3543 | gl::Context *context = gl::getNonLostContext(); |
| 3544 | |
| 3545 | if (context) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3546 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3547 | if (!gl::ValidateReadPixelsParameters(context, x, y, width, height, |
| 3548 | format, type, &bufSize, data)) |
| 3549 | { |
| 3550 | return; |
| 3551 | } |
| 3552 | |
| 3553 | context->readPixels(x, y, width, height, format, type, &bufSize, data); |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3554 | } |
| 3555 | } |
| 3556 | |
| 3557 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 3558 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3559 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3560 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3561 | "GLenum format = 0x%X, GLenum type = 0x%X, GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3562 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3563 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3564 | if (width < 0 || height < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3565 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3566 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3567 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3568 | |
| 3569 | gl::Context *context = gl::getNonLostContext(); |
| 3570 | |
| 3571 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3572 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3573 | if (!gl::ValidateReadPixelsParameters(context, x, y, width, height, |
| 3574 | format, type, NULL, pixels)) |
| 3575 | { |
| 3576 | return; |
| 3577 | } |
| 3578 | |
| 3579 | context->readPixels(x, y, width, height, format, type, NULL, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3580 | } |
| 3581 | } |
| 3582 | |
| 3583 | void __stdcall glReleaseShaderCompiler(void) |
| 3584 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3585 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3586 | |
Brandon Jones | f05cdee | 2014-08-27 15:24:07 -0700 | [diff] [blame^] | 3587 | gl::Context *context = gl::getNonLostContext(); |
| 3588 | |
| 3589 | if (context) |
| 3590 | { |
| 3591 | context->releaseShaderCompiler(); |
| 3592 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3593 | } |
| 3594 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3595 | void __stdcall glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3596 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3597 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3598 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3599 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3600 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3601 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3602 | if (context) |
| 3603 | { |
| 3604 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 3605 | width, height, true)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3606 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3607 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3608 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3609 | |
| 3610 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3611 | } |
| 3612 | } |
| 3613 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3614 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 3615 | { |
| 3616 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 3617 | } |
| 3618 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3619 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 3620 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3621 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3622 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3623 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3624 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3625 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3626 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3627 | context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3628 | } |
| 3629 | } |
| 3630 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3631 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 3632 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3633 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3634 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3635 | if (condition != GL_ALL_COMPLETED_NV) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3636 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3637 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3638 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3639 | |
| 3640 | gl::Context *context = gl::getNonLostContext(); |
| 3641 | |
| 3642 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3643 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3644 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 3645 | |
| 3646 | if (fenceObject == NULL) |
| 3647 | { |
| 3648 | return gl::error(GL_INVALID_OPERATION); |
| 3649 | } |
| 3650 | |
| 3651 | fenceObject->setFence(condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3652 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3653 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3654 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3655 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3656 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3657 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3658 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3659 | if (width < 0 || height < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3660 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3661 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3662 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3663 | |
| 3664 | gl::Context* context = gl::getNonLostContext(); |
| 3665 | |
| 3666 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3667 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3668 | context->getState().setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3669 | } |
| 3670 | } |
| 3671 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3672 | void __stdcall glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3673 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3674 | EVENT("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3675 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3676 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3677 | |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3678 | gl::Context* context = gl::getNonLostContext(); |
| 3679 | if (context) |
| 3680 | { |
| 3681 | const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats; |
| 3682 | if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end()) |
| 3683 | { |
| 3684 | return gl::error(GL_INVALID_ENUM); |
| 3685 | } |
| 3686 | |
| 3687 | // No binary shader formats are supported. |
| 3688 | UNIMPLEMENTED(); |
| 3689 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3690 | } |
| 3691 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 3692 | void __stdcall glShaderSource(GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3693 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3694 | EVENT("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3695 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3696 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3697 | if (count < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3698 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3699 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3700 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3701 | |
| 3702 | gl::Context *context = gl::getNonLostContext(); |
| 3703 | |
| 3704 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3705 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3706 | gl::Shader *shaderObject = context->getShader(shader); |
| 3707 | |
| 3708 | if (!shaderObject) |
| 3709 | { |
| 3710 | if (context->getProgram(shader)) |
| 3711 | { |
| 3712 | return gl::error(GL_INVALID_OPERATION); |
| 3713 | } |
| 3714 | else |
| 3715 | { |
| 3716 | return gl::error(GL_INVALID_VALUE); |
| 3717 | } |
| 3718 | } |
| 3719 | |
| 3720 | shaderObject->setSource(count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3721 | } |
| 3722 | } |
| 3723 | |
| 3724 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 3725 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3726 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3727 | } |
| 3728 | |
| 3729 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 3730 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3731 | EVENT("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3732 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3733 | switch (face) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3734 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3735 | case GL_FRONT: |
| 3736 | case GL_BACK: |
| 3737 | case GL_FRONT_AND_BACK: |
| 3738 | break; |
| 3739 | default: |
| 3740 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3741 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3742 | |
| 3743 | switch (func) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3744 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3745 | case GL_NEVER: |
| 3746 | case GL_ALWAYS: |
| 3747 | case GL_LESS: |
| 3748 | case GL_LEQUAL: |
| 3749 | case GL_EQUAL: |
| 3750 | case GL_GEQUAL: |
| 3751 | case GL_GREATER: |
| 3752 | case GL_NOTEQUAL: |
| 3753 | break; |
| 3754 | default: |
| 3755 | return gl::error(GL_INVALID_ENUM); |
| 3756 | } |
| 3757 | |
| 3758 | gl::Context *context = gl::getNonLostContext(); |
| 3759 | |
| 3760 | if (context) |
| 3761 | { |
| 3762 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3763 | { |
| 3764 | context->getState().setStencilParams(func, ref, mask); |
| 3765 | } |
| 3766 | |
| 3767 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3768 | { |
| 3769 | context->getState().setStencilBackParams(func, ref, mask); |
| 3770 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3771 | } |
| 3772 | } |
| 3773 | |
| 3774 | void __stdcall glStencilMask(GLuint mask) |
| 3775 | { |
| 3776 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 3777 | } |
| 3778 | |
| 3779 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 3780 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3781 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3782 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3783 | switch (face) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3784 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3785 | case GL_FRONT: |
| 3786 | case GL_BACK: |
| 3787 | case GL_FRONT_AND_BACK: |
| 3788 | break; |
| 3789 | default: |
| 3790 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3791 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3792 | |
| 3793 | gl::Context *context = gl::getNonLostContext(); |
| 3794 | |
| 3795 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3796 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3797 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3798 | { |
| 3799 | context->getState().setStencilWritemask(mask); |
| 3800 | } |
| 3801 | |
| 3802 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3803 | { |
| 3804 | context->getState().setStencilBackWritemask(mask); |
| 3805 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3806 | } |
| 3807 | } |
| 3808 | |
| 3809 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 3810 | { |
| 3811 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 3812 | } |
| 3813 | |
| 3814 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 3815 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3816 | EVENT("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3817 | face, fail, zfail, zpass); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3818 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3819 | switch (face) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3820 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3821 | case GL_FRONT: |
| 3822 | case GL_BACK: |
| 3823 | case GL_FRONT_AND_BACK: |
| 3824 | break; |
| 3825 | default: |
| 3826 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3827 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3828 | |
| 3829 | switch (fail) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3830 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3831 | case GL_ZERO: |
| 3832 | case GL_KEEP: |
| 3833 | case GL_REPLACE: |
| 3834 | case GL_INCR: |
| 3835 | case GL_DECR: |
| 3836 | case GL_INVERT: |
| 3837 | case GL_INCR_WRAP: |
| 3838 | case GL_DECR_WRAP: |
| 3839 | break; |
| 3840 | default: |
| 3841 | return gl::error(GL_INVALID_ENUM); |
| 3842 | } |
| 3843 | |
| 3844 | switch (zfail) |
| 3845 | { |
| 3846 | case GL_ZERO: |
| 3847 | case GL_KEEP: |
| 3848 | case GL_REPLACE: |
| 3849 | case GL_INCR: |
| 3850 | case GL_DECR: |
| 3851 | case GL_INVERT: |
| 3852 | case GL_INCR_WRAP: |
| 3853 | case GL_DECR_WRAP: |
| 3854 | break; |
| 3855 | default: |
| 3856 | return gl::error(GL_INVALID_ENUM); |
| 3857 | } |
| 3858 | |
| 3859 | switch (zpass) |
| 3860 | { |
| 3861 | case GL_ZERO: |
| 3862 | case GL_KEEP: |
| 3863 | case GL_REPLACE: |
| 3864 | case GL_INCR: |
| 3865 | case GL_DECR: |
| 3866 | case GL_INVERT: |
| 3867 | case GL_INCR_WRAP: |
| 3868 | case GL_DECR_WRAP: |
| 3869 | break; |
| 3870 | default: |
| 3871 | return gl::error(GL_INVALID_ENUM); |
| 3872 | } |
| 3873 | |
| 3874 | gl::Context *context = gl::getNonLostContext(); |
| 3875 | |
| 3876 | if (context) |
| 3877 | { |
| 3878 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3879 | { |
| 3880 | context->getState().setStencilOperations(fail, zfail, zpass); |
| 3881 | } |
| 3882 | |
| 3883 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3884 | { |
| 3885 | context->getState().setStencilBackOperations(fail, zfail, zpass); |
| 3886 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3887 | } |
| 3888 | } |
| 3889 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3890 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 3891 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3892 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3893 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3894 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3895 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3896 | if (context) |
| 3897 | { |
| 3898 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 3899 | |
| 3900 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3901 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3902 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3903 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3904 | |
| 3905 | if (fenceObject->isFence() != GL_TRUE) |
| 3906 | { |
| 3907 | return gl::error(GL_INVALID_OPERATION, GL_TRUE); |
| 3908 | } |
| 3909 | |
| 3910 | return fenceObject->testFence(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3911 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3912 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3913 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3914 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3915 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3916 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 3917 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3918 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3919 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, GLsizei height = %d, " |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 3920 | "GLint border = %d, GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3921 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3922 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3923 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3924 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3925 | if (context) |
| 3926 | { |
| 3927 | if (context->getClientVersion() < 3 && |
| 3928 | !ValidateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 3929 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3930 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3931 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3932 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3933 | |
| 3934 | if (context->getClientVersion() >= 3 && |
| 3935 | !ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 3936 | 0, 0, 0, width, height, 1, border, format, type, pixels)) |
| 3937 | { |
| 3938 | return; |
| 3939 | } |
| 3940 | |
| 3941 | switch (target) |
| 3942 | { |
| 3943 | case GL_TEXTURE_2D: |
| 3944 | { |
| 3945 | gl::Texture2D *texture = context->getTexture2D(); |
| 3946 | texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3947 | } |
| 3948 | break; |
| 3949 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 3950 | { |
| 3951 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3952 | texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3953 | } |
| 3954 | break; |
| 3955 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 3956 | { |
| 3957 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3958 | texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3959 | } |
| 3960 | break; |
| 3961 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 3962 | { |
| 3963 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3964 | texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3965 | } |
| 3966 | break; |
| 3967 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 3968 | { |
| 3969 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3970 | texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3971 | } |
| 3972 | break; |
| 3973 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 3974 | { |
| 3975 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3976 | texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3977 | } |
| 3978 | break; |
| 3979 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 3980 | { |
| 3981 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 3982 | texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 3983 | } |
| 3984 | break; |
| 3985 | default: UNREACHABLE(); |
| 3986 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3987 | } |
| 3988 | } |
| 3989 | |
| 3990 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 3991 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3992 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 3993 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3994 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3995 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3996 | if (context) |
| 3997 | { |
| 3998 | if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 3999 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4000 | return; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4001 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4002 | |
| 4003 | gl::Texture *texture = context->getTargetTexture(target); |
| 4004 | |
| 4005 | if (!texture) |
| 4006 | { |
| 4007 | return gl::error(GL_INVALID_ENUM); |
| 4008 | } |
| 4009 | |
| 4010 | switch (pname) |
| 4011 | { |
| 4012 | case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break; |
| 4013 | case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break; |
| 4014 | case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break; |
| 4015 | case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break; |
| 4016 | case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break; |
| 4017 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 4018 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break; |
| 4019 | case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break; |
| 4020 | case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break; |
| 4021 | case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break; |
| 4022 | case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break; |
| 4023 | case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break; |
| 4024 | case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break; |
| 4025 | case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break; |
| 4026 | case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break; |
| 4027 | case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break; |
| 4028 | case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break; |
| 4029 | default: UNREACHABLE(); break; |
| 4030 | } |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4031 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4032 | } |
| 4033 | |
| 4034 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 4035 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4036 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4037 | } |
| 4038 | |
| 4039 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 4040 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4041 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %d)", target, pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4042 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4043 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4044 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4045 | if (context) |
| 4046 | { |
| 4047 | if (!ValidateTexParamParameters(context, pname, param)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4048 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4049 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4050 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4051 | |
| 4052 | gl::Texture *texture = context->getTargetTexture(target); |
| 4053 | |
| 4054 | if (!texture) |
| 4055 | { |
| 4056 | return gl::error(GL_INVALID_ENUM); |
| 4057 | } |
| 4058 | |
| 4059 | switch (pname) |
| 4060 | { |
| 4061 | case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break; |
| 4062 | case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break; |
| 4063 | case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break; |
| 4064 | case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break; |
| 4065 | case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break; |
| 4066 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 4067 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break; |
| 4068 | case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break; |
| 4069 | case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break; |
| 4070 | case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break; |
| 4071 | case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break; |
| 4072 | case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break; |
| 4073 | case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break; |
| 4074 | case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break; |
| 4075 | case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break; |
| 4076 | case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break; |
| 4077 | case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break; |
| 4078 | default: UNREACHABLE(); break; |
| 4079 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4080 | } |
| 4081 | } |
| 4082 | |
| 4083 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 4084 | { |
| 4085 | glTexParameteri(target, pname, *params); |
| 4086 | } |
| 4087 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4088 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 4089 | { |
| 4090 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 4091 | target, levels, internalformat, width, height); |
| 4092 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4093 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4094 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4095 | if (context) |
| 4096 | { |
| 4097 | if (!context->getExtensions().textureStorage) |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4098 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4099 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4100 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4101 | |
| 4102 | if (context->getClientVersion() < 3 && |
| 4103 | !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
| 4104 | { |
| 4105 | return; |
| 4106 | } |
| 4107 | |
| 4108 | if (context->getClientVersion() >= 3 && |
| 4109 | !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 4110 | { |
| 4111 | return; |
| 4112 | } |
| 4113 | |
| 4114 | switch (target) |
| 4115 | { |
| 4116 | case GL_TEXTURE_2D: |
| 4117 | { |
| 4118 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 4119 | texture2d->storage(levels, internalformat, width, height); |
| 4120 | } |
| 4121 | break; |
| 4122 | |
| 4123 | case GL_TEXTURE_CUBE_MAP: |
| 4124 | { |
| 4125 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 4126 | textureCube->storage(levels, internalformat, width); |
| 4127 | } |
| 4128 | break; |
| 4129 | |
| 4130 | default: |
| 4131 | return gl::error(GL_INVALID_ENUM); |
| 4132 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4133 | } |
| 4134 | } |
| 4135 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4136 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 4137 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4138 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4139 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4140 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, GLenum type = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4141 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4142 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4143 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4144 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 4145 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4146 | if (context) |
| 4147 | { |
| 4148 | if (context->getClientVersion() < 3 && |
| 4149 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 4150 | xoffset, yoffset, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 4151 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4152 | return; |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 4153 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4154 | |
| 4155 | if (context->getClientVersion() >= 3 && |
| 4156 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 4157 | xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels)) |
| 4158 | { |
| 4159 | return; |
| 4160 | } |
| 4161 | |
| 4162 | // Zero sized uploads are valid but no-ops |
| 4163 | if (width == 0 || height == 0) |
| 4164 | { |
| 4165 | return; |
| 4166 | } |
| 4167 | |
| 4168 | switch (target) |
| 4169 | { |
| 4170 | case GL_TEXTURE_2D: |
| 4171 | { |
| 4172 | gl::Texture2D *texture = context->getTexture2D(); |
| 4173 | texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); |
| 4174 | } |
| 4175 | break; |
| 4176 | |
| 4177 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 4178 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 4179 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 4180 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 4181 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 4182 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 4183 | { |
| 4184 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 4185 | texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); |
| 4186 | } |
| 4187 | break; |
| 4188 | |
| 4189 | default: |
| 4190 | UNREACHABLE(); |
| 4191 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4192 | } |
| 4193 | } |
| 4194 | |
| 4195 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 4196 | { |
| 4197 | glUniform1fv(location, 1, &x); |
| 4198 | } |
| 4199 | |
| 4200 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 4201 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4202 | EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4203 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4204 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4205 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4206 | if (context) |
| 4207 | { |
| 4208 | if (!ValidateUniform(context, GL_FLOAT, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4209 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4210 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4211 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4212 | |
| 4213 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4214 | programBinary->setUniform1fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4215 | } |
| 4216 | } |
| 4217 | |
| 4218 | void __stdcall glUniform1i(GLint location, GLint x) |
| 4219 | { |
| 4220 | glUniform1iv(location, 1, &x); |
| 4221 | } |
| 4222 | |
| 4223 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 4224 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4225 | EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4226 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4227 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4228 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4229 | if (context) |
| 4230 | { |
| 4231 | if (!ValidateUniform(context, GL_INT, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4232 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4233 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4234 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4235 | |
| 4236 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4237 | programBinary->setUniform1iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4238 | } |
| 4239 | } |
| 4240 | |
| 4241 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 4242 | { |
| 4243 | GLfloat xy[2] = {x, y}; |
| 4244 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4245 | glUniform2fv(location, 1, xy); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4246 | } |
| 4247 | |
| 4248 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 4249 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4250 | EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4251 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4252 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4253 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4254 | if (context) |
| 4255 | { |
| 4256 | if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4257 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4258 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4259 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4260 | |
| 4261 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4262 | programBinary->setUniform2fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4263 | } |
| 4264 | } |
| 4265 | |
| 4266 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 4267 | { |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4268 | GLint xy[2] = {x, y}; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4269 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4270 | glUniform2iv(location, 1, xy); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4271 | } |
| 4272 | |
| 4273 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 4274 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4275 | EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4276 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4277 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4278 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4279 | if (context) |
| 4280 | { |
| 4281 | if (!ValidateUniform(context, GL_INT_VEC2, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4282 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4283 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4284 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4285 | |
| 4286 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4287 | programBinary->setUniform2iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4288 | } |
| 4289 | } |
| 4290 | |
| 4291 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 4292 | { |
| 4293 | GLfloat xyz[3] = {x, y, z}; |
| 4294 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4295 | glUniform3fv(location, 1, xyz); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 4299 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4300 | EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4301 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4302 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4303 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4304 | if (context) |
| 4305 | { |
| 4306 | if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4307 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4308 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4309 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4310 | |
| 4311 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4312 | programBinary->setUniform3fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4313 | } |
| 4314 | } |
| 4315 | |
| 4316 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 4317 | { |
| 4318 | GLint xyz[3] = {x, y, z}; |
| 4319 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4320 | glUniform3iv(location, 1, xyz); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4321 | } |
| 4322 | |
| 4323 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 4324 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4325 | EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4326 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4327 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4328 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4329 | if (context) |
| 4330 | { |
| 4331 | if (!ValidateUniform(context, GL_INT_VEC3, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4332 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4333 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4334 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4335 | |
| 4336 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4337 | programBinary->setUniform3iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4338 | } |
| 4339 | } |
| 4340 | |
| 4341 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4342 | { |
| 4343 | GLfloat xyzw[4] = {x, y, z, w}; |
| 4344 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4345 | glUniform4fv(location, 1, xyzw); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4346 | } |
| 4347 | |
| 4348 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 4349 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4350 | EVENT("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4351 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4352 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4353 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4354 | if (context) |
| 4355 | { |
| 4356 | if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4357 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4358 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4359 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4360 | |
| 4361 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4362 | programBinary->setUniform4fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4363 | } |
| 4364 | } |
| 4365 | |
| 4366 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 4367 | { |
| 4368 | GLint xyzw[4] = {x, y, z, w}; |
| 4369 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4370 | glUniform4iv(location, 1, xyzw); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4371 | } |
| 4372 | |
| 4373 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 4374 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4375 | EVENT("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4376 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4377 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4378 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4379 | if (context) |
| 4380 | { |
| 4381 | if (!ValidateUniform(context, GL_INT_VEC4, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4382 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4383 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4384 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4385 | |
| 4386 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4387 | programBinary->setUniform4iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4388 | } |
| 4389 | } |
| 4390 | |
| 4391 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4392 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4393 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4394 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4395 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4396 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4397 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4398 | if (context) |
| 4399 | { |
| 4400 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4401 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4402 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4403 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4404 | |
| 4405 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4406 | programBinary->setUniformMatrix2fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4407 | } |
| 4408 | } |
| 4409 | |
| 4410 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4411 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4412 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4413 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4414 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4415 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4416 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4417 | if (context) |
| 4418 | { |
| 4419 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4420 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4421 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4422 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4423 | |
| 4424 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4425 | programBinary->setUniformMatrix3fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4426 | } |
| 4427 | } |
| 4428 | |
| 4429 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4430 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4431 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4432 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4433 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4434 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4435 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4436 | if (context) |
| 4437 | { |
| 4438 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4439 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4440 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4441 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4442 | |
| 4443 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4444 | programBinary->setUniformMatrix4fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4445 | } |
| 4446 | } |
| 4447 | |
| 4448 | void __stdcall glUseProgram(GLuint program) |
| 4449 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4450 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4451 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4452 | gl::Context *context = gl::getNonLostContext(); |
| 4453 | |
| 4454 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4455 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4456 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4457 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4458 | if (!programObject && program != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4459 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4460 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4461 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4462 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4463 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4464 | else |
| 4465 | { |
| 4466 | return gl::error(GL_INVALID_VALUE); |
| 4467 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4468 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4469 | |
| 4470 | if (program != 0 && !programObject->isLinked()) |
| 4471 | { |
| 4472 | return gl::error(GL_INVALID_OPERATION); |
| 4473 | } |
| 4474 | |
| 4475 | context->useProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4476 | } |
| 4477 | } |
| 4478 | |
| 4479 | void __stdcall glValidateProgram(GLuint program) |
| 4480 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4481 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4482 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4483 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4484 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4485 | if (context) |
| 4486 | { |
| 4487 | gl::Program *programObject = context->getProgram(program); |
| 4488 | |
| 4489 | if (!programObject) |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4490 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4491 | if (context->getShader(program)) |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4492 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4493 | return gl::error(GL_INVALID_OPERATION); |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4494 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4495 | else |
| 4496 | { |
| 4497 | return gl::error(GL_INVALID_VALUE); |
| 4498 | } |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4499 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4500 | |
| 4501 | programObject->validate(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4502 | } |
| 4503 | } |
| 4504 | |
| 4505 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 4506 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4507 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4508 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4509 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4510 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4511 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4512 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4513 | |
| 4514 | gl::Context *context = gl::getNonLostContext(); |
| 4515 | |
| 4516 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4517 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4518 | GLfloat vals[4] = { x, 0, 0, 1 }; |
| 4519 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4520 | } |
| 4521 | } |
| 4522 | |
| 4523 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 4524 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4525 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4526 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4527 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4528 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4529 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4530 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4531 | |
| 4532 | gl::Context *context = gl::getNonLostContext(); |
| 4533 | |
| 4534 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4535 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4536 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
| 4537 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4538 | } |
| 4539 | } |
| 4540 | |
| 4541 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4542 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4543 | EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4544 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4545 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4546 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4547 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4548 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4549 | |
| 4550 | gl::Context *context = gl::getNonLostContext(); |
| 4551 | |
| 4552 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4553 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4554 | GLfloat vals[4] = { x, y, 0, 1 }; |
| 4555 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4556 | } |
| 4557 | } |
| 4558 | |
| 4559 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 4560 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4561 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4562 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4563 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4564 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4565 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4566 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4567 | |
| 4568 | gl::Context *context = gl::getNonLostContext(); |
| 4569 | |
| 4570 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4571 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4572 | GLfloat vals[4] = { values[0], values[1], 0, 1 }; |
| 4573 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4574 | } |
| 4575 | } |
| 4576 | |
| 4577 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4578 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4579 | EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4580 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4581 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4582 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4583 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4584 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4585 | |
| 4586 | gl::Context *context = gl::getNonLostContext(); |
| 4587 | |
| 4588 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4589 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4590 | GLfloat vals[4] = { x, y, z, 1 }; |
| 4591 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4592 | } |
| 4593 | } |
| 4594 | |
| 4595 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 4596 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4597 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4598 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4599 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4600 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4601 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4602 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4603 | |
| 4604 | gl::Context *context = gl::getNonLostContext(); |
| 4605 | |
| 4606 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4607 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4608 | GLfloat vals[4] = { values[0], values[1], values[2], 1 }; |
| 4609 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4610 | } |
| 4611 | } |
| 4612 | |
| 4613 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4614 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4615 | EVENT("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4616 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4617 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4618 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4619 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4620 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4621 | |
| 4622 | gl::Context *context = gl::getNonLostContext(); |
| 4623 | |
| 4624 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4625 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4626 | GLfloat vals[4] = { x, y, z, w }; |
| 4627 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4628 | } |
| 4629 | } |
| 4630 | |
| 4631 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 4632 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4633 | EVENT("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4634 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4635 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4636 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4637 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4638 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4639 | |
| 4640 | gl::Context *context = gl::getNonLostContext(); |
| 4641 | |
| 4642 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4643 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4644 | context->getState().setVertexAttribf(index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4645 | } |
| 4646 | } |
| 4647 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4648 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 4649 | { |
| 4650 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 4651 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4652 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4653 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4654 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4655 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4656 | |
| 4657 | gl::Context *context = gl::getNonLostContext(); |
| 4658 | |
| 4659 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4660 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4661 | context->setVertexAttribDivisor(index, divisor); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4662 | } |
| 4663 | } |
| 4664 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4665 | void __stdcall glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4666 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4667 | EVENT("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, " |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4668 | "GLboolean normalized = %u, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 4669 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4670 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4671 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4672 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4673 | return gl::error(GL_INVALID_VALUE); |
| 4674 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4675 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4676 | if (size < 1 || size > 4) |
| 4677 | { |
| 4678 | return gl::error(GL_INVALID_VALUE); |
| 4679 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4680 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4681 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | 1a4e09a | 2013-04-13 03:33:30 +0000 | [diff] [blame] | 4682 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4683 | switch (type) |
| 4684 | { |
| 4685 | case GL_BYTE: |
| 4686 | case GL_UNSIGNED_BYTE: |
| 4687 | case GL_SHORT: |
| 4688 | case GL_UNSIGNED_SHORT: |
| 4689 | case GL_FIXED: |
| 4690 | case GL_FLOAT: |
| 4691 | break; |
| 4692 | case GL_HALF_FLOAT: |
| 4693 | case GL_INT: |
| 4694 | case GL_UNSIGNED_INT: |
| 4695 | case GL_INT_2_10_10_10_REV: |
| 4696 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 4697 | if (context && context->getClientVersion() < 3) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4698 | { |
shannon.woods@transgaming.com | 779aa26 | 2013-02-28 23:04:58 +0000 | [diff] [blame] | 4699 | return gl::error(GL_INVALID_ENUM); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4700 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4701 | else |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4702 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4703 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4704 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4705 | default: |
| 4706 | return gl::error(GL_INVALID_ENUM); |
| 4707 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4708 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4709 | if (stride < 0) |
| 4710 | { |
| 4711 | return gl::error(GL_INVALID_VALUE); |
| 4712 | } |
| 4713 | |
| 4714 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 4715 | { |
| 4716 | return gl::error(GL_INVALID_OPERATION); |
| 4717 | } |
| 4718 | |
| 4719 | if (context) |
| 4720 | { |
| 4721 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 4722 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 4723 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 4724 | // and the pointer argument is not NULL. |
| 4725 | if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && ptr != NULL) |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 4726 | { |
| 4727 | return gl::error(GL_INVALID_OPERATION); |
| 4728 | } |
| 4729 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4730 | context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, |
| 4731 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4732 | } |
| 4733 | } |
| 4734 | |
| 4735 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4736 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4737 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4738 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4739 | if (width < 0 || height < 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4740 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4741 | return gl::error(GL_INVALID_VALUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4742 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4743 | |
| 4744 | gl::Context *context = gl::getNonLostContext(); |
| 4745 | |
| 4746 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4747 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4748 | context->getState().setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4749 | } |
| 4750 | } |
| 4751 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4752 | // OpenGL ES 3.0 functions |
| 4753 | |
| 4754 | void __stdcall glReadBuffer(GLenum mode) |
| 4755 | { |
| 4756 | EVENT("(GLenum mode = 0x%X)", mode); |
| 4757 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4758 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4759 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4760 | if (context) |
| 4761 | { |
| 4762 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4763 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4764 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 4765 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4766 | |
| 4767 | // glReadBuffer |
| 4768 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4769 | } |
| 4770 | } |
| 4771 | |
| 4772 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 4773 | { |
| 4774 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 4775 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 4776 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4777 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4778 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4779 | if (context) |
| 4780 | { |
| 4781 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4782 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4783 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 4784 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4785 | |
| 4786 | // glDrawRangeElements |
| 4787 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4788 | } |
| 4789 | } |
| 4790 | |
| 4791 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 4792 | { |
| 4793 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 4794 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 4795 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 4796 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 4797 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4798 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4799 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4800 | if (context) |
| 4801 | { |
| 4802 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4803 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4804 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 4805 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4806 | |
| 4807 | // validateES3TexImageFormat sets the error code if there is an error |
| 4808 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 4809 | 0, 0, 0, width, height, depth, border, format, type, pixels)) |
| 4810 | { |
| 4811 | return; |
| 4812 | } |
| 4813 | |
| 4814 | switch(target) |
| 4815 | { |
| 4816 | case GL_TEXTURE_3D: |
| 4817 | { |
| 4818 | gl::Texture3D *texture = context->getTexture3D(); |
| 4819 | texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 4820 | } |
| 4821 | break; |
| 4822 | |
| 4823 | case GL_TEXTURE_2D_ARRAY: |
| 4824 | { |
| 4825 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 4826 | texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 4827 | } |
| 4828 | break; |
| 4829 | |
| 4830 | default: |
| 4831 | return gl::error(GL_INVALID_ENUM); |
| 4832 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4833 | } |
| 4834 | } |
| 4835 | |
| 4836 | void __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) |
| 4837 | { |
| 4838 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 4839 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 4840 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 4841 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 4842 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4843 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4844 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4845 | if (context) |
| 4846 | { |
| 4847 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4848 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4849 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 4850 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4851 | |
| 4852 | // validateES3TexImageFormat sets the error code if there is an error |
| 4853 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 4854 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 4855 | format, type, pixels)) |
| 4856 | { |
| 4857 | return; |
| 4858 | } |
| 4859 | |
| 4860 | // Zero sized uploads are valid but no-ops |
| 4861 | if (width == 0 || height == 0 || depth == 0) |
| 4862 | { |
| 4863 | return; |
| 4864 | } |
| 4865 | |
| 4866 | switch(target) |
| 4867 | { |
| 4868 | case GL_TEXTURE_3D: |
| 4869 | { |
| 4870 | gl::Texture3D *texture = context->getTexture3D(); |
| 4871 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); |
| 4872 | } |
| 4873 | break; |
| 4874 | |
| 4875 | case GL_TEXTURE_2D_ARRAY: |
| 4876 | { |
| 4877 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 4878 | texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); |
| 4879 | } |
| 4880 | break; |
| 4881 | |
| 4882 | default: |
| 4883 | return gl::error(GL_INVALID_ENUM); |
| 4884 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4885 | } |
| 4886 | } |
| 4887 | |
| 4888 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 4889 | { |
| 4890 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 4891 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 4892 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 4893 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4894 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4895 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4896 | if (context) |
| 4897 | { |
| 4898 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4899 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4900 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 4901 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4902 | |
| 4903 | if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset, |
| 4904 | x, y, width, height, 0)) |
| 4905 | { |
| 4906 | return; |
| 4907 | } |
| 4908 | |
| 4909 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 4910 | gl::Texture *texture = NULL; |
| 4911 | switch (target) |
| 4912 | { |
| 4913 | case GL_TEXTURE_3D: |
| 4914 | texture = context->getTexture3D(); |
| 4915 | break; |
| 4916 | |
| 4917 | case GL_TEXTURE_2D_ARRAY: |
| 4918 | texture = context->getTexture2DArray(); |
| 4919 | break; |
| 4920 | |
| 4921 | default: |
| 4922 | return gl::error(GL_INVALID_ENUM); |
| 4923 | } |
| 4924 | |
| 4925 | texture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, framebuffer); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4926 | } |
| 4927 | } |
| 4928 | |
| 4929 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 4930 | { |
Geoff Lang | eef52cc | 2013-10-16 15:07:39 -0400 | [diff] [blame] | 4931 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4932 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 4933 | "const GLvoid* data = 0x%0.8p)", |
| 4934 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 4935 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4936 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4937 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4938 | if (context) |
| 4939 | { |
| 4940 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4941 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4942 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 4943 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4944 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 4945 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
| 4946 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4947 | { |
| 4948 | return gl::error(GL_INVALID_VALUE); |
| 4949 | } |
| 4950 | |
| 4951 | // validateES3TexImageFormat sets the error code if there is an error |
| 4952 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 4953 | 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data)) |
| 4954 | { |
| 4955 | return; |
| 4956 | } |
| 4957 | |
| 4958 | switch(target) |
| 4959 | { |
| 4960 | case GL_TEXTURE_3D: |
| 4961 | { |
| 4962 | gl::Texture3D *texture = context->getTexture3D(); |
| 4963 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 4964 | } |
| 4965 | break; |
| 4966 | |
| 4967 | case GL_TEXTURE_2D_ARRAY: |
| 4968 | { |
| 4969 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 4970 | texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 4971 | } |
| 4972 | break; |
| 4973 | |
| 4974 | default: |
| 4975 | return gl::error(GL_INVALID_ENUM); |
| 4976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4977 | } |
| 4978 | } |
| 4979 | |
| 4980 | void __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) |
| 4981 | { |
| 4982 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 4983 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 4984 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 4985 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 4986 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4987 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4988 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4989 | if (context) |
| 4990 | { |
| 4991 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4992 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4993 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 4994 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4995 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 4996 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format); |
| 4997 | if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4998 | { |
| 4999 | return gl::error(GL_INVALID_VALUE); |
| 5000 | } |
| 5001 | |
| 5002 | if (!data) |
| 5003 | { |
| 5004 | return gl::error(GL_INVALID_VALUE); |
| 5005 | } |
| 5006 | |
| 5007 | // validateES3TexImageFormat sets the error code if there is an error |
| 5008 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 5009 | 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data)) |
| 5010 | { |
| 5011 | return; |
| 5012 | } |
| 5013 | |
| 5014 | // Zero sized uploads are valid but no-ops |
| 5015 | if (width == 0 || height == 0) |
| 5016 | { |
| 5017 | return; |
| 5018 | } |
| 5019 | |
| 5020 | switch(target) |
| 5021 | { |
| 5022 | case GL_TEXTURE_3D: |
| 5023 | { |
| 5024 | gl::Texture3D *texture = context->getTexture3D(); |
| 5025 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 5026 | format, imageSize, data); |
| 5027 | } |
| 5028 | break; |
| 5029 | |
| 5030 | case GL_TEXTURE_2D_ARRAY: |
| 5031 | { |
| 5032 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
| 5033 | texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 5034 | format, imageSize, data); |
| 5035 | } |
| 5036 | break; |
| 5037 | |
| 5038 | default: |
| 5039 | return gl::error(GL_INVALID_ENUM); |
| 5040 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5041 | } |
| 5042 | } |
| 5043 | |
| 5044 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 5045 | { |
| 5046 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 5047 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5048 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5049 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5050 | if (context) |
| 5051 | { |
| 5052 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5053 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5054 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5055 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5056 | |
| 5057 | if (n < 0) |
| 5058 | { |
| 5059 | return gl::error(GL_INVALID_VALUE); |
| 5060 | } |
| 5061 | |
| 5062 | for (GLsizei i = 0; i < n; i++) |
| 5063 | { |
| 5064 | ids[i] = context->createQuery(); |
| 5065 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5066 | } |
| 5067 | } |
| 5068 | |
| 5069 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 5070 | { |
| 5071 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 5072 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5073 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5074 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5075 | if (context) |
| 5076 | { |
| 5077 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5078 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5079 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5080 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5081 | |
| 5082 | if (n < 0) |
| 5083 | { |
| 5084 | return gl::error(GL_INVALID_VALUE); |
| 5085 | } |
| 5086 | |
| 5087 | for (GLsizei i = 0; i < n; i++) |
| 5088 | { |
| 5089 | context->deleteQuery(ids[i]); |
| 5090 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5091 | } |
| 5092 | } |
| 5093 | |
| 5094 | GLboolean __stdcall glIsQuery(GLuint id) |
| 5095 | { |
| 5096 | EVENT("(GLuint id = %u)", id); |
| 5097 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5098 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5099 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5100 | if (context) |
| 5101 | { |
| 5102 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5103 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5104 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5105 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5106 | |
| 5107 | return (context->getQuery(id, false, GL_NONE) != NULL) ? GL_TRUE : GL_FALSE; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5108 | } |
| 5109 | |
| 5110 | return GL_FALSE; |
| 5111 | } |
| 5112 | |
| 5113 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 5114 | { |
| 5115 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 5116 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5117 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5118 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5119 | if (context) |
| 5120 | { |
| 5121 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5122 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5123 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5124 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5125 | |
| 5126 | if (!ValidateBeginQuery(context, target, id)) |
| 5127 | { |
| 5128 | return; |
| 5129 | } |
| 5130 | context->beginQuery(target, id); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5131 | } |
| 5132 | } |
| 5133 | |
| 5134 | void __stdcall glEndQuery(GLenum target) |
| 5135 | { |
| 5136 | EVENT("(GLenum target = 0x%X)", target); |
| 5137 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5138 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5139 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5140 | if (context) |
| 5141 | { |
| 5142 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5143 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5144 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5145 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5146 | |
| 5147 | if (!ValidateEndQuery(context, target)) |
| 5148 | { |
| 5149 | return; |
| 5150 | } |
| 5151 | |
| 5152 | context->endQuery(target); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5153 | } |
| 5154 | } |
| 5155 | |
| 5156 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 5157 | { |
| 5158 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 5159 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5160 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5161 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5162 | if (context) |
| 5163 | { |
| 5164 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5165 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5166 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5167 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5168 | |
| 5169 | if (!ValidQueryType(context, target)) |
| 5170 | { |
| 5171 | return gl::error(GL_INVALID_ENUM); |
| 5172 | } |
| 5173 | |
| 5174 | switch (pname) |
| 5175 | { |
| 5176 | case GL_CURRENT_QUERY: |
| 5177 | params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target)); |
| 5178 | break; |
| 5179 | |
| 5180 | default: |
| 5181 | return gl::error(GL_INVALID_ENUM); |
| 5182 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5183 | } |
| 5184 | } |
| 5185 | |
| 5186 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 5187 | { |
| 5188 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 5189 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5190 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5191 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5192 | if (context) |
| 5193 | { |
| 5194 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5195 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5196 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5197 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5198 | |
| 5199 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5200 | |
| 5201 | if (!queryObject) |
| 5202 | { |
| 5203 | return gl::error(GL_INVALID_OPERATION); |
| 5204 | } |
| 5205 | |
| 5206 | if (context->getState().getActiveQueryId(queryObject->getType()) == id) |
| 5207 | { |
| 5208 | return gl::error(GL_INVALID_OPERATION); |
| 5209 | } |
| 5210 | |
| 5211 | switch(pname) |
| 5212 | { |
| 5213 | case GL_QUERY_RESULT: |
| 5214 | params[0] = queryObject->getResult(); |
| 5215 | break; |
| 5216 | case GL_QUERY_RESULT_AVAILABLE: |
| 5217 | params[0] = queryObject->isResultAvailable(); |
| 5218 | break; |
| 5219 | default: |
| 5220 | return gl::error(GL_INVALID_ENUM); |
| 5221 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5222 | } |
| 5223 | } |
| 5224 | |
| 5225 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 5226 | { |
| 5227 | EVENT("(GLenum target = 0x%X)", target); |
| 5228 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5229 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5230 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5231 | if (context) |
| 5232 | { |
| 5233 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5234 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5235 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5236 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5237 | |
| 5238 | return glUnmapBufferOES(target); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5239 | } |
| 5240 | |
| 5241 | return GL_FALSE; |
| 5242 | } |
| 5243 | |
| 5244 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 5245 | { |
| 5246 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 5247 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5248 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5249 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5250 | if (context) |
| 5251 | { |
| 5252 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5253 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5254 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5255 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5256 | |
| 5257 | glGetBufferPointervOES(target, pname, params); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5258 | } |
| 5259 | } |
| 5260 | |
| 5261 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 5262 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5263 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5264 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5265 | if (context) |
| 5266 | { |
| 5267 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5268 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5269 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 5270 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5271 | |
| 5272 | glDrawBuffersEXT(n, bufs); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5273 | } |
| 5274 | } |
| 5275 | |
| 5276 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5277 | { |
| 5278 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5279 | location, count, transpose, value); |
| 5280 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5281 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5282 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5283 | if (context) |
| 5284 | { |
| 5285 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5286 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5287 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5288 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5289 | |
| 5290 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5291 | programBinary->setUniformMatrix2x3fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5292 | } |
| 5293 | } |
| 5294 | |
| 5295 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5296 | { |
| 5297 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5298 | location, count, transpose, value); |
| 5299 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5300 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5301 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5302 | if (context) |
| 5303 | { |
| 5304 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5305 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5306 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5307 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5308 | |
| 5309 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5310 | programBinary->setUniformMatrix3x2fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5311 | } |
| 5312 | } |
| 5313 | |
| 5314 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5315 | { |
| 5316 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5317 | location, count, transpose, value); |
| 5318 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5319 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5320 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5321 | if (context) |
| 5322 | { |
| 5323 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5324 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5325 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5326 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5327 | |
| 5328 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5329 | programBinary->setUniformMatrix2x4fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5330 | } |
| 5331 | } |
| 5332 | |
| 5333 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5334 | { |
| 5335 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5336 | location, count, transpose, value); |
| 5337 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5338 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5339 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5340 | if (context) |
| 5341 | { |
| 5342 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5343 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5344 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5345 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5346 | |
| 5347 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5348 | programBinary->setUniformMatrix4x2fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5349 | } |
| 5350 | } |
| 5351 | |
| 5352 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5353 | { |
| 5354 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5355 | location, count, transpose, value); |
| 5356 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5357 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5358 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5359 | if (context) |
| 5360 | { |
| 5361 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5362 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5363 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5364 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5365 | |
| 5366 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5367 | programBinary->setUniformMatrix3x4fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5368 | } |
| 5369 | } |
| 5370 | |
| 5371 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5372 | { |
| 5373 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5374 | location, count, transpose, value); |
| 5375 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5376 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5377 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5378 | if (context) |
| 5379 | { |
| 5380 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5381 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5382 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5383 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5384 | |
| 5385 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5386 | programBinary->setUniformMatrix4x3fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5387 | } |
| 5388 | } |
| 5389 | |
| 5390 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 5391 | { |
| 5392 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 5393 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 5394 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 5395 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5396 | gl::Context *context = gl::getNonLostContext(); |
| 5397 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5398 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5399 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5400 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5401 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5402 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5403 | |
| 5404 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 5405 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 5406 | false)) |
| 5407 | { |
| 5408 | return; |
| 5409 | } |
| 5410 | |
| 5411 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 5412 | mask, filter); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5413 | } |
| 5414 | } |
| 5415 | |
| 5416 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 5417 | { |
| 5418 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 5419 | target, samples, internalformat, width, height); |
| 5420 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5421 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5422 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5423 | if (context) |
| 5424 | { |
| 5425 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5426 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5427 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5428 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5429 | |
| 5430 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 5431 | width, height, false)) |
| 5432 | { |
| 5433 | return; |
| 5434 | } |
| 5435 | |
| 5436 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5437 | } |
| 5438 | } |
| 5439 | |
| 5440 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 5441 | { |
| 5442 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 5443 | target, attachment, texture, level, layer); |
| 5444 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5445 | gl::Context *context = gl::getNonLostContext(); |
| 5446 | |
| 5447 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5448 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5449 | if (!ValidateFramebufferTextureLayer(context, target, attachment, texture, |
| 5450 | level, layer)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5451 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5452 | return; |
| 5453 | } |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5454 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5455 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 5456 | ASSERT(framebuffer); |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5457 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5458 | gl::Texture *textureObject = context->getTexture(texture); |
| 5459 | GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE; |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5460 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5461 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 5462 | { |
| 5463 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5464 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer); |
| 5465 | } |
| 5466 | else |
| 5467 | { |
| 5468 | switch (attachment) |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5469 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5470 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break; |
| 5471 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break; |
| 5472 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break; |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5473 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5474 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5475 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5476 | } |
| 5477 | |
| 5478 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 5479 | { |
| 5480 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 5481 | target, offset, length, access); |
| 5482 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5483 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5484 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5485 | if (context) |
| 5486 | { |
| 5487 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5488 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5489 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5490 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5491 | |
| 5492 | return glMapBufferRangeEXT(target, offset, length, access); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5493 | } |
| 5494 | |
| 5495 | return NULL; |
| 5496 | } |
| 5497 | |
| 5498 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 5499 | { |
| 5500 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 5501 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5502 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5503 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5504 | if (context) |
| 5505 | { |
| 5506 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5507 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5508 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5509 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5510 | |
| 5511 | glFlushMappedBufferRangeEXT(target, offset, length); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5512 | } |
| 5513 | } |
| 5514 | |
| 5515 | void __stdcall glBindVertexArray(GLuint array) |
| 5516 | { |
| 5517 | EVENT("(GLuint array = %u)", array); |
| 5518 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5519 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5520 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5521 | if (context) |
| 5522 | { |
| 5523 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5524 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5525 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5526 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5527 | |
| 5528 | gl::VertexArray *vao = context->getVertexArray(array); |
| 5529 | |
| 5530 | if (!vao) |
| 5531 | { |
| 5532 | // The default VAO should always exist |
| 5533 | ASSERT(array != 0); |
| 5534 | return gl::error(GL_INVALID_OPERATION); |
| 5535 | } |
| 5536 | |
| 5537 | context->bindVertexArray(array); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5538 | } |
| 5539 | } |
| 5540 | |
| 5541 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 5542 | { |
| 5543 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 5544 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5545 | gl::Context *context = gl::getNonLostContext(); |
| 5546 | |
| 5547 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5548 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5549 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5550 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5551 | return gl::error(GL_INVALID_OPERATION); |
| 5552 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5553 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5554 | if (n < 0) |
| 5555 | { |
| 5556 | return gl::error(GL_INVALID_VALUE); |
| 5557 | } |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5558 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5559 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 5560 | { |
| 5561 | if (arrays[arrayIndex] != 0) |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5562 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5563 | context->deleteVertexArray(arrays[arrayIndex]); |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5564 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5565 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5566 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5567 | } |
| 5568 | |
| 5569 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 5570 | { |
| 5571 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 5572 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5573 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5574 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5575 | if (context) |
| 5576 | { |
| 5577 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5578 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5579 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5580 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5581 | |
| 5582 | if (n < 0) |
| 5583 | { |
| 5584 | return gl::error(GL_INVALID_VALUE); |
| 5585 | } |
| 5586 | |
| 5587 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 5588 | { |
| 5589 | arrays[arrayIndex] = context->createVertexArray(); |
| 5590 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5591 | } |
| 5592 | } |
| 5593 | |
| 5594 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 5595 | { |
| 5596 | EVENT("(GLuint array = %u)", array); |
| 5597 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5598 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5599 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5600 | if (context) |
| 5601 | { |
| 5602 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5603 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5604 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5605 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5606 | |
| 5607 | if (array == 0) |
| 5608 | { |
| 5609 | return GL_FALSE; |
| 5610 | } |
| 5611 | |
| 5612 | gl::VertexArray *vao = context->getVertexArray(array); |
| 5613 | |
| 5614 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5615 | } |
| 5616 | |
| 5617 | return GL_FALSE; |
| 5618 | } |
| 5619 | |
| 5620 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 5621 | { |
| 5622 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 5623 | target, index, data); |
| 5624 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5625 | gl::Context *context = gl::getNonLostContext(); |
| 5626 | |
| 5627 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5628 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5629 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5630 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5631 | return gl::error(GL_INVALID_OPERATION); |
| 5632 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5633 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5634 | switch (target) |
| 5635 | { |
| 5636 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 5637 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 5638 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 5639 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
| 5640 | return gl::error(GL_INVALID_VALUE); |
| 5641 | break; |
| 5642 | case GL_UNIFORM_BUFFER_START: |
| 5643 | case GL_UNIFORM_BUFFER_SIZE: |
| 5644 | case GL_UNIFORM_BUFFER_BINDING: |
| 5645 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 5646 | return gl::error(GL_INVALID_VALUE); |
| 5647 | break; |
| 5648 | default: |
| 5649 | return gl::error(GL_INVALID_ENUM); |
| 5650 | } |
| 5651 | |
| 5652 | if (!(context->getIndexedIntegerv(target, index, data))) |
| 5653 | { |
| 5654 | GLenum nativeType; |
| 5655 | unsigned int numParams = 0; |
| 5656 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5657 | return gl::error(GL_INVALID_ENUM); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5658 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5659 | if (numParams == 0) |
| 5660 | return; // it is known that pname is valid, but there are no parameters to return |
| 5661 | |
| 5662 | if (nativeType == GL_INT_64_ANGLEX) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5663 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5664 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 5665 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 5666 | GLint64 *int64Params = new GLint64[numParams]; |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5667 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5668 | context->getIndexedInteger64v(target, index, int64Params); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5669 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5670 | for (unsigned int i = 0; i < numParams; ++i) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5671 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5672 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 5673 | data[i] = static_cast<GLint>(clampedValue); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5674 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5675 | |
| 5676 | delete [] int64Params; |
| 5677 | } |
| 5678 | else |
| 5679 | { |
| 5680 | UNREACHABLE(); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5681 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5682 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5683 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5684 | } |
| 5685 | |
| 5686 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 5687 | { |
| 5688 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 5689 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5690 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5691 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5692 | if (context) |
| 5693 | { |
| 5694 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5695 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5696 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5697 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5698 | |
| 5699 | switch (primitiveMode) |
| 5700 | { |
| 5701 | case GL_TRIANGLES: |
| 5702 | case GL_LINES: |
| 5703 | case GL_POINTS: |
| 5704 | break; |
| 5705 | default: |
| 5706 | return gl::error(GL_INVALID_ENUM); |
| 5707 | } |
| 5708 | |
| 5709 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 5710 | ASSERT(transformFeedback != NULL); |
| 5711 | |
| 5712 | if (transformFeedback->isStarted()) |
| 5713 | { |
| 5714 | return gl::error(GL_INVALID_OPERATION); |
| 5715 | } |
| 5716 | |
| 5717 | if (transformFeedback->isPaused()) |
| 5718 | { |
| 5719 | transformFeedback->resume(); |
| 5720 | } |
| 5721 | else |
| 5722 | { |
| 5723 | transformFeedback->start(primitiveMode); |
| 5724 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5725 | } |
| 5726 | } |
| 5727 | |
| 5728 | void __stdcall glEndTransformFeedback(void) |
| 5729 | { |
| 5730 | EVENT("(void)"); |
| 5731 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5732 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5733 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5734 | if (context) |
| 5735 | { |
| 5736 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5737 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5738 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5739 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5740 | |
| 5741 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 5742 | ASSERT(transformFeedback != NULL); |
| 5743 | |
| 5744 | if (!transformFeedback->isStarted()) |
| 5745 | { |
| 5746 | return gl::error(GL_INVALID_OPERATION); |
| 5747 | } |
| 5748 | |
| 5749 | transformFeedback->stop(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5750 | } |
| 5751 | } |
| 5752 | |
| 5753 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 5754 | { |
| 5755 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 5756 | target, index, buffer, offset, size); |
| 5757 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5758 | gl::Context *context = gl::getNonLostContext(); |
| 5759 | |
| 5760 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5761 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5762 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5763 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5764 | return gl::error(GL_INVALID_OPERATION); |
| 5765 | } |
| 5766 | |
| 5767 | switch (target) |
| 5768 | { |
| 5769 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 5770 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5771 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5772 | return gl::error(GL_INVALID_VALUE); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5773 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5774 | break; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5775 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5776 | case GL_UNIFORM_BUFFER: |
| 5777 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5778 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5779 | return gl::error(GL_INVALID_VALUE); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5780 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5781 | break; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5782 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5783 | default: |
| 5784 | return gl::error(GL_INVALID_ENUM); |
| 5785 | } |
| 5786 | |
| 5787 | if (buffer != 0 && size <= 0) |
| 5788 | { |
| 5789 | return gl::error(GL_INVALID_VALUE); |
| 5790 | } |
| 5791 | |
| 5792 | switch (target) |
| 5793 | { |
| 5794 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 5795 | |
| 5796 | // size and offset must be a multiple of 4 |
| 5797 | if (buffer != 0 && ((offset % 4) != 0 || (size % 4) != 0)) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5798 | { |
| 5799 | return gl::error(GL_INVALID_VALUE); |
| 5800 | } |
| 5801 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5802 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 5803 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 5804 | break; |
| 5805 | |
| 5806 | case GL_UNIFORM_BUFFER: |
| 5807 | |
| 5808 | // it is an error to bind an offset not a multiple of the alignment |
| 5809 | if (buffer != 0 && (offset % context->getUniformBufferOffsetAlignment()) != 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5810 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5811 | return gl::error(GL_INVALID_VALUE); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5812 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5813 | |
| 5814 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 5815 | context->bindGenericUniformBuffer(buffer); |
| 5816 | break; |
| 5817 | |
| 5818 | default: |
| 5819 | UNREACHABLE(); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5820 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5821 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5822 | } |
| 5823 | |
| 5824 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 5825 | { |
| 5826 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 5827 | target, index, buffer); |
| 5828 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5829 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5830 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5831 | if (context) |
| 5832 | { |
| 5833 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5834 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5835 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 5836 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5837 | |
| 5838 | switch (target) |
| 5839 | { |
| 5840 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 5841 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
| 5842 | { |
| 5843 | return gl::error(GL_INVALID_VALUE); |
| 5844 | } |
| 5845 | break; |
| 5846 | |
| 5847 | case GL_UNIFORM_BUFFER: |
| 5848 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 5849 | { |
| 5850 | return gl::error(GL_INVALID_VALUE); |
| 5851 | } |
| 5852 | break; |
| 5853 | |
| 5854 | default: |
| 5855 | return gl::error(GL_INVALID_ENUM); |
| 5856 | } |
| 5857 | |
| 5858 | switch (target) |
| 5859 | { |
| 5860 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 5861 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
| 5862 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 5863 | break; |
| 5864 | |
| 5865 | case GL_UNIFORM_BUFFER: |
| 5866 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
| 5867 | context->bindGenericUniformBuffer(buffer); |
| 5868 | break; |
| 5869 | |
| 5870 | default: |
| 5871 | UNREACHABLE(); |
| 5872 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5873 | } |
| 5874 | } |
| 5875 | |
| 5876 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 5877 | { |
| 5878 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 5879 | program, count, varyings, bufferMode); |
| 5880 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5881 | gl::Context *context = gl::getNonLostContext(); |
| 5882 | |
| 5883 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5884 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5885 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5886 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5887 | return gl::error(GL_INVALID_OPERATION); |
| 5888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5889 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5890 | if (count < 0) |
| 5891 | { |
| 5892 | return gl::error(GL_INVALID_VALUE); |
| 5893 | } |
| 5894 | |
| 5895 | switch (bufferMode) |
| 5896 | { |
| 5897 | case GL_INTERLEAVED_ATTRIBS: |
| 5898 | break; |
| 5899 | case GL_SEPARATE_ATTRIBS: |
| 5900 | if (static_cast<GLuint>(count) > context->getMaxTransformFeedbackBufferBindings()) |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 5901 | { |
| 5902 | return gl::error(GL_INVALID_VALUE); |
| 5903 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5904 | break; |
| 5905 | default: |
| 5906 | return gl::error(GL_INVALID_ENUM); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5907 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5908 | |
| 5909 | if (!gl::ValidProgram(context, program)) |
| 5910 | { |
| 5911 | return; |
| 5912 | } |
| 5913 | |
| 5914 | gl::Program *programObject = context->getProgram(program); |
| 5915 | ASSERT(programObject); |
| 5916 | |
| 5917 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5918 | } |
| 5919 | } |
| 5920 | |
| 5921 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 5922 | { |
| 5923 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 5924 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 5925 | program, index, bufSize, length, size, type, name); |
| 5926 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5927 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5928 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5929 | if (context) |
| 5930 | { |
| 5931 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5932 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5933 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5934 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5935 | |
| 5936 | if (bufSize < 0) |
| 5937 | { |
| 5938 | return gl::error(GL_INVALID_VALUE); |
| 5939 | } |
| 5940 | |
| 5941 | if (!gl::ValidProgram(context, program)) |
| 5942 | { |
| 5943 | return; |
| 5944 | } |
| 5945 | |
| 5946 | gl::Program *programObject = context->getProgram(program); |
| 5947 | ASSERT(programObject); |
| 5948 | |
| 5949 | if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount())) |
| 5950 | { |
| 5951 | return gl::error(GL_INVALID_VALUE); |
| 5952 | } |
| 5953 | |
| 5954 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5955 | } |
| 5956 | } |
| 5957 | |
| 5958 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 5959 | { |
| 5960 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 5961 | index, size, type, stride, pointer); |
| 5962 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5963 | gl::Context *context = gl::getNonLostContext(); |
| 5964 | |
| 5965 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5966 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5967 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5968 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5969 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5970 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5971 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5972 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5973 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 5974 | { |
| 5975 | return gl::error(GL_INVALID_VALUE); |
| 5976 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5977 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5978 | if (size < 1 || size > 4) |
| 5979 | { |
| 5980 | return gl::error(GL_INVALID_VALUE); |
| 5981 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5982 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5983 | switch (type) |
| 5984 | { |
| 5985 | case GL_BYTE: |
| 5986 | case GL_UNSIGNED_BYTE: |
| 5987 | case GL_SHORT: |
| 5988 | case GL_UNSIGNED_SHORT: |
| 5989 | case GL_INT: |
| 5990 | case GL_UNSIGNED_INT: |
| 5991 | case GL_INT_2_10_10_10_REV: |
| 5992 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 5993 | break; |
| 5994 | default: |
| 5995 | return gl::error(GL_INVALID_ENUM); |
| 5996 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 5997 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5998 | if (stride < 0) |
| 5999 | { |
| 6000 | return gl::error(GL_INVALID_VALUE); |
| 6001 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6002 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6003 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 6004 | { |
| 6005 | return gl::error(GL_INVALID_OPERATION); |
| 6006 | } |
| 6007 | |
| 6008 | if (context) |
| 6009 | { |
| 6010 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 6011 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 6012 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 6013 | // and the pointer argument is not NULL. |
| 6014 | if (context->getState().getVertexArray()->id() != 0 && context->getState().getArrayBufferId() == 0 && pointer != NULL) |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 6015 | { |
| 6016 | return gl::error(GL_INVALID_OPERATION); |
| 6017 | } |
| 6018 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6019 | context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true, |
| 6020 | stride, pointer); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6021 | } |
| 6022 | } |
| 6023 | |
| 6024 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 6025 | { |
| 6026 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 6027 | index, pname, params); |
| 6028 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6029 | gl::Context *context = gl::getNonLostContext(); |
| 6030 | |
| 6031 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6032 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6033 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6034 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6035 | return gl::error(GL_INVALID_OPERATION); |
| 6036 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6037 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6038 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6039 | { |
| 6040 | return gl::error(GL_INVALID_VALUE); |
| 6041 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6042 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6043 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6044 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6045 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 6046 | { |
| 6047 | return; |
| 6048 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6049 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6050 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6051 | { |
| 6052 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 6053 | for (int i = 0; i < 4; ++i) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6054 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6055 | params[i] = currentValueData.IntValues[i]; |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6056 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6057 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6058 | else |
| 6059 | { |
| 6060 | *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname); |
| 6061 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6062 | } |
| 6063 | } |
| 6064 | |
| 6065 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 6066 | { |
| 6067 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 6068 | index, pname, params); |
| 6069 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6070 | gl::Context *context = gl::getNonLostContext(); |
| 6071 | |
| 6072 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6073 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6074 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6075 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6076 | return gl::error(GL_INVALID_OPERATION); |
| 6077 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6078 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6079 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6080 | { |
| 6081 | return gl::error(GL_INVALID_VALUE); |
| 6082 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6083 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6084 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6085 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6086 | if (!gl::ValidateGetVertexAttribParameters(pname, context->getClientVersion())) |
| 6087 | { |
| 6088 | return; |
| 6089 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6090 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6091 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6092 | { |
| 6093 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 6094 | for (int i = 0; i < 4; ++i) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6095 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6096 | params[i] = currentValueData.UnsignedIntValues[i]; |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6097 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6098 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6099 | else |
| 6100 | { |
| 6101 | *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname); |
| 6102 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6103 | } |
| 6104 | } |
| 6105 | |
| 6106 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 6107 | { |
| 6108 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 6109 | index, x, y, z, w); |
| 6110 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6111 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6112 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6113 | if (context) |
| 6114 | { |
| 6115 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6116 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6117 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6118 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6119 | |
| 6120 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6121 | { |
| 6122 | return gl::error(GL_INVALID_VALUE); |
| 6123 | } |
| 6124 | |
| 6125 | GLint vals[4] = { x, y, z, w }; |
| 6126 | context->getState().setVertexAttribi(index, vals); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6127 | } |
| 6128 | } |
| 6129 | |
| 6130 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 6131 | { |
| 6132 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 6133 | index, x, y, z, w); |
| 6134 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6135 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6136 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6137 | if (context) |
| 6138 | { |
| 6139 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6140 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6141 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6142 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6143 | |
| 6144 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6145 | { |
| 6146 | return gl::error(GL_INVALID_VALUE); |
| 6147 | } |
| 6148 | |
| 6149 | GLuint vals[4] = { x, y, z, w }; |
| 6150 | context->getState().setVertexAttribu(index, vals); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6151 | } |
| 6152 | } |
| 6153 | |
| 6154 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 6155 | { |
| 6156 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 6157 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6158 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6159 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6160 | if (context) |
| 6161 | { |
| 6162 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6163 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6164 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6165 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6166 | |
| 6167 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6168 | { |
| 6169 | return gl::error(GL_INVALID_VALUE); |
| 6170 | } |
| 6171 | |
| 6172 | context->getState().setVertexAttribi(index, v); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6173 | } |
| 6174 | } |
| 6175 | |
| 6176 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 6177 | { |
| 6178 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 6179 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6180 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6181 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6182 | if (context) |
| 6183 | { |
| 6184 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6185 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6186 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6187 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6188 | |
| 6189 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6190 | { |
| 6191 | return gl::error(GL_INVALID_VALUE); |
| 6192 | } |
| 6193 | |
| 6194 | context->getState().setVertexAttribu(index, v); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6195 | } |
| 6196 | } |
| 6197 | |
| 6198 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 6199 | { |
| 6200 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 6201 | program, location, params); |
| 6202 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6203 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6204 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6205 | if (context) |
| 6206 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6207 | if (!ValidateGetUniformuiv(context, program, location, params)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6208 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6209 | return; |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 6210 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6211 | |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6212 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6213 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6214 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 6215 | programBinary->getUniformuiv(location, params); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6216 | } |
| 6217 | } |
| 6218 | |
| 6219 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 6220 | { |
| 6221 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 6222 | program, name); |
| 6223 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6224 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6225 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6226 | if (context) |
| 6227 | { |
| 6228 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6229 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6230 | return gl::error(GL_INVALID_OPERATION, -1); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6231 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6232 | |
| 6233 | if (program == 0) |
| 6234 | { |
| 6235 | return gl::error(GL_INVALID_VALUE, -1); |
| 6236 | } |
| 6237 | |
| 6238 | gl::Program *programObject = context->getProgram(program); |
| 6239 | |
| 6240 | if (!programObject || !programObject->isLinked()) |
| 6241 | { |
| 6242 | return gl::error(GL_INVALID_OPERATION, -1); |
| 6243 | } |
| 6244 | |
| 6245 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6246 | if (!programBinary) |
| 6247 | { |
| 6248 | return gl::error(GL_INVALID_OPERATION, -1); |
| 6249 | } |
| 6250 | |
| 6251 | return programBinary->getFragDataLocation(name); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6252 | } |
| 6253 | |
| 6254 | return 0; |
| 6255 | } |
| 6256 | |
| 6257 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 6258 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6259 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6260 | } |
| 6261 | |
| 6262 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 6263 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6264 | const GLuint xy[] = { v0, v1 }; |
| 6265 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6266 | } |
| 6267 | |
| 6268 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6269 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6270 | const GLuint xyz[] = { v0, v1, v2 }; |
| 6271 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6272 | } |
| 6273 | |
| 6274 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6275 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6276 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 6277 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6278 | } |
| 6279 | |
| 6280 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 6281 | { |
| 6282 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6283 | location, count, value); |
| 6284 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6285 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6286 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6287 | if (context) |
| 6288 | { |
| 6289 | if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6290 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6291 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6292 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6293 | |
| 6294 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6295 | programBinary->setUniform1uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6296 | } |
| 6297 | } |
| 6298 | |
| 6299 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 6300 | { |
| 6301 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6302 | location, count, value); |
| 6303 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6304 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6305 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6306 | if (context) |
| 6307 | { |
| 6308 | if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6309 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6310 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6311 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6312 | |
| 6313 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6314 | programBinary->setUniform2uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6315 | } |
| 6316 | } |
| 6317 | |
| 6318 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 6319 | { |
| 6320 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 6321 | location, count, value); |
| 6322 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6323 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6324 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6325 | if (context) |
| 6326 | { |
| 6327 | if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6328 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6329 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6330 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6331 | |
| 6332 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6333 | programBinary->setUniform3uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6334 | } |
| 6335 | } |
| 6336 | |
| 6337 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 6338 | { |
| 6339 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6340 | location, count, value); |
| 6341 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6342 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6343 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6344 | if (context) |
| 6345 | { |
| 6346 | if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6347 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6348 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6349 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6350 | |
| 6351 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6352 | programBinary->setUniform4uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6353 | } |
| 6354 | } |
| 6355 | |
| 6356 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 6357 | { |
| 6358 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 6359 | buffer, drawbuffer, value); |
| 6360 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6361 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6362 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6363 | if (context) |
| 6364 | { |
| 6365 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6366 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6367 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6368 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6369 | |
| 6370 | switch (buffer) |
| 6371 | { |
| 6372 | case GL_COLOR: |
| 6373 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6374 | { |
| 6375 | return gl::error(GL_INVALID_VALUE); |
| 6376 | } |
| 6377 | break; |
| 6378 | case GL_STENCIL: |
| 6379 | if (drawbuffer != 0) |
| 6380 | { |
| 6381 | return gl::error(GL_INVALID_VALUE); |
| 6382 | } |
| 6383 | break; |
| 6384 | default: |
| 6385 | return gl::error(GL_INVALID_ENUM); |
| 6386 | } |
| 6387 | |
| 6388 | context->clearBufferiv(buffer, drawbuffer, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6389 | } |
| 6390 | } |
| 6391 | |
| 6392 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 6393 | { |
| 6394 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 6395 | buffer, drawbuffer, value); |
| 6396 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6397 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6398 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6399 | if (context) |
| 6400 | { |
| 6401 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6402 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6403 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6404 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6405 | |
| 6406 | switch (buffer) |
| 6407 | { |
| 6408 | case GL_COLOR: |
| 6409 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6410 | { |
| 6411 | return gl::error(GL_INVALID_VALUE); |
| 6412 | } |
| 6413 | break; |
| 6414 | default: |
| 6415 | return gl::error(GL_INVALID_ENUM); |
| 6416 | } |
| 6417 | |
| 6418 | context->clearBufferuiv(buffer, drawbuffer, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6419 | } |
| 6420 | } |
| 6421 | |
| 6422 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 6423 | { |
| 6424 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 6425 | buffer, drawbuffer, value); |
| 6426 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6427 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6428 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6429 | if (context) |
| 6430 | { |
| 6431 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6432 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6433 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6434 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6435 | |
| 6436 | switch (buffer) |
| 6437 | { |
| 6438 | case GL_COLOR: |
| 6439 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6440 | { |
| 6441 | return gl::error(GL_INVALID_VALUE); |
| 6442 | } |
| 6443 | break; |
| 6444 | case GL_DEPTH: |
| 6445 | if (drawbuffer != 0) |
| 6446 | { |
| 6447 | return gl::error(GL_INVALID_VALUE); |
| 6448 | } |
| 6449 | break; |
| 6450 | default: |
| 6451 | return gl::error(GL_INVALID_ENUM); |
| 6452 | } |
| 6453 | |
| 6454 | context->clearBufferfv(buffer, drawbuffer, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6455 | } |
| 6456 | } |
| 6457 | |
| 6458 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 6459 | { |
| 6460 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 6461 | buffer, drawbuffer, depth, stencil); |
| 6462 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6463 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6464 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6465 | if (context) |
| 6466 | { |
| 6467 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6468 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6469 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6470 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6471 | |
| 6472 | switch (buffer) |
| 6473 | { |
| 6474 | case GL_DEPTH_STENCIL: |
| 6475 | if (drawbuffer != 0) |
| 6476 | { |
| 6477 | return gl::error(GL_INVALID_VALUE); |
| 6478 | } |
| 6479 | break; |
| 6480 | default: |
| 6481 | return gl::error(GL_INVALID_ENUM); |
| 6482 | } |
| 6483 | |
| 6484 | context->clearBufferfi(buffer, drawbuffer, depth, stencil); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6485 | } |
| 6486 | } |
| 6487 | |
| 6488 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 6489 | { |
| 6490 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 6491 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6492 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6493 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6494 | if (context) |
| 6495 | { |
| 6496 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6497 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6498 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLubyte*>(NULL)); |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 6499 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6500 | |
| 6501 | if (name != GL_EXTENSIONS) |
| 6502 | { |
| 6503 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLubyte*>(NULL)); |
| 6504 | } |
| 6505 | |
| 6506 | if (index >= context->getExtensionStringCount()) |
| 6507 | { |
| 6508 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLubyte*>(NULL)); |
| 6509 | } |
| 6510 | |
| 6511 | return reinterpret_cast<const GLubyte*>(context->getExtensionString(index).c_str()); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6512 | } |
| 6513 | |
| 6514 | return NULL; |
| 6515 | } |
| 6516 | |
| 6517 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 6518 | { |
| 6519 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 6520 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 6521 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6522 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6523 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6524 | if (context) |
| 6525 | { |
| 6526 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6527 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6528 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 6529 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6530 | |
| 6531 | if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget)) |
| 6532 | { |
| 6533 | return gl::error(GL_INVALID_ENUM); |
| 6534 | } |
| 6535 | |
| 6536 | gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget); |
| 6537 | gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget); |
| 6538 | |
| 6539 | if (!readBuffer || !writeBuffer) |
| 6540 | { |
| 6541 | return gl::error(GL_INVALID_OPERATION); |
| 6542 | } |
| 6543 | |
Jamie Madill | cfaaf72 | 2014-07-31 10:47:54 -0400 | [diff] [blame] | 6544 | // Verify that readBuffer and writeBuffer are not currently mapped |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6545 | if (readBuffer->isMapped() || writeBuffer->isMapped()) |
| 6546 | { |
| 6547 | return gl::error(GL_INVALID_OPERATION); |
| 6548 | } |
| 6549 | |
| 6550 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 6551 | static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() || |
| 6552 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize()) |
| 6553 | { |
| 6554 | return gl::error(GL_INVALID_VALUE); |
| 6555 | } |
| 6556 | |
| 6557 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 6558 | { |
| 6559 | return gl::error(GL_INVALID_VALUE); |
| 6560 | } |
| 6561 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6562 | // if size is zero, the copy is a successful no-op |
| 6563 | if (size > 0) |
| 6564 | { |
| 6565 | writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 6566 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6567 | } |
| 6568 | } |
| 6569 | |
| 6570 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 6571 | { |
| 6572 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 6573 | program, uniformCount, uniformNames, uniformIndices); |
| 6574 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6575 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6576 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6577 | if (context) |
| 6578 | { |
| 6579 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6580 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6581 | return gl::error(GL_INVALID_OPERATION); |
| 6582 | } |
| 6583 | |
| 6584 | if (uniformCount < 0) |
| 6585 | { |
| 6586 | return gl::error(GL_INVALID_VALUE); |
| 6587 | } |
| 6588 | |
| 6589 | gl::Program *programObject = context->getProgram(program); |
| 6590 | |
| 6591 | if (!programObject) |
| 6592 | { |
| 6593 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6594 | { |
| 6595 | return gl::error(GL_INVALID_OPERATION); |
| 6596 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6597 | else |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 6598 | { |
| 6599 | return gl::error(GL_INVALID_VALUE); |
| 6600 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6601 | } |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 6602 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6603 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6604 | if (!programObject->isLinked() || !programBinary) |
| 6605 | { |
| 6606 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 6607 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6608 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 6609 | } |
| 6610 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6611 | else |
| 6612 | { |
| 6613 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6614 | { |
| 6615 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 6616 | } |
| 6617 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6618 | } |
| 6619 | } |
| 6620 | |
| 6621 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 6622 | { |
| 6623 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 6624 | program, uniformCount, uniformIndices, pname, params); |
| 6625 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6626 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6627 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6628 | if (context) |
| 6629 | { |
| 6630 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6631 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6632 | return gl::error(GL_INVALID_OPERATION); |
| 6633 | } |
| 6634 | |
| 6635 | if (uniformCount < 0) |
| 6636 | { |
| 6637 | return gl::error(GL_INVALID_VALUE); |
| 6638 | } |
| 6639 | |
| 6640 | gl::Program *programObject = context->getProgram(program); |
| 6641 | |
| 6642 | if (!programObject) |
| 6643 | { |
| 6644 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6645 | { |
| 6646 | return gl::error(GL_INVALID_OPERATION); |
| 6647 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6648 | else |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 6649 | { |
| 6650 | return gl::error(GL_INVALID_VALUE); |
| 6651 | } |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 6652 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6653 | |
| 6654 | switch (pname) |
| 6655 | { |
| 6656 | case GL_UNIFORM_TYPE: |
| 6657 | case GL_UNIFORM_SIZE: |
| 6658 | case GL_UNIFORM_NAME_LENGTH: |
| 6659 | case GL_UNIFORM_BLOCK_INDEX: |
| 6660 | case GL_UNIFORM_OFFSET: |
| 6661 | case GL_UNIFORM_ARRAY_STRIDE: |
| 6662 | case GL_UNIFORM_MATRIX_STRIDE: |
| 6663 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 6664 | break; |
| 6665 | default: |
| 6666 | return gl::error(GL_INVALID_ENUM); |
| 6667 | } |
| 6668 | |
| 6669 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6670 | |
| 6671 | if (!programBinary && uniformCount > 0) |
| 6672 | { |
| 6673 | return gl::error(GL_INVALID_VALUE); |
| 6674 | } |
| 6675 | |
| 6676 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6677 | { |
| 6678 | const GLuint index = uniformIndices[uniformId]; |
| 6679 | |
| 6680 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 6681 | { |
| 6682 | return gl::error(GL_INVALID_VALUE); |
| 6683 | } |
| 6684 | } |
| 6685 | |
| 6686 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 6687 | { |
| 6688 | const GLuint index = uniformIndices[uniformId]; |
| 6689 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 6690 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6691 | } |
| 6692 | } |
| 6693 | |
| 6694 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 6695 | { |
| 6696 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 6697 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6698 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6699 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6700 | if (context) |
| 6701 | { |
| 6702 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6703 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6704 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
| 6705 | } |
| 6706 | |
| 6707 | gl::Program *programObject = context->getProgram(program); |
| 6708 | |
| 6709 | if (!programObject) |
| 6710 | { |
| 6711 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6712 | { |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 6713 | return gl::error(GL_INVALID_OPERATION, GL_INVALID_INDEX); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6714 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6715 | else |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 6716 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6717 | return gl::error(GL_INVALID_VALUE, GL_INVALID_INDEX); |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 6718 | } |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 6719 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6720 | |
| 6721 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6722 | if (!programBinary) |
| 6723 | { |
| 6724 | return GL_INVALID_INDEX; |
| 6725 | } |
| 6726 | |
| 6727 | return programBinary->getUniformBlockIndex(uniformBlockName); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6728 | } |
| 6729 | |
| 6730 | return 0; |
| 6731 | } |
| 6732 | |
| 6733 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 6734 | { |
| 6735 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 6736 | program, uniformBlockIndex, pname, params); |
| 6737 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6738 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6739 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6740 | if (context) |
| 6741 | { |
| 6742 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6743 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6744 | return gl::error(GL_INVALID_OPERATION); |
| 6745 | } |
| 6746 | gl::Program *programObject = context->getProgram(program); |
| 6747 | |
| 6748 | if (!programObject) |
| 6749 | { |
| 6750 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6751 | { |
| 6752 | return gl::error(GL_INVALID_OPERATION); |
| 6753 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6754 | else |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 6755 | { |
| 6756 | return gl::error(GL_INVALID_VALUE); |
| 6757 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 6758 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6759 | |
| 6760 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6761 | |
| 6762 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 6763 | { |
| 6764 | return gl::error(GL_INVALID_VALUE); |
| 6765 | } |
| 6766 | |
| 6767 | switch (pname) |
| 6768 | { |
| 6769 | case GL_UNIFORM_BLOCK_BINDING: |
| 6770 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 6771 | break; |
| 6772 | |
| 6773 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 6774 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 6775 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 6776 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 6777 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 6778 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 6779 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 6780 | break; |
| 6781 | |
| 6782 | default: |
| 6783 | return gl::error(GL_INVALID_ENUM); |
| 6784 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6785 | } |
| 6786 | } |
| 6787 | |
| 6788 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 6789 | { |
| 6790 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 6791 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 6792 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6793 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6794 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6795 | if (context) |
| 6796 | { |
| 6797 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6798 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6799 | return gl::error(GL_INVALID_OPERATION); |
| 6800 | } |
| 6801 | |
| 6802 | gl::Program *programObject = context->getProgram(program); |
| 6803 | |
| 6804 | if (!programObject) |
| 6805 | { |
| 6806 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6807 | { |
| 6808 | return gl::error(GL_INVALID_OPERATION); |
| 6809 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6810 | else |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 6811 | { |
| 6812 | return gl::error(GL_INVALID_VALUE); |
| 6813 | } |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 6814 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6815 | |
| 6816 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6817 | |
| 6818 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 6819 | { |
| 6820 | return gl::error(GL_INVALID_VALUE); |
| 6821 | } |
| 6822 | |
| 6823 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6824 | } |
| 6825 | } |
| 6826 | |
| 6827 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 6828 | { |
| 6829 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 6830 | program, uniformBlockIndex, uniformBlockBinding); |
| 6831 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6832 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6833 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6834 | if (context) |
| 6835 | { |
| 6836 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6837 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6838 | return gl::error(GL_INVALID_OPERATION); |
| 6839 | } |
| 6840 | |
| 6841 | if (uniformBlockBinding >= context->getMaximumCombinedUniformBufferBindings()) |
| 6842 | { |
| 6843 | return gl::error(GL_INVALID_VALUE); |
| 6844 | } |
| 6845 | |
| 6846 | gl::Program *programObject = context->getProgram(program); |
| 6847 | |
| 6848 | if (!programObject) |
| 6849 | { |
| 6850 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6851 | { |
| 6852 | return gl::error(GL_INVALID_OPERATION); |
| 6853 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6854 | else |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 6855 | { |
| 6856 | return gl::error(GL_INVALID_VALUE); |
| 6857 | } |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 6858 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6859 | |
| 6860 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6861 | |
| 6862 | // if never linked, there won't be any uniform blocks |
| 6863 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 6864 | { |
| 6865 | return gl::error(GL_INVALID_VALUE); |
| 6866 | } |
| 6867 | |
| 6868 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6869 | } |
| 6870 | } |
| 6871 | |
| 6872 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 6873 | { |
| 6874 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 6875 | mode, first, count, instanceCount); |
| 6876 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6877 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6878 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6879 | if (context) |
| 6880 | { |
| 6881 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6882 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6883 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6884 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6885 | |
| 6886 | // glDrawArraysInstanced |
| 6887 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6888 | } |
| 6889 | } |
| 6890 | |
| 6891 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 6892 | { |
| 6893 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 6894 | mode, count, type, indices, instanceCount); |
| 6895 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6896 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6897 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6898 | if (context) |
| 6899 | { |
| 6900 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6901 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6902 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6903 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6904 | |
| 6905 | // glDrawElementsInstanced |
| 6906 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6907 | } |
| 6908 | } |
| 6909 | |
| 6910 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 6911 | { |
| 6912 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 6913 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6914 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6915 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6916 | if (context) |
| 6917 | { |
| 6918 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6919 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6920 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLsync>(0)); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6921 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6922 | |
| 6923 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 6924 | { |
| 6925 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLsync>(0)); |
| 6926 | } |
| 6927 | |
| 6928 | if (flags != 0) |
| 6929 | { |
| 6930 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLsync>(0)); |
| 6931 | } |
| 6932 | |
| 6933 | return context->createFenceSync(condition); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6934 | } |
| 6935 | |
| 6936 | return NULL; |
| 6937 | } |
| 6938 | |
| 6939 | GLboolean __stdcall glIsSync(GLsync sync) |
| 6940 | { |
| 6941 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 6942 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6943 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6944 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6945 | if (context) |
| 6946 | { |
| 6947 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6948 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6949 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6950 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6951 | |
| 6952 | return (context->getFenceSync(sync) != NULL); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6953 | } |
| 6954 | |
| 6955 | return GL_FALSE; |
| 6956 | } |
| 6957 | |
| 6958 | void __stdcall glDeleteSync(GLsync sync) |
| 6959 | { |
| 6960 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 6961 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6962 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6963 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6964 | if (context) |
| 6965 | { |
| 6966 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6967 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6968 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6969 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6970 | |
| 6971 | if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) |
| 6972 | { |
| 6973 | return gl::error(GL_INVALID_VALUE); |
| 6974 | } |
| 6975 | |
| 6976 | context->deleteFenceSync(sync); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6977 | } |
| 6978 | } |
| 6979 | |
| 6980 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 6981 | { |
| 6982 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 6983 | sync, flags, timeout); |
| 6984 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6985 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6986 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6987 | if (context) |
| 6988 | { |
| 6989 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6990 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6991 | return gl::error(GL_INVALID_OPERATION, GL_WAIT_FAILED); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6992 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6993 | |
| 6994 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 6995 | { |
| 6996 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 6997 | } |
| 6998 | |
| 6999 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7000 | |
| 7001 | if (!fenceSync) |
| 7002 | { |
| 7003 | return gl::error(GL_INVALID_VALUE, GL_WAIT_FAILED); |
| 7004 | } |
| 7005 | |
| 7006 | return fenceSync->clientWait(flags, timeout); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7007 | } |
| 7008 | |
| 7009 | return GL_FALSE; |
| 7010 | } |
| 7011 | |
| 7012 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 7013 | { |
| 7014 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 7015 | sync, flags, timeout); |
| 7016 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7017 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7018 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7019 | if (context) |
| 7020 | { |
| 7021 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7022 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7023 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7024 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7025 | |
| 7026 | if (flags != 0) |
| 7027 | { |
| 7028 | return gl::error(GL_INVALID_VALUE); |
| 7029 | } |
| 7030 | |
| 7031 | if (timeout != GL_TIMEOUT_IGNORED) |
| 7032 | { |
| 7033 | return gl::error(GL_INVALID_VALUE); |
| 7034 | } |
| 7035 | |
| 7036 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7037 | |
| 7038 | if (!fenceSync) |
| 7039 | { |
| 7040 | return gl::error(GL_INVALID_VALUE); |
| 7041 | } |
| 7042 | |
| 7043 | fenceSync->serverWait(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7044 | } |
| 7045 | } |
| 7046 | |
| 7047 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 7048 | { |
| 7049 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 7050 | pname, params); |
| 7051 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7052 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7053 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7054 | if (context) |
| 7055 | { |
| 7056 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7057 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7058 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7059 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7060 | |
| 7061 | GLenum nativeType; |
| 7062 | unsigned int numParams = 0; |
| 7063 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
| 7064 | { |
| 7065 | return; |
| 7066 | } |
| 7067 | |
| 7068 | if (nativeType == GL_INT_64_ANGLEX) |
| 7069 | { |
| 7070 | context->getInteger64v(pname, params); |
| 7071 | } |
| 7072 | else |
| 7073 | { |
| 7074 | CastStateValues(context, nativeType, pname, numParams, params); |
| 7075 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7076 | } |
| 7077 | } |
| 7078 | |
| 7079 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 7080 | { |
| 7081 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 7082 | sync, pname, bufSize, length, values); |
| 7083 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7084 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7085 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7086 | if (context) |
| 7087 | { |
| 7088 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7089 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7090 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7091 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7092 | |
| 7093 | if (bufSize < 0) |
| 7094 | { |
| 7095 | return gl::error(GL_INVALID_VALUE); |
| 7096 | } |
| 7097 | |
| 7098 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7099 | |
| 7100 | if (!fenceSync) |
| 7101 | { |
| 7102 | return gl::error(GL_INVALID_VALUE); |
| 7103 | } |
| 7104 | |
| 7105 | switch (pname) |
| 7106 | { |
| 7107 | case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break; |
| 7108 | case GL_SYNC_STATUS: values[0] = static_cast<GLint>(fenceSync->getStatus()); break; |
| 7109 | case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break; |
| 7110 | case GL_SYNC_FLAGS: values[0] = 0; break; |
| 7111 | |
| 7112 | default: |
| 7113 | return gl::error(GL_INVALID_ENUM); |
| 7114 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7115 | } |
| 7116 | } |
| 7117 | |
| 7118 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 7119 | { |
| 7120 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 7121 | target, index, data); |
| 7122 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7123 | gl::Context *context = gl::getNonLostContext(); |
| 7124 | |
| 7125 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7126 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7127 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7128 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7129 | return gl::error(GL_INVALID_OPERATION); |
| 7130 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7131 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7132 | switch (target) |
| 7133 | { |
| 7134 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7135 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7136 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
| 7137 | if (index >= context->getMaxTransformFeedbackBufferBindings()) |
| 7138 | return gl::error(GL_INVALID_VALUE); |
| 7139 | break; |
| 7140 | case GL_UNIFORM_BUFFER_START: |
| 7141 | case GL_UNIFORM_BUFFER_SIZE: |
| 7142 | case GL_UNIFORM_BUFFER_BINDING: |
| 7143 | if (index >= context->getMaximumCombinedUniformBufferBindings()) |
| 7144 | return gl::error(GL_INVALID_VALUE); |
| 7145 | break; |
| 7146 | default: |
| 7147 | return gl::error(GL_INVALID_ENUM); |
| 7148 | } |
| 7149 | |
| 7150 | if (!(context->getIndexedInteger64v(target, index, data))) |
| 7151 | { |
| 7152 | GLenum nativeType; |
| 7153 | unsigned int numParams = 0; |
| 7154 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7155 | return gl::error(GL_INVALID_ENUM); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7156 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7157 | if (numParams == 0) |
| 7158 | return; // it is known that pname is valid, but there are no parameters to return |
| 7159 | |
| 7160 | if (nativeType == GL_INT) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7161 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7162 | GLint *intParams = new GLint[numParams]; |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7163 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7164 | context->getIndexedIntegerv(target, index, intParams); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7165 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7166 | for (unsigned int i = 0; i < numParams; ++i) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7167 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7168 | data[i] = static_cast<GLint64>(intParams[i]); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7169 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7170 | |
| 7171 | delete [] intParams; |
| 7172 | } |
| 7173 | else |
| 7174 | { |
| 7175 | UNREACHABLE(); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7176 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7177 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7178 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7179 | } |
| 7180 | |
| 7181 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 7182 | { |
| 7183 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 7184 | target, pname, params); |
| 7185 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7186 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7187 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7188 | if (context) |
| 7189 | { |
| 7190 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7191 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7192 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7193 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7194 | |
| 7195 | if (!gl::ValidBufferTarget(context, target)) |
| 7196 | { |
| 7197 | return gl::error(GL_INVALID_ENUM); |
| 7198 | } |
| 7199 | |
| 7200 | if (!gl::ValidBufferParameter(context, pname)) |
| 7201 | { |
| 7202 | return gl::error(GL_INVALID_ENUM); |
| 7203 | } |
| 7204 | |
| 7205 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 7206 | |
| 7207 | if (!buffer) |
| 7208 | { |
| 7209 | // A null buffer means that "0" is bound to the requested buffer target |
| 7210 | return gl::error(GL_INVALID_OPERATION); |
| 7211 | } |
| 7212 | |
| 7213 | switch (pname) |
| 7214 | { |
| 7215 | case GL_BUFFER_USAGE: |
| 7216 | *params = static_cast<GLint64>(buffer->getUsage()); |
| 7217 | break; |
| 7218 | case GL_BUFFER_SIZE: |
| 7219 | *params = buffer->getSize(); |
| 7220 | break; |
| 7221 | case GL_BUFFER_ACCESS_FLAGS: |
| 7222 | *params = static_cast<GLint64>(buffer->getAccessFlags()); |
| 7223 | break; |
| 7224 | case GL_BUFFER_MAPPED: |
| 7225 | *params = static_cast<GLint64>(buffer->isMapped()); |
| 7226 | break; |
| 7227 | case GL_BUFFER_MAP_OFFSET: |
| 7228 | *params = buffer->getMapOffset(); |
| 7229 | break; |
| 7230 | case GL_BUFFER_MAP_LENGTH: |
| 7231 | *params = buffer->getMapLength(); |
| 7232 | break; |
| 7233 | default: UNREACHABLE(); break; |
| 7234 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7235 | } |
| 7236 | } |
| 7237 | |
| 7238 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 7239 | { |
| 7240 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 7241 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7242 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7243 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7244 | if (context) |
| 7245 | { |
| 7246 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7247 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7248 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7249 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7250 | |
| 7251 | if (count < 0) |
| 7252 | { |
| 7253 | return gl::error(GL_INVALID_VALUE); |
| 7254 | } |
| 7255 | |
| 7256 | for (int i = 0; i < count; i++) |
| 7257 | { |
| 7258 | samplers[i] = context->createSampler(); |
| 7259 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7260 | } |
| 7261 | } |
| 7262 | |
| 7263 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 7264 | { |
| 7265 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 7266 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7267 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7268 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7269 | if (context) |
| 7270 | { |
| 7271 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7272 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7273 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7274 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7275 | |
| 7276 | if (count < 0) |
| 7277 | { |
| 7278 | return gl::error(GL_INVALID_VALUE); |
| 7279 | } |
| 7280 | |
| 7281 | for (int i = 0; i < count; i++) |
| 7282 | { |
| 7283 | context->deleteSampler(samplers[i]); |
| 7284 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7285 | } |
| 7286 | } |
| 7287 | |
| 7288 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 7289 | { |
| 7290 | EVENT("(GLuint sampler = %u)", sampler); |
| 7291 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7292 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7293 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7294 | if (context) |
| 7295 | { |
| 7296 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7297 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7298 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7299 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7300 | |
| 7301 | return context->isSampler(sampler); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7302 | } |
| 7303 | |
| 7304 | return GL_FALSE; |
| 7305 | } |
| 7306 | |
| 7307 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 7308 | { |
| 7309 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 7310 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7311 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7312 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7313 | if (context) |
| 7314 | { |
| 7315 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7316 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7317 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7318 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7319 | |
| 7320 | if (sampler != 0 && !context->isSampler(sampler)) |
| 7321 | { |
| 7322 | return gl::error(GL_INVALID_OPERATION); |
| 7323 | } |
| 7324 | |
| 7325 | if (unit >= context->getMaximumCombinedTextureImageUnits()) |
| 7326 | { |
| 7327 | return gl::error(GL_INVALID_VALUE); |
| 7328 | } |
| 7329 | |
| 7330 | context->bindSampler(unit, sampler); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7331 | } |
| 7332 | } |
| 7333 | |
| 7334 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 7335 | { |
| 7336 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 7337 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7338 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7339 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7340 | if (context) |
| 7341 | { |
| 7342 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7343 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7344 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7345 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7346 | |
| 7347 | if (!gl::ValidateSamplerObjectParameter(pname)) |
| 7348 | { |
| 7349 | return; |
| 7350 | } |
| 7351 | |
| 7352 | if (!gl::ValidateTexParamParameters(context, pname, param)) |
| 7353 | { |
| 7354 | return; |
| 7355 | } |
| 7356 | |
| 7357 | if (!context->isSampler(sampler)) |
| 7358 | { |
| 7359 | return gl::error(GL_INVALID_OPERATION); |
| 7360 | } |
| 7361 | |
| 7362 | context->samplerParameteri(sampler, pname, param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7363 | } |
| 7364 | } |
| 7365 | |
| 7366 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 7367 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 7368 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7369 | } |
| 7370 | |
| 7371 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 7372 | { |
| 7373 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 7374 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7375 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7376 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7377 | if (context) |
| 7378 | { |
| 7379 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7380 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7381 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7382 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7383 | |
| 7384 | if (!gl::ValidateSamplerObjectParameter(pname)) |
| 7385 | { |
| 7386 | return; |
| 7387 | } |
| 7388 | |
| 7389 | if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7390 | { |
| 7391 | return; |
| 7392 | } |
| 7393 | |
| 7394 | if (!context->isSampler(sampler)) |
| 7395 | { |
| 7396 | return gl::error(GL_INVALID_OPERATION); |
| 7397 | } |
| 7398 | |
| 7399 | context->samplerParameterf(sampler, pname, param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7400 | } |
| 7401 | } |
| 7402 | |
| 7403 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 7404 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 7405 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7406 | } |
| 7407 | |
| 7408 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 7409 | { |
| 7410 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 7411 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7412 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7413 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7414 | if (context) |
| 7415 | { |
| 7416 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7417 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7418 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7419 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7420 | |
| 7421 | if (!gl::ValidateSamplerObjectParameter(pname)) |
| 7422 | { |
| 7423 | return; |
| 7424 | } |
| 7425 | |
| 7426 | if (!context->isSampler(sampler)) |
| 7427 | { |
| 7428 | return gl::error(GL_INVALID_OPERATION); |
| 7429 | } |
| 7430 | |
| 7431 | *params = context->getSamplerParameteri(sampler, pname); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7432 | } |
| 7433 | } |
| 7434 | |
| 7435 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 7436 | { |
| 7437 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 7438 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7439 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7440 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7441 | if (context) |
| 7442 | { |
| 7443 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7444 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7445 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7446 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7447 | |
| 7448 | if (!gl::ValidateSamplerObjectParameter(pname)) |
| 7449 | { |
| 7450 | return; |
| 7451 | } |
| 7452 | |
| 7453 | if (!context->isSampler(sampler)) |
| 7454 | { |
| 7455 | return gl::error(GL_INVALID_OPERATION); |
| 7456 | } |
| 7457 | |
| 7458 | *params = context->getSamplerParameterf(sampler, pname); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7459 | } |
| 7460 | } |
| 7461 | |
| 7462 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 7463 | { |
| 7464 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 7465 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7466 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7467 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7468 | return gl::error(GL_INVALID_VALUE); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7469 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7470 | |
| 7471 | gl::Context *context = gl::getNonLostContext(); |
| 7472 | |
| 7473 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7474 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7475 | if (context->getClientVersion() < 3) |
| 7476 | { |
| 7477 | return gl::error(GL_INVALID_OPERATION); |
| 7478 | } |
| 7479 | |
| 7480 | context->setVertexAttribDivisor(index, divisor); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7481 | } |
| 7482 | } |
| 7483 | |
| 7484 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 7485 | { |
| 7486 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 7487 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7488 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7489 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7490 | if (context) |
| 7491 | { |
| 7492 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7493 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7494 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7495 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7496 | |
| 7497 | switch (target) |
| 7498 | { |
| 7499 | case GL_TRANSFORM_FEEDBACK: |
| 7500 | { |
| 7501 | // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1) |
| 7502 | gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); |
| 7503 | if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused()) |
| 7504 | { |
| 7505 | return gl::error(GL_INVALID_OPERATION); |
| 7506 | } |
| 7507 | |
| 7508 | // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1) |
| 7509 | if (context->getTransformFeedback(id) == NULL) |
| 7510 | { |
| 7511 | return gl::error(GL_INVALID_OPERATION); |
| 7512 | } |
| 7513 | |
| 7514 | context->bindTransformFeedback(id); |
| 7515 | } |
| 7516 | break; |
| 7517 | |
| 7518 | default: |
| 7519 | return gl::error(GL_INVALID_ENUM); |
| 7520 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7521 | } |
| 7522 | } |
| 7523 | |
| 7524 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 7525 | { |
| 7526 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 7527 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7528 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7529 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7530 | if (context) |
| 7531 | { |
| 7532 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7533 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7534 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7535 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7536 | |
| 7537 | for (int i = 0; i < n; i++) |
| 7538 | { |
| 7539 | context->deleteTransformFeedback(ids[i]); |
| 7540 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7541 | } |
| 7542 | } |
| 7543 | |
| 7544 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 7545 | { |
| 7546 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 7547 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7548 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7549 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7550 | if (context) |
| 7551 | { |
| 7552 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7553 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7554 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7555 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7556 | |
| 7557 | for (int i = 0; i < n; i++) |
| 7558 | { |
| 7559 | ids[i] = context->createTransformFeedback(); |
| 7560 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7561 | } |
| 7562 | } |
| 7563 | |
| 7564 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 7565 | { |
| 7566 | EVENT("(GLuint id = %u)", id); |
| 7567 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7568 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7569 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7570 | if (context) |
| 7571 | { |
| 7572 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7573 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7574 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7575 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7576 | |
| 7577 | return ((context->getTransformFeedback(id) != NULL) ? GL_TRUE : GL_FALSE); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7578 | } |
| 7579 | |
| 7580 | return GL_FALSE; |
| 7581 | } |
| 7582 | |
| 7583 | void __stdcall glPauseTransformFeedback(void) |
| 7584 | { |
| 7585 | EVENT("(void)"); |
| 7586 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7587 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7588 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7589 | if (context) |
| 7590 | { |
| 7591 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7592 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7593 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7594 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7595 | |
| 7596 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 7597 | ASSERT(transformFeedback != NULL); |
| 7598 | |
| 7599 | // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86) |
| 7600 | if (!transformFeedback->isStarted() || transformFeedback->isPaused()) |
| 7601 | { |
| 7602 | return gl::error(GL_INVALID_OPERATION); |
| 7603 | } |
| 7604 | |
| 7605 | transformFeedback->pause(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7606 | } |
| 7607 | } |
| 7608 | |
| 7609 | void __stdcall glResumeTransformFeedback(void) |
| 7610 | { |
| 7611 | EVENT("(void)"); |
| 7612 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7613 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7614 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7615 | if (context) |
| 7616 | { |
| 7617 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7618 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7619 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7620 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7621 | |
| 7622 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 7623 | ASSERT(transformFeedback != NULL); |
| 7624 | |
| 7625 | // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86) |
| 7626 | if (!transformFeedback->isStarted() || !transformFeedback->isPaused()) |
| 7627 | { |
| 7628 | return gl::error(GL_INVALID_OPERATION); |
| 7629 | } |
| 7630 | |
| 7631 | transformFeedback->resume(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7632 | } |
| 7633 | } |
| 7634 | |
| 7635 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 7636 | { |
| 7637 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 7638 | program, bufSize, length, binaryFormat, binary); |
| 7639 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7640 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7641 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7642 | if (context) |
| 7643 | { |
| 7644 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7645 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7646 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7647 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7648 | |
| 7649 | // glGetProgramBinary |
| 7650 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7651 | } |
| 7652 | } |
| 7653 | |
| 7654 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 7655 | { |
| 7656 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 7657 | program, binaryFormat, binary, length); |
| 7658 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7659 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7660 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7661 | if (context) |
| 7662 | { |
| 7663 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7664 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7665 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7666 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7667 | |
| 7668 | // glProgramBinary |
| 7669 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7670 | } |
| 7671 | } |
| 7672 | |
| 7673 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 7674 | { |
| 7675 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 7676 | program, pname, value); |
| 7677 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7678 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7679 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7680 | if (context) |
| 7681 | { |
| 7682 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7683 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7684 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7685 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7686 | |
| 7687 | // glProgramParameteri |
| 7688 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7689 | } |
| 7690 | } |
| 7691 | |
| 7692 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 7693 | { |
| 7694 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 7695 | target, numAttachments, attachments); |
| 7696 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7697 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7698 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7699 | if (context) |
| 7700 | { |
| 7701 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7702 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7703 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 7704 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7705 | |
| 7706 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 7707 | { |
| 7708 | return; |
| 7709 | } |
| 7710 | |
| 7711 | GLuint maxDimension = context->getCaps().maxRenderbufferSize; |
| 7712 | context->invalidateFrameBuffer(target, numAttachments, attachments, 0, 0, maxDimension, maxDimension); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7713 | } |
| 7714 | } |
| 7715 | |
| 7716 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 7717 | { |
| 7718 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 7719 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 7720 | target, numAttachments, attachments, x, y, width, height); |
| 7721 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7722 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7723 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7724 | if (context) |
| 7725 | { |
| 7726 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7727 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7728 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 7729 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7730 | |
| 7731 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 7732 | { |
| 7733 | return; |
| 7734 | } |
| 7735 | |
| 7736 | context->invalidateFrameBuffer(target, numAttachments, attachments, x, y, width, height); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7737 | } |
| 7738 | } |
| 7739 | |
| 7740 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 7741 | { |
| 7742 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 7743 | target, levels, internalformat, width, height); |
| 7744 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7745 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7746 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7747 | if (context) |
| 7748 | { |
| 7749 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7750 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7751 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 7752 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7753 | |
| 7754 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 7755 | { |
| 7756 | return; |
| 7757 | } |
| 7758 | |
| 7759 | switch (target) |
| 7760 | { |
| 7761 | case GL_TEXTURE_2D: |
| 7762 | { |
| 7763 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 7764 | texture2d->storage(levels, internalformat, width, height); |
| 7765 | } |
| 7766 | break; |
| 7767 | |
| 7768 | case GL_TEXTURE_CUBE_MAP: |
| 7769 | { |
| 7770 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 7771 | textureCube->storage(levels, internalformat, width); |
| 7772 | } |
| 7773 | break; |
| 7774 | |
| 7775 | default: |
| 7776 | return gl::error(GL_INVALID_ENUM); |
| 7777 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7778 | } |
| 7779 | } |
| 7780 | |
| 7781 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 7782 | { |
| 7783 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 7784 | "GLsizei height = %d, GLsizei depth = %d)", |
| 7785 | target, levels, internalformat, width, height, depth); |
| 7786 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7787 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7788 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7789 | if (context) |
| 7790 | { |
| 7791 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7792 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7793 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 7794 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7795 | |
| 7796 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 7797 | { |
| 7798 | return; |
| 7799 | } |
| 7800 | |
| 7801 | switch (target) |
| 7802 | { |
| 7803 | case GL_TEXTURE_3D: |
| 7804 | { |
| 7805 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 7806 | texture3d->storage(levels, internalformat, width, height, depth); |
| 7807 | } |
| 7808 | break; |
| 7809 | |
| 7810 | case GL_TEXTURE_2D_ARRAY: |
| 7811 | { |
| 7812 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 7813 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 7814 | } |
| 7815 | break; |
| 7816 | |
| 7817 | default: |
| 7818 | UNREACHABLE(); |
| 7819 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7820 | } |
| 7821 | } |
| 7822 | |
| 7823 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 7824 | { |
| 7825 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 7826 | "GLint* params = 0x%0.8p)", |
| 7827 | target, internalformat, pname, bufSize, params); |
| 7828 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7829 | gl::Context *context = gl::getNonLostContext(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7830 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7831 | if (context) |
| 7832 | { |
| 7833 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7834 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7835 | return gl::error(GL_INVALID_OPERATION); |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7836 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7837 | |
| 7838 | const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 7839 | if (!formatCaps.renderable) |
| 7840 | { |
| 7841 | return gl::error(GL_INVALID_ENUM); |
| 7842 | } |
| 7843 | |
| 7844 | if (target != GL_RENDERBUFFER) |
| 7845 | { |
| 7846 | return gl::error(GL_INVALID_ENUM); |
| 7847 | } |
| 7848 | |
| 7849 | if (bufSize < 0) |
| 7850 | { |
| 7851 | return gl::error(GL_INVALID_VALUE); |
| 7852 | } |
| 7853 | |
| 7854 | switch (pname) |
| 7855 | { |
| 7856 | case GL_NUM_SAMPLE_COUNTS: |
| 7857 | if (bufSize != 0) |
Geoff Lang | 5f4c463 | 2014-07-03 13:46:52 -0400 | [diff] [blame] | 7858 | { |
| 7859 | *params = formatCaps.sampleCounts.size(); |
| 7860 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7861 | break; |
| 7862 | case GL_SAMPLES: |
Geoff Lang | 5f4c463 | 2014-07-03 13:46:52 -0400 | [diff] [blame] | 7863 | std::copy_n(formatCaps.sampleCounts.rbegin(), std::min<size_t>(bufSize, formatCaps.sampleCounts.size()), params); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7864 | break; |
| 7865 | default: |
| 7866 | return gl::error(GL_INVALID_ENUM); |
| 7867 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7868 | } |
| 7869 | } |
| 7870 | |
| 7871 | // Extension functions |
| 7872 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7873 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 7874 | GLbitfield mask, GLenum filter) |
| 7875 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7876 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, " |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7877 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 7878 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 7879 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 7880 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7881 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7882 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7883 | if (context) |
| 7884 | { |
| 7885 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 7886 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 7887 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7888 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7889 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7890 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7891 | |
| 7892 | context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 7893 | mask, filter); |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 7894 | } |
| 7895 | } |
| 7896 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7897 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 7898 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7899 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 7900 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, " |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 7901 | "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 7902 | "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7903 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 7904 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7905 | UNIMPLEMENTED(); // FIXME |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 7906 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 7907 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7908 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7909 | GLenum *binaryFormat, void *binary) |
| 7910 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 7911 | EVENT("(GLenum program = 0x%X, bufSize = %d, length = 0x%0.8p, binaryFormat = 0x%0.8p, binary = 0x%0.8p)", |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7912 | program, bufSize, length, binaryFormat, binary); |
| 7913 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7914 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7915 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7916 | if (context) |
| 7917 | { |
| 7918 | gl::Program *programObject = context->getProgram(program); |
| 7919 | |
| 7920 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7921 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7922 | return gl::error(GL_INVALID_OPERATION); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7923 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7924 | |
| 7925 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7926 | |
| 7927 | if (!programBinary) |
| 7928 | { |
| 7929 | return gl::error(GL_INVALID_OPERATION); |
| 7930 | } |
| 7931 | |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 7932 | if (!programBinary->save(binaryFormat, binary, bufSize, length)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7933 | { |
| 7934 | return gl::error(GL_INVALID_OPERATION); |
| 7935 | } |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7936 | } |
| 7937 | } |
| 7938 | |
| 7939 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 7940 | const void *binary, GLint length) |
| 7941 | { |
| 7942 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 7943 | program, binaryFormat, binary, length); |
| 7944 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7945 | gl::Context *context = gl::getNonLostContext(); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7946 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7947 | if (context) |
| 7948 | { |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 7949 | const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats; |
| 7950 | if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7951 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7952 | return gl::error(GL_INVALID_ENUM); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7953 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7954 | |
| 7955 | gl::Program *programObject = context->getProgram(program); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7956 | if (!programObject) |
| 7957 | { |
| 7958 | return gl::error(GL_INVALID_OPERATION); |
| 7959 | } |
| 7960 | |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 7961 | context->setProgramBinary(program, binaryFormat, binary, length); |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 7962 | } |
| 7963 | } |
| 7964 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7965 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 7966 | { |
| 7967 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 7968 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7969 | gl::Context *context = gl::getNonLostContext(); |
| 7970 | |
| 7971 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7972 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7973 | if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7974 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7975 | return gl::error(GL_INVALID_VALUE); |
| 7976 | } |
| 7977 | |
| 7978 | if (context->getState().getDrawFramebuffer()->id() == 0) |
| 7979 | { |
| 7980 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7981 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7982 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7983 | } |
| 7984 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7985 | if (bufs[0] != GL_NONE && bufs[0] != GL_BACK) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7986 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7987 | return gl::error(GL_INVALID_OPERATION); |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 7988 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 7989 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7990 | else |
| 7991 | { |
| 7992 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 7993 | { |
| 7994 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 7995 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 7996 | { |
| 7997 | return gl::error(GL_INVALID_OPERATION); |
| 7998 | } |
| 7999 | } |
| 8000 | } |
| 8001 | |
| 8002 | gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer(); |
| 8003 | |
| 8004 | for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++) |
| 8005 | { |
| 8006 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 8007 | } |
| 8008 | |
| 8009 | for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++) |
| 8010 | { |
| 8011 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 8012 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8013 | } |
| 8014 | } |
| 8015 | |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8016 | void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params) |
| 8017 | { |
| 8018 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8019 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8020 | gl::Context *context = gl::getNonLostContext(); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8021 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8022 | if (context) |
| 8023 | { |
| 8024 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8025 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8026 | return gl::error(GL_INVALID_ENUM); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8027 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8028 | |
| 8029 | if (pname != GL_BUFFER_MAP_POINTER) |
| 8030 | { |
| 8031 | return gl::error(GL_INVALID_ENUM); |
| 8032 | } |
| 8033 | |
| 8034 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8035 | |
| 8036 | if (!buffer || !buffer->isMapped()) |
| 8037 | { |
| 8038 | *params = NULL; |
| 8039 | } |
| 8040 | else |
| 8041 | { |
| 8042 | *params = buffer->getMapPointer(); |
| 8043 | } |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8044 | } |
| 8045 | } |
| 8046 | |
| 8047 | void * __stdcall glMapBufferOES(GLenum target, GLenum access) |
| 8048 | { |
| 8049 | EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access); |
| 8050 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8051 | gl::Context *context = gl::getNonLostContext(); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8052 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8053 | if (context) |
| 8054 | { |
| 8055 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8056 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8057 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL)); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8058 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8059 | |
| 8060 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8061 | |
| 8062 | if (buffer == NULL) |
| 8063 | { |
| 8064 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8065 | } |
| 8066 | |
| 8067 | if (access != GL_WRITE_ONLY_OES) |
| 8068 | { |
| 8069 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL)); |
| 8070 | } |
| 8071 | |
| 8072 | if (buffer->isMapped()) |
| 8073 | { |
| 8074 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8075 | } |
| 8076 | |
| 8077 | return buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8078 | } |
| 8079 | |
| 8080 | return NULL; |
| 8081 | } |
| 8082 | |
| 8083 | GLboolean __stdcall glUnmapBufferOES(GLenum target) |
| 8084 | { |
| 8085 | EVENT("(GLenum target = 0x%X)", target); |
| 8086 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8087 | gl::Context *context = gl::getNonLostContext(); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8088 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8089 | if (context) |
| 8090 | { |
| 8091 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8092 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8093 | return gl::error(GL_INVALID_ENUM, GL_FALSE); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8094 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8095 | |
| 8096 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8097 | |
| 8098 | if (buffer == NULL || !buffer->isMapped()) |
| 8099 | { |
| 8100 | return gl::error(GL_INVALID_OPERATION, GL_FALSE); |
| 8101 | } |
| 8102 | |
| 8103 | // TODO: detect if we had corruption. if so, throw an error and return false. |
| 8104 | |
| 8105 | buffer->unmap(); |
| 8106 | |
| 8107 | return GL_TRUE; |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8108 | } |
| 8109 | |
| 8110 | return GL_FALSE; |
| 8111 | } |
| 8112 | |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8113 | void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8114 | { |
| 8115 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8116 | target, offset, length, access); |
| 8117 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8118 | gl::Context *context = gl::getNonLostContext(); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8119 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8120 | if (context) |
| 8121 | { |
| 8122 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8123 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8124 | return gl::error(GL_INVALID_ENUM, reinterpret_cast<GLvoid*>(NULL)); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8125 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8126 | |
| 8127 | if (offset < 0 || length < 0) |
| 8128 | { |
| 8129 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL)); |
| 8130 | } |
| 8131 | |
| 8132 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8133 | |
| 8134 | if (buffer == NULL) |
| 8135 | { |
| 8136 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8137 | } |
| 8138 | |
| 8139 | // Check for buffer overflow |
| 8140 | size_t offsetSize = static_cast<size_t>(offset); |
| 8141 | size_t lengthSize = static_cast<size_t>(length); |
| 8142 | |
| 8143 | if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || |
| 8144 | offsetSize + lengthSize > static_cast<size_t>(buffer->getSize())) |
| 8145 | { |
| 8146 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL)); |
| 8147 | } |
| 8148 | |
| 8149 | // Check for invalid bits in the mask |
| 8150 | GLbitfield allAccessBits = GL_MAP_READ_BIT | |
| 8151 | GL_MAP_WRITE_BIT | |
| 8152 | GL_MAP_INVALIDATE_RANGE_BIT | |
| 8153 | GL_MAP_INVALIDATE_BUFFER_BIT | |
| 8154 | GL_MAP_FLUSH_EXPLICIT_BIT | |
| 8155 | GL_MAP_UNSYNCHRONIZED_BIT; |
| 8156 | |
| 8157 | if (access & ~(allAccessBits)) |
| 8158 | { |
| 8159 | return gl::error(GL_INVALID_VALUE, reinterpret_cast<GLvoid*>(NULL)); |
| 8160 | } |
| 8161 | |
| 8162 | if (length == 0 || buffer->isMapped()) |
| 8163 | { |
| 8164 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8165 | } |
| 8166 | |
| 8167 | // Check for invalid bit combinations |
| 8168 | if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) |
| 8169 | { |
| 8170 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8171 | } |
| 8172 | |
| 8173 | GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT | |
| 8174 | GL_MAP_INVALIDATE_BUFFER_BIT | |
| 8175 | GL_MAP_UNSYNCHRONIZED_BIT; |
| 8176 | |
| 8177 | if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0) |
| 8178 | { |
| 8179 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8180 | } |
| 8181 | |
| 8182 | if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0) |
| 8183 | { |
| 8184 | return gl::error(GL_INVALID_OPERATION, reinterpret_cast<GLvoid*>(NULL)); |
| 8185 | } |
| 8186 | |
| 8187 | return buffer->mapRange(offset, length, access); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8188 | } |
| 8189 | |
| 8190 | return NULL; |
| 8191 | } |
| 8192 | |
| 8193 | void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length) |
| 8194 | { |
| 8195 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8196 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8197 | gl::Context *context = gl::getNonLostContext(); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8198 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8199 | if (context) |
| 8200 | { |
| 8201 | if (offset < 0 || length < 0) |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8202 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8203 | return gl::error(GL_INVALID_VALUE); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8204 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8205 | |
| 8206 | if (!gl::ValidBufferTarget(context, target)) |
| 8207 | { |
| 8208 | return gl::error(GL_INVALID_ENUM); |
| 8209 | } |
| 8210 | |
| 8211 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8212 | |
| 8213 | if (buffer == NULL) |
| 8214 | { |
| 8215 | return gl::error(GL_INVALID_OPERATION); |
| 8216 | } |
| 8217 | |
| 8218 | if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) |
| 8219 | { |
| 8220 | return gl::error(GL_INVALID_OPERATION); |
| 8221 | } |
| 8222 | |
| 8223 | // Check for buffer overflow |
| 8224 | size_t offsetSize = static_cast<size_t>(offset); |
| 8225 | size_t lengthSize = static_cast<size_t>(length); |
| 8226 | |
| 8227 | if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || |
| 8228 | offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength())) |
| 8229 | { |
| 8230 | return gl::error(GL_INVALID_VALUE); |
| 8231 | } |
| 8232 | |
| 8233 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8234 | } |
| 8235 | } |
| 8236 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8237 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 8238 | { |
| 8239 | struct Extension |
| 8240 | { |
| 8241 | const char *name; |
| 8242 | __eglMustCastToProperFunctionPointerType address; |
| 8243 | }; |
| 8244 | |
| 8245 | static const Extension glExtensions[] = |
| 8246 | { |
| 8247 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 8248 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 8249 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 8250 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 8251 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 8252 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 8253 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 8254 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 8255 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 8256 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 8257 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 8258 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 8259 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 8260 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 8261 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 8262 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 8263 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 8264 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 8265 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 8266 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 8267 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 8268 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 8269 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 8270 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 8271 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 8272 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 8273 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8274 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8275 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, |
| 8276 | {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES}, |
| 8277 | {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES}, |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8278 | {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES}, |
| 8279 | {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT}, |
| 8280 | {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8281 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 8282 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8283 | { |
| 8284 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 8285 | { |
| 8286 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 8287 | } |
| 8288 | } |
| 8289 | |
| 8290 | return NULL; |
| 8291 | } |
| 8292 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 8293 | // Non-public functions used by EGL |
| 8294 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 8295 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8296 | { |
| 8297 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 8298 | surface); |
| 8299 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8300 | gl::Context *context = gl::getNonLostContext(); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8301 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8302 | if (context) |
| 8303 | { |
| 8304 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 8305 | ASSERT(textureObject != NULL); |
| 8306 | |
| 8307 | if (textureObject->isImmutable()) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8308 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8309 | return false; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8310 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8311 | |
| 8312 | textureObject->bindTexImage(surface); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8313 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 8314 | |
| 8315 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8316 | } |
| 8317 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8318 | } |