daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions. |
| 8 | |
daniel@transgaming.com | a0ce7e6 | 2011-01-25 14:47:16 +0000 | [diff] [blame] | 9 | #include "common/version.h" |
Geoff Lang | 0b7eef7 | 2014-06-12 14:10:47 -0400 | [diff] [blame] | 10 | #include "common/utilities.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 11 | |
| 12 | #include "libGLESv2/main.h" |
shannonwoods@chromium.org | 8dcfc6a | 2013-05-30 00:09:48 +0000 | [diff] [blame] | 13 | #include "libGLESv2/formatutils.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 14 | #include "libGLESv2/Buffer.h" |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 15 | #include "libGLESv2/Fence.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 16 | #include "libGLESv2/Framebuffer.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 17 | #include "libGLESv2/Renderbuffer.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 18 | #include "libGLESv2/Program.h" |
apatrick@chromium.org | ea09f9b | 2012-06-08 00:45:32 +0000 | [diff] [blame] | 19 | #include "libGLESv2/ProgramBinary.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 20 | #include "libGLESv2/Texture.h" |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 21 | #include "libGLESv2/Query.h" |
shannon.woods@transgaming.com | 486d9e9 | 2013-02-28 23:15:41 +0000 | [diff] [blame] | 22 | #include "libGLESv2/Context.h" |
Jamie Madill | 57a8972 | 2013-07-02 11:57:03 -0400 | [diff] [blame] | 23 | #include "libGLESv2/VertexArray.h" |
Brandon Jones | 5bf9829 | 2014-06-06 17:19:38 -0700 | [diff] [blame] | 24 | #include "libGLESv2/VertexAttribute.h" |
Geoff Lang | c805845 | 2014-02-03 12:04:11 -0500 | [diff] [blame] | 25 | #include "libGLESv2/TransformFeedback.h" |
Jamie Madill | e261b44 | 2014-06-25 12:42:21 -0400 | [diff] [blame] | 26 | #include "libGLESv2/FramebufferAttachment.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 27 | |
Geoff Lang | e8ebe7f | 2013-08-05 15:03:13 -0400 | [diff] [blame] | 28 | #include "libGLESv2/validationES.h" |
| 29 | #include "libGLESv2/validationES2.h" |
| 30 | #include "libGLESv2/validationES3.h" |
Jamie Madill | 55856b1 | 2014-01-02 13:59:50 -0500 | [diff] [blame] | 31 | #include "libGLESv2/queryconversions.h" |
Jamie Madill | 478fdb2 | 2013-07-19 16:36:59 -0400 | [diff] [blame] | 32 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 33 | extern "C" |
| 34 | { |
| 35 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 36 | // OpenGL ES 2.0 functions |
| 37 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 38 | void __stdcall glActiveTexture(GLenum texture) |
| 39 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 40 | EVENT("(GLenum texture = 0x%X)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 42 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 43 | if (context) |
| 44 | { |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 45 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 46 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 47 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 48 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 49 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 50 | |
| 51 | context->getState().setActiveSampler(texture - GL_TEXTURE0); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
| 55 | void __stdcall glAttachShader(GLuint program, GLuint shader) |
| 56 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 57 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 58 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 59 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 60 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 61 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 62 | gl::Program *programObject = context->getProgram(program); |
| 63 | gl::Shader *shaderObject = context->getShader(shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 64 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 65 | if (!programObject) |
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 (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 68 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 69 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 70 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 71 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 72 | else |
| 73 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 74 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 75 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 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 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 83 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 84 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 85 | } |
| 86 | else |
| 87 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 88 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 89 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
| 93 | if (!programObject->attachShader(shaderObject)) |
| 94 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 95 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 96 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 97 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 101 | void __stdcall glBeginQueryEXT(GLenum target, GLuint id) |
| 102 | { |
| 103 | EVENT("(GLenum target = 0x%X, GLuint %d)", target, id); |
| 104 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 105 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 106 | if (context) |
| 107 | { |
| 108 | if (!ValidateBeginQuery(context, target, id)) |
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 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 111 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 112 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 113 | gl::Error error = context->beginQuery(target, id); |
| 114 | if (error.isError()) |
| 115 | { |
| 116 | context->recordError(error); |
| 117 | return; |
| 118 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 122 | void __stdcall glBindAttribLocation(GLuint program, GLuint index, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 124 | 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] | 125 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 126 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 127 | if (context) |
| 128 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 129 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 130 | { |
| 131 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 132 | return; |
| 133 | } |
| 134 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 135 | gl::Program *programObject = context->getProgram(program); |
| 136 | |
| 137 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 138 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 139 | if (context->getShader(program)) |
daniel@transgaming.com | 9807983 | 2010-04-13 03:26:29 +0000 | [diff] [blame] | 140 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 141 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 142 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 143 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 144 | else |
| 145 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 146 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 147 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 148 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 149 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 150 | |
| 151 | if (strncmp(name, "gl_", 3) == 0) |
| 152 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 153 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 154 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | programObject->bindAttributeLocation(index, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
| 161 | void __stdcall glBindBuffer(GLenum target, GLuint buffer) |
| 162 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 163 | EVENT("(GLenum target = 0x%X, GLuint buffer = %d)", target, buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 164 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 165 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 166 | if (context) |
| 167 | { |
| 168 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 169 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 170 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 171 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 172 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 173 | |
| 174 | switch (target) |
| 175 | { |
| 176 | case GL_ARRAY_BUFFER: |
| 177 | context->bindArrayBuffer(buffer); |
| 178 | return; |
| 179 | case GL_ELEMENT_ARRAY_BUFFER: |
| 180 | context->bindElementArrayBuffer(buffer); |
| 181 | return; |
| 182 | case GL_COPY_READ_BUFFER: |
| 183 | context->bindCopyReadBuffer(buffer); |
| 184 | return; |
| 185 | case GL_COPY_WRITE_BUFFER: |
| 186 | context->bindCopyWriteBuffer(buffer); |
| 187 | return; |
| 188 | case GL_PIXEL_PACK_BUFFER: |
| 189 | context->bindPixelPackBuffer(buffer); |
| 190 | return; |
| 191 | case GL_PIXEL_UNPACK_BUFFER: |
| 192 | context->bindPixelUnpackBuffer(buffer); |
| 193 | return; |
| 194 | case GL_UNIFORM_BUFFER: |
| 195 | context->bindGenericUniformBuffer(buffer); |
| 196 | return; |
| 197 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 198 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 199 | return; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 200 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 201 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 202 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 203 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 204 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 205 | } |
| 206 | } |
| 207 | |
| 208 | void __stdcall glBindFramebuffer(GLenum target, GLuint framebuffer) |
| 209 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 210 | EVENT("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 211 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 212 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 213 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 214 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 215 | if (!gl::ValidFramebufferTarget(target)) |
| 216 | { |
| 217 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 218 | return; |
| 219 | } |
| 220 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 221 | if (target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 222 | { |
| 223 | context->bindReadFramebuffer(framebuffer); |
| 224 | } |
| 225 | |
| 226 | if (target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER) |
| 227 | { |
| 228 | context->bindDrawFramebuffer(framebuffer); |
| 229 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
| 233 | void __stdcall glBindRenderbuffer(GLenum target, GLuint renderbuffer) |
| 234 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 235 | EVENT("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 236 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 237 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 238 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 239 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 240 | if (target != GL_RENDERBUFFER) |
| 241 | { |
| 242 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 243 | return; |
| 244 | } |
| 245 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 246 | context->bindRenderbuffer(renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
| 250 | void __stdcall glBindTexture(GLenum target, GLuint texture) |
| 251 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 252 | EVENT("(GLenum target = 0x%X, GLuint texture = %d)", target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 253 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 254 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 255 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 256 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 257 | gl::Texture *textureObject = context->getTexture(texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 258 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 259 | if (textureObject && textureObject->getTarget() != target && texture != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 260 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 261 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 262 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 263 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 264 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 265 | switch (target) |
| 266 | { |
| 267 | case GL_TEXTURE_2D: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 268 | case GL_TEXTURE_CUBE_MAP: |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 269 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 270 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 271 | case GL_TEXTURE_3D: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 272 | case GL_TEXTURE_2D_ARRAY: |
| 273 | if (context->getClientVersion() < 3) |
| 274 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 275 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 276 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 277 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 278 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 279 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 280 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 281 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 282 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 283 | } |
Geoff Lang | 76b10c9 | 2014-09-05 16:28:14 -0400 | [diff] [blame] | 284 | |
| 285 | context->bindTexture(target, texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 286 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | void __stdcall glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 290 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 291 | 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] | 292 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 293 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 294 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 295 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 296 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 297 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 298 | 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] | 299 | } |
| 300 | } |
| 301 | |
| 302 | void __stdcall glBlendEquation(GLenum mode) |
| 303 | { |
| 304 | glBlendEquationSeparate(mode, mode); |
| 305 | } |
| 306 | |
| 307 | void __stdcall glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) |
| 308 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 309 | EVENT("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 310 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 311 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 312 | if (context) |
| 313 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 314 | switch (modeRGB) |
| 315 | { |
| 316 | case GL_FUNC_ADD: |
| 317 | case GL_FUNC_SUBTRACT: |
| 318 | case GL_FUNC_REVERSE_SUBTRACT: |
| 319 | case GL_MIN: |
| 320 | case GL_MAX: |
| 321 | break; |
| 322 | |
| 323 | default: |
| 324 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | switch (modeAlpha) |
| 329 | { |
| 330 | case GL_FUNC_ADD: |
| 331 | case GL_FUNC_SUBTRACT: |
| 332 | case GL_FUNC_REVERSE_SUBTRACT: |
| 333 | case GL_MIN: |
| 334 | case GL_MAX: |
| 335 | break; |
| 336 | |
| 337 | default: |
| 338 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 339 | return; |
| 340 | } |
| 341 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 342 | context->getState().setBlendEquation(modeRGB, modeAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 343 | } |
| 344 | } |
| 345 | |
| 346 | void __stdcall glBlendFunc(GLenum sfactor, GLenum dfactor) |
| 347 | { |
| 348 | glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor); |
| 349 | } |
| 350 | |
| 351 | void __stdcall glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) |
| 352 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 353 | 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] | 354 | srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 355 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 356 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 357 | if (context) |
| 358 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 359 | switch (srcRGB) |
| 360 | { |
| 361 | case GL_ZERO: |
| 362 | case GL_ONE: |
| 363 | case GL_SRC_COLOR: |
| 364 | case GL_ONE_MINUS_SRC_COLOR: |
| 365 | case GL_DST_COLOR: |
| 366 | case GL_ONE_MINUS_DST_COLOR: |
| 367 | case GL_SRC_ALPHA: |
| 368 | case GL_ONE_MINUS_SRC_ALPHA: |
| 369 | case GL_DST_ALPHA: |
| 370 | case GL_ONE_MINUS_DST_ALPHA: |
| 371 | case GL_CONSTANT_COLOR: |
| 372 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 373 | case GL_CONSTANT_ALPHA: |
| 374 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 375 | case GL_SRC_ALPHA_SATURATE: |
| 376 | break; |
| 377 | |
| 378 | default: |
| 379 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 380 | return; |
| 381 | } |
| 382 | |
| 383 | switch (dstRGB) |
| 384 | { |
| 385 | case GL_ZERO: |
| 386 | case GL_ONE: |
| 387 | case GL_SRC_COLOR: |
| 388 | case GL_ONE_MINUS_SRC_COLOR: |
| 389 | case GL_DST_COLOR: |
| 390 | case GL_ONE_MINUS_DST_COLOR: |
| 391 | case GL_SRC_ALPHA: |
| 392 | case GL_ONE_MINUS_SRC_ALPHA: |
| 393 | case GL_DST_ALPHA: |
| 394 | case GL_ONE_MINUS_DST_ALPHA: |
| 395 | case GL_CONSTANT_COLOR: |
| 396 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 397 | case GL_CONSTANT_ALPHA: |
| 398 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 399 | break; |
| 400 | |
| 401 | case GL_SRC_ALPHA_SATURATE: |
| 402 | if (context->getClientVersion() < 3) |
| 403 | { |
| 404 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 405 | return; |
| 406 | } |
| 407 | break; |
| 408 | |
| 409 | default: |
| 410 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | switch (srcAlpha) |
| 415 | { |
| 416 | case GL_ZERO: |
| 417 | case GL_ONE: |
| 418 | case GL_SRC_COLOR: |
| 419 | case GL_ONE_MINUS_SRC_COLOR: |
| 420 | case GL_DST_COLOR: |
| 421 | case GL_ONE_MINUS_DST_COLOR: |
| 422 | case GL_SRC_ALPHA: |
| 423 | case GL_ONE_MINUS_SRC_ALPHA: |
| 424 | case GL_DST_ALPHA: |
| 425 | case GL_ONE_MINUS_DST_ALPHA: |
| 426 | case GL_CONSTANT_COLOR: |
| 427 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 428 | case GL_CONSTANT_ALPHA: |
| 429 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 430 | case GL_SRC_ALPHA_SATURATE: |
| 431 | break; |
| 432 | |
| 433 | default: |
| 434 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | switch (dstAlpha) |
| 439 | { |
| 440 | case GL_ZERO: |
| 441 | case GL_ONE: |
| 442 | case GL_SRC_COLOR: |
| 443 | case GL_ONE_MINUS_SRC_COLOR: |
| 444 | case GL_DST_COLOR: |
| 445 | case GL_ONE_MINUS_DST_COLOR: |
| 446 | case GL_SRC_ALPHA: |
| 447 | case GL_ONE_MINUS_SRC_ALPHA: |
| 448 | case GL_DST_ALPHA: |
| 449 | case GL_ONE_MINUS_DST_ALPHA: |
| 450 | case GL_CONSTANT_COLOR: |
| 451 | case GL_ONE_MINUS_CONSTANT_COLOR: |
| 452 | case GL_CONSTANT_ALPHA: |
| 453 | case GL_ONE_MINUS_CONSTANT_ALPHA: |
| 454 | break; |
| 455 | |
| 456 | case GL_SRC_ALPHA_SATURATE: |
| 457 | if (context->getClientVersion() < 3) |
| 458 | { |
| 459 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 460 | return; |
| 461 | } |
| 462 | break; |
| 463 | |
| 464 | default: |
| 465 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 466 | return; |
| 467 | } |
| 468 | |
| 469 | bool constantColorUsed = (srcRGB == GL_CONSTANT_COLOR || srcRGB == GL_ONE_MINUS_CONSTANT_COLOR || |
| 470 | dstRGB == GL_CONSTANT_COLOR || dstRGB == GL_ONE_MINUS_CONSTANT_COLOR); |
| 471 | |
| 472 | bool constantAlphaUsed = (srcRGB == GL_CONSTANT_ALPHA || srcRGB == GL_ONE_MINUS_CONSTANT_ALPHA || |
| 473 | dstRGB == GL_CONSTANT_ALPHA || dstRGB == GL_ONE_MINUS_CONSTANT_ALPHA); |
| 474 | |
| 475 | if (constantColorUsed && constantAlphaUsed) |
| 476 | { |
| 477 | ERR("Simultaneous use of GL_CONSTANT_ALPHA/GL_ONE_MINUS_CONSTANT_ALPHA and GL_CONSTANT_COLOR/GL_ONE_MINUS_CONSTANT_COLOR invalid under WebGL"); |
| 478 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 479 | return; |
| 480 | } |
| 481 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 482 | context->getState().setBlendFactors(srcRGB, dstRGB, srcAlpha, dstAlpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 483 | } |
| 484 | } |
| 485 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 486 | 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] | 487 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 488 | 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] | 489 | target, size, data, usage); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 490 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 491 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 492 | if (context) |
| 493 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 494 | if (size < 0) |
| 495 | { |
| 496 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 497 | return; |
| 498 | } |
| 499 | |
| 500 | switch (usage) |
| 501 | { |
| 502 | case GL_STREAM_DRAW: |
| 503 | case GL_STATIC_DRAW: |
| 504 | case GL_DYNAMIC_DRAW: |
| 505 | break; |
| 506 | |
| 507 | case GL_STREAM_READ: |
| 508 | case GL_STREAM_COPY: |
| 509 | case GL_STATIC_READ: |
| 510 | case GL_STATIC_COPY: |
| 511 | case GL_DYNAMIC_READ: |
| 512 | case GL_DYNAMIC_COPY: |
| 513 | if (context->getClientVersion() < 3) |
| 514 | { |
| 515 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 516 | return; |
| 517 | } |
| 518 | break; |
| 519 | |
| 520 | default: |
| 521 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 522 | return; |
| 523 | } |
| 524 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 525 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 526 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 527 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 528 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 529 | } |
| 530 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 531 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 532 | |
| 533 | if (!buffer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 534 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 535 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 536 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 537 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 538 | |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 539 | gl::Error error = buffer->bufferData(data, size, usage); |
| 540 | if (error.isError()) |
| 541 | { |
| 542 | context->recordError(error); |
| 543 | return; |
| 544 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 545 | } |
| 546 | } |
| 547 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 548 | 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] | 549 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 550 | 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] | 551 | target, offset, size, data); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 552 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 553 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 554 | if (context) |
| 555 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 556 | if (size < 0 || offset < 0) |
| 557 | { |
| 558 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 559 | return; |
| 560 | } |
| 561 | |
| 562 | if (data == NULL) |
| 563 | { |
| 564 | return; |
| 565 | } |
| 566 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 567 | if (!gl::ValidBufferTarget(context, target)) |
| 568 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 569 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 570 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 574 | |
| 575 | if (!buffer) |
| 576 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 577 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 578 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | if (buffer->isMapped()) |
| 582 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 583 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 584 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | // Check for possible overflow of size + offset |
| 588 | if (!rx::IsUnsignedAdditionSafe<size_t>(size, offset)) |
| 589 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 590 | context->recordError(gl::Error(GL_OUT_OF_MEMORY)); |
| 591 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | if (size + offset > buffer->getSize()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 595 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 596 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 597 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 600 | gl::Error error = buffer->bufferSubData(data, size, offset); |
| 601 | if (error.isError()) |
| 602 | { |
| 603 | context->recordError(error); |
| 604 | return; |
| 605 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 606 | } |
| 607 | } |
| 608 | |
| 609 | GLenum __stdcall glCheckFramebufferStatus(GLenum target) |
| 610 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 611 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 612 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 613 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 614 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 615 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 616 | if (!gl::ValidFramebufferTarget(target)) |
| 617 | { |
| 618 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 619 | return 0; |
| 620 | } |
| 621 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 622 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 623 | ASSERT(framebuffer); |
| 624 | return framebuffer->completeness(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | void __stdcall glClear(GLbitfield mask) |
| 631 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 632 | EVENT("(GLbitfield mask = 0x%X)", mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 633 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 634 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 635 | if (context) |
| 636 | { |
| 637 | gl::Framebuffer *framebufferObject = context->getState().getDrawFramebuffer(); |
| 638 | |
| 639 | if (!framebufferObject || framebufferObject->completeness() != GL_FRAMEBUFFER_COMPLETE) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 640 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 641 | context->recordError(gl::Error(GL_INVALID_FRAMEBUFFER_OPERATION)); |
| 642 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 643 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 644 | |
| 645 | if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) |
| 646 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 647 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 648 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 649 | } |
| 650 | |
Geoff Lang | cc79b8c | 2014-07-25 13:48:02 -0400 | [diff] [blame] | 651 | gl::Error error = context->clear(mask); |
| 652 | if (error.isError()) |
| 653 | { |
| 654 | context->recordError(error); |
| 655 | return; |
| 656 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 657 | } |
| 658 | } |
| 659 | |
| 660 | void __stdcall glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) |
| 661 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 662 | 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] | 663 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 664 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 665 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 666 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 667 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 668 | context->getState().setClearColor(red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
| 672 | void __stdcall glClearDepthf(GLclampf depth) |
| 673 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 674 | EVENT("(GLclampf depth = %f)", depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 675 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 676 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 677 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 678 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 679 | context->getState().setClearDepth(depth); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 680 | } |
| 681 | } |
| 682 | |
| 683 | void __stdcall glClearStencil(GLint s) |
| 684 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 685 | EVENT("(GLint s = %d)", s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 686 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 687 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 688 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 689 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 690 | context->getState().setClearStencil(s); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 691 | } |
| 692 | } |
| 693 | |
| 694 | void __stdcall glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) |
| 695 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 696 | 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] | 697 | red, green, blue, alpha); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 698 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 699 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 700 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 701 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 702 | 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] | 703 | } |
| 704 | } |
| 705 | |
| 706 | void __stdcall glCompileShader(GLuint shader) |
| 707 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 708 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 709 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 710 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 711 | if (context) |
| 712 | { |
| 713 | gl::Shader *shaderObject = context->getShader(shader); |
| 714 | |
| 715 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 716 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 717 | if (context->getProgram(shader)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 718 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 719 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 720 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 721 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 722 | else |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 723 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 724 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 725 | return; |
daniel@transgaming.com | 5d752f2 | 2010-10-07 13:37:20 +0000 | [diff] [blame] | 726 | } |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 727 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 728 | |
| 729 | shaderObject->compile(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 730 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | void __stdcall glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, |
| 734 | GLint border, GLsizei imageSize, const GLvoid* data) |
| 735 | { |
| 736 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 737 | "GLsizei height = %d, GLint border = %d, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 738 | target, level, internalformat, width, height, border, imageSize, data); |
| 739 | |
| 740 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 741 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 742 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 743 | if (context->getClientVersion() < 3 && |
| 744 | !ValidateES2TexImageParameters(context, target, level, internalformat, true, false, |
| 745 | 0, 0, width, height, border, GL_NONE, GL_NONE, data)) |
| 746 | { |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | if (context->getClientVersion() >= 3 && |
| 751 | !ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 752 | 0, 0, 0, width, height, 1, border, GL_NONE, GL_NONE, data)) |
| 753 | { |
| 754 | return; |
| 755 | } |
| 756 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 757 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
| 758 | 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] | 759 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 760 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 761 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 762 | } |
| 763 | |
| 764 | switch (target) |
| 765 | { |
| 766 | case GL_TEXTURE_2D: |
| 767 | { |
| 768 | gl::Texture2D *texture = context->getTexture2D(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 769 | gl::Error error = texture->setCompressedImage(level, internalformat, width, height, imageSize, data); |
| 770 | if (error.isError()) |
| 771 | { |
| 772 | context->recordError(error); |
| 773 | return; |
| 774 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 775 | } |
| 776 | break; |
| 777 | |
| 778 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 779 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 780 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 781 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 782 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 783 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 784 | { |
| 785 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 786 | gl::Error error = texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data); |
| 787 | if (error.isError()) |
| 788 | { |
| 789 | context->recordError(error); |
| 790 | return; |
| 791 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 792 | } |
| 793 | break; |
| 794 | |
| 795 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 796 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 797 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 798 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 799 | } |
| 800 | } |
| 801 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 802 | void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 803 | GLenum format, GLsizei imageSize, const GLvoid* data) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 804 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 805 | 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] | 806 | "GLsizei width = %d, GLsizei height = %d, GLenum format = 0x%X, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 807 | "GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 808 | target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 809 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 810 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 811 | if (context) |
| 812 | { |
| 813 | if (context->getClientVersion() < 3 && |
| 814 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, |
| 815 | xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 816 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 817 | return; |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 818 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 819 | |
| 820 | if (context->getClientVersion() >= 3 && |
| 821 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 822 | xoffset, yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE, data)) |
| 823 | { |
| 824 | return; |
| 825 | } |
| 826 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 827 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format); |
| 828 | 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] | 829 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 830 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 831 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | switch (target) |
| 835 | { |
| 836 | case GL_TEXTURE_2D: |
| 837 | { |
| 838 | gl::Texture2D *texture = context->getTexture2D(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 839 | gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); |
| 840 | if (error.isError()) |
| 841 | { |
| 842 | context->recordError(error); |
| 843 | return; |
| 844 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 845 | } |
| 846 | break; |
| 847 | |
| 848 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 849 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 850 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 851 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 852 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 853 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 854 | { |
| 855 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 856 | gl::Error error = texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 857 | if (error.isError()) |
| 858 | { |
| 859 | context->recordError(error); |
| 860 | return; |
| 861 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 862 | } |
| 863 | break; |
| 864 | |
| 865 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 866 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 867 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 868 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 869 | } |
| 870 | } |
| 871 | |
| 872 | void __stdcall glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
| 873 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 874 | 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] | 875 | "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] | 876 | target, level, internalformat, x, y, width, height, border); |
| 877 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 878 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 879 | if (context) |
| 880 | { |
| 881 | if (context->getClientVersion() < 3 && |
| 882 | !ValidateES2CopyTexImageParameters(context, target, level, internalformat, false, |
| 883 | 0, 0, x, y, width, height, border)) |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 884 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 885 | return; |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 886 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 887 | |
| 888 | if (context->getClientVersion() >= 3 && |
| 889 | !ValidateES3CopyTexImageParameters(context, target, level, internalformat, false, |
| 890 | 0, 0, 0, x, y, width, height, border)) |
| 891 | { |
| 892 | return; |
| 893 | } |
| 894 | |
| 895 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 896 | |
| 897 | switch (target) |
| 898 | { |
| 899 | case GL_TEXTURE_2D: |
| 900 | { |
| 901 | gl::Texture2D *texture = context->getTexture2D(); |
| 902 | texture->copyImage(level, internalformat, x, y, width, height, framebuffer); |
| 903 | } |
| 904 | break; |
| 905 | |
| 906 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 907 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 908 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 909 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 910 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 911 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 912 | { |
| 913 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 914 | texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer); |
| 915 | } |
| 916 | break; |
| 917 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 918 | default: |
| 919 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 920 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 921 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 922 | } |
| 923 | } |
| 924 | |
| 925 | void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 926 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 927 | 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] | 928 | "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] | 929 | target, level, xoffset, yoffset, x, y, width, height); |
| 930 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 931 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 932 | if (context) |
| 933 | { |
| 934 | if (context->getClientVersion() < 3 && |
| 935 | !ValidateES2CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 936 | xoffset, yoffset, x, y, width, height, 0)) |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 937 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 938 | return; |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 939 | } |
daniel@transgaming.com | b8c28ed | 2010-04-13 03:26:32 +0000 | [diff] [blame] | 940 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 941 | if (context->getClientVersion() >= 3 && |
| 942 | !ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, |
| 943 | xoffset, yoffset, 0, x, y, width, height, 0)) |
| 944 | { |
| 945 | return; |
| 946 | } |
| 947 | |
| 948 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 949 | |
| 950 | switch (target) |
| 951 | { |
| 952 | case GL_TEXTURE_2D: |
| 953 | { |
| 954 | gl::Texture2D *texture = context->getTexture2D(); |
| 955 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
| 956 | } |
| 957 | break; |
| 958 | |
| 959 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 960 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 961 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 962 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 963 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 964 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 965 | { |
| 966 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
| 967 | texture->copySubImage(target, level, xoffset, yoffset, 0, x, y, width, height, framebuffer); |
| 968 | } |
| 969 | break; |
| 970 | |
| 971 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 972 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 973 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 974 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 975 | } |
| 976 | } |
| 977 | |
| 978 | GLuint __stdcall glCreateProgram(void) |
| 979 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 980 | EVENT("()"); |
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 | gl::Context *context = gl::getNonLostContext(); |
| 983 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 984 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 985 | return context->createProgram(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | GLuint __stdcall glCreateShader(GLenum type) |
| 992 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 993 | EVENT("(GLenum type = 0x%X)", type); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 994 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 995 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 996 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 997 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 998 | switch (type) |
| 999 | { |
| 1000 | case GL_FRAGMENT_SHADER: |
| 1001 | case GL_VERTEX_SHADER: |
| 1002 | return context->createShader(type); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1003 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1004 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1005 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1006 | return 0; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1007 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
| 1013 | void __stdcall glCullFace(GLenum mode) |
| 1014 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1015 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1016 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1017 | gl::Context *context = gl::getNonLostContext(); |
| 1018 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1019 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1020 | switch (mode) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1021 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1022 | case GL_FRONT: |
| 1023 | case GL_BACK: |
| 1024 | case GL_FRONT_AND_BACK: |
| 1025 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1026 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1027 | default: |
| 1028 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1029 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1030 | } |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1031 | |
| 1032 | context->getState().setCullMode(mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | void __stdcall glDeleteBuffers(GLsizei n, const GLuint* buffers) |
| 1037 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1038 | 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] | 1039 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1040 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1041 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1042 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1043 | if (n < 0) |
| 1044 | { |
| 1045 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1046 | return; |
| 1047 | } |
| 1048 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1049 | for (int i = 0; i < n; i++) |
| 1050 | { |
| 1051 | context->deleteBuffer(buffers[i]); |
| 1052 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1053 | } |
| 1054 | } |
| 1055 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1056 | void __stdcall glDeleteFencesNV(GLsizei n, const GLuint* fences) |
| 1057 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1058 | 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] | 1059 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1060 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1061 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1062 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1063 | if (n < 0) |
| 1064 | { |
| 1065 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1066 | return; |
| 1067 | } |
| 1068 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1069 | for (int i = 0; i < n; i++) |
| 1070 | { |
| 1071 | context->deleteFenceNV(fences[i]); |
| 1072 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1073 | } |
| 1074 | } |
| 1075 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1076 | void __stdcall glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) |
| 1077 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1078 | 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] | 1079 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1080 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1081 | if (context) |
| 1082 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1083 | if (n < 0) |
| 1084 | { |
| 1085 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1086 | return; |
| 1087 | } |
| 1088 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1089 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1090 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1091 | if (framebuffers[i] != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1092 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1093 | context->deleteFramebuffer(framebuffers[i]); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1094 | } |
| 1095 | } |
| 1096 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | void __stdcall glDeleteProgram(GLuint program) |
| 1100 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1101 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1102 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1103 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1104 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1105 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1106 | if (program == 0) |
| 1107 | { |
| 1108 | return; |
| 1109 | } |
| 1110 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1111 | if (!context->getProgram(program)) |
| 1112 | { |
| 1113 | if(context->getShader(program)) |
| 1114 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1115 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1116 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1117 | } |
| 1118 | else |
| 1119 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1120 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1121 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1122 | } |
| 1123 | } |
| 1124 | |
| 1125 | context->deleteProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1126 | } |
| 1127 | } |
| 1128 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1129 | void __stdcall glDeleteQueriesEXT(GLsizei n, const GLuint *ids) |
| 1130 | { |
| 1131 | EVENT("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids); |
| 1132 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1133 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1134 | if (context) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1135 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1136 | if (n < 0) |
| 1137 | { |
| 1138 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1139 | return; |
| 1140 | } |
| 1141 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1142 | for (int i = 0; i < n; i++) |
| 1143 | { |
| 1144 | context->deleteQuery(ids[i]); |
| 1145 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1146 | } |
| 1147 | } |
| 1148 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1149 | void __stdcall glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) |
| 1150 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1151 | 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] | 1152 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1153 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1154 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1155 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1156 | if (n < 0) |
| 1157 | { |
| 1158 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1159 | return; |
| 1160 | } |
| 1161 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1162 | for (int i = 0; i < n; i++) |
| 1163 | { |
| 1164 | context->deleteRenderbuffer(renderbuffers[i]); |
| 1165 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | void __stdcall glDeleteShader(GLuint shader) |
| 1170 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1171 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1172 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1173 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1174 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1175 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1176 | if (shader == 0) |
| 1177 | { |
| 1178 | return; |
| 1179 | } |
| 1180 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1181 | if (!context->getShader(shader)) |
| 1182 | { |
| 1183 | if(context->getProgram(shader)) |
| 1184 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1185 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1186 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1187 | } |
| 1188 | else |
| 1189 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1190 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1191 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | context->deleteShader(shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | void __stdcall glDeleteTextures(GLsizei n, const GLuint* textures) |
| 1200 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1201 | 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] | 1202 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1203 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1204 | if (context) |
| 1205 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1206 | if (n < 0) |
| 1207 | { |
| 1208 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1209 | return; |
| 1210 | } |
| 1211 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1212 | for (int i = 0; i < n; i++) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1213 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1214 | if (textures[i] != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1215 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1216 | context->deleteTexture(textures[i]); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1217 | } |
| 1218 | } |
| 1219 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | void __stdcall glDepthFunc(GLenum func) |
| 1223 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1224 | EVENT("(GLenum func = 0x%X)", func); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1225 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1226 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1227 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1228 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1229 | switch (func) |
| 1230 | { |
| 1231 | case GL_NEVER: |
| 1232 | case GL_ALWAYS: |
| 1233 | case GL_LESS: |
| 1234 | case GL_LEQUAL: |
| 1235 | case GL_EQUAL: |
| 1236 | case GL_GREATER: |
| 1237 | case GL_GEQUAL: |
| 1238 | case GL_NOTEQUAL: |
| 1239 | context->getState().setDepthFunc(func); |
| 1240 | break; |
| 1241 | |
| 1242 | default: |
| 1243 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1244 | return; |
| 1245 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | void __stdcall glDepthMask(GLboolean flag) |
| 1250 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 1251 | EVENT("(GLboolean flag = %u)", flag); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1252 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1253 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1254 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1255 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1256 | context->getState().setDepthMask(flag != GL_FALSE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | void __stdcall glDepthRangef(GLclampf zNear, GLclampf zFar) |
| 1261 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1262 | EVENT("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1263 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1264 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1265 | if (context) |
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 | context->getState().setDepthRange(zNear, zFar); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | void __stdcall glDetachShader(GLuint program, GLuint shader) |
| 1272 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1273 | EVENT("(GLuint program = %d, GLuint shader = %d)", program, shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1274 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1275 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1276 | if (context) |
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 | gl::Program *programObject = context->getProgram(program); |
| 1279 | gl::Shader *shaderObject = context->getShader(shader); |
| 1280 | |
| 1281 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1282 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1283 | gl::Shader *shaderByProgramHandle; |
| 1284 | shaderByProgramHandle = context->getShader(program); |
| 1285 | if (!shaderByProgramHandle) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1286 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1287 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1288 | return; |
daniel@transgaming.com | 73c2c2e | 2010-04-13 03:26:11 +0000 | [diff] [blame] | 1289 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1290 | else |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1291 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1292 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1293 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1294 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1295 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1296 | |
| 1297 | if (!shaderObject) |
| 1298 | { |
| 1299 | gl::Program *programByShaderHandle = context->getProgram(shader); |
| 1300 | if (!programByShaderHandle) |
| 1301 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1302 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1303 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1304 | } |
| 1305 | else |
| 1306 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1307 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1308 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | if (!programObject->detachShader(shaderObject)) |
| 1313 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1314 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1315 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1316 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | void __stdcall glDisable(GLenum cap) |
| 1321 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1322 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1323 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1324 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1325 | if (context) |
| 1326 | { |
| 1327 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1328 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1329 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1330 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1331 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1332 | |
| 1333 | context->getState().setEnableFeature(cap, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1334 | } |
| 1335 | } |
| 1336 | |
| 1337 | void __stdcall glDisableVertexAttribArray(GLuint index) |
| 1338 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1339 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1340 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1341 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1342 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1343 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1344 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1345 | { |
| 1346 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1347 | return; |
| 1348 | } |
| 1349 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1350 | context->getState().setEnableVertexAttribArray(index, false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | void __stdcall glDrawArrays(GLenum mode, GLint first, GLsizei count) |
| 1355 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1356 | 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] | 1357 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1358 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1359 | if (context) |
| 1360 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1361 | if (!ValidateDrawArrays(context, mode, first, count, 0)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1362 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1363 | return; |
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 | |
Geoff Lang | c77e8c3 | 2014-09-08 16:28:24 -0400 | [diff] [blame] | 1366 | gl::Error error = context->drawArrays(mode, first, count, 0); |
| 1367 | if (error.isError()) |
| 1368 | { |
| 1369 | context->recordError(error); |
| 1370 | return; |
| 1371 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1372 | } |
| 1373 | } |
| 1374 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1375 | void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei count, GLsizei primcount) |
| 1376 | { |
| 1377 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei primcount = %d)", mode, first, count, primcount); |
| 1378 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1379 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1380 | if (context) |
| 1381 | { |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1382 | if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount)) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1383 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1384 | return; |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1385 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1386 | |
Geoff Lang | c77e8c3 | 2014-09-08 16:28:24 -0400 | [diff] [blame] | 1387 | gl::Error error = context->drawArrays(mode, first, count, primcount); |
| 1388 | if (error.isError()) |
| 1389 | { |
| 1390 | context->recordError(error); |
| 1391 | return; |
| 1392 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1393 | } |
| 1394 | } |
| 1395 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1396 | 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] | 1397 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1398 | 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] | 1399 | mode, count, type, indices); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1400 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1401 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1402 | if (context) |
| 1403 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1404 | rx::RangeUI indexRange; |
| 1405 | if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1406 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1407 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1408 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1409 | |
Geoff Lang | c77e8c3 | 2014-09-08 16:28:24 -0400 | [diff] [blame] | 1410 | gl::Error error = context->drawElements(mode, count, type, indices, 0, indexRange); |
| 1411 | if (error.isError()) |
| 1412 | { |
| 1413 | context->recordError(error); |
| 1414 | return; |
| 1415 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1416 | } |
| 1417 | } |
| 1418 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1419 | void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) |
| 1420 | { |
| 1421 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei primcount = %d)", |
| 1422 | mode, count, type, indices, primcount); |
| 1423 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1424 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1425 | if (context) |
| 1426 | { |
Jamie Madill | 2b97681 | 2014-08-25 15:47:49 -0400 | [diff] [blame] | 1427 | rx::RangeUI indexRange; |
Geoff Lang | 87a9330 | 2014-09-16 13:29:43 -0400 | [diff] [blame] | 1428 | if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange)) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1429 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1430 | return; |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1431 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1432 | |
Geoff Lang | c77e8c3 | 2014-09-08 16:28:24 -0400 | [diff] [blame] | 1433 | gl::Error error = context->drawElements(mode, count, type, indices, primcount, indexRange); |
| 1434 | if (error.isError()) |
| 1435 | { |
| 1436 | context->recordError(error); |
| 1437 | return; |
| 1438 | } |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 1439 | } |
| 1440 | } |
| 1441 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1442 | void __stdcall glEnable(GLenum cap) |
| 1443 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1444 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1445 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1446 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1447 | if (context) |
| 1448 | { |
| 1449 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1450 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1451 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1452 | return; |
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 | |
| 1455 | context->getState().setEnableFeature(cap, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1456 | } |
| 1457 | } |
| 1458 | |
| 1459 | void __stdcall glEnableVertexAttribArray(GLuint index) |
| 1460 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1461 | EVENT("(GLuint index = %d)", index); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1462 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1463 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1464 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1465 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1466 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 1467 | { |
| 1468 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1469 | return; |
| 1470 | } |
| 1471 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1472 | context->getState().setEnableVertexAttribArray(index, true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1473 | } |
| 1474 | } |
| 1475 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1476 | void __stdcall glEndQueryEXT(GLenum target) |
| 1477 | { |
| 1478 | EVENT("GLenum target = 0x%X)", target); |
| 1479 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1480 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1481 | if (context) |
| 1482 | { |
| 1483 | if (!ValidateEndQuery(context, target)) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1484 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1485 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1486 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1487 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 1488 | gl::Error error = context->endQuery(target); |
| 1489 | if (error.isError()) |
| 1490 | { |
| 1491 | context->recordError(error); |
| 1492 | return; |
| 1493 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1494 | } |
| 1495 | } |
| 1496 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1497 | void __stdcall glFinishFenceNV(GLuint fence) |
| 1498 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1499 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1500 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1501 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1502 | if (context) |
| 1503 | { |
| 1504 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 1505 | |
| 1506 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1507 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1508 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1509 | return; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1510 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1511 | |
| 1512 | if (fenceObject->isFence() != GL_TRUE) |
| 1513 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1514 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1515 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1516 | } |
| 1517 | |
| 1518 | fenceObject->finishFence(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1519 | } |
| 1520 | } |
| 1521 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1522 | void __stdcall glFinish(void) |
| 1523 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1524 | EVENT("()"); |
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::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1527 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1528 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1529 | context->sync(true); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | void __stdcall glFlush(void) |
| 1534 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1535 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1536 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1537 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1538 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1539 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1540 | context->sync(false); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | void __stdcall glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) |
| 1545 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1546 | 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] | 1547 | "GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer); |
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 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1550 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1551 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1552 | if (!gl::ValidFramebufferTarget(target) || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0)) |
| 1553 | { |
| 1554 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1555 | return; |
| 1556 | } |
| 1557 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1558 | if (!gl::ValidateFramebufferRenderbufferParameters(context, target, attachment, renderbuffertarget, renderbuffer)) |
| 1559 | { |
| 1560 | return; |
| 1561 | } |
| 1562 | |
| 1563 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 1564 | ASSERT(framebuffer); |
| 1565 | |
| 1566 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 1567 | { |
| 1568 | unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 1569 | framebuffer->setColorbuffer(colorAttachment, GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1570 | } |
| 1571 | else |
| 1572 | { |
| 1573 | switch (attachment) |
| 1574 | { |
| 1575 | case GL_DEPTH_ATTACHMENT: |
| 1576 | framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1577 | break; |
| 1578 | case GL_STENCIL_ATTACHMENT: |
| 1579 | framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1580 | break; |
| 1581 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 1582 | framebuffer->setDepthStencilBuffer(GL_RENDERBUFFER, renderbuffer, 0, 0); |
| 1583 | break; |
| 1584 | default: |
| 1585 | UNREACHABLE(); |
| 1586 | break; |
| 1587 | } |
| 1588 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | void __stdcall glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) |
| 1593 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1594 | 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] | 1595 | "GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1596 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1597 | gl::Context *context = gl::getNonLostContext(); |
| 1598 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1599 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1600 | if (!ValidateFramebufferTexture2D(context, target, attachment, textarget, texture, level)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1601 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1602 | return; |
| 1603 | } |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 1604 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1605 | if (texture == 0) |
| 1606 | { |
| 1607 | textarget = GL_NONE; |
| 1608 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1609 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1610 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1611 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1612 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 1613 | { |
| 1614 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 1615 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, 0); |
| 1616 | } |
| 1617 | else |
| 1618 | { |
| 1619 | switch (attachment) |
daniel@transgaming.com | fbc0953 | 2010-04-26 15:33:41 +0000 | [diff] [blame] | 1620 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1621 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, 0); break; |
| 1622 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, 0); break; |
| 1623 | 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] | 1624 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1625 | } |
| 1626 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1627 | } |
| 1628 | |
| 1629 | void __stdcall glFrontFace(GLenum mode) |
| 1630 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1631 | EVENT("(GLenum mode = 0x%X)", mode); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1632 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1633 | gl::Context *context = gl::getNonLostContext(); |
| 1634 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1635 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1636 | switch (mode) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1637 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1638 | case GL_CW: |
| 1639 | case GL_CCW: |
| 1640 | context->getState().setFrontFace(mode); |
| 1641 | break; |
| 1642 | default: |
| 1643 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1644 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1645 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1646 | } |
| 1647 | } |
| 1648 | |
| 1649 | void __stdcall glGenBuffers(GLsizei n, GLuint* buffers) |
| 1650 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1651 | EVENT("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1652 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1653 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1654 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1655 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1656 | if (n < 0) |
| 1657 | { |
| 1658 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1659 | return; |
| 1660 | } |
| 1661 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1662 | for (int i = 0; i < n; i++) |
| 1663 | { |
| 1664 | buffers[i] = context->createBuffer(); |
| 1665 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1666 | } |
| 1667 | } |
| 1668 | |
| 1669 | void __stdcall glGenerateMipmap(GLenum target) |
| 1670 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1671 | EVENT("(GLenum target = 0x%X)", target); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1672 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1673 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1674 | if (context) |
| 1675 | { |
| 1676 | if (!ValidTextureTarget(context, target)) |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 1677 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1678 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 1679 | return; |
daniel@transgaming.com | 8fd99e2 | 2010-04-20 18:52:00 +0000 | [diff] [blame] | 1680 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1681 | |
| 1682 | gl::Texture *texture = context->getTargetTexture(target); |
| 1683 | |
| 1684 | if (texture == NULL) |
| 1685 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1686 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1687 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | GLenum internalFormat = texture->getBaseLevelInternalFormat(); |
| 1691 | const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1692 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1693 | |
| 1694 | // GenerateMipmap should not generate an INVALID_OPERATION for textures created with |
| 1695 | // unsized formats or that are color renderable and filterable. Since we do not track if |
| 1696 | // the texture was created with sized or unsized format (only sized formats are stored), |
| 1697 | // it is not possible to make sure the the LUMA formats can generate mipmaps (they should |
| 1698 | // be able to) because they aren't color renderable. Simply do a special case for LUMA |
| 1699 | // textures since they're the only texture format that can be created with unsized formats |
| 1700 | // that is not color renderable. New unsized formats are unlikely to be added, since ES2 |
| 1701 | // was the last version to use add them. |
| 1702 | bool isLUMA = internalFormat == GL_LUMINANCE8_EXT || |
| 1703 | internalFormat == GL_LUMINANCE8_ALPHA8_EXT || |
| 1704 | internalFormat == GL_ALPHA8_EXT; |
| 1705 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1706 | if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0 || !formatCaps.filterable || |
| 1707 | (!formatCaps.renderable && !isLUMA) || formatInfo.compressed) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1708 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1709 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1710 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1711 | } |
| 1712 | |
| 1713 | // GL_EXT_sRGB does not support mipmap generation on sRGB textures |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1714 | if (context->getClientVersion() == 2 && formatInfo.colorEncoding == GL_SRGB) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1715 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1716 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1717 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1718 | } |
| 1719 | |
| 1720 | // Non-power of 2 ES2 check |
| 1721 | if (!context->getExtensions().textureNPOT && (!gl::isPow2(texture->getBaseLevelWidth()) || !gl::isPow2(texture->getBaseLevelHeight()))) |
| 1722 | { |
| 1723 | ASSERT(context->getClientVersion() <= 2 && (target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP)); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1724 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1725 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1726 | } |
| 1727 | |
| 1728 | // Cube completeness check |
| 1729 | if (target == GL_TEXTURE_CUBE_MAP) |
| 1730 | { |
| 1731 | gl::TextureCubeMap *textureCube = static_cast<gl::TextureCubeMap *>(texture); |
| 1732 | if (!textureCube->isCubeComplete()) |
| 1733 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1734 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1735 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | texture->generateMipmaps(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1743 | void __stdcall glGenFencesNV(GLsizei n, GLuint* fences) |
| 1744 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1745 | EVENT("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1746 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1747 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1748 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1749 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1750 | if (n < 0) |
| 1751 | { |
| 1752 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1753 | return; |
| 1754 | } |
| 1755 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1756 | for (int i = 0; i < n; i++) |
| 1757 | { |
| 1758 | fences[i] = context->createFenceNV(); |
| 1759 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 1760 | } |
| 1761 | } |
| 1762 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1763 | void __stdcall glGenFramebuffers(GLsizei n, GLuint* framebuffers) |
| 1764 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1765 | EVENT("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1766 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1767 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1768 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1769 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1770 | if (n < 0) |
| 1771 | { |
| 1772 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1773 | return; |
| 1774 | } |
| 1775 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1776 | for (int i = 0; i < n; i++) |
| 1777 | { |
| 1778 | framebuffers[i] = context->createFramebuffer(); |
| 1779 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1780 | } |
| 1781 | } |
| 1782 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1783 | void __stdcall glGenQueriesEXT(GLsizei n, GLuint* ids) |
| 1784 | { |
| 1785 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 1786 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1787 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1788 | if (context) |
| 1789 | { |
| 1790 | if (n < 0) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1791 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1792 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1793 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1794 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1795 | |
| 1796 | for (GLsizei i = 0; i < n; i++) |
| 1797 | { |
| 1798 | ids[i] = context->createQuery(); |
| 1799 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 1800 | } |
| 1801 | } |
| 1802 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1803 | void __stdcall glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) |
| 1804 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1805 | EVENT("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1806 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1807 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1808 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1809 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1810 | if (n < 0) |
| 1811 | { |
| 1812 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1813 | return; |
| 1814 | } |
| 1815 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1816 | for (int i = 0; i < n; i++) |
| 1817 | { |
| 1818 | renderbuffers[i] = context->createRenderbuffer(); |
| 1819 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | void __stdcall glGenTextures(GLsizei n, GLuint* textures) |
| 1824 | { |
Jamie Madill | 1fc7e2c | 2014-01-21 16:47:10 -0500 | [diff] [blame] | 1825 | EVENT("(GLsizei n = %d, GLuint* textures = 0x%0.8p)", n, textures); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1826 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1827 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1828 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1829 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1830 | if (n < 0) |
| 1831 | { |
| 1832 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1833 | return; |
| 1834 | } |
| 1835 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1836 | for (int i = 0; i < n; i++) |
| 1837 | { |
| 1838 | textures[i] = context->createTexture(); |
| 1839 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1840 | } |
| 1841 | } |
| 1842 | |
daniel@transgaming.com | 8542318 | 2010-04-22 13:35:27 +0000 | [diff] [blame] | 1843 | 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] | 1844 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1845 | 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] | 1846 | "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] | 1847 | program, index, bufsize, length, size, type, name); |
| 1848 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1849 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1850 | if (context) |
| 1851 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1852 | if (bufsize < 0) |
| 1853 | { |
| 1854 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1855 | return; |
| 1856 | } |
| 1857 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1858 | gl::Program *programObject = context->getProgram(program); |
| 1859 | |
| 1860 | if (!programObject) |
| 1861 | { |
| 1862 | if (context->getShader(program)) |
| 1863 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1864 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1865 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1866 | } |
| 1867 | else |
| 1868 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1869 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1870 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1871 | } |
| 1872 | } |
| 1873 | |
| 1874 | if (index >= (GLuint)programObject->getActiveAttributeCount()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1875 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1876 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1877 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1878 | } |
| 1879 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1880 | programObject->getActiveAttribute(index, bufsize, length, size, type, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1881 | } |
| 1882 | } |
| 1883 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1884 | 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] | 1885 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1886 | EVENT("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, " |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 1887 | "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] | 1888 | program, index, bufsize, length, size, type, name); |
| 1889 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1890 | |
| 1891 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1892 | if (context) |
| 1893 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1894 | if (bufsize < 0) |
| 1895 | { |
| 1896 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1897 | return; |
| 1898 | } |
| 1899 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1900 | gl::Program *programObject = context->getProgram(program); |
| 1901 | |
| 1902 | if (!programObject) |
| 1903 | { |
| 1904 | if (context->getShader(program)) |
| 1905 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1906 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1907 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1908 | } |
| 1909 | else |
| 1910 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1911 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1912 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1913 | } |
| 1914 | } |
| 1915 | |
| 1916 | if (index >= (GLuint)programObject->getActiveUniformCount()) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1917 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1918 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1919 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1920 | } |
| 1921 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1922 | programObject->getActiveUniform(index, bufsize, length, size, type, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1923 | } |
| 1924 | } |
| 1925 | |
| 1926 | void __stdcall glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) |
| 1927 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1928 | 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] | 1929 | program, maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1930 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1931 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1932 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1933 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1934 | if (maxcount < 0) |
| 1935 | { |
| 1936 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1937 | return; |
| 1938 | } |
| 1939 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1940 | gl::Program *programObject = context->getProgram(program); |
| 1941 | |
| 1942 | if (!programObject) |
| 1943 | { |
| 1944 | if (context->getShader(program)) |
| 1945 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1946 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1947 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1948 | } |
| 1949 | else |
| 1950 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1951 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1952 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1953 | } |
| 1954 | } |
| 1955 | |
| 1956 | return programObject->getAttachedShaders(maxcount, count, shaders); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1957 | } |
| 1958 | } |
| 1959 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1960 | GLint __stdcall glGetAttribLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1961 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1962 | EVENT("(GLuint program = %d, const GLchar* name = %s)", program, name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1963 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1964 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1965 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1966 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1967 | gl::Program *programObject = context->getProgram(program); |
| 1968 | |
| 1969 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1970 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1971 | if (context->getShader(program)) |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 1972 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1973 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1974 | return -1; |
daniel@transgaming.com | cf4aa87 | 2010-04-13 03:26:27 +0000 | [diff] [blame] | 1975 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1976 | else |
| 1977 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1978 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 1979 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1980 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1981 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1982 | |
| 1983 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 1984 | if (!programObject->isLinked() || !programBinary) |
| 1985 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 1986 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 1987 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 1988 | } |
| 1989 | |
| 1990 | return programBinary->getAttributeLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1991 | } |
| 1992 | |
| 1993 | return -1; |
| 1994 | } |
| 1995 | |
| 1996 | void __stdcall glGetBooleanv(GLenum pname, GLboolean* params) |
| 1997 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 1998 | 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] | 1999 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2000 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2001 | if (context) |
| 2002 | { |
| 2003 | GLenum nativeType; |
| 2004 | unsigned int numParams = 0; |
| 2005 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2006 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2007 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2008 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2009 | |
| 2010 | if (nativeType == GL_BOOL) |
| 2011 | { |
| 2012 | context->getBooleanv(pname, params); |
| 2013 | } |
| 2014 | else |
| 2015 | { |
| 2016 | CastStateValues(context, nativeType, pname, numParams, params); |
| 2017 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2018 | } |
| 2019 | } |
| 2020 | |
| 2021 | void __stdcall glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2022 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2023 | 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] | 2024 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2025 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2026 | if (context) |
| 2027 | { |
| 2028 | if (!gl::ValidBufferTarget(context, target)) |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2029 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2030 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2031 | return; |
daniel@transgaming.com | aa0ccbd | 2010-04-15 20:45:05 +0000 | [diff] [blame] | 2032 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2033 | |
| 2034 | if (!gl::ValidBufferParameter(context, pname)) |
| 2035 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2036 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2037 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2038 | } |
| 2039 | |
| 2040 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 2041 | |
| 2042 | if (!buffer) |
| 2043 | { |
| 2044 | // A null buffer means that "0" is bound to the requested buffer target |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2045 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2046 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | switch (pname) |
| 2050 | { |
| 2051 | case GL_BUFFER_USAGE: |
| 2052 | *params = static_cast<GLint>(buffer->getUsage()); |
| 2053 | break; |
| 2054 | case GL_BUFFER_SIZE: |
| 2055 | *params = gl::clampCast<GLint>(buffer->getSize()); |
| 2056 | break; |
| 2057 | case GL_BUFFER_ACCESS_FLAGS: |
| 2058 | *params = buffer->getAccessFlags(); |
| 2059 | break; |
| 2060 | case GL_BUFFER_MAPPED: |
| 2061 | *params = static_cast<GLint>(buffer->isMapped()); |
| 2062 | break; |
| 2063 | case GL_BUFFER_MAP_OFFSET: |
| 2064 | *params = gl::clampCast<GLint>(buffer->getMapOffset()); |
| 2065 | break; |
| 2066 | case GL_BUFFER_MAP_LENGTH: |
| 2067 | *params = gl::clampCast<GLint>(buffer->getMapLength()); |
| 2068 | break; |
| 2069 | default: UNREACHABLE(); break; |
| 2070 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2071 | } |
| 2072 | } |
| 2073 | |
| 2074 | GLenum __stdcall glGetError(void) |
| 2075 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2076 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2077 | |
| 2078 | gl::Context *context = gl::getContext(); |
| 2079 | |
| 2080 | if (context) |
| 2081 | { |
daniel@transgaming.com | 82b2891 | 2011-12-12 21:01:35 +0000 | [diff] [blame] | 2082 | return context->getError(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | return GL_NO_ERROR; |
| 2086 | } |
| 2087 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2088 | void __stdcall glGetFenceivNV(GLuint fence, GLenum pname, GLint *params) |
| 2089 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2090 | 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] | 2091 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2092 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2093 | if (context) |
| 2094 | { |
| 2095 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 2096 | |
| 2097 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2098 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2099 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2100 | return; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2101 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2102 | |
| 2103 | if (fenceObject->isFence() != GL_TRUE) |
| 2104 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2105 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2106 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2107 | } |
| 2108 | |
| 2109 | switch (pname) |
| 2110 | { |
| 2111 | case GL_FENCE_STATUS_NV: |
| 2112 | case GL_FENCE_CONDITION_NV: |
| 2113 | break; |
| 2114 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2115 | default: |
| 2116 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2117 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2118 | } |
| 2119 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 2120 | gl::Error error = fenceObject->getFencei(pname, params); |
| 2121 | if (error.isError()) |
| 2122 | { |
| 2123 | context->recordError(error); |
| 2124 | return; |
| 2125 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 2126 | } |
| 2127 | } |
| 2128 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2129 | void __stdcall glGetFloatv(GLenum pname, GLfloat* params) |
| 2130 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2131 | 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] | 2132 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2133 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2134 | if (context) |
| 2135 | { |
| 2136 | GLenum nativeType; |
| 2137 | unsigned int numParams = 0; |
| 2138 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2139 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2140 | return; |
daniel@transgaming.com | 32e58cd | 2010-03-24 09:44:10 +0000 | [diff] [blame] | 2141 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2142 | |
| 2143 | if (nativeType == GL_FLOAT) |
| 2144 | { |
| 2145 | context->getFloatv(pname, params); |
| 2146 | } |
| 2147 | else |
| 2148 | { |
| 2149 | CastStateValues(context, nativeType, pname, numParams, params); |
| 2150 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | void __stdcall glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) |
| 2155 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2156 | 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] | 2157 | target, attachment, pname, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2158 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2159 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2160 | if (context) |
| 2161 | { |
| 2162 | if (!gl::ValidFramebufferTarget(target)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2163 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2164 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2165 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2166 | } |
| 2167 | |
| 2168 | int clientVersion = context->getClientVersion(); |
| 2169 | |
| 2170 | switch (pname) |
| 2171 | { |
| 2172 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2173 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2174 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2175 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2176 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2177 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2178 | case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: |
| 2179 | if (clientVersion < 3 && !context->getExtensions().sRGB) |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2180 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2181 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2182 | return; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2183 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2184 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2185 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2186 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
| 2187 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
| 2188 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
| 2189 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
| 2190 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
| 2191 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
| 2192 | case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: |
| 2193 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 2194 | if (clientVersion < 3) |
| 2195 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2196 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2197 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2198 | } |
| 2199 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2200 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2201 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2202 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2203 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2204 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2205 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2206 | // Determine if the attachment is a valid enum |
| 2207 | switch (attachment) |
| 2208 | { |
| 2209 | case GL_BACK: |
| 2210 | case GL_FRONT: |
| 2211 | case GL_DEPTH: |
| 2212 | case GL_STENCIL: |
| 2213 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2214 | if (clientVersion < 3) |
| 2215 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2216 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2217 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2218 | } |
| 2219 | break; |
| 2220 | |
| 2221 | case GL_DEPTH_ATTACHMENT: |
| 2222 | case GL_STENCIL_ATTACHMENT: |
| 2223 | break; |
| 2224 | |
| 2225 | default: |
| 2226 | if (attachment < GL_COLOR_ATTACHMENT0_EXT || |
| 2227 | (attachment - GL_COLOR_ATTACHMENT0_EXT) >= context->getCaps().maxColorAttachments) |
| 2228 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2229 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2230 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2231 | } |
| 2232 | break; |
| 2233 | } |
| 2234 | |
| 2235 | GLuint framebufferHandle = context->getState().getTargetFramebuffer(target)->id(); |
| 2236 | gl::Framebuffer *framebuffer = context->getFramebuffer(framebufferHandle); |
| 2237 | |
| 2238 | if (framebufferHandle == 0) |
| 2239 | { |
| 2240 | if (clientVersion < 3) |
| 2241 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2242 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2243 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2244 | } |
| 2245 | |
| 2246 | switch (attachment) |
| 2247 | { |
| 2248 | case GL_BACK: |
| 2249 | case GL_DEPTH: |
| 2250 | case GL_STENCIL: |
| 2251 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2252 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2253 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2254 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2255 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2256 | } |
| 2257 | } |
| 2258 | else |
| 2259 | { |
| 2260 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 2261 | { |
| 2262 | // Valid attachment query |
| 2263 | } |
| 2264 | else |
| 2265 | { |
| 2266 | switch (attachment) |
| 2267 | { |
| 2268 | case GL_DEPTH_ATTACHMENT: |
| 2269 | case GL_STENCIL_ATTACHMENT: |
| 2270 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2271 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2272 | case GL_DEPTH_STENCIL_ATTACHMENT: |
| 2273 | if (framebuffer->hasValidDepthStencil()) |
| 2274 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2275 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2276 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2277 | } |
| 2278 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2279 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2280 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2281 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2282 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2283 | } |
| 2284 | } |
| 2285 | } |
| 2286 | |
| 2287 | GLenum attachmentType = GL_NONE; |
| 2288 | GLuint attachmentHandle = 0; |
| 2289 | GLuint attachmentLevel = 0; |
| 2290 | GLuint attachmentLayer = 0; |
| 2291 | |
| 2292 | const gl::FramebufferAttachment *attachmentObject = framebuffer->getAttachment(attachment); |
| 2293 | |
| 2294 | if (attachmentObject) |
| 2295 | { |
| 2296 | attachmentType = attachmentObject->type(); |
| 2297 | attachmentHandle = attachmentObject->id(); |
| 2298 | attachmentLevel = attachmentObject->mipLevel(); |
| 2299 | attachmentLayer = attachmentObject->layer(); |
| 2300 | } |
| 2301 | |
| 2302 | GLenum attachmentObjectType; // Type category |
| 2303 | if (framebufferHandle == 0) |
| 2304 | { |
| 2305 | attachmentObjectType = GL_FRAMEBUFFER_DEFAULT; |
| 2306 | } |
| 2307 | else if (attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER) |
| 2308 | { |
| 2309 | attachmentObjectType = attachmentType; |
| 2310 | } |
| 2311 | else if (gl::ValidTexture2DDestinationTarget(context, attachmentType)) |
| 2312 | { |
| 2313 | attachmentObjectType = GL_TEXTURE; |
| 2314 | } |
| 2315 | else |
| 2316 | { |
| 2317 | UNREACHABLE(); |
| 2318 | return; |
| 2319 | } |
| 2320 | |
| 2321 | if (attachmentObjectType == GL_NONE) |
| 2322 | { |
| 2323 | // ES 2.0.25 spec pg 127 states that if the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE |
| 2324 | // is NONE, then querying any other pname will generate INVALID_ENUM. |
| 2325 | |
| 2326 | // ES 3.0.2 spec pg 235 states that if the attachment type is none, |
| 2327 | // GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero and be an |
| 2328 | // INVALID_OPERATION for all other pnames |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 2329 | |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2330 | switch (pname) |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2331 | { |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2332 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2333 | *params = attachmentObjectType; |
| 2334 | break; |
| 2335 | |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2336 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
Geoff Lang | 05b0502 | 2014-06-11 15:31:45 -0400 | [diff] [blame] | 2337 | if (clientVersion < 3) |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2338 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2339 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2340 | return; |
daniel@transgaming.com | a27ff1e | 2010-08-24 19:20:11 +0000 | [diff] [blame] | 2341 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2342 | *params = 0; |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2343 | break; |
| 2344 | |
| 2345 | default: |
Jamie Madill | 1e3fa74 | 2014-06-16 10:34:00 -0400 | [diff] [blame] | 2346 | if (clientVersion < 3) |
shannon.woods%transgaming.com@gtempaccount.com | 89ae113 | 2013-04-13 03:28:43 +0000 | [diff] [blame] | 2347 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2348 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2349 | return; |
Geoff Lang | 646559f | 2013-08-15 11:08:15 -0400 | [diff] [blame] | 2350 | } |
| 2351 | else |
| 2352 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2353 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2354 | return; |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2355 | } |
daniel@transgaming.com | c46c9c0 | 2010-04-23 18:34:55 +0000 | [diff] [blame] | 2356 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2357 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2358 | else |
| 2359 | { |
| 2360 | ASSERT(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE || |
| 2361 | attachmentObjectType == GL_FRAMEBUFFER_DEFAULT); |
| 2362 | ASSERT(attachmentObject != NULL); |
| 2363 | |
| 2364 | switch (pname) |
| 2365 | { |
| 2366 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2367 | *params = attachmentObjectType; |
| 2368 | break; |
| 2369 | |
| 2370 | case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2371 | if (attachmentObjectType != GL_RENDERBUFFER && attachmentObjectType != GL_TEXTURE) |
| 2372 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2373 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2374 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2375 | } |
| 2376 | *params = attachmentHandle; |
| 2377 | break; |
| 2378 | |
| 2379 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2380 | if (attachmentObjectType != GL_TEXTURE) |
| 2381 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2382 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2383 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2384 | } |
| 2385 | *params = attachmentLevel; |
| 2386 | break; |
| 2387 | |
| 2388 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2389 | if (attachmentObjectType != GL_TEXTURE) |
| 2390 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2391 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2392 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2393 | } |
| 2394 | *params = gl::IsCubemapTextureTarget(attachmentType) ? attachmentType : 0; |
| 2395 | break; |
| 2396 | |
| 2397 | case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: |
| 2398 | *params = attachmentObject->getRedSize(); |
| 2399 | break; |
| 2400 | |
| 2401 | case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: |
| 2402 | *params = attachmentObject->getGreenSize(); |
| 2403 | break; |
| 2404 | |
| 2405 | case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: |
| 2406 | *params = attachmentObject->getBlueSize(); |
| 2407 | break; |
| 2408 | |
| 2409 | case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: |
| 2410 | *params = attachmentObject->getAlphaSize(); |
| 2411 | break; |
| 2412 | |
| 2413 | case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: |
| 2414 | *params = attachmentObject->getDepthSize(); |
| 2415 | break; |
| 2416 | |
| 2417 | case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: |
| 2418 | *params = attachmentObject->getStencilSize(); |
| 2419 | break; |
| 2420 | |
| 2421 | case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: |
Jamie Madill | ee85d1b | 2014-09-17 10:35:23 -0400 | [diff] [blame] | 2422 | if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2423 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2424 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2425 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2426 | } |
| 2427 | *params = attachmentObject->getComponentType(); |
| 2428 | break; |
| 2429 | |
| 2430 | case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: |
| 2431 | *params = attachmentObject->getColorEncoding(); |
| 2432 | break; |
| 2433 | |
| 2434 | case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: |
| 2435 | if (attachmentObjectType != GL_TEXTURE) |
| 2436 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2437 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2438 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2439 | } |
| 2440 | *params = attachmentLayer; |
| 2441 | break; |
| 2442 | |
| 2443 | default: |
| 2444 | UNREACHABLE(); |
| 2445 | break; |
| 2446 | } |
| 2447 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2448 | } |
| 2449 | } |
| 2450 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2451 | GLenum __stdcall glGetGraphicsResetStatusEXT(void) |
| 2452 | { |
| 2453 | EVENT("()"); |
| 2454 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2455 | gl::Context *context = gl::getContext(); |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2456 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2457 | if (context) |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2458 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2459 | return context->getResetStatus(); |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2460 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2461 | |
| 2462 | return GL_NO_ERROR; |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 2463 | } |
| 2464 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2465 | void __stdcall glGetIntegerv(GLenum pname, GLint* params) |
| 2466 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2467 | 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] | 2468 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2469 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2470 | if (context) |
| 2471 | { |
| 2472 | GLenum nativeType; |
| 2473 | unsigned int numParams = 0; |
| 2474 | |
| 2475 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2476 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2477 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2478 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2479 | |
| 2480 | if (nativeType == GL_INT) |
| 2481 | { |
| 2482 | context->getIntegerv(pname, params); |
| 2483 | } |
| 2484 | else |
| 2485 | { |
| 2486 | CastStateValues(context, nativeType, pname, numParams, params); |
| 2487 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2488 | } |
| 2489 | } |
| 2490 | |
| 2491 | void __stdcall glGetProgramiv(GLuint program, GLenum pname, GLint* params) |
| 2492 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2493 | 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] | 2494 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2495 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2496 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2497 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2498 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2499 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2500 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2501 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2502 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2503 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2504 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2505 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2506 | if (context->getClientVersion() < 3) |
| 2507 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2508 | switch (pname) |
| 2509 | { |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 2510 | case GL_ACTIVE_UNIFORM_BLOCKS: |
shannonwoods@chromium.org | e684b58 | 2013-05-30 00:07:42 +0000 | [diff] [blame] | 2511 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2512 | case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2513 | case GL_TRANSFORM_FEEDBACK_VARYINGS: |
Geoff Lang | 1b6edcb | 2014-02-03 14:27:56 -0500 | [diff] [blame] | 2514 | case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2515 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2516 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2517 | } |
| 2518 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2519 | |
| 2520 | switch (pname) |
| 2521 | { |
| 2522 | case GL_DELETE_STATUS: |
| 2523 | *params = programObject->isFlaggedForDeletion(); |
| 2524 | return; |
| 2525 | case GL_LINK_STATUS: |
| 2526 | *params = programObject->isLinked(); |
| 2527 | return; |
| 2528 | case GL_VALIDATE_STATUS: |
| 2529 | *params = programObject->isValidated(); |
| 2530 | return; |
| 2531 | case GL_INFO_LOG_LENGTH: |
| 2532 | *params = programObject->getInfoLogLength(); |
| 2533 | return; |
| 2534 | case GL_ATTACHED_SHADERS: |
| 2535 | *params = programObject->getAttachedShadersCount(); |
| 2536 | return; |
| 2537 | case GL_ACTIVE_ATTRIBUTES: |
| 2538 | *params = programObject->getActiveAttributeCount(); |
| 2539 | return; |
| 2540 | case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: |
| 2541 | *params = programObject->getActiveAttributeMaxLength(); |
| 2542 | return; |
| 2543 | case GL_ACTIVE_UNIFORMS: |
| 2544 | *params = programObject->getActiveUniformCount(); |
| 2545 | return; |
| 2546 | case GL_ACTIVE_UNIFORM_MAX_LENGTH: |
| 2547 | *params = programObject->getActiveUniformMaxLength(); |
| 2548 | return; |
| 2549 | case GL_PROGRAM_BINARY_LENGTH_OES: |
| 2550 | *params = programObject->getProgramBinaryLength(); |
| 2551 | return; |
| 2552 | case GL_ACTIVE_UNIFORM_BLOCKS: |
| 2553 | *params = programObject->getActiveUniformBlockCount(); |
| 2554 | return; |
| 2555 | case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: |
| 2556 | *params = programObject->getActiveUniformBlockMaxLength(); |
| 2557 | break; |
| 2558 | case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: |
| 2559 | *params = programObject->getTransformFeedbackBufferMode(); |
| 2560 | break; |
| 2561 | case GL_TRANSFORM_FEEDBACK_VARYINGS: |
| 2562 | *params = programObject->getTransformFeedbackVaryingCount(); |
| 2563 | break; |
| 2564 | case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: |
| 2565 | *params = programObject->getTransformFeedbackVaryingMaxLength(); |
| 2566 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2567 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2568 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2569 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2570 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2571 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2572 | } |
| 2573 | } |
| 2574 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2575 | void __stdcall glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2576 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2577 | 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] | 2578 | program, bufsize, length, infolog); |
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 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2581 | if (context) |
| 2582 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2583 | if (bufsize < 0) |
| 2584 | { |
| 2585 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2586 | return; |
| 2587 | } |
| 2588 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2589 | gl::Program *programObject = context->getProgram(program); |
| 2590 | |
| 2591 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2592 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2593 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2594 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2595 | } |
| 2596 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2597 | programObject->getInfoLog(bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2598 | } |
| 2599 | } |
| 2600 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2601 | void __stdcall glGetQueryivEXT(GLenum target, GLenum pname, GLint *params) |
| 2602 | { |
| 2603 | EVENT("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params); |
| 2604 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2605 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2606 | if (context) |
| 2607 | { |
| 2608 | if (!ValidQueryType(context, target)) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2609 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2610 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2611 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2612 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2613 | |
| 2614 | switch (pname) |
| 2615 | { |
| 2616 | case GL_CURRENT_QUERY_EXT: |
| 2617 | params[0] = context->getState().getActiveQueryId(target); |
| 2618 | break; |
| 2619 | |
| 2620 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2621 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2622 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2623 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2624 | } |
| 2625 | } |
| 2626 | |
| 2627 | void __stdcall glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params) |
| 2628 | { |
| 2629 | EVENT("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params); |
| 2630 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2631 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2632 | if (context) |
| 2633 | { |
| 2634 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 2635 | |
| 2636 | if (!queryObject) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2637 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2638 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2639 | return; |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2640 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2641 | |
| 2642 | if (context->getState().getActiveQueryId(queryObject->getType()) == id) |
| 2643 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2644 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2645 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2646 | } |
| 2647 | |
| 2648 | switch(pname) |
| 2649 | { |
| 2650 | case GL_QUERY_RESULT_EXT: |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 2651 | { |
| 2652 | gl::Error error = queryObject->getResult(params); |
| 2653 | if (error.isError()) |
| 2654 | { |
| 2655 | context->recordError(error); |
| 2656 | return; |
| 2657 | } |
| 2658 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2659 | break; |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 2660 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2661 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 2662 | { |
| 2663 | gl::Error error = queryObject->isResultAvailable(params); |
| 2664 | if (error.isError()) |
| 2665 | { |
| 2666 | context->recordError(error); |
| 2667 | return; |
| 2668 | } |
| 2669 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2670 | break; |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 2671 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2672 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2673 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2674 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2675 | } |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 2676 | } |
| 2677 | } |
| 2678 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2679 | void __stdcall glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) |
| 2680 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2681 | 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] | 2682 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2683 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2684 | if (context) |
| 2685 | { |
| 2686 | if (target != GL_RENDERBUFFER) |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 2687 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2688 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2689 | return; |
daniel@transgaming.com | 4901fca | 2010-04-20 18:52:41 +0000 | [diff] [blame] | 2690 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2691 | |
| 2692 | if (context->getState().getRenderbufferId() == 0) |
| 2693 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2694 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2695 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getState().getRenderbufferId()); |
| 2699 | |
| 2700 | switch (pname) |
| 2701 | { |
| 2702 | case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break; |
| 2703 | case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break; |
| 2704 | case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getInternalFormat(); break; |
| 2705 | case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break; |
| 2706 | case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break; |
| 2707 | case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break; |
| 2708 | case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break; |
| 2709 | case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break; |
| 2710 | case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2711 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2712 | case GL_RENDERBUFFER_SAMPLES_ANGLE: |
| 2713 | if (!context->getExtensions().framebufferMultisample) |
| 2714 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2715 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2716 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2717 | } |
| 2718 | *params = renderbuffer->getSamples(); |
| 2719 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2720 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2721 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2722 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2723 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2724 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2725 | } |
| 2726 | } |
| 2727 | |
| 2728 | void __stdcall glGetShaderiv(GLuint shader, GLenum pname, GLint* params) |
| 2729 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2730 | 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] | 2731 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2732 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2733 | if (context) |
| 2734 | { |
| 2735 | gl::Shader *shaderObject = context->getShader(shader); |
| 2736 | |
| 2737 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2738 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2739 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2740 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2741 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2742 | |
| 2743 | switch (pname) |
| 2744 | { |
| 2745 | case GL_SHADER_TYPE: |
| 2746 | *params = shaderObject->getType(); |
| 2747 | return; |
| 2748 | case GL_DELETE_STATUS: |
| 2749 | *params = shaderObject->isFlaggedForDeletion(); |
| 2750 | return; |
| 2751 | case GL_COMPILE_STATUS: |
| 2752 | *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE; |
| 2753 | return; |
| 2754 | case GL_INFO_LOG_LENGTH: |
| 2755 | *params = shaderObject->getInfoLogLength(); |
| 2756 | return; |
| 2757 | case GL_SHADER_SOURCE_LENGTH: |
| 2758 | *params = shaderObject->getSourceLength(); |
| 2759 | return; |
| 2760 | case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: |
| 2761 | *params = shaderObject->getTranslatedSourceLength(); |
| 2762 | return; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2763 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2764 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2765 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2766 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2767 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2768 | } |
| 2769 | } |
| 2770 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2771 | void __stdcall glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2772 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2773 | 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] | 2774 | shader, bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2775 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2776 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2777 | if (context) |
| 2778 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2779 | if (bufsize < 0) |
| 2780 | { |
| 2781 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2782 | return; |
| 2783 | } |
| 2784 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2785 | gl::Shader *shaderObject = context->getShader(shader); |
| 2786 | |
| 2787 | if (!shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2788 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2789 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2790 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2791 | } |
| 2792 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2793 | shaderObject->getInfoLog(bufsize, length, infolog); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2794 | } |
| 2795 | } |
| 2796 | |
| 2797 | void __stdcall glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) |
| 2798 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2799 | 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] | 2800 | shadertype, precisiontype, range, precision); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2801 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2802 | gl::Context *context = gl::getNonLostContext(); |
| 2803 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2804 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2805 | switch (shadertype) |
| 2806 | { |
| 2807 | case GL_VERTEX_SHADER: |
| 2808 | case GL_FRAGMENT_SHADER: |
| 2809 | break; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2810 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2811 | default: |
| 2812 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2813 | return; |
| 2814 | } |
| 2815 | |
| 2816 | switch (precisiontype) |
| 2817 | { |
| 2818 | case GL_LOW_FLOAT: |
| 2819 | case GL_MEDIUM_FLOAT: |
| 2820 | case GL_HIGH_FLOAT: |
| 2821 | // Assume IEEE 754 precision |
| 2822 | range[0] = 127; |
| 2823 | range[1] = 127; |
| 2824 | *precision = 23; |
| 2825 | break; |
| 2826 | |
| 2827 | case GL_LOW_INT: |
| 2828 | case GL_MEDIUM_INT: |
| 2829 | case GL_HIGH_INT: |
| 2830 | // Some (most) hardware only supports single-precision floating-point numbers, |
| 2831 | // which can accurately represent integers up to +/-16777216 |
| 2832 | range[0] = 24; |
| 2833 | range[1] = 24; |
| 2834 | *precision = 0; |
| 2835 | break; |
| 2836 | |
| 2837 | default: |
| 2838 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2839 | return; |
| 2840 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2841 | } |
| 2842 | } |
| 2843 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 2844 | void __stdcall glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2845 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2846 | 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] | 2847 | shader, bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2848 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2849 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2850 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2851 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2852 | if (bufsize < 0) |
| 2853 | { |
| 2854 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2855 | return; |
| 2856 | } |
| 2857 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2858 | gl::Shader *shaderObject = context->getShader(shader); |
| 2859 | |
| 2860 | if (!shaderObject) |
| 2861 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2862 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2863 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2864 | } |
| 2865 | |
| 2866 | shaderObject->getSource(bufsize, length, source); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2867 | } |
| 2868 | } |
| 2869 | |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2870 | void __stdcall glGetTranslatedShaderSourceANGLE(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source) |
| 2871 | { |
| 2872 | EVENT("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)", |
| 2873 | shader, bufsize, length, source); |
| 2874 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2875 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2876 | if (context) |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2877 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2878 | if (bufsize < 0) |
| 2879 | { |
| 2880 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 2881 | return; |
| 2882 | } |
| 2883 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2884 | gl::Shader *shaderObject = context->getShader(shader); |
| 2885 | |
| 2886 | if (!shaderObject) |
| 2887 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2888 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 2889 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2890 | } |
| 2891 | |
| 2892 | shaderObject->getTranslatedSource(bufsize, length, source); |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 2893 | } |
| 2894 | } |
| 2895 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2896 | const GLubyte* __stdcall glGetString(GLenum name) |
| 2897 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2898 | EVENT("(GLenum name = 0x%X)", name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2899 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2900 | gl::Context *context = gl::getNonLostContext(); |
daniel@transgaming.com | 3e4c600 | 2010-05-05 18:50:13 +0000 | [diff] [blame] | 2901 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2902 | switch (name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2903 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2904 | case GL_VENDOR: |
| 2905 | return (GLubyte*)"Google Inc."; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2906 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2907 | case GL_RENDERER: |
| 2908 | return (GLubyte*)((context != NULL) ? context->getRendererString().c_str() : "ANGLE"); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2909 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2910 | case GL_VERSION: |
| 2911 | if (context->getClientVersion() == 2) |
| 2912 | { |
| 2913 | return (GLubyte*)"OpenGL ES 2.0 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2914 | } |
| 2915 | else |
| 2916 | { |
| 2917 | return (GLubyte*)"OpenGL ES 3.0 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2918 | } |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2919 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2920 | case GL_SHADING_LANGUAGE_VERSION: |
| 2921 | if (context->getClientVersion() == 2) |
| 2922 | { |
| 2923 | return (GLubyte*)"OpenGL ES GLSL ES 1.00 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2924 | } |
| 2925 | else |
| 2926 | { |
| 2927 | return (GLubyte*)"OpenGL ES GLSL ES 3.00 (ANGLE " ANGLE_VERSION_STRING ")"; |
| 2928 | } |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2929 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2930 | case GL_EXTENSIONS: |
| 2931 | return (GLubyte*)((context != NULL) ? context->getExtensionString().c_str() : ""); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2932 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2933 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2934 | if (context) |
| 2935 | { |
| 2936 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2937 | } |
| 2938 | return NULL; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2939 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 2940 | } |
| 2941 | |
| 2942 | void __stdcall glGetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) |
| 2943 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 2944 | 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] | 2945 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2946 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2947 | if (context) |
| 2948 | { |
| 2949 | gl::Texture *texture = context->getTargetTexture(target); |
| 2950 | |
| 2951 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2952 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2953 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2954 | return; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 2955 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2956 | |
| 2957 | switch (pname) |
| 2958 | { |
| 2959 | case GL_TEXTURE_MAG_FILTER: |
| 2960 | *params = (GLfloat)texture->getSamplerState().magFilter; |
| 2961 | break; |
| 2962 | case GL_TEXTURE_MIN_FILTER: |
| 2963 | *params = (GLfloat)texture->getSamplerState().minFilter; |
| 2964 | break; |
| 2965 | case GL_TEXTURE_WRAP_S: |
| 2966 | *params = (GLfloat)texture->getSamplerState().wrapS; |
| 2967 | break; |
| 2968 | case GL_TEXTURE_WRAP_T: |
| 2969 | *params = (GLfloat)texture->getSamplerState().wrapT; |
| 2970 | break; |
| 2971 | case GL_TEXTURE_WRAP_R: |
| 2972 | if (context->getClientVersion() < 3) |
| 2973 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2974 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2975 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2976 | } |
| 2977 | *params = (GLfloat)texture->getSamplerState().wrapR; |
| 2978 | break; |
| 2979 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 2980 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
| 2981 | *params = (GLfloat)(texture->isImmutable() ? GL_TRUE : GL_FALSE); |
| 2982 | break; |
| 2983 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 2984 | if (context->getClientVersion() < 3) |
| 2985 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2986 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2987 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2988 | } |
| 2989 | *params = (GLfloat)texture->immutableLevelCount(); |
| 2990 | break; |
| 2991 | case GL_TEXTURE_USAGE_ANGLE: |
| 2992 | *params = (GLfloat)texture->getUsage(); |
| 2993 | break; |
| 2994 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 2995 | if (!context->getExtensions().textureFilterAnisotropic) |
| 2996 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 2997 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 2998 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 2999 | } |
| 3000 | *params = (GLfloat)texture->getSamplerState().maxAnisotropy; |
| 3001 | break; |
| 3002 | case GL_TEXTURE_SWIZZLE_R: |
| 3003 | if (context->getClientVersion() < 3) |
| 3004 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3005 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3006 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3007 | } |
| 3008 | *params = (GLfloat)texture->getSamplerState().swizzleRed; |
| 3009 | break; |
| 3010 | case GL_TEXTURE_SWIZZLE_G: |
| 3011 | if (context->getClientVersion() < 3) |
| 3012 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3013 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3014 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3015 | } |
| 3016 | *params = (GLfloat)texture->getSamplerState().swizzleGreen; |
| 3017 | break; |
| 3018 | case GL_TEXTURE_SWIZZLE_B: |
| 3019 | if (context->getClientVersion() < 3) |
| 3020 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3021 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3022 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3023 | } |
| 3024 | *params = (GLfloat)texture->getSamplerState().swizzleBlue; |
| 3025 | break; |
| 3026 | case GL_TEXTURE_SWIZZLE_A: |
| 3027 | if (context->getClientVersion() < 3) |
| 3028 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3029 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3030 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3031 | } |
| 3032 | *params = (GLfloat)texture->getSamplerState().swizzleAlpha; |
| 3033 | break; |
| 3034 | case GL_TEXTURE_BASE_LEVEL: |
| 3035 | if (context->getClientVersion() < 3) |
| 3036 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3037 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3038 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3039 | } |
| 3040 | *params = (GLfloat)texture->getSamplerState().baseLevel; |
| 3041 | break; |
| 3042 | case GL_TEXTURE_MAX_LEVEL: |
| 3043 | if (context->getClientVersion() < 3) |
| 3044 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3045 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3046 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3047 | } |
| 3048 | *params = (GLfloat)texture->getSamplerState().maxLevel; |
| 3049 | break; |
| 3050 | case GL_TEXTURE_MIN_LOD: |
| 3051 | if (context->getClientVersion() < 3) |
| 3052 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3053 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3054 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3055 | } |
| 3056 | *params = texture->getSamplerState().minLod; |
| 3057 | break; |
| 3058 | case GL_TEXTURE_MAX_LOD: |
| 3059 | if (context->getClientVersion() < 3) |
| 3060 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3061 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3062 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3063 | } |
| 3064 | *params = texture->getSamplerState().maxLod; |
| 3065 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3066 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3067 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3068 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3069 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3070 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3071 | } |
| 3072 | } |
| 3073 | |
| 3074 | void __stdcall glGetTexParameteriv(GLenum target, GLenum pname, GLint* params) |
| 3075 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3076 | 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] | 3077 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3078 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3079 | if (context) |
| 3080 | { |
| 3081 | gl::Texture *texture = context->getTargetTexture(target); |
| 3082 | |
| 3083 | if (!texture) |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3084 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3085 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3086 | return; |
daniel@transgaming.com | 5d2bee9 | 2010-04-20 18:51:56 +0000 | [diff] [blame] | 3087 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3088 | |
| 3089 | switch (pname) |
| 3090 | { |
| 3091 | case GL_TEXTURE_MAG_FILTER: |
| 3092 | *params = texture->getSamplerState().magFilter; |
| 3093 | break; |
| 3094 | case GL_TEXTURE_MIN_FILTER: |
| 3095 | *params = texture->getSamplerState().minFilter; |
| 3096 | break; |
| 3097 | case GL_TEXTURE_WRAP_S: |
| 3098 | *params = texture->getSamplerState().wrapS; |
| 3099 | break; |
| 3100 | case GL_TEXTURE_WRAP_T: |
| 3101 | *params = texture->getSamplerState().wrapT; |
| 3102 | break; |
| 3103 | case GL_TEXTURE_WRAP_R: |
| 3104 | if (context->getClientVersion() < 3) |
| 3105 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3106 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3107 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3108 | } |
| 3109 | *params = texture->getSamplerState().wrapR; |
| 3110 | break; |
| 3111 | case GL_TEXTURE_IMMUTABLE_FORMAT: |
| 3112 | // Exposed to ES2.0 through EXT_texture_storage, no client version validation. |
| 3113 | *params = texture->isImmutable() ? GL_TRUE : GL_FALSE; |
| 3114 | break; |
| 3115 | case GL_TEXTURE_IMMUTABLE_LEVELS: |
| 3116 | if (context->getClientVersion() < 3) |
| 3117 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3118 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3119 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3120 | } |
| 3121 | *params = texture->immutableLevelCount(); |
| 3122 | break; |
| 3123 | case GL_TEXTURE_USAGE_ANGLE: |
| 3124 | *params = texture->getUsage(); |
| 3125 | break; |
| 3126 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
| 3127 | if (!context->getExtensions().textureFilterAnisotropic) |
| 3128 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3129 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3130 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3131 | } |
| 3132 | *params = (GLint)texture->getSamplerState().maxAnisotropy; |
| 3133 | break; |
| 3134 | case GL_TEXTURE_SWIZZLE_R: |
| 3135 | if (context->getClientVersion() < 3) |
| 3136 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3137 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3138 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3139 | } |
| 3140 | *params = texture->getSamplerState().swizzleRed; |
| 3141 | break; |
| 3142 | case GL_TEXTURE_SWIZZLE_G: |
| 3143 | if (context->getClientVersion() < 3) |
| 3144 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3145 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3146 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3147 | } |
| 3148 | *params = texture->getSamplerState().swizzleGreen; |
| 3149 | break; |
| 3150 | case GL_TEXTURE_SWIZZLE_B: |
| 3151 | if (context->getClientVersion() < 3) |
| 3152 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3153 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3154 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3155 | } |
| 3156 | *params = texture->getSamplerState().swizzleBlue; |
| 3157 | break; |
| 3158 | case GL_TEXTURE_SWIZZLE_A: |
| 3159 | if (context->getClientVersion() < 3) |
| 3160 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3161 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3162 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3163 | } |
| 3164 | *params = texture->getSamplerState().swizzleAlpha; |
| 3165 | break; |
| 3166 | case GL_TEXTURE_BASE_LEVEL: |
| 3167 | if (context->getClientVersion() < 3) |
| 3168 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3169 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3170 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3171 | } |
| 3172 | *params = texture->getSamplerState().baseLevel; |
| 3173 | break; |
| 3174 | case GL_TEXTURE_MAX_LEVEL: |
| 3175 | if (context->getClientVersion() < 3) |
| 3176 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3177 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3178 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3179 | } |
| 3180 | *params = texture->getSamplerState().maxLevel; |
| 3181 | break; |
| 3182 | case GL_TEXTURE_MIN_LOD: |
| 3183 | if (context->getClientVersion() < 3) |
| 3184 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3185 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3186 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3187 | } |
| 3188 | *params = (GLint)texture->getSamplerState().minLod; |
| 3189 | break; |
| 3190 | case GL_TEXTURE_MAX_LOD: |
| 3191 | if (context->getClientVersion() < 3) |
| 3192 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3193 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3194 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3195 | } |
| 3196 | *params = (GLint)texture->getSamplerState().maxLod; |
| 3197 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3198 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3199 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3200 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3201 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3202 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3203 | } |
| 3204 | } |
| 3205 | |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3206 | void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params) |
| 3207 | { |
| 3208 | EVENT("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)", |
| 3209 | program, location, bufSize, params); |
| 3210 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3211 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3212 | if (context) |
| 3213 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3214 | if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3215 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3216 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3217 | } |
| 3218 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 3219 | gl::Program *programObject = context->getProgram(program); |
| 3220 | ASSERT(programObject); |
| 3221 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3222 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3223 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3224 | programBinary->getUniformfv(location, params); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3225 | } |
| 3226 | } |
| 3227 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3228 | void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) |
| 3229 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3230 | 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] | 3231 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3232 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3233 | if (context) |
| 3234 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3235 | if (!ValidateGetUniformfv(context, program, location, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3236 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3237 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3238 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3239 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 3240 | gl::Program *programObject = context->getProgram(program); |
| 3241 | ASSERT(programObject); |
| 3242 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3243 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3244 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3245 | programBinary->getUniformfv(location, params); |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3246 | } |
| 3247 | } |
| 3248 | |
| 3249 | void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params) |
| 3250 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3251 | 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] | 3252 | program, location, bufSize, params); |
| 3253 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3254 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3255 | if (context) |
| 3256 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3257 | if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params)) |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3258 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3259 | return; |
daniel@transgaming.com | 9a84912 | 2011-11-12 03:18:00 +0000 | [diff] [blame] | 3260 | } |
| 3261 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 3262 | gl::Program *programObject = context->getProgram(program); |
| 3263 | ASSERT(programObject); |
| 3264 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3265 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3266 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3267 | programBinary->getUniformiv(location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3268 | } |
| 3269 | } |
| 3270 | |
| 3271 | void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) |
| 3272 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3273 | 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] | 3274 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3275 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3276 | if (context) |
| 3277 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3278 | if (!ValidateGetUniformiv(context, program, location, params)) |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3279 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3280 | return; |
daniel@transgaming.com | bb3d9d0 | 2010-04-13 03:26:06 +0000 | [diff] [blame] | 3281 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3282 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 3283 | gl::Program *programObject = context->getProgram(program); |
| 3284 | ASSERT(programObject); |
| 3285 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 3286 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3287 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 3288 | programBinary->getUniformiv(location, params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3289 | } |
| 3290 | } |
| 3291 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3292 | GLint __stdcall glGetUniformLocation(GLuint program, const GLchar* name) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3293 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3294 | 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] | 3295 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3296 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3297 | if (context) |
| 3298 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3299 | if (strstr(name, "gl_") == name) |
| 3300 | { |
| 3301 | return -1; |
| 3302 | } |
| 3303 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3304 | gl::Program *programObject = context->getProgram(program); |
| 3305 | |
| 3306 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3307 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3308 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3309 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3310 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 3311 | return -1; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3312 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3313 | else |
| 3314 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3315 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3316 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3317 | } |
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 | |
| 3320 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 3321 | if (!programObject->isLinked() || !programBinary) |
| 3322 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3323 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 3324 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3325 | } |
| 3326 | |
| 3327 | return programBinary->getUniformLocation(name); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3328 | } |
| 3329 | |
| 3330 | return -1; |
| 3331 | } |
| 3332 | |
| 3333 | void __stdcall glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) |
| 3334 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3335 | 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] | 3336 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3337 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3338 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3339 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3340 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3341 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3342 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3343 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3344 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3345 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3346 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3347 | if (!gl::ValidateGetVertexAttribParameters(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3348 | { |
| 3349 | return; |
| 3350 | } |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3351 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3352 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 3353 | { |
| 3354 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 3355 | for (int i = 0; i < 4; ++i) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3356 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3357 | params[i] = currentValueData.FloatValues[i]; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3358 | } |
| 3359 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3360 | else |
| 3361 | { |
| 3362 | *params = gl::QuerySingleVertexAttributeParameter<GLfloat>(attribState, pname); |
| 3363 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3364 | } |
| 3365 | } |
| 3366 | |
| 3367 | void __stdcall glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) |
| 3368 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3369 | 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] | 3370 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3371 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3372 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3373 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3374 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3375 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3376 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3377 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3378 | } |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3379 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3380 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
daniel@transgaming.com | 428d158 | 2010-05-04 03:35:25 +0000 | [diff] [blame] | 3381 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3382 | if (!gl::ValidateGetVertexAttribParameters(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3383 | { |
| 3384 | return; |
| 3385 | } |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3386 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3387 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 3388 | { |
| 3389 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 3390 | for (int i = 0; i < 4; ++i) |
Jamie Madill | aff7150 | 2013-07-02 11:57:05 -0400 | [diff] [blame] | 3391 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3392 | float currentValue = currentValueData.FloatValues[i]; |
| 3393 | params[i] = gl::iround<GLint>(currentValue); |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3394 | } |
| 3395 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3396 | else |
| 3397 | { |
| 3398 | *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname); |
| 3399 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3400 | } |
| 3401 | } |
| 3402 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3403 | void __stdcall glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3404 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3405 | 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] | 3406 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3407 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3408 | if (context) |
| 3409 | { |
| 3410 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3411 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3412 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3413 | return; |
daniel@transgaming.com | e007896 | 2010-04-15 20:45:08 +0000 | [diff] [blame] | 3414 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3415 | |
| 3416 | if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) |
| 3417 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3418 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3419 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3420 | } |
| 3421 | |
| 3422 | *pointer = const_cast<GLvoid*>(context->getState().getVertexAttribPointer(index)); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3423 | } |
| 3424 | } |
| 3425 | |
| 3426 | void __stdcall glHint(GLenum target, GLenum mode) |
| 3427 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3428 | EVENT("(GLenum target = 0x%X, GLenum mode = 0x%X)", target, mode); |
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 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3431 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3432 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3433 | switch (mode) |
| 3434 | { |
| 3435 | case GL_FASTEST: |
| 3436 | case GL_NICEST: |
| 3437 | case GL_DONT_CARE: |
| 3438 | break; |
| 3439 | |
| 3440 | default: |
| 3441 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3442 | return; |
| 3443 | } |
| 3444 | |
| 3445 | switch (target) |
| 3446 | { |
| 3447 | case GL_GENERATE_MIPMAP_HINT: |
| 3448 | context->getState().setGenerateMipmapHint(mode); |
| 3449 | break; |
| 3450 | |
| 3451 | case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: |
| 3452 | context->getState().setFragmentShaderDerivativeHint(mode); |
| 3453 | break; |
| 3454 | |
| 3455 | default: |
| 3456 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3457 | return; |
| 3458 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3459 | } |
| 3460 | } |
| 3461 | |
| 3462 | GLboolean __stdcall glIsBuffer(GLuint buffer) |
| 3463 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3464 | EVENT("(GLuint buffer = %d)", buffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3465 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3466 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3467 | if (context && buffer) |
| 3468 | { |
| 3469 | gl::Buffer *bufferObject = context->getBuffer(buffer); |
| 3470 | |
| 3471 | if (bufferObject) |
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 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3474 | } |
| 3475 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3476 | |
| 3477 | return GL_FALSE; |
| 3478 | } |
| 3479 | |
| 3480 | GLboolean __stdcall glIsEnabled(GLenum cap) |
| 3481 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3482 | EVENT("(GLenum cap = 0x%X)", cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3483 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3484 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3485 | if (context) |
| 3486 | { |
| 3487 | if (!ValidCap(context, cap)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3488 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3489 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3490 | return GL_FALSE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3491 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3492 | |
| 3493 | return context->getState().getEnableFeature(cap); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3494 | } |
| 3495 | |
| 3496 | return false; |
| 3497 | } |
| 3498 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3499 | GLboolean __stdcall glIsFenceNV(GLuint fence) |
| 3500 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3501 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3502 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3503 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3504 | if (context) |
| 3505 | { |
| 3506 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 3507 | |
| 3508 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3509 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3510 | return GL_FALSE; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3511 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3512 | |
| 3513 | return fenceObject->isFence(); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3514 | } |
| 3515 | |
| 3516 | return GL_FALSE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3517 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3518 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3519 | GLboolean __stdcall glIsFramebuffer(GLuint framebuffer) |
| 3520 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3521 | EVENT("(GLuint framebuffer = %d)", framebuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3522 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3523 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3524 | if (context && framebuffer) |
| 3525 | { |
| 3526 | gl::Framebuffer *framebufferObject = context->getFramebuffer(framebuffer); |
| 3527 | |
| 3528 | if (framebufferObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3529 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3530 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3531 | } |
| 3532 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3533 | |
| 3534 | return GL_FALSE; |
| 3535 | } |
| 3536 | |
| 3537 | GLboolean __stdcall glIsProgram(GLuint program) |
| 3538 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3539 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3540 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3541 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3542 | if (context && program) |
| 3543 | { |
| 3544 | gl::Program *programObject = context->getProgram(program); |
| 3545 | |
| 3546 | if (programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3547 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3548 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3549 | } |
| 3550 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3551 | |
| 3552 | return GL_FALSE; |
| 3553 | } |
| 3554 | |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3555 | GLboolean __stdcall glIsQueryEXT(GLuint id) |
| 3556 | { |
| 3557 | EVENT("(GLuint id = %d)", id); |
| 3558 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3559 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3560 | if (context) |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 3561 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3562 | 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] | 3563 | } |
| 3564 | |
| 3565 | return GL_FALSE; |
| 3566 | } |
| 3567 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3568 | GLboolean __stdcall glIsRenderbuffer(GLuint renderbuffer) |
| 3569 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3570 | EVENT("(GLuint renderbuffer = %d)", renderbuffer); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3571 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3572 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3573 | if (context && renderbuffer) |
| 3574 | { |
| 3575 | gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer); |
| 3576 | |
| 3577 | if (renderbufferObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3578 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3579 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3580 | } |
| 3581 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3582 | |
| 3583 | return GL_FALSE; |
| 3584 | } |
| 3585 | |
| 3586 | GLboolean __stdcall glIsShader(GLuint shader) |
| 3587 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3588 | EVENT("(GLuint shader = %d)", shader); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3589 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3590 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3591 | if (context && shader) |
| 3592 | { |
| 3593 | gl::Shader *shaderObject = context->getShader(shader); |
| 3594 | |
| 3595 | if (shaderObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3596 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3597 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3598 | } |
| 3599 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3600 | |
| 3601 | return GL_FALSE; |
| 3602 | } |
| 3603 | |
| 3604 | GLboolean __stdcall glIsTexture(GLuint texture) |
| 3605 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3606 | EVENT("(GLuint texture = %d)", texture); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3607 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3608 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3609 | if (context && texture) |
| 3610 | { |
| 3611 | gl::Texture *textureObject = context->getTexture(texture); |
| 3612 | |
| 3613 | if (textureObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3614 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3615 | return GL_TRUE; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3616 | } |
| 3617 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3618 | |
| 3619 | return GL_FALSE; |
| 3620 | } |
| 3621 | |
| 3622 | void __stdcall glLineWidth(GLfloat width) |
| 3623 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3624 | EVENT("(GLfloat width = %f)", width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3625 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3626 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3627 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3628 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3629 | if (width <= 0.0f) |
| 3630 | { |
| 3631 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3632 | return; |
| 3633 | } |
| 3634 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3635 | context->getState().setLineWidth(width); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3636 | } |
| 3637 | } |
| 3638 | |
| 3639 | void __stdcall glLinkProgram(GLuint program) |
| 3640 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3641 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3642 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3643 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3644 | if (context) |
| 3645 | { |
| 3646 | gl::Program *programObject = context->getProgram(program); |
| 3647 | |
| 3648 | if (!programObject) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3649 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3650 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3651 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3652 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 3653 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3654 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3655 | else |
| 3656 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3657 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3658 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3659 | } |
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 | |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 3662 | gl::Error error = context->linkProgram(program); |
| 3663 | if (error.isError()) |
| 3664 | { |
| 3665 | context->recordError(error); |
| 3666 | return; |
| 3667 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3668 | } |
| 3669 | } |
| 3670 | |
| 3671 | void __stdcall glPixelStorei(GLenum pname, GLint param) |
| 3672 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3673 | EVENT("(GLenum pname = 0x%X, GLint param = %d)", pname, param); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3674 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3675 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3676 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3677 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3678 | switch (pname) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3679 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3680 | case GL_UNPACK_ALIGNMENT: |
| 3681 | if (param != 1 && param != 2 && param != 4 && param != 8) |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3682 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3683 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3684 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3685 | } |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3686 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3687 | context->getState().setUnpackAlignment(param); |
| 3688 | break; |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3689 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3690 | case GL_PACK_ALIGNMENT: |
| 3691 | if (param != 1 && param != 2 && param != 4 && param != 8) |
| 3692 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3693 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3694 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3695 | } |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3696 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3697 | context->getState().setPackAlignment(param); |
| 3698 | break; |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3699 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3700 | case GL_PACK_REVERSE_ROW_ORDER_ANGLE: |
| 3701 | context->getState().setPackReverseRowOrder(param != 0); |
| 3702 | break; |
bsalomon@google.com | 56d46ab | 2011-11-23 14:53:10 +0000 | [diff] [blame] | 3703 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3704 | case GL_UNPACK_IMAGE_HEIGHT: |
| 3705 | case GL_UNPACK_SKIP_IMAGES: |
| 3706 | case GL_UNPACK_ROW_LENGTH: |
| 3707 | case GL_UNPACK_SKIP_ROWS: |
| 3708 | case GL_UNPACK_SKIP_PIXELS: |
| 3709 | case GL_PACK_ROW_LENGTH: |
| 3710 | case GL_PACK_SKIP_ROWS: |
| 3711 | case GL_PACK_SKIP_PIXELS: |
| 3712 | if (context->getClientVersion() < 3) |
| 3713 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3714 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3715 | return; |
daniel@transgaming.com | 3489e3a | 2010-03-21 04:31:11 +0000 | [diff] [blame] | 3716 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3717 | UNIMPLEMENTED(); |
| 3718 | break; |
| 3719 | |
| 3720 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3721 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3722 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3723 | } |
| 3724 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | void __stdcall glPolygonOffset(GLfloat factor, GLfloat units) |
| 3728 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3729 | EVENT("(GLfloat factor = %f, GLfloat units = %f)", factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3730 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3731 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3732 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3733 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3734 | context->getState().setPolygonOffsetParams(factor, units); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3735 | } |
| 3736 | } |
| 3737 | |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3738 | void __stdcall glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height, |
| 3739 | GLenum format, GLenum type, GLsizei bufSize, |
| 3740 | GLvoid *data) |
| 3741 | { |
| 3742 | EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, " |
| 3743 | "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)", |
| 3744 | x, y, width, height, format, type, bufSize, data); |
| 3745 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3746 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3747 | if (context) |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3748 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3749 | if (width < 0 || height < 0 || bufSize < 0) |
| 3750 | { |
| 3751 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3752 | return; |
| 3753 | } |
| 3754 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3755 | if (!gl::ValidateReadPixelsParameters(context, x, y, width, height, |
| 3756 | format, type, &bufSize, data)) |
| 3757 | { |
| 3758 | return; |
| 3759 | } |
| 3760 | |
Geoff Lang | 63d2fc7 | 2014-07-25 14:51:41 -0400 | [diff] [blame] | 3761 | gl::Error error = context->readPixels(x, y, width, height, format, type, &bufSize, data); |
| 3762 | if (error.isError()) |
| 3763 | { |
| 3764 | context->recordError(error); |
| 3765 | return; |
| 3766 | } |
daniel@transgaming.com | b7915a5 | 2011-11-12 03:14:20 +0000 | [diff] [blame] | 3767 | } |
| 3768 | } |
| 3769 | |
| 3770 | void __stdcall glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, |
| 3771 | GLenum format, GLenum type, GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3772 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3773 | 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] | 3774 | "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] | 3775 | x, y, width, height, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3776 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3777 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3778 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3779 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3780 | if (width < 0 || height < 0) |
| 3781 | { |
| 3782 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3783 | return; |
| 3784 | } |
| 3785 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3786 | if (!gl::ValidateReadPixelsParameters(context, x, y, width, height, |
| 3787 | format, type, NULL, pixels)) |
| 3788 | { |
| 3789 | return; |
| 3790 | } |
| 3791 | |
Geoff Lang | 63d2fc7 | 2014-07-25 14:51:41 -0400 | [diff] [blame] | 3792 | gl::Error error = context->readPixels(x, y, width, height, format, type, NULL, pixels); |
| 3793 | if (error.isError()) |
| 3794 | { |
| 3795 | context->recordError(error); |
| 3796 | return; |
| 3797 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3798 | } |
| 3799 | } |
| 3800 | |
| 3801 | void __stdcall glReleaseShaderCompiler(void) |
| 3802 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3803 | EVENT("()"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3804 | |
Brandon Jones | f05cdee | 2014-08-27 15:24:07 -0700 | [diff] [blame] | 3805 | gl::Context *context = gl::getNonLostContext(); |
| 3806 | |
| 3807 | if (context) |
| 3808 | { |
| 3809 | context->releaseShaderCompiler(); |
| 3810 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3811 | } |
| 3812 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3813 | 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] | 3814 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3815 | 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] | 3816 | target, samples, internalformat, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3817 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3818 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3819 | if (context) |
| 3820 | { |
| 3821 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 3822 | width, height, true)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3823 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3824 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3825 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3826 | |
| 3827 | context->setRenderbufferStorage(width, height, internalformat, samples); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3828 | } |
| 3829 | } |
| 3830 | |
daniel@transgaming.com | 1f135d8 | 2010-08-24 19:20:36 +0000 | [diff] [blame] | 3831 | void __stdcall glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) |
| 3832 | { |
| 3833 | glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height); |
| 3834 | } |
| 3835 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3836 | void __stdcall glSampleCoverage(GLclampf value, GLboolean invert) |
| 3837 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 3838 | EVENT("(GLclampf value = %f, GLboolean invert = %u)", value, invert); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3839 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3840 | gl::Context* context = gl::getNonLostContext(); |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3841 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3842 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3843 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3844 | context->getState().setSampleCoverageParams(gl::clamp01(value), invert == GL_TRUE); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3845 | } |
| 3846 | } |
| 3847 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3848 | void __stdcall glSetFenceNV(GLuint fence, GLenum condition) |
| 3849 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3850 | EVENT("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3851 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3852 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3853 | if (context) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3854 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3855 | if (condition != GL_ALL_COMPLETED_NV) |
| 3856 | { |
| 3857 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3858 | return; |
| 3859 | } |
| 3860 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3861 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 3862 | |
| 3863 | if (fenceObject == NULL) |
| 3864 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3865 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 3866 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3867 | } |
| 3868 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 3869 | gl::Error error = fenceObject->setFence(condition); |
| 3870 | if (error.isError()) |
| 3871 | { |
| 3872 | context->recordError(error); |
| 3873 | return; |
| 3874 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3875 | } |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 3876 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 3877 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3878 | void __stdcall glScissor(GLint x, GLint y, GLsizei width, GLsizei height) |
| 3879 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3880 | 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] | 3881 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3882 | gl::Context* context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3883 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3884 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3885 | if (width < 0 || height < 0) |
| 3886 | { |
| 3887 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3888 | return; |
| 3889 | } |
| 3890 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3891 | context->getState().setScissorParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3892 | } |
| 3893 | } |
| 3894 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 3895 | 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] | 3896 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3897 | 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] | 3898 | "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
daniel@transgaming.com | b5b0616 | 2010-03-21 04:31:32 +0000 | [diff] [blame] | 3899 | n, shaders, binaryformat, binary, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3900 | |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3901 | gl::Context* context = gl::getNonLostContext(); |
| 3902 | if (context) |
| 3903 | { |
| 3904 | const std::vector<GLenum> &shaderBinaryFormats = context->getCaps().shaderBinaryFormats; |
| 3905 | if (std::find(shaderBinaryFormats.begin(), shaderBinaryFormats.end(), binaryformat) == shaderBinaryFormats.end()) |
| 3906 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3907 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3908 | return; |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 3909 | } |
| 3910 | |
| 3911 | // No binary shader formats are supported. |
| 3912 | UNIMPLEMENTED(); |
| 3913 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3914 | } |
| 3915 | |
shannon.woods%transgaming.com@gtempaccount.com | 5f33933 | 2013-04-13 03:29:02 +0000 | [diff] [blame] | 3916 | 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] | 3917 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3918 | 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] | 3919 | shader, count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3920 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3921 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3922 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3923 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3924 | if (count < 0) |
| 3925 | { |
| 3926 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3927 | return; |
| 3928 | } |
| 3929 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3930 | gl::Shader *shaderObject = context->getShader(shader); |
| 3931 | |
| 3932 | if (!shaderObject) |
| 3933 | { |
| 3934 | if (context->getProgram(shader)) |
| 3935 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3936 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 3937 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3938 | } |
| 3939 | else |
| 3940 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3941 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 3942 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | |
| 3946 | shaderObject->setSource(count, string, length); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3947 | } |
| 3948 | } |
| 3949 | |
| 3950 | void __stdcall glStencilFunc(GLenum func, GLint ref, GLuint mask) |
| 3951 | { |
daniel@transgaming.com | fab5a1a | 2010-03-11 19:22:30 +0000 | [diff] [blame] | 3952 | glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3953 | } |
| 3954 | |
| 3955 | void __stdcall glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) |
| 3956 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 3957 | 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] | 3958 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3959 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3960 | if (context) |
| 3961 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 3962 | switch (face) |
| 3963 | { |
| 3964 | case GL_FRONT: |
| 3965 | case GL_BACK: |
| 3966 | case GL_FRONT_AND_BACK: |
| 3967 | break; |
| 3968 | |
| 3969 | default: |
| 3970 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3971 | return; |
| 3972 | } |
| 3973 | |
| 3974 | switch (func) |
| 3975 | { |
| 3976 | case GL_NEVER: |
| 3977 | case GL_ALWAYS: |
| 3978 | case GL_LESS: |
| 3979 | case GL_LEQUAL: |
| 3980 | case GL_EQUAL: |
| 3981 | case GL_GEQUAL: |
| 3982 | case GL_GREATER: |
| 3983 | case GL_NOTEQUAL: |
| 3984 | break; |
| 3985 | |
| 3986 | default: |
| 3987 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 3988 | return; |
| 3989 | } |
| 3990 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 3991 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 3992 | { |
| 3993 | context->getState().setStencilParams(func, ref, mask); |
| 3994 | } |
| 3995 | |
| 3996 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 3997 | { |
| 3998 | context->getState().setStencilBackParams(func, ref, mask); |
| 3999 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4000 | } |
| 4001 | } |
| 4002 | |
| 4003 | void __stdcall glStencilMask(GLuint mask) |
| 4004 | { |
| 4005 | glStencilMaskSeparate(GL_FRONT_AND_BACK, mask); |
| 4006 | } |
| 4007 | |
| 4008 | void __stdcall glStencilMaskSeparate(GLenum face, GLuint mask) |
| 4009 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4010 | EVENT("(GLenum face = 0x%X, GLuint mask = %d)", face, mask); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4011 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4012 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4013 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4014 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4015 | switch (face) |
| 4016 | { |
| 4017 | case GL_FRONT: |
| 4018 | case GL_BACK: |
| 4019 | case GL_FRONT_AND_BACK: |
| 4020 | break; |
| 4021 | |
| 4022 | default: |
| 4023 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4024 | return; |
| 4025 | } |
| 4026 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4027 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4028 | { |
| 4029 | context->getState().setStencilWritemask(mask); |
| 4030 | } |
| 4031 | |
| 4032 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4033 | { |
| 4034 | context->getState().setStencilBackWritemask(mask); |
| 4035 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4036 | } |
| 4037 | } |
| 4038 | |
| 4039 | void __stdcall glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) |
| 4040 | { |
| 4041 | glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass); |
| 4042 | } |
| 4043 | |
| 4044 | void __stdcall glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) |
| 4045 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4046 | 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] | 4047 | face, fail, zfail, zpass); |
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 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4050 | if (context) |
| 4051 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4052 | switch (face) |
| 4053 | { |
| 4054 | case GL_FRONT: |
| 4055 | case GL_BACK: |
| 4056 | case GL_FRONT_AND_BACK: |
| 4057 | break; |
| 4058 | |
| 4059 | default: |
| 4060 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4061 | return; |
| 4062 | } |
| 4063 | |
| 4064 | switch (fail) |
| 4065 | { |
| 4066 | case GL_ZERO: |
| 4067 | case GL_KEEP: |
| 4068 | case GL_REPLACE: |
| 4069 | case GL_INCR: |
| 4070 | case GL_DECR: |
| 4071 | case GL_INVERT: |
| 4072 | case GL_INCR_WRAP: |
| 4073 | case GL_DECR_WRAP: |
| 4074 | break; |
| 4075 | |
| 4076 | default: |
| 4077 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4078 | return; |
| 4079 | } |
| 4080 | |
| 4081 | switch (zfail) |
| 4082 | { |
| 4083 | case GL_ZERO: |
| 4084 | case GL_KEEP: |
| 4085 | case GL_REPLACE: |
| 4086 | case GL_INCR: |
| 4087 | case GL_DECR: |
| 4088 | case GL_INVERT: |
| 4089 | case GL_INCR_WRAP: |
| 4090 | case GL_DECR_WRAP: |
| 4091 | break; |
| 4092 | |
| 4093 | default: |
| 4094 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4095 | return; |
| 4096 | } |
| 4097 | |
| 4098 | switch (zpass) |
| 4099 | { |
| 4100 | case GL_ZERO: |
| 4101 | case GL_KEEP: |
| 4102 | case GL_REPLACE: |
| 4103 | case GL_INCR: |
| 4104 | case GL_DECR: |
| 4105 | case GL_INVERT: |
| 4106 | case GL_INCR_WRAP: |
| 4107 | case GL_DECR_WRAP: |
| 4108 | break; |
| 4109 | |
| 4110 | default: |
| 4111 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4112 | return; |
| 4113 | } |
| 4114 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4115 | if (face == GL_FRONT || face == GL_FRONT_AND_BACK) |
| 4116 | { |
| 4117 | context->getState().setStencilOperations(fail, zfail, zpass); |
| 4118 | } |
| 4119 | |
| 4120 | if (face == GL_BACK || face == GL_FRONT_AND_BACK) |
| 4121 | { |
| 4122 | context->getState().setStencilBackOperations(fail, zfail, zpass); |
| 4123 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4124 | } |
| 4125 | } |
| 4126 | |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4127 | GLboolean __stdcall glTestFenceNV(GLuint fence) |
| 4128 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4129 | EVENT("(GLuint fence = %d)", fence); |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4130 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4131 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4132 | if (context) |
| 4133 | { |
| 4134 | gl::FenceNV *fenceObject = context->getFenceNV(fence); |
| 4135 | |
| 4136 | if (fenceObject == NULL) |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4137 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4138 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4139 | return GL_TRUE; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4140 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4141 | |
| 4142 | if (fenceObject->isFence() != GL_TRUE) |
| 4143 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4144 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4145 | return GL_TRUE; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4146 | } |
| 4147 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 4148 | GLboolean result; |
| 4149 | gl::Error error = fenceObject->testFence(&result); |
| 4150 | if (error.isError()) |
| 4151 | { |
| 4152 | context->recordError(error); |
| 4153 | return GL_TRUE; |
| 4154 | } |
| 4155 | |
| 4156 | return result; |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4157 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4158 | |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4159 | return GL_TRUE; |
daniel@transgaming.com | fe20888 | 2010-09-01 15:47:57 +0000 | [diff] [blame] | 4160 | } |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 4161 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4162 | void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, |
| 4163 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4164 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4165 | 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] | 4166 | "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] | 4167 | target, level, internalformat, width, height, border, format, type, pixels); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4168 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4169 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4170 | if (context) |
| 4171 | { |
| 4172 | if (context->getClientVersion() < 3 && |
| 4173 | !ValidateES2TexImageParameters(context, target, level, internalformat, false, false, |
| 4174 | 0, 0, width, height, border, format, type, pixels)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4175 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4176 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4177 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4178 | |
| 4179 | if (context->getClientVersion() >= 3 && |
| 4180 | !ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 4181 | 0, 0, 0, width, height, 1, border, format, type, pixels)) |
| 4182 | { |
| 4183 | return; |
| 4184 | } |
| 4185 | |
| 4186 | switch (target) |
| 4187 | { |
| 4188 | case GL_TEXTURE_2D: |
| 4189 | { |
| 4190 | gl::Texture2D *texture = context->getTexture2D(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 4191 | gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 4192 | if (error.isError()) |
| 4193 | { |
| 4194 | context->recordError(error); |
| 4195 | return; |
| 4196 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4197 | } |
| 4198 | break; |
Geoff Lang | 8376cea | 2014-09-02 11:47:07 -0400 | [diff] [blame] | 4199 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4200 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4201 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4202 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4203 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4204 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4205 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 4206 | { |
| 4207 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
Geoff Lang | 8376cea | 2014-09-02 11:47:07 -0400 | [diff] [blame] | 4208 | gl::Error error = texture->setImage(target, level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 4209 | if (error.isError()) |
| 4210 | { |
| 4211 | context->recordError(error); |
| 4212 | return; |
| 4213 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4214 | } |
| 4215 | break; |
Geoff Lang | 8376cea | 2014-09-02 11:47:07 -0400 | [diff] [blame] | 4216 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4217 | default: UNREACHABLE(); |
| 4218 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4219 | } |
| 4220 | } |
| 4221 | |
| 4222 | void __stdcall glTexParameterf(GLenum target, GLenum pname, GLfloat param) |
| 4223 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4224 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint param = %f)", target, pname, param); |
| 4225 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4226 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4227 | if (context) |
| 4228 | { |
| 4229 | if (!ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4230 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4231 | return; |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4232 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4233 | |
| 4234 | gl::Texture *texture = context->getTargetTexture(target); |
| 4235 | |
| 4236 | if (!texture) |
| 4237 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4238 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4239 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4240 | } |
| 4241 | |
| 4242 | switch (pname) |
| 4243 | { |
| 4244 | case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = gl::uiround<GLenum>(param); break; |
| 4245 | case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = gl::uiround<GLenum>(param); break; |
| 4246 | case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = gl::uiround<GLenum>(param); break; |
| 4247 | case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = gl::uiround<GLenum>(param); break; |
| 4248 | case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = gl::uiround<GLenum>(param); break; |
| 4249 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage(gl::uiround<GLenum>(param)); break; |
| 4250 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min(param, context->getExtensions().maxTextureAnisotropy); break; |
| 4251 | case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = gl::uiround<GLenum>(param); break; |
| 4252 | case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = gl::uiround<GLenum>(param); break; |
| 4253 | case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = gl::uiround<GLenum>(param); break; |
| 4254 | case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = gl::uiround<GLenum>(param); break; |
| 4255 | case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = gl::uiround<GLenum>(param); break; |
| 4256 | case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = gl::uiround<GLenum>(param); break; |
| 4257 | case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = gl::iround<GLint>(param); break; |
| 4258 | case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = gl::iround<GLint>(param); break; |
| 4259 | case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = param; break; |
| 4260 | case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = param; break; |
| 4261 | default: UNREACHABLE(); break; |
| 4262 | } |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4263 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4264 | } |
| 4265 | |
| 4266 | void __stdcall glTexParameterfv(GLenum target, GLenum pname, const GLfloat* params) |
| 4267 | { |
daniel@transgaming.com | 07ab841 | 2012-07-12 15:17:09 +0000 | [diff] [blame] | 4268 | glTexParameterf(target, pname, (GLfloat)*params); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4269 | } |
| 4270 | |
| 4271 | void __stdcall glTexParameteri(GLenum target, GLenum pname, GLint param) |
| 4272 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4273 | 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] | 4274 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4275 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4276 | if (context) |
| 4277 | { |
| 4278 | if (!ValidateTexParamParameters(context, pname, param)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4279 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4280 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4281 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4282 | |
| 4283 | gl::Texture *texture = context->getTargetTexture(target); |
| 4284 | |
| 4285 | if (!texture) |
| 4286 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4287 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4288 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4289 | } |
| 4290 | |
| 4291 | switch (pname) |
| 4292 | { |
| 4293 | case GL_TEXTURE_WRAP_S: texture->getSamplerState().wrapS = (GLenum)param; break; |
| 4294 | case GL_TEXTURE_WRAP_T: texture->getSamplerState().wrapT = (GLenum)param; break; |
| 4295 | case GL_TEXTURE_WRAP_R: texture->getSamplerState().wrapR = (GLenum)param; break; |
| 4296 | case GL_TEXTURE_MIN_FILTER: texture->getSamplerState().minFilter = (GLenum)param; break; |
| 4297 | case GL_TEXTURE_MAG_FILTER: texture->getSamplerState().magFilter = (GLenum)param; break; |
| 4298 | case GL_TEXTURE_USAGE_ANGLE: texture->setUsage((GLenum)param); break; |
| 4299 | case GL_TEXTURE_MAX_ANISOTROPY_EXT: texture->getSamplerState().maxAnisotropy = std::min((float)param, context->getExtensions().maxTextureAnisotropy); break; |
| 4300 | case GL_TEXTURE_COMPARE_MODE: texture->getSamplerState().compareMode = (GLenum)param; break; |
| 4301 | case GL_TEXTURE_COMPARE_FUNC: texture->getSamplerState().compareFunc = (GLenum)param; break; |
| 4302 | case GL_TEXTURE_SWIZZLE_R: texture->getSamplerState().swizzleRed = (GLenum)param; break; |
| 4303 | case GL_TEXTURE_SWIZZLE_G: texture->getSamplerState().swizzleGreen = (GLenum)param; break; |
| 4304 | case GL_TEXTURE_SWIZZLE_B: texture->getSamplerState().swizzleBlue = (GLenum)param; break; |
| 4305 | case GL_TEXTURE_SWIZZLE_A: texture->getSamplerState().swizzleAlpha = (GLenum)param; break; |
| 4306 | case GL_TEXTURE_BASE_LEVEL: texture->getSamplerState().baseLevel = param; break; |
| 4307 | case GL_TEXTURE_MAX_LEVEL: texture->getSamplerState().maxLevel = param; break; |
| 4308 | case GL_TEXTURE_MIN_LOD: texture->getSamplerState().minLod = (GLfloat)param; break; |
| 4309 | case GL_TEXTURE_MAX_LOD: texture->getSamplerState().maxLod = (GLfloat)param; break; |
| 4310 | default: UNREACHABLE(); break; |
| 4311 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4312 | } |
| 4313 | } |
| 4314 | |
| 4315 | void __stdcall glTexParameteriv(GLenum target, GLenum pname, const GLint* params) |
| 4316 | { |
| 4317 | glTexParameteri(target, pname, *params); |
| 4318 | } |
| 4319 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4320 | void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 4321 | { |
| 4322 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 4323 | target, levels, internalformat, width, height); |
| 4324 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4325 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4326 | if (context) |
| 4327 | { |
| 4328 | if (!context->getExtensions().textureStorage) |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4329 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4330 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4331 | return; |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4332 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4333 | |
| 4334 | if (context->getClientVersion() < 3 && |
| 4335 | !ValidateES2TexStorageParameters(context, target, levels, internalformat, width, height)) |
| 4336 | { |
| 4337 | return; |
| 4338 | } |
| 4339 | |
| 4340 | if (context->getClientVersion() >= 3 && |
| 4341 | !ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 4342 | { |
| 4343 | return; |
| 4344 | } |
| 4345 | |
| 4346 | switch (target) |
| 4347 | { |
| 4348 | case GL_TEXTURE_2D: |
| 4349 | { |
| 4350 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 4351 | texture2d->storage(levels, internalformat, width, height); |
| 4352 | } |
| 4353 | break; |
| 4354 | |
| 4355 | case GL_TEXTURE_CUBE_MAP: |
| 4356 | { |
| 4357 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 4358 | textureCube->storage(levels, internalformat, width); |
| 4359 | } |
| 4360 | break; |
| 4361 | |
| 4362 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4363 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4364 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4365 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 4366 | } |
| 4367 | } |
| 4368 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4369 | void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, |
| 4370 | GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4371 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4372 | 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] | 4373 | "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] | 4374 | "const GLvoid* pixels = 0x%0.8p)", |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4375 | target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 4376 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4377 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4378 | if (context) |
| 4379 | { |
| 4380 | if (context->getClientVersion() < 3 && |
| 4381 | !ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, |
| 4382 | xoffset, yoffset, width, height, 0, format, type, pixels)) |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 4383 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4384 | return; |
daniel@transgaming.com | 00c7596 | 2010-03-11 20:36:15 +0000 | [diff] [blame] | 4385 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4386 | |
| 4387 | if (context->getClientVersion() >= 3 && |
| 4388 | !ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 4389 | xoffset, yoffset, 0, width, height, 1, 0, format, type, pixels)) |
| 4390 | { |
| 4391 | return; |
| 4392 | } |
| 4393 | |
| 4394 | // Zero sized uploads are valid but no-ops |
| 4395 | if (width == 0 || height == 0) |
| 4396 | { |
| 4397 | return; |
| 4398 | } |
| 4399 | |
| 4400 | switch (target) |
| 4401 | { |
| 4402 | case GL_TEXTURE_2D: |
| 4403 | { |
| 4404 | gl::Texture2D *texture = context->getTexture2D(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 4405 | gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); |
| 4406 | if (error.isError()) |
| 4407 | { |
| 4408 | context->recordError(error); |
| 4409 | return; |
| 4410 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4411 | } |
| 4412 | break; |
| 4413 | |
| 4414 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
| 4415 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
| 4416 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
| 4417 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
| 4418 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
| 4419 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
| 4420 | { |
| 4421 | gl::TextureCubeMap *texture = context->getTextureCubeMap(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 4422 | gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); |
| 4423 | if (error.isError()) |
| 4424 | { |
| 4425 | context->recordError(error); |
| 4426 | return; |
| 4427 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4428 | } |
| 4429 | break; |
| 4430 | |
| 4431 | default: |
| 4432 | UNREACHABLE(); |
| 4433 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4434 | } |
| 4435 | } |
| 4436 | |
| 4437 | void __stdcall glUniform1f(GLint location, GLfloat x) |
| 4438 | { |
| 4439 | glUniform1fv(location, 1, &x); |
| 4440 | } |
| 4441 | |
| 4442 | void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) |
| 4443 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4444 | 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] | 4445 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4446 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4447 | if (context) |
| 4448 | { |
| 4449 | if (!ValidateUniform(context, GL_FLOAT, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4450 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4451 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4452 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4453 | |
| 4454 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4455 | programBinary->setUniform1fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4456 | } |
| 4457 | } |
| 4458 | |
| 4459 | void __stdcall glUniform1i(GLint location, GLint x) |
| 4460 | { |
| 4461 | glUniform1iv(location, 1, &x); |
| 4462 | } |
| 4463 | |
| 4464 | void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) |
| 4465 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4466 | 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] | 4467 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4468 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4469 | if (context) |
| 4470 | { |
| 4471 | if (!ValidateUniform(context, GL_INT, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4472 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4473 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4474 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4475 | |
| 4476 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4477 | programBinary->setUniform1iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4478 | } |
| 4479 | } |
| 4480 | |
| 4481 | void __stdcall glUniform2f(GLint location, GLfloat x, GLfloat y) |
| 4482 | { |
| 4483 | GLfloat xy[2] = {x, y}; |
| 4484 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4485 | glUniform2fv(location, 1, xy); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4486 | } |
| 4487 | |
| 4488 | void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) |
| 4489 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4490 | 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] | 4491 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4492 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4493 | if (context) |
| 4494 | { |
| 4495 | if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4496 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4497 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4498 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4499 | |
| 4500 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4501 | programBinary->setUniform2fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4502 | } |
| 4503 | } |
| 4504 | |
| 4505 | void __stdcall glUniform2i(GLint location, GLint x, GLint y) |
| 4506 | { |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4507 | GLint xy[2] = {x, y}; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4508 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4509 | glUniform2iv(location, 1, xy); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4510 | } |
| 4511 | |
| 4512 | void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) |
| 4513 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4514 | 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] | 4515 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4516 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4517 | if (context) |
| 4518 | { |
| 4519 | if (!ValidateUniform(context, GL_INT_VEC2, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4520 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4521 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4522 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4523 | |
| 4524 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4525 | programBinary->setUniform2iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4526 | } |
| 4527 | } |
| 4528 | |
| 4529 | void __stdcall glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) |
| 4530 | { |
| 4531 | GLfloat xyz[3] = {x, y, z}; |
| 4532 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4533 | glUniform3fv(location, 1, xyz); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4534 | } |
| 4535 | |
| 4536 | void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) |
| 4537 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4538 | 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] | 4539 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4540 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4541 | if (context) |
| 4542 | { |
| 4543 | if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count)) |
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 | return; |
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 | |
| 4548 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4549 | programBinary->setUniform3fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4550 | } |
| 4551 | } |
| 4552 | |
| 4553 | void __stdcall glUniform3i(GLint location, GLint x, GLint y, GLint z) |
| 4554 | { |
| 4555 | GLint xyz[3] = {x, y, z}; |
| 4556 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4557 | glUniform3iv(location, 1, xyz); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4558 | } |
| 4559 | |
| 4560 | void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) |
| 4561 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4562 | 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] | 4563 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4564 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4565 | if (context) |
| 4566 | { |
| 4567 | if (!ValidateUniform(context, GL_INT_VEC3, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4568 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4569 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4570 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4571 | |
| 4572 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4573 | programBinary->setUniform3iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4574 | } |
| 4575 | } |
| 4576 | |
| 4577 | void __stdcall glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4578 | { |
| 4579 | GLfloat xyzw[4] = {x, y, z, w}; |
| 4580 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4581 | glUniform4fv(location, 1, xyzw); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4582 | } |
| 4583 | |
| 4584 | void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) |
| 4585 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4586 | 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] | 4587 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4588 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4589 | if (context) |
| 4590 | { |
| 4591 | if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4592 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4593 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4594 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4595 | |
| 4596 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4597 | programBinary->setUniform4fv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4598 | } |
| 4599 | } |
| 4600 | |
| 4601 | void __stdcall glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) |
| 4602 | { |
| 4603 | GLint xyzw[4] = {x, y, z, w}; |
| 4604 | |
Geoff Lang | 3b3ad1f | 2014-03-05 14:35:01 -0500 | [diff] [blame] | 4605 | glUniform4iv(location, 1, xyzw); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4606 | } |
| 4607 | |
| 4608 | void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) |
| 4609 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4610 | 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] | 4611 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4612 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4613 | if (context) |
| 4614 | { |
| 4615 | if (!ValidateUniform(context, GL_INT_VEC4, location, count)) |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4616 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4617 | return; |
daniel@transgaming.com | 9a95e2b | 2010-04-13 03:26:03 +0000 | [diff] [blame] | 4618 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4619 | |
| 4620 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4621 | programBinary->setUniform4iv(location, count, v); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4622 | } |
| 4623 | } |
| 4624 | |
| 4625 | void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4626 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4627 | 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] | 4628 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4629 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4630 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4631 | if (context) |
| 4632 | { |
| 4633 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose)) |
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 | return; |
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 | |
| 4638 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4639 | programBinary->setUniformMatrix2fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4640 | } |
| 4641 | } |
| 4642 | |
| 4643 | void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4644 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4645 | 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] | 4646 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4647 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4648 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4649 | if (context) |
| 4650 | { |
| 4651 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4652 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4653 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4654 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4655 | |
| 4656 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4657 | programBinary->setUniformMatrix3fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4658 | } |
| 4659 | } |
| 4660 | |
| 4661 | void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 4662 | { |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4663 | 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] | 4664 | location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4665 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4666 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4667 | if (context) |
| 4668 | { |
| 4669 | if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose)) |
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 | return; |
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 | |
| 4674 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 4675 | programBinary->setUniformMatrix4fv(location, count, transpose, value); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4676 | } |
| 4677 | } |
| 4678 | |
| 4679 | void __stdcall glUseProgram(GLuint program) |
| 4680 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4681 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4682 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4683 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4684 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4685 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4686 | gl::Program *programObject = context->getProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4687 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4688 | if (!programObject && program != 0) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4689 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4690 | if (context->getShader(program)) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4691 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4692 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4693 | return; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4694 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4695 | else |
| 4696 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4697 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4698 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4699 | } |
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 | |
| 4702 | if (program != 0 && !programObject->isLinked()) |
| 4703 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4704 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4705 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4706 | } |
| 4707 | |
| 4708 | context->useProgram(program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4709 | } |
| 4710 | } |
| 4711 | |
| 4712 | void __stdcall glValidateProgram(GLuint program) |
| 4713 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4714 | EVENT("(GLuint program = %d)", program); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4715 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4716 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4717 | if (context) |
| 4718 | { |
| 4719 | gl::Program *programObject = context->getProgram(program); |
| 4720 | |
| 4721 | if (!programObject) |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4722 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4723 | if (context->getShader(program)) |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4724 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4725 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4726 | return; |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4727 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4728 | else |
| 4729 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4730 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4731 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4732 | } |
daniel@transgaming.com | 86a7a13 | 2010-04-29 03:32:32 +0000 | [diff] [blame] | 4733 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4734 | |
Brandon Jones | 43a53e2 | 2014-08-28 16:23:22 -0700 | [diff] [blame] | 4735 | programObject->validate(context->getCaps()); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4736 | } |
| 4737 | } |
| 4738 | |
| 4739 | void __stdcall glVertexAttrib1f(GLuint index, GLfloat x) |
| 4740 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4741 | EVENT("(GLuint index = %d, GLfloat x = %f)", index, x); |
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 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4744 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4745 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4746 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4747 | { |
| 4748 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4749 | return; |
| 4750 | } |
| 4751 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4752 | GLfloat vals[4] = { x, 0, 0, 1 }; |
| 4753 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4754 | } |
| 4755 | } |
| 4756 | |
| 4757 | void __stdcall glVertexAttrib1fv(GLuint index, const GLfloat* values) |
| 4758 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4759 | 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] | 4760 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4761 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4762 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4763 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4764 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4765 | { |
| 4766 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4767 | return; |
| 4768 | } |
| 4769 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4770 | GLfloat vals[4] = { values[0], 0, 0, 1 }; |
| 4771 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4772 | } |
| 4773 | } |
| 4774 | |
| 4775 | void __stdcall glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y) |
| 4776 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4777 | 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] | 4778 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4779 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4780 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4781 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4782 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4783 | { |
| 4784 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4785 | return; |
| 4786 | } |
| 4787 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4788 | GLfloat vals[4] = { x, y, 0, 1 }; |
| 4789 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4790 | } |
| 4791 | } |
| 4792 | |
| 4793 | void __stdcall glVertexAttrib2fv(GLuint index, const GLfloat* values) |
| 4794 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4795 | 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] | 4796 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4797 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4798 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4799 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4800 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4801 | { |
| 4802 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4803 | return; |
| 4804 | } |
| 4805 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4806 | GLfloat vals[4] = { values[0], values[1], 0, 1 }; |
| 4807 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4808 | } |
| 4809 | } |
| 4810 | |
| 4811 | void __stdcall glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) |
| 4812 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4813 | 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] | 4814 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4815 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4816 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4817 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4818 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4819 | { |
| 4820 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4821 | return; |
| 4822 | } |
| 4823 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4824 | GLfloat vals[4] = { x, y, z, 1 }; |
| 4825 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4826 | } |
| 4827 | } |
| 4828 | |
| 4829 | void __stdcall glVertexAttrib3fv(GLuint index, const GLfloat* values) |
| 4830 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4831 | 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] | 4832 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4833 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4834 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4835 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4836 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4837 | { |
| 4838 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4839 | return; |
| 4840 | } |
| 4841 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4842 | GLfloat vals[4] = { values[0], values[1], values[2], 1 }; |
| 4843 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4844 | } |
| 4845 | } |
| 4846 | |
| 4847 | void __stdcall glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
| 4848 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4849 | 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] | 4850 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4851 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4852 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4853 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4854 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4855 | { |
| 4856 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4857 | return; |
| 4858 | } |
| 4859 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4860 | GLfloat vals[4] = { x, y, z, w }; |
| 4861 | context->getState().setVertexAttribf(index, vals); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4862 | } |
| 4863 | } |
| 4864 | |
| 4865 | void __stdcall glVertexAttrib4fv(GLuint index, const GLfloat* values) |
| 4866 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4867 | 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] | 4868 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4869 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4870 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4871 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4872 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4873 | { |
| 4874 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4875 | return; |
| 4876 | } |
| 4877 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4878 | context->getState().setVertexAttribf(index, values); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4879 | } |
| 4880 | } |
| 4881 | |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4882 | void __stdcall glVertexAttribDivisorANGLE(GLuint index, GLuint divisor) |
| 4883 | { |
| 4884 | EVENT("(GLuint index = %d, GLuint divisor = %d)", index, divisor); |
| 4885 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4886 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4887 | if (context) |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4888 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4889 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4890 | { |
| 4891 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4892 | return; |
| 4893 | } |
| 4894 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4895 | context->setVertexAttribDivisor(index, divisor); |
daniel@transgaming.com | d2820bf | 2012-01-27 15:38:48 +0000 | [diff] [blame] | 4896 | } |
| 4897 | } |
| 4898 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 4899 | 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] | 4900 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4901 | 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] | 4902 | "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] | 4903 | index, size, type, normalized, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4904 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4905 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4906 | if (context) |
| 4907 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4908 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 4909 | { |
| 4910 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4911 | return; |
| 4912 | } |
| 4913 | |
| 4914 | if (size < 1 || size > 4) |
| 4915 | { |
| 4916 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4917 | return; |
| 4918 | } |
| 4919 | |
| 4920 | switch (type) |
| 4921 | { |
| 4922 | case GL_BYTE: |
| 4923 | case GL_UNSIGNED_BYTE: |
| 4924 | case GL_SHORT: |
| 4925 | case GL_UNSIGNED_SHORT: |
| 4926 | case GL_FIXED: |
| 4927 | case GL_FLOAT: |
| 4928 | break; |
| 4929 | |
| 4930 | case GL_HALF_FLOAT: |
| 4931 | case GL_INT: |
| 4932 | case GL_UNSIGNED_INT: |
| 4933 | case GL_INT_2_10_10_10_REV: |
| 4934 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 4935 | if (context->getClientVersion() < 3) |
| 4936 | { |
| 4937 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4938 | return; |
| 4939 | } |
| 4940 | break; |
| 4941 | |
| 4942 | default: |
| 4943 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 4944 | return; |
| 4945 | } |
| 4946 | |
| 4947 | if (stride < 0) |
| 4948 | { |
| 4949 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4950 | return; |
| 4951 | } |
| 4952 | |
| 4953 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 4954 | { |
| 4955 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4956 | return; |
| 4957 | } |
| 4958 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4959 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 4960 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 4961 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 4962 | // and the pointer argument is not NULL. |
| 4963 | 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] | 4964 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4965 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 4966 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 4967 | } |
| 4968 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4969 | context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, |
| 4970 | normalized == GL_TRUE, false, stride, ptr); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4971 | } |
| 4972 | } |
| 4973 | |
| 4974 | void __stdcall glViewport(GLint x, GLint y, GLsizei width, GLsizei height) |
| 4975 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 4976 | 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] | 4977 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4978 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4979 | if (context) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4980 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 4981 | if (width < 0 || height < 0) |
| 4982 | { |
| 4983 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 4984 | return; |
| 4985 | } |
| 4986 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4987 | context->getState().setViewportParams(x, y, width, height); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 4988 | } |
| 4989 | } |
| 4990 | |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 4991 | // OpenGL ES 3.0 functions |
| 4992 | |
| 4993 | void __stdcall glReadBuffer(GLenum mode) |
| 4994 | { |
| 4995 | EVENT("(GLenum mode = 0x%X)", mode); |
| 4996 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4997 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 4998 | if (context) |
| 4999 | { |
| 5000 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5001 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5002 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5003 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5004 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5005 | |
| 5006 | // glReadBuffer |
| 5007 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5008 | } |
| 5009 | } |
| 5010 | |
| 5011 | void __stdcall glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) |
| 5012 | { |
| 5013 | EVENT("(GLenum mode = 0x%X, GLuint start = %u, GLuint end = %u, GLsizei count = %d, GLenum type = 0x%X, " |
| 5014 | "const GLvoid* indices = 0x%0.8p)", mode, start, end, count, type, indices); |
| 5015 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5016 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5017 | if (context) |
| 5018 | { |
| 5019 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5020 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5021 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5022 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5023 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5024 | |
| 5025 | // glDrawRangeElements |
| 5026 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5027 | } |
| 5028 | } |
| 5029 | |
| 5030 | void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
| 5031 | { |
| 5032 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint internalformat = %d, GLsizei width = %d, " |
| 5033 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLenum format = 0x%X, " |
| 5034 | "GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 5035 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 5036 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5037 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5038 | if (context) |
| 5039 | { |
| 5040 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5041 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5042 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5043 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 5044 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5045 | |
| 5046 | // validateES3TexImageFormat sets the error code if there is an error |
| 5047 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, false, false, |
| 5048 | 0, 0, 0, width, height, depth, border, format, type, pixels)) |
| 5049 | { |
| 5050 | return; |
| 5051 | } |
| 5052 | |
| 5053 | switch(target) |
| 5054 | { |
| 5055 | case GL_TEXTURE_3D: |
| 5056 | { |
| 5057 | gl::Texture3D *texture = context->getTexture3D(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 5058 | gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 5059 | if (error.isError()) |
| 5060 | { |
| 5061 | context->recordError(error); |
| 5062 | return; |
| 5063 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5064 | } |
| 5065 | break; |
| 5066 | |
| 5067 | case GL_TEXTURE_2D_ARRAY: |
| 5068 | { |
| 5069 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 5070 | gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); |
| 5071 | if (error.isError()) |
| 5072 | { |
| 5073 | context->recordError(error); |
| 5074 | return; |
| 5075 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5076 | } |
| 5077 | break; |
| 5078 | |
| 5079 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5080 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5081 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5082 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5083 | } |
| 5084 | } |
| 5085 | |
| 5086 | 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) |
| 5087 | { |
| 5088 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 5089 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 5090 | "GLenum format = 0x%X, GLenum type = 0x%X, const GLvoid* pixels = 0x%0.8p)", |
| 5091 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); |
| 5092 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5093 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5094 | if (context) |
| 5095 | { |
| 5096 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5097 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5098 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5099 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 5100 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5101 | |
| 5102 | // validateES3TexImageFormat sets the error code if there is an error |
| 5103 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, false, true, |
| 5104 | xoffset, yoffset, zoffset, width, height, depth, 0, |
| 5105 | format, type, pixels)) |
| 5106 | { |
| 5107 | return; |
| 5108 | } |
| 5109 | |
| 5110 | // Zero sized uploads are valid but no-ops |
| 5111 | if (width == 0 || height == 0 || depth == 0) |
| 5112 | { |
| 5113 | return; |
| 5114 | } |
| 5115 | |
| 5116 | switch(target) |
| 5117 | { |
| 5118 | case GL_TEXTURE_3D: |
| 5119 | { |
| 5120 | gl::Texture3D *texture = context->getTexture3D(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 5121 | gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); |
| 5122 | if (error.isError()) |
| 5123 | { |
| 5124 | context->recordError(error); |
| 5125 | return; |
| 5126 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5127 | } |
| 5128 | break; |
| 5129 | |
| 5130 | case GL_TEXTURE_2D_ARRAY: |
| 5131 | { |
| 5132 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
Geoff Lang | 1ba6b8d | 2014-08-28 10:57:31 -0400 | [diff] [blame] | 5133 | gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); |
| 5134 | if (error.isError()) |
| 5135 | { |
| 5136 | context->recordError(error); |
| 5137 | return; |
| 5138 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5139 | } |
| 5140 | break; |
| 5141 | |
| 5142 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5143 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5144 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5145 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5146 | } |
| 5147 | } |
| 5148 | |
| 5149 | void __stdcall glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) |
| 5150 | { |
| 5151 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 5152 | "GLint zoffset = %d, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 5153 | target, level, xoffset, yoffset, zoffset, x, y, width, height); |
| 5154 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5155 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5156 | if (context) |
| 5157 | { |
| 5158 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5159 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5160 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5161 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 5162 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5163 | |
| 5164 | if (!ValidateES3CopyTexImageParameters(context, target, level, GL_NONE, true, xoffset, yoffset, zoffset, |
| 5165 | x, y, width, height, 0)) |
| 5166 | { |
| 5167 | return; |
| 5168 | } |
| 5169 | |
| 5170 | gl::Framebuffer *framebuffer = context->getState().getReadFramebuffer(); |
| 5171 | gl::Texture *texture = NULL; |
| 5172 | switch (target) |
| 5173 | { |
| 5174 | case GL_TEXTURE_3D: |
| 5175 | texture = context->getTexture3D(); |
| 5176 | break; |
| 5177 | |
| 5178 | case GL_TEXTURE_2D_ARRAY: |
| 5179 | texture = context->getTexture2DArray(); |
| 5180 | break; |
| 5181 | |
| 5182 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5183 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5184 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5185 | } |
| 5186 | |
| 5187 | 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] | 5188 | } |
| 5189 | } |
| 5190 | |
| 5191 | void __stdcall glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) |
| 5192 | { |
Geoff Lang | eef52cc | 2013-10-16 15:07:39 -0400 | [diff] [blame] | 5193 | 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] | 5194 | "GLsizei height = %d, GLsizei depth = %d, GLint border = %d, GLsizei imageSize = %d, " |
| 5195 | "const GLvoid* data = 0x%0.8p)", |
| 5196 | target, level, internalformat, width, height, depth, border, imageSize, data); |
| 5197 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5198 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5199 | if (context) |
| 5200 | { |
| 5201 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5202 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5203 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5204 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 5205 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5206 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 5207 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat); |
| 5208 | 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] | 5209 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5210 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5211 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5212 | } |
| 5213 | |
| 5214 | // validateES3TexImageFormat sets the error code if there is an error |
| 5215 | if (!ValidateES3TexImageParameters(context, target, level, internalformat, true, false, |
| 5216 | 0, 0, 0, width, height, depth, border, GL_NONE, GL_NONE, data)) |
| 5217 | { |
| 5218 | return; |
| 5219 | } |
| 5220 | |
| 5221 | switch(target) |
| 5222 | { |
| 5223 | case GL_TEXTURE_3D: |
| 5224 | { |
| 5225 | gl::Texture3D *texture = context->getTexture3D(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 5226 | gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 5227 | if (error.isError()) |
| 5228 | { |
| 5229 | context->recordError(error); |
| 5230 | return; |
| 5231 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5232 | } |
| 5233 | break; |
| 5234 | |
| 5235 | case GL_TEXTURE_2D_ARRAY: |
| 5236 | { |
| 5237 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 5238 | gl::Error error = texture->setCompressedImage(level, internalformat, width, height, depth, imageSize, data); |
| 5239 | if (error.isError()) |
| 5240 | { |
| 5241 | context->recordError(error); |
| 5242 | return; |
| 5243 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5244 | } |
| 5245 | break; |
| 5246 | |
| 5247 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5248 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5249 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5250 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5251 | } |
| 5252 | } |
| 5253 | |
| 5254 | 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) |
| 5255 | { |
| 5256 | EVENT("(GLenum target = 0x%X, GLint level = %d, GLint xoffset = %d, GLint yoffset = %d, " |
| 5257 | "GLint zoffset = %d, GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, " |
| 5258 | "GLenum format = 0x%X, GLsizei imageSize = %d, const GLvoid* data = 0x%0.8p)", |
| 5259 | target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); |
| 5260 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5261 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5262 | if (context) |
| 5263 | { |
| 5264 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5265 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5266 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5267 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 875994b | 2013-04-13 03:45:17 +0000 | [diff] [blame] | 5268 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5269 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 5270 | const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(format); |
| 5271 | 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] | 5272 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5273 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5274 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5275 | } |
| 5276 | |
| 5277 | if (!data) |
| 5278 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5279 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5280 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5281 | } |
| 5282 | |
| 5283 | // validateES3TexImageFormat sets the error code if there is an error |
| 5284 | if (!ValidateES3TexImageParameters(context, target, level, GL_NONE, true, true, |
| 5285 | 0, 0, 0, width, height, depth, 0, GL_NONE, GL_NONE, data)) |
| 5286 | { |
| 5287 | return; |
| 5288 | } |
| 5289 | |
| 5290 | // Zero sized uploads are valid but no-ops |
| 5291 | if (width == 0 || height == 0) |
| 5292 | { |
| 5293 | return; |
| 5294 | } |
| 5295 | |
| 5296 | switch(target) |
| 5297 | { |
| 5298 | case GL_TEXTURE_3D: |
| 5299 | { |
| 5300 | gl::Texture3D *texture = context->getTexture3D(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 5301 | gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 5302 | format, imageSize, data); |
| 5303 | if (error.isError()) |
| 5304 | { |
| 5305 | context->recordError(error); |
| 5306 | return; |
| 5307 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5308 | } |
| 5309 | break; |
| 5310 | |
| 5311 | case GL_TEXTURE_2D_ARRAY: |
| 5312 | { |
| 5313 | gl::Texture2DArray *texture = context->getTexture2DArray(); |
Geoff Lang | b534833 | 2014-09-02 13:16:34 -0400 | [diff] [blame] | 5314 | gl::Error error = texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, |
| 5315 | format, imageSize, data); |
| 5316 | if (error.isError()) |
| 5317 | { |
| 5318 | context->recordError(error); |
| 5319 | return; |
| 5320 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5321 | } |
| 5322 | break; |
| 5323 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5324 | default: |
| 5325 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5326 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5327 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5328 | } |
| 5329 | } |
| 5330 | |
| 5331 | void __stdcall glGenQueries(GLsizei n, GLuint* ids) |
| 5332 | { |
| 5333 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 5334 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5335 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5336 | if (context) |
| 5337 | { |
| 5338 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5339 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5340 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5341 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5342 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5343 | |
| 5344 | if (n < 0) |
| 5345 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5346 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5347 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5348 | } |
| 5349 | |
| 5350 | for (GLsizei i = 0; i < n; i++) |
| 5351 | { |
| 5352 | ids[i] = context->createQuery(); |
| 5353 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5354 | } |
| 5355 | } |
| 5356 | |
| 5357 | void __stdcall glDeleteQueries(GLsizei n, const GLuint* ids) |
| 5358 | { |
| 5359 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 5360 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5361 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5362 | if (context) |
| 5363 | { |
| 5364 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5365 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5366 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5367 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5368 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5369 | |
| 5370 | if (n < 0) |
| 5371 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5372 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5373 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5374 | } |
| 5375 | |
| 5376 | for (GLsizei i = 0; i < n; i++) |
| 5377 | { |
| 5378 | context->deleteQuery(ids[i]); |
| 5379 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5380 | } |
| 5381 | } |
| 5382 | |
| 5383 | GLboolean __stdcall glIsQuery(GLuint id) |
| 5384 | { |
| 5385 | EVENT("(GLuint id = %u)", id); |
| 5386 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5387 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5388 | if (context) |
| 5389 | { |
| 5390 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5391 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5392 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5393 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5394 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5395 | |
| 5396 | 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] | 5397 | } |
| 5398 | |
| 5399 | return GL_FALSE; |
| 5400 | } |
| 5401 | |
| 5402 | void __stdcall glBeginQuery(GLenum target, GLuint id) |
| 5403 | { |
| 5404 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 5405 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5406 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5407 | if (context) |
| 5408 | { |
| 5409 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5410 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5411 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5412 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5413 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5414 | |
| 5415 | if (!ValidateBeginQuery(context, target, id)) |
| 5416 | { |
| 5417 | return; |
| 5418 | } |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 5419 | |
| 5420 | gl::Error error = context->beginQuery(target, id); |
| 5421 | if (error.isError()) |
| 5422 | { |
| 5423 | context->recordError(error); |
| 5424 | return; |
| 5425 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5426 | } |
| 5427 | } |
| 5428 | |
| 5429 | void __stdcall glEndQuery(GLenum target) |
| 5430 | { |
| 5431 | EVENT("(GLenum target = 0x%X)", target); |
| 5432 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5433 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5434 | if (context) |
| 5435 | { |
| 5436 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5437 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5438 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5439 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5440 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5441 | |
| 5442 | if (!ValidateEndQuery(context, target)) |
| 5443 | { |
| 5444 | return; |
| 5445 | } |
| 5446 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 5447 | gl::Error error = context->endQuery(target); |
| 5448 | if (error.isError()) |
| 5449 | { |
| 5450 | context->recordError(error); |
| 5451 | return; |
| 5452 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5453 | } |
| 5454 | } |
| 5455 | |
| 5456 | void __stdcall glGetQueryiv(GLenum target, GLenum pname, GLint* params) |
| 5457 | { |
| 5458 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params); |
| 5459 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5460 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5461 | if (context) |
| 5462 | { |
| 5463 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5464 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5465 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5466 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5467 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5468 | |
| 5469 | if (!ValidQueryType(context, target)) |
| 5470 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5471 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5472 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5473 | } |
| 5474 | |
| 5475 | switch (pname) |
| 5476 | { |
| 5477 | case GL_CURRENT_QUERY: |
| 5478 | params[0] = static_cast<GLint>(context->getState().getActiveQueryId(target)); |
| 5479 | break; |
| 5480 | |
| 5481 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5482 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5483 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5484 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5485 | } |
| 5486 | } |
| 5487 | |
| 5488 | void __stdcall glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) |
| 5489 | { |
| 5490 | EVENT("(GLuint id = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", id, pname, params); |
| 5491 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5492 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5493 | if (context) |
| 5494 | { |
| 5495 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5496 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5497 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5498 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5499 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5500 | |
| 5501 | gl::Query *queryObject = context->getQuery(id, false, GL_NONE); |
| 5502 | |
| 5503 | if (!queryObject) |
| 5504 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5505 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5506 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5507 | } |
| 5508 | |
| 5509 | if (context->getState().getActiveQueryId(queryObject->getType()) == id) |
| 5510 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5511 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5512 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5513 | } |
| 5514 | |
| 5515 | switch(pname) |
| 5516 | { |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 5517 | case GL_QUERY_RESULT_EXT: |
| 5518 | { |
| 5519 | gl::Error error = queryObject->getResult(params); |
| 5520 | if (error.isError()) |
| 5521 | { |
| 5522 | context->recordError(error); |
| 5523 | return; |
| 5524 | } |
| 5525 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5526 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5527 | |
Geoff Lang | 5aad967 | 2014-09-08 11:10:42 -0400 | [diff] [blame] | 5528 | case GL_QUERY_RESULT_AVAILABLE_EXT: |
| 5529 | { |
| 5530 | gl::Error error = queryObject->isResultAvailable(params); |
| 5531 | if (error.isError()) |
| 5532 | { |
| 5533 | context->recordError(error); |
| 5534 | return; |
| 5535 | } |
| 5536 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5537 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5538 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5539 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5540 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5541 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5543 | } |
| 5544 | } |
| 5545 | |
| 5546 | GLboolean __stdcall glUnmapBuffer(GLenum target) |
| 5547 | { |
| 5548 | EVENT("(GLenum target = 0x%X)", target); |
| 5549 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5550 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5551 | if (context) |
| 5552 | { |
| 5553 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5554 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5555 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5556 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5557 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5558 | |
| 5559 | return glUnmapBufferOES(target); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5560 | } |
| 5561 | |
| 5562 | return GL_FALSE; |
| 5563 | } |
| 5564 | |
| 5565 | void __stdcall glGetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) |
| 5566 | { |
| 5567 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 5568 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5569 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5570 | if (context) |
| 5571 | { |
| 5572 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5573 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5574 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5575 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5576 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5577 | |
| 5578 | glGetBufferPointervOES(target, pname, params); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5579 | } |
| 5580 | } |
| 5581 | |
| 5582 | void __stdcall glDrawBuffers(GLsizei n, const GLenum* bufs) |
| 5583 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5584 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5585 | if (context) |
| 5586 | { |
| 5587 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5588 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5589 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5590 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 7948c5f | 2013-04-13 03:38:58 +0000 | [diff] [blame] | 5591 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5592 | |
| 5593 | glDrawBuffersEXT(n, bufs); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5598 | { |
| 5599 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5600 | location, count, transpose, value); |
| 5601 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5602 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5603 | if (context) |
| 5604 | { |
| 5605 | 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] | 5606 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5607 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5608 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5609 | |
| 5610 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5611 | programBinary->setUniformMatrix2x3fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5612 | } |
| 5613 | } |
| 5614 | |
| 5615 | void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5616 | { |
| 5617 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5618 | location, count, transpose, value); |
| 5619 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5620 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5621 | if (context) |
| 5622 | { |
| 5623 | 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] | 5624 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5625 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5626 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5627 | |
| 5628 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5629 | programBinary->setUniformMatrix3x2fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5630 | } |
| 5631 | } |
| 5632 | |
| 5633 | void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5634 | { |
| 5635 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5636 | location, count, transpose, value); |
| 5637 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5638 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5639 | if (context) |
| 5640 | { |
| 5641 | 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] | 5642 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5643 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5644 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5645 | |
| 5646 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5647 | programBinary->setUniformMatrix2x4fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5648 | } |
| 5649 | } |
| 5650 | |
| 5651 | void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5652 | { |
| 5653 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5654 | location, count, transpose, value); |
| 5655 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5656 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5657 | if (context) |
| 5658 | { |
| 5659 | 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] | 5660 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5661 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5662 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5663 | |
| 5664 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5665 | programBinary->setUniformMatrix4x2fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5666 | } |
| 5667 | } |
| 5668 | |
| 5669 | void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5670 | { |
| 5671 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5672 | location, count, transpose, value); |
| 5673 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5674 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5675 | if (context) |
| 5676 | { |
| 5677 | 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] | 5678 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5679 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5680 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5681 | |
| 5682 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5683 | programBinary->setUniformMatrix3x4fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5684 | } |
| 5685 | } |
| 5686 | |
| 5687 | void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) |
| 5688 | { |
| 5689 | EVENT("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %u, const GLfloat* value = 0x%0.8p)", |
| 5690 | location, count, transpose, value); |
| 5691 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5692 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5693 | if (context) |
| 5694 | { |
| 5695 | 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] | 5696 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5697 | return; |
shannon.woods%transgaming.com@gtempaccount.com | f130616 | 2013-04-13 03:40:04 +0000 | [diff] [blame] | 5698 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5699 | |
| 5700 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 5701 | programBinary->setUniformMatrix4x3fv(location, count, transpose, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5702 | } |
| 5703 | } |
| 5704 | |
| 5705 | void __stdcall glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) |
| 5706 | { |
| 5707 | EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, GLint dstX0 = %d, " |
| 5708 | "GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 5709 | srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 5710 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5711 | gl::Context *context = gl::getNonLostContext(); |
| 5712 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5713 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5714 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5715 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5716 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5717 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5718 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5719 | |
| 5720 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 5721 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 5722 | false)) |
| 5723 | { |
| 5724 | return; |
| 5725 | } |
| 5726 | |
Geoff Lang | 6483915 | 2014-08-26 16:23:25 -0400 | [diff] [blame] | 5727 | gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 5728 | mask, filter); |
| 5729 | if (error.isError()) |
| 5730 | { |
| 5731 | context->recordError(error); |
| 5732 | return; |
| 5733 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5734 | } |
| 5735 | } |
| 5736 | |
| 5737 | void __stdcall glRenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| 5738 | { |
| 5739 | EVENT("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 5740 | target, samples, internalformat, width, height); |
| 5741 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5742 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5743 | if (context) |
| 5744 | { |
| 5745 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5746 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5747 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5748 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5749 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5750 | |
| 5751 | if (!ValidateRenderbufferStorageParameters(context, target, samples, internalformat, |
| 5752 | width, height, false)) |
| 5753 | { |
| 5754 | return; |
| 5755 | } |
| 5756 | |
| 5757 | context->setRenderbufferStorage(width, height, internalformat, samples); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5758 | } |
| 5759 | } |
| 5760 | |
| 5761 | void __stdcall glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) |
| 5762 | { |
| 5763 | EVENT("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLuint texture = %u, GLint level = %d, GLint layer = %d)", |
| 5764 | target, attachment, texture, level, layer); |
| 5765 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5766 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5767 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5768 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5769 | if (!ValidateFramebufferTextureLayer(context, target, attachment, texture, |
| 5770 | level, layer)) |
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; |
| 5773 | } |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5774 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5775 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 5776 | ASSERT(framebuffer); |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5777 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5778 | gl::Texture *textureObject = context->getTexture(texture); |
| 5779 | GLenum textarget = textureObject ? textureObject->getTarget() : GL_NONE; |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5780 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5781 | if (attachment >= GL_COLOR_ATTACHMENT0_EXT && attachment <= GL_COLOR_ATTACHMENT15_EXT) |
| 5782 | { |
| 5783 | const unsigned int colorAttachment = (attachment - GL_COLOR_ATTACHMENT0_EXT); |
| 5784 | framebuffer->setColorbuffer(colorAttachment, textarget, texture, level, layer); |
| 5785 | } |
| 5786 | else |
| 5787 | { |
| 5788 | switch (attachment) |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5789 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5790 | case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture, level, layer); break; |
| 5791 | case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture, level, layer); break; |
| 5792 | case GL_DEPTH_STENCIL_ATTACHMENT: framebuffer->setDepthStencilBuffer(textarget, texture, level, layer); break; |
Geoff Lang | 3ed0c48 | 2013-07-25 17:03:18 -0400 | [diff] [blame] | 5793 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5794 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5795 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5796 | } |
| 5797 | |
| 5798 | GLvoid* __stdcall glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 5799 | { |
| 5800 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 5801 | target, offset, length, access); |
| 5802 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5803 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5804 | if (context) |
| 5805 | { |
| 5806 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5807 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5808 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5809 | return NULL; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5810 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5811 | |
| 5812 | return glMapBufferRangeEXT(target, offset, length, access); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5813 | } |
| 5814 | |
| 5815 | return NULL; |
| 5816 | } |
| 5817 | |
| 5818 | void __stdcall glFlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) |
| 5819 | { |
| 5820 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 5821 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5822 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5823 | if (context) |
| 5824 | { |
| 5825 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5826 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5827 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5828 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5829 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5830 | |
| 5831 | glFlushMappedBufferRangeEXT(target, offset, length); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5832 | } |
| 5833 | } |
| 5834 | |
| 5835 | void __stdcall glBindVertexArray(GLuint array) |
| 5836 | { |
| 5837 | EVENT("(GLuint array = %u)", array); |
| 5838 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5839 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5840 | if (context) |
| 5841 | { |
| 5842 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5843 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5844 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5845 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5846 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5847 | |
| 5848 | gl::VertexArray *vao = context->getVertexArray(array); |
| 5849 | |
| 5850 | if (!vao) |
| 5851 | { |
| 5852 | // The default VAO should always exist |
| 5853 | ASSERT(array != 0); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5854 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5855 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5856 | } |
| 5857 | |
| 5858 | context->bindVertexArray(array); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5859 | } |
| 5860 | } |
| 5861 | |
| 5862 | void __stdcall glDeleteVertexArrays(GLsizei n, const GLuint* arrays) |
| 5863 | { |
| 5864 | EVENT("(GLsizei n = %d, const GLuint* arrays = 0x%0.8p)", n, arrays); |
| 5865 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5866 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5867 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5868 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5869 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5870 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5871 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5872 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5873 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5874 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5875 | if (n < 0) |
| 5876 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5877 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5878 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5879 | } |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5880 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5881 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 5882 | { |
| 5883 | if (arrays[arrayIndex] != 0) |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5884 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5885 | context->deleteVertexArray(arrays[arrayIndex]); |
Jamie Madill | d102854 | 2013-07-02 11:57:04 -0400 | [diff] [blame] | 5886 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5887 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5888 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5889 | } |
| 5890 | |
| 5891 | void __stdcall glGenVertexArrays(GLsizei n, GLuint* arrays) |
| 5892 | { |
| 5893 | EVENT("(GLsizei n = %d, GLuint* arrays = 0x%0.8p)", n, arrays); |
| 5894 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5895 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5896 | if (context) |
| 5897 | { |
| 5898 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5899 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5900 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5901 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5902 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5903 | |
| 5904 | if (n < 0) |
| 5905 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5906 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5907 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5908 | } |
| 5909 | |
| 5910 | for (int arrayIndex = 0; arrayIndex < n; arrayIndex++) |
| 5911 | { |
| 5912 | arrays[arrayIndex] = context->createVertexArray(); |
| 5913 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5914 | } |
| 5915 | } |
| 5916 | |
| 5917 | GLboolean __stdcall glIsVertexArray(GLuint array) |
| 5918 | { |
| 5919 | EVENT("(GLuint array = %u)", array); |
| 5920 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5921 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5922 | if (context) |
| 5923 | { |
| 5924 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5925 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5926 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5927 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 5928 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5929 | |
| 5930 | if (array == 0) |
| 5931 | { |
| 5932 | return GL_FALSE; |
| 5933 | } |
| 5934 | |
| 5935 | gl::VertexArray *vao = context->getVertexArray(array); |
| 5936 | |
| 5937 | return (vao != NULL ? GL_TRUE : GL_FALSE); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5938 | } |
| 5939 | |
| 5940 | return GL_FALSE; |
| 5941 | } |
| 5942 | |
| 5943 | void __stdcall glGetIntegeri_v(GLenum target, GLuint index, GLint* data) |
| 5944 | { |
| 5945 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint* data = 0x%0.8p)", |
| 5946 | target, index, data); |
| 5947 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5948 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5949 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5950 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5951 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5952 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5953 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 5954 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5955 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 5956 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 5957 | const gl::Caps &caps = context->getCaps(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5958 | switch (target) |
| 5959 | { |
| 5960 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 5961 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 5962 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 5963 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
| 5964 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5965 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5966 | return; |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 5967 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5968 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5969 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5970 | case GL_UNIFORM_BUFFER_START: |
| 5971 | case GL_UNIFORM_BUFFER_SIZE: |
| 5972 | case GL_UNIFORM_BUFFER_BINDING: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 5973 | if (index >= caps.maxCombinedUniformBlocks) |
| 5974 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5975 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 5976 | return; |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 5977 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5978 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5979 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5980 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5981 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5982 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5983 | } |
| 5984 | |
| 5985 | if (!(context->getIndexedIntegerv(target, index, data))) |
| 5986 | { |
| 5987 | GLenum nativeType; |
| 5988 | unsigned int numParams = 0; |
| 5989 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5990 | { |
| 5991 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 5992 | return; |
| 5993 | } |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 5994 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5995 | if (numParams == 0) |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5996 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5997 | return; // it is known that pname is valid, but there are no parameters to return |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 5998 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 5999 | |
| 6000 | if (nativeType == GL_INT_64_ANGLEX) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6001 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6002 | GLint64 minIntValue = static_cast<GLint64>(std::numeric_limits<int>::min()); |
| 6003 | GLint64 maxIntValue = static_cast<GLint64>(std::numeric_limits<int>::max()); |
| 6004 | GLint64 *int64Params = new GLint64[numParams]; |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6005 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6006 | context->getIndexedInteger64v(target, index, int64Params); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6007 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6008 | for (unsigned int i = 0; i < numParams; ++i) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6009 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6010 | GLint64 clampedValue = std::max(std::min(int64Params[i], maxIntValue), minIntValue); |
| 6011 | data[i] = static_cast<GLint>(clampedValue); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6012 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6013 | |
| 6014 | delete [] int64Params; |
| 6015 | } |
| 6016 | else |
| 6017 | { |
| 6018 | UNREACHABLE(); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 6019 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6020 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6021 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6022 | } |
| 6023 | |
| 6024 | void __stdcall glBeginTransformFeedback(GLenum primitiveMode) |
| 6025 | { |
| 6026 | EVENT("(GLenum primitiveMode = 0x%X)", primitiveMode); |
| 6027 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6028 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6029 | if (context) |
| 6030 | { |
| 6031 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6032 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6033 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6034 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6035 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6036 | |
| 6037 | switch (primitiveMode) |
| 6038 | { |
| 6039 | case GL_TRIANGLES: |
| 6040 | case GL_LINES: |
| 6041 | case GL_POINTS: |
| 6042 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6043 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6044 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6045 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6046 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6047 | } |
| 6048 | |
| 6049 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 6050 | ASSERT(transformFeedback != NULL); |
| 6051 | |
| 6052 | if (transformFeedback->isStarted()) |
| 6053 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6054 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6055 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6056 | } |
| 6057 | |
| 6058 | if (transformFeedback->isPaused()) |
| 6059 | { |
| 6060 | transformFeedback->resume(); |
| 6061 | } |
| 6062 | else |
| 6063 | { |
| 6064 | transformFeedback->start(primitiveMode); |
| 6065 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6066 | } |
| 6067 | } |
| 6068 | |
| 6069 | void __stdcall glEndTransformFeedback(void) |
| 6070 | { |
| 6071 | EVENT("(void)"); |
| 6072 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6073 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6074 | if (context) |
| 6075 | { |
| 6076 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6077 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6078 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6079 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6080 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6081 | |
| 6082 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 6083 | ASSERT(transformFeedback != NULL); |
| 6084 | |
| 6085 | if (!transformFeedback->isStarted()) |
| 6086 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6087 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6088 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6089 | } |
| 6090 | |
| 6091 | transformFeedback->stop(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6092 | } |
| 6093 | } |
| 6094 | |
| 6095 | void __stdcall glBindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) |
| 6096 | { |
| 6097 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u, GLintptr offset = %d, GLsizeiptr size = %d)", |
| 6098 | target, index, buffer, offset, size); |
| 6099 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6100 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6101 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6102 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6103 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6104 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6105 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6106 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6107 | } |
| 6108 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 6109 | const gl::Caps &caps = context->getCaps(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6110 | switch (target) |
| 6111 | { |
| 6112 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 6113 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6114 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6115 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6116 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6117 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6118 | break; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6119 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6120 | case GL_UNIFORM_BUFFER: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 6121 | if (index >= caps.maxUniformBufferBindings) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6122 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6123 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6124 | return; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6125 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6126 | break; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6127 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6128 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6129 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6130 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6131 | } |
| 6132 | |
| 6133 | if (buffer != 0 && size <= 0) |
| 6134 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6135 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6136 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6137 | } |
| 6138 | |
| 6139 | switch (target) |
| 6140 | { |
| 6141 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 6142 | |
| 6143 | // size and offset must be a multiple of 4 |
| 6144 | 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] | 6145 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6146 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6147 | return; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6148 | } |
| 6149 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6150 | context->bindIndexedTransformFeedbackBuffer(buffer, index, offset, size); |
| 6151 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 6152 | break; |
| 6153 | |
| 6154 | case GL_UNIFORM_BUFFER: |
| 6155 | |
| 6156 | // it is an error to bind an offset not a multiple of the alignment |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 6157 | if (buffer != 0 && (offset % caps.uniformBufferOffsetAlignment) != 0) |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6158 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6159 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6160 | return; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6161 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6162 | |
| 6163 | context->bindIndexedUniformBuffer(buffer, index, offset, size); |
| 6164 | context->bindGenericUniformBuffer(buffer); |
| 6165 | break; |
| 6166 | |
| 6167 | default: |
| 6168 | UNREACHABLE(); |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6169 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6170 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6171 | } |
| 6172 | |
| 6173 | void __stdcall glBindBufferBase(GLenum target, GLuint index, GLuint buffer) |
| 6174 | { |
| 6175 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLuint buffer = %u)", |
| 6176 | target, index, buffer); |
| 6177 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6178 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6179 | if (context) |
| 6180 | { |
| 6181 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6182 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6183 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6184 | return; |
shannon.woods%transgaming.com@gtempaccount.com | d4e6197 | 2013-04-13 03:37:04 +0000 | [diff] [blame] | 6185 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6186 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 6187 | const gl::Caps &caps = context->getCaps(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6188 | switch (target) |
| 6189 | { |
| 6190 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 6191 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6192 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6193 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6194 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6195 | } |
| 6196 | break; |
| 6197 | |
| 6198 | case GL_UNIFORM_BUFFER: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 6199 | if (index >= caps.maxUniformBufferBindings) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6200 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6201 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6202 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6203 | } |
| 6204 | break; |
| 6205 | |
| 6206 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6207 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6208 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6209 | } |
| 6210 | |
| 6211 | switch (target) |
| 6212 | { |
| 6213 | case GL_TRANSFORM_FEEDBACK_BUFFER: |
| 6214 | context->bindIndexedTransformFeedbackBuffer(buffer, index, 0, 0); |
| 6215 | context->bindGenericTransformFeedbackBuffer(buffer); |
| 6216 | break; |
| 6217 | |
| 6218 | case GL_UNIFORM_BUFFER: |
| 6219 | context->bindIndexedUniformBuffer(buffer, index, 0, 0); |
| 6220 | context->bindGenericUniformBuffer(buffer); |
| 6221 | break; |
| 6222 | |
| 6223 | default: |
| 6224 | UNREACHABLE(); |
| 6225 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6226 | } |
| 6227 | } |
| 6228 | |
| 6229 | void __stdcall glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) |
| 6230 | { |
| 6231 | EVENT("(GLuint program = %u, GLsizei count = %d, const GLchar* const* varyings = 0x%0.8p, GLenum bufferMode = 0x%X)", |
| 6232 | program, count, varyings, bufferMode); |
| 6233 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6234 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6235 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6236 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6237 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6238 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6239 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6240 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6241 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6242 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6243 | if (count < 0) |
| 6244 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6245 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6246 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6247 | } |
| 6248 | |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 6249 | const gl::Caps &caps = context->getCaps(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6250 | switch (bufferMode) |
| 6251 | { |
| 6252 | case GL_INTERLEAVED_ATTRIBS: |
| 6253 | break; |
| 6254 | case GL_SEPARATE_ATTRIBS: |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 6255 | if (static_cast<GLuint>(count) > caps.maxTransformFeedbackSeparateAttributes) |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 6256 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6257 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6258 | return; |
Geoff Lang | 48dcae7 | 2014-02-05 16:28:24 -0500 | [diff] [blame] | 6259 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6260 | break; |
| 6261 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6262 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6263 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6264 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6265 | |
| 6266 | if (!gl::ValidProgram(context, program)) |
| 6267 | { |
| 6268 | return; |
| 6269 | } |
| 6270 | |
| 6271 | gl::Program *programObject = context->getProgram(program); |
| 6272 | ASSERT(programObject); |
| 6273 | |
| 6274 | programObject->setTransformFeedbackVaryings(count, varyings, bufferMode); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6275 | } |
| 6276 | } |
| 6277 | |
| 6278 | void __stdcall glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) |
| 6279 | { |
| 6280 | EVENT("(GLuint program = %u, GLuint index = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, " |
| 6281 | "GLsizei* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)", |
| 6282 | program, index, bufSize, length, size, type, name); |
| 6283 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6284 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6285 | if (context) |
| 6286 | { |
| 6287 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6288 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6289 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6290 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6291 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6292 | |
| 6293 | if (bufSize < 0) |
| 6294 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6295 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6296 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6297 | } |
| 6298 | |
| 6299 | if (!gl::ValidProgram(context, program)) |
| 6300 | { |
| 6301 | return; |
| 6302 | } |
| 6303 | |
| 6304 | gl::Program *programObject = context->getProgram(program); |
| 6305 | ASSERT(programObject); |
| 6306 | |
| 6307 | if (index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount())) |
| 6308 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6309 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6310 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6311 | } |
| 6312 | |
| 6313 | programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6314 | } |
| 6315 | } |
| 6316 | |
| 6317 | void __stdcall glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) |
| 6318 | { |
| 6319 | EVENT("(GLuint index = %u, GLint size = %d, GLenum type = 0x%X, GLsizei stride = %d, const GLvoid* pointer = 0x%0.8p)", |
| 6320 | index, size, type, stride, pointer); |
| 6321 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6322 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6323 | if (context) |
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->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6326 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6327 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6328 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6329 | } |
| 6330 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6331 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6332 | { |
| 6333 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6334 | return; |
| 6335 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6336 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6337 | if (size < 1 || size > 4) |
| 6338 | { |
| 6339 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6340 | return; |
| 6341 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6342 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6343 | switch (type) |
| 6344 | { |
| 6345 | case GL_BYTE: |
| 6346 | case GL_UNSIGNED_BYTE: |
| 6347 | case GL_SHORT: |
| 6348 | case GL_UNSIGNED_SHORT: |
| 6349 | case GL_INT: |
| 6350 | case GL_UNSIGNED_INT: |
| 6351 | case GL_INT_2_10_10_10_REV: |
| 6352 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 6353 | break; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6354 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6355 | default: |
| 6356 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6357 | return; |
| 6358 | } |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6359 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6360 | if (stride < 0) |
| 6361 | { |
| 6362 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6363 | return; |
| 6364 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6365 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6366 | if ((type == GL_INT_2_10_10_10_REV || type == GL_UNSIGNED_INT_2_10_10_10_REV) && size != 4) |
| 6367 | { |
| 6368 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6369 | return; |
| 6370 | } |
| 6371 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6372 | // [OpenGL ES 3.0.2] Section 2.8 page 24: |
| 6373 | // An INVALID_OPERATION error is generated when a non-zero vertex array object |
| 6374 | // is bound, zero is bound to the ARRAY_BUFFER buffer object binding point, |
| 6375 | // and the pointer argument is not NULL. |
| 6376 | 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] | 6377 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6378 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6379 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 1ab57be | 2013-04-13 03:38:39 +0000 | [diff] [blame] | 6380 | } |
| 6381 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6382 | context->getState().setVertexAttribState(index, context->getState().getTargetBuffer(GL_ARRAY_BUFFER), size, type, false, true, |
| 6383 | stride, pointer); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6384 | } |
| 6385 | } |
| 6386 | |
| 6387 | void __stdcall glGetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) |
| 6388 | { |
| 6389 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 6390 | index, pname, params); |
| 6391 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6392 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6393 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6394 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6395 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6396 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6397 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6398 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6399 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6400 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6401 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6402 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6403 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6404 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6405 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6406 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6407 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6408 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6409 | if (!gl::ValidateGetVertexAttribParameters(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6410 | { |
| 6411 | return; |
| 6412 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6413 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6414 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6415 | { |
| 6416 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 6417 | for (int i = 0; i < 4; ++i) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6418 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6419 | params[i] = currentValueData.IntValues[i]; |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6420 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6421 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6422 | else |
| 6423 | { |
| 6424 | *params = gl::QuerySingleVertexAttributeParameter<GLint>(attribState, pname); |
| 6425 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6426 | } |
| 6427 | } |
| 6428 | |
| 6429 | void __stdcall glGetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) |
| 6430 | { |
| 6431 | EVENT("(GLuint index = %u, GLenum pname = 0x%X, GLuint* params = 0x%0.8p)", |
| 6432 | index, pname, params); |
| 6433 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6434 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6435 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6436 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6437 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6438 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6439 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6440 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6441 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6442 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6443 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6444 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6445 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6446 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6447 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6448 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6449 | const gl::VertexAttribute &attribState = context->getState().getVertexAttribState(index); |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6450 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6451 | if (!gl::ValidateGetVertexAttribParameters(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6452 | { |
| 6453 | return; |
| 6454 | } |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6455 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6456 | if (pname == GL_CURRENT_VERTEX_ATTRIB) |
| 6457 | { |
| 6458 | const gl::VertexAttribCurrentValueData ¤tValueData = context->getState().getVertexAttribCurrentValue(index); |
| 6459 | for (int i = 0; i < 4; ++i) |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6460 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6461 | params[i] = currentValueData.UnsignedIntValues[i]; |
Jamie Madill | a7d0586 | 2013-07-02 11:57:06 -0400 | [diff] [blame] | 6462 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6463 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6464 | else |
| 6465 | { |
| 6466 | *params = gl::QuerySingleVertexAttributeParameter<GLuint>(attribState, pname); |
| 6467 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6468 | } |
| 6469 | } |
| 6470 | |
| 6471 | void __stdcall glVertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) |
| 6472 | { |
| 6473 | EVENT("(GLuint index = %u, GLint x = %d, GLint y = %d, GLint z = %d, GLint w = %d)", |
| 6474 | index, x, y, z, w); |
| 6475 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6476 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6477 | if (context) |
| 6478 | { |
| 6479 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6480 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6481 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6482 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6483 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6484 | |
| 6485 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6486 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6487 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6488 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6489 | } |
| 6490 | |
| 6491 | GLint vals[4] = { x, y, z, w }; |
| 6492 | context->getState().setVertexAttribi(index, vals); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6493 | } |
| 6494 | } |
| 6495 | |
| 6496 | void __stdcall glVertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) |
| 6497 | { |
| 6498 | EVENT("(GLuint index = %u, GLuint x = %u, GLuint y = %u, GLuint z = %u, GLuint w = %u)", |
| 6499 | index, x, y, z, w); |
| 6500 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6501 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6502 | if (context) |
| 6503 | { |
| 6504 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6505 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6506 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6507 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6508 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6509 | |
| 6510 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6511 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6512 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6513 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6514 | } |
| 6515 | |
| 6516 | GLuint vals[4] = { x, y, z, w }; |
| 6517 | context->getState().setVertexAttribu(index, vals); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6518 | } |
| 6519 | } |
| 6520 | |
| 6521 | void __stdcall glVertexAttribI4iv(GLuint index, const GLint* v) |
| 6522 | { |
| 6523 | EVENT("(GLuint index = %u, const GLint* v = 0x%0.8p)", index, v); |
| 6524 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6525 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6526 | if (context) |
| 6527 | { |
| 6528 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6529 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6530 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6531 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6532 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6533 | |
| 6534 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6535 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6536 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6537 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6538 | } |
| 6539 | |
| 6540 | context->getState().setVertexAttribi(index, v); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6541 | } |
| 6542 | } |
| 6543 | |
| 6544 | void __stdcall glVertexAttribI4uiv(GLuint index, const GLuint* v) |
| 6545 | { |
| 6546 | EVENT("(GLuint index = %u, const GLuint* v = 0x%0.8p)", index, v); |
| 6547 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6548 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6549 | if (context) |
| 6550 | { |
| 6551 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6552 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6553 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6554 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a888586 | 2013-04-13 03:37:53 +0000 | [diff] [blame] | 6555 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6556 | |
| 6557 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 6558 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6559 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6560 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6561 | } |
| 6562 | |
| 6563 | context->getState().setVertexAttribu(index, v); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6564 | } |
| 6565 | } |
| 6566 | |
| 6567 | void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) |
| 6568 | { |
| 6569 | EVENT("(GLuint program = %u, GLint location = %d, GLuint* params = 0x%0.8p)", |
| 6570 | program, location, params); |
| 6571 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6572 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6573 | if (context) |
| 6574 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6575 | if (!ValidateGetUniformuiv(context, program, location, params)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6576 | { |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6577 | return; |
shannon.woods%transgaming.com@gtempaccount.com | e229012 | 2013-04-13 03:41:07 +0000 | [diff] [blame] | 6578 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6579 | |
Jamie Madill | a502c74 | 2014-08-28 17:19:13 -0400 | [diff] [blame] | 6580 | gl::Program *programObject = context->getProgram(program); |
| 6581 | ASSERT(programObject); |
| 6582 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
Jamie Madill | 0063c51 | 2014-08-25 15:47:53 -0400 | [diff] [blame] | 6583 | ASSERT(programBinary); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6584 | |
Jamie Madill | 99a1e98 | 2014-08-25 15:47:54 -0400 | [diff] [blame] | 6585 | programBinary->getUniformuiv(location, params); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6586 | } |
| 6587 | } |
| 6588 | |
| 6589 | GLint __stdcall glGetFragDataLocation(GLuint program, const GLchar *name) |
| 6590 | { |
| 6591 | EVENT("(GLuint program = %u, const GLchar *name = 0x%0.8p)", |
| 6592 | program, name); |
| 6593 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6594 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6595 | if (context) |
| 6596 | { |
| 6597 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6598 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6599 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6600 | return -1; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6601 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6602 | |
| 6603 | if (program == 0) |
| 6604 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6605 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6606 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6607 | } |
| 6608 | |
| 6609 | gl::Program *programObject = context->getProgram(program); |
| 6610 | |
| 6611 | if (!programObject || !programObject->isLinked()) |
| 6612 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6613 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6614 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6615 | } |
| 6616 | |
| 6617 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 6618 | if (!programBinary) |
| 6619 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6620 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6621 | return -1; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6622 | } |
| 6623 | |
| 6624 | return programBinary->getFragDataLocation(name); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6625 | } |
| 6626 | |
| 6627 | return 0; |
| 6628 | } |
| 6629 | |
| 6630 | void __stdcall glUniform1ui(GLint location, GLuint v0) |
| 6631 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6632 | glUniform1uiv(location, 1, &v0); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6633 | } |
| 6634 | |
| 6635 | void __stdcall glUniform2ui(GLint location, GLuint v0, GLuint v1) |
| 6636 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6637 | const GLuint xy[] = { v0, v1 }; |
| 6638 | glUniform2uiv(location, 1, xy); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6639 | } |
| 6640 | |
| 6641 | void __stdcall glUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) |
| 6642 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6643 | const GLuint xyz[] = { v0, v1, v2 }; |
| 6644 | glUniform3uiv(location, 1, xyz); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6645 | } |
| 6646 | |
| 6647 | void __stdcall glUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) |
| 6648 | { |
shannon.woods%transgaming.com@gtempaccount.com | 8431b9c | 2013-04-13 03:40:17 +0000 | [diff] [blame] | 6649 | const GLuint xyzw[] = { v0, v1, v2, v3 }; |
| 6650 | glUniform4uiv(location, 1, xyzw); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6651 | } |
| 6652 | |
| 6653 | void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) |
| 6654 | { |
| 6655 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6656 | location, count, value); |
| 6657 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6658 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6659 | if (context) |
| 6660 | { |
| 6661 | if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6662 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6663 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6664 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6665 | |
| 6666 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6667 | programBinary->setUniform1uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6668 | } |
| 6669 | } |
| 6670 | |
| 6671 | void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) |
| 6672 | { |
| 6673 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6674 | location, count, value); |
| 6675 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6676 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6677 | if (context) |
| 6678 | { |
| 6679 | 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] | 6680 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6681 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6682 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6683 | |
| 6684 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6685 | programBinary->setUniform2uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6686 | } |
| 6687 | } |
| 6688 | |
| 6689 | void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) |
| 6690 | { |
| 6691 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value)", |
| 6692 | location, count, value); |
| 6693 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6694 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6695 | if (context) |
| 6696 | { |
| 6697 | 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] | 6698 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6699 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6700 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6701 | |
| 6702 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6703 | programBinary->setUniform3uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6704 | } |
| 6705 | } |
| 6706 | |
| 6707 | void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) |
| 6708 | { |
| 6709 | EVENT("(GLint location = %d, GLsizei count = %d, const GLuint* value = 0x%0.8p)", |
| 6710 | location, count, value); |
| 6711 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6712 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6713 | if (context) |
| 6714 | { |
| 6715 | 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] | 6716 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6717 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 50ea4ab | 2013-04-13 03:40:36 +0000 | [diff] [blame] | 6718 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6719 | |
| 6720 | gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); |
| 6721 | programBinary->setUniform4uiv(location, count, value); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6722 | } |
| 6723 | } |
| 6724 | |
| 6725 | void __stdcall glClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) |
| 6726 | { |
| 6727 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint* value = 0x%0.8p)", |
| 6728 | buffer, drawbuffer, value); |
| 6729 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6730 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6731 | if (context) |
| 6732 | { |
| 6733 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6734 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6735 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6736 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6737 | |
| 6738 | switch (buffer) |
| 6739 | { |
| 6740 | case GL_COLOR: |
| 6741 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6742 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6743 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6744 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6745 | } |
| 6746 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6747 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6748 | case GL_STENCIL: |
| 6749 | if (drawbuffer != 0) |
| 6750 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6751 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6752 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6753 | } |
| 6754 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6755 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6756 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6757 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6758 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6759 | } |
| 6760 | |
Geoff Lang | cc79b8c | 2014-07-25 13:48:02 -0400 | [diff] [blame] | 6761 | gl::Error error = context->clearBufferiv(buffer, drawbuffer, value); |
| 6762 | if (error.isError()) |
| 6763 | { |
| 6764 | context->recordError(error); |
| 6765 | return; |
| 6766 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6767 | } |
| 6768 | } |
| 6769 | |
| 6770 | void __stdcall glClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) |
| 6771 | { |
| 6772 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint* value = 0x%0.8p)", |
| 6773 | buffer, drawbuffer, value); |
| 6774 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6775 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6776 | if (context) |
| 6777 | { |
| 6778 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6779 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6780 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6781 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6782 | |
| 6783 | switch (buffer) |
| 6784 | { |
| 6785 | case GL_COLOR: |
| 6786 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6787 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6788 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6789 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6790 | } |
| 6791 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6792 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6793 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6794 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6795 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6796 | } |
| 6797 | |
Geoff Lang | cc79b8c | 2014-07-25 13:48:02 -0400 | [diff] [blame] | 6798 | gl::Error error = context->clearBufferuiv(buffer, drawbuffer, value); |
| 6799 | if (error.isError()) |
| 6800 | { |
| 6801 | context->recordError(error); |
| 6802 | return; |
| 6803 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6804 | } |
| 6805 | } |
| 6806 | |
| 6807 | void __stdcall glClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) |
| 6808 | { |
| 6809 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat* value = 0x%0.8p)", |
| 6810 | buffer, drawbuffer, value); |
| 6811 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6812 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6813 | if (context) |
| 6814 | { |
| 6815 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6816 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6817 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6818 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6819 | |
| 6820 | switch (buffer) |
| 6821 | { |
| 6822 | case GL_COLOR: |
| 6823 | if (drawbuffer < 0 || static_cast<GLuint>(drawbuffer) >= context->getCaps().maxDrawBuffers) |
| 6824 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6825 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6826 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6827 | } |
| 6828 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6829 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6830 | case GL_DEPTH: |
| 6831 | if (drawbuffer != 0) |
| 6832 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6833 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6834 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6835 | } |
| 6836 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6837 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6838 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6839 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6840 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6841 | } |
| 6842 | |
Geoff Lang | cc79b8c | 2014-07-25 13:48:02 -0400 | [diff] [blame] | 6843 | gl::Error error = context->clearBufferfv(buffer, drawbuffer, value); |
| 6844 | if (error.isError()) |
| 6845 | { |
| 6846 | context->recordError(error); |
| 6847 | return; |
| 6848 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6849 | } |
| 6850 | } |
| 6851 | |
| 6852 | void __stdcall glClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) |
| 6853 | { |
| 6854 | EVENT("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth, GLint stencil = %d)", |
| 6855 | buffer, drawbuffer, depth, stencil); |
| 6856 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6857 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6858 | if (context) |
| 6859 | { |
| 6860 | if (!ValidateClearBuffer(context)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6861 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6862 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 6863 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6864 | |
| 6865 | switch (buffer) |
| 6866 | { |
| 6867 | case GL_DEPTH_STENCIL: |
| 6868 | if (drawbuffer != 0) |
| 6869 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6870 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6871 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6872 | } |
| 6873 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6874 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6875 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6876 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6877 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6878 | } |
| 6879 | |
Geoff Lang | cc79b8c | 2014-07-25 13:48:02 -0400 | [diff] [blame] | 6880 | gl::Error error = context->clearBufferfi(buffer, drawbuffer, depth, stencil); |
| 6881 | if (error.isError()) |
| 6882 | { |
| 6883 | context->recordError(error); |
| 6884 | return; |
| 6885 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6886 | } |
| 6887 | } |
| 6888 | |
| 6889 | const GLubyte* __stdcall glGetStringi(GLenum name, GLuint index) |
| 6890 | { |
| 6891 | EVENT("(GLenum name = 0x%X, GLuint index = %u)", name, index); |
| 6892 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6893 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6894 | if (context) |
| 6895 | { |
| 6896 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6897 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6898 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6899 | return NULL; |
shannonwoods@chromium.org | 302df74 | 2013-05-30 00:05:54 +0000 | [diff] [blame] | 6900 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6901 | |
| 6902 | if (name != GL_EXTENSIONS) |
| 6903 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6904 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6905 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6906 | } |
| 6907 | |
| 6908 | if (index >= context->getExtensionStringCount()) |
| 6909 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6910 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6911 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6912 | } |
| 6913 | |
| 6914 | 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] | 6915 | } |
| 6916 | |
| 6917 | return NULL; |
| 6918 | } |
| 6919 | |
| 6920 | void __stdcall glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) |
| 6921 | { |
| 6922 | EVENT("(GLenum readTarget = 0x%X, GLenum writeTarget = 0x%X, GLintptr readOffset = %d, GLintptr writeOffset = %d, GLsizeiptr size = %d)", |
| 6923 | readTarget, writeTarget, readOffset, writeOffset, size); |
| 6924 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6925 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6926 | if (context) |
| 6927 | { |
| 6928 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6929 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6930 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6931 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 296c3f2 | 2013-04-13 03:39:39 +0000 | [diff] [blame] | 6932 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6933 | |
| 6934 | if (!gl::ValidBufferTarget(context, readTarget) || !gl::ValidBufferTarget(context, readTarget)) |
| 6935 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6936 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 6937 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6938 | } |
| 6939 | |
| 6940 | gl::Buffer *readBuffer = context->getState().getTargetBuffer(readTarget); |
| 6941 | gl::Buffer *writeBuffer = context->getState().getTargetBuffer(writeTarget); |
| 6942 | |
| 6943 | if (!readBuffer || !writeBuffer) |
| 6944 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6945 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6946 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6947 | } |
| 6948 | |
Jamie Madill | cfaaf72 | 2014-07-31 10:47:54 -0400 | [diff] [blame] | 6949 | // Verify that readBuffer and writeBuffer are not currently mapped |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6950 | if (readBuffer->isMapped() || writeBuffer->isMapped()) |
| 6951 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6952 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6953 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6954 | } |
| 6955 | |
| 6956 | if (readOffset < 0 || writeOffset < 0 || size < 0 || |
| 6957 | static_cast<unsigned int>(readOffset + size) > readBuffer->getSize() || |
| 6958 | static_cast<unsigned int>(writeOffset + size) > writeBuffer->getSize()) |
| 6959 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6960 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6961 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6962 | } |
| 6963 | |
| 6964 | if (readBuffer == writeBuffer && abs(readOffset - writeOffset) < size) |
| 6965 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6966 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 6967 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6968 | } |
| 6969 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6970 | // if size is zero, the copy is a successful no-op |
| 6971 | if (size > 0) |
| 6972 | { |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 6973 | gl::Error error = writeBuffer->copyBufferSubData(readBuffer, readOffset, writeOffset, size); |
| 6974 | if (error.isError()) |
| 6975 | { |
| 6976 | context->recordError(error); |
| 6977 | return; |
| 6978 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6979 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6980 | } |
| 6981 | } |
| 6982 | |
| 6983 | void __stdcall glGetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) |
| 6984 | { |
| 6985 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLchar* const* uniformNames = 0x%0.8p, GLuint* uniformIndices = 0x%0.8p)", |
| 6986 | program, uniformCount, uniformNames, uniformIndices); |
| 6987 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6988 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6989 | if (context) |
| 6990 | { |
| 6991 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 6992 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6993 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 6994 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 6995 | } |
| 6996 | |
| 6997 | if (uniformCount < 0) |
| 6998 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 6999 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7000 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7001 | } |
| 7002 | |
| 7003 | gl::Program *programObject = context->getProgram(program); |
| 7004 | |
| 7005 | if (!programObject) |
| 7006 | { |
| 7007 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7008 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7009 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7010 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7011 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7012 | else |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 7013 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7014 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7015 | return; |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 7016 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7017 | } |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 7018 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7019 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7020 | if (!programObject->isLinked() || !programBinary) |
| 7021 | { |
| 7022 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 7023 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7024 | uniformIndices[uniformId] = GL_INVALID_INDEX; |
shannonwoods@chromium.org | c2ed991 | 2013-05-30 00:05:33 +0000 | [diff] [blame] | 7025 | } |
| 7026 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7027 | else |
| 7028 | { |
| 7029 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 7030 | { |
| 7031 | uniformIndices[uniformId] = programBinary->getUniformIndex(uniformNames[uniformId]); |
| 7032 | } |
| 7033 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7034 | } |
| 7035 | } |
| 7036 | |
| 7037 | void __stdcall glGetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) |
| 7038 | { |
| 7039 | EVENT("(GLuint program = %u, GLsizei uniformCount = %d, const GLuint* uniformIndices = 0x%0.8p, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 7040 | program, uniformCount, uniformIndices, pname, params); |
| 7041 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7042 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7043 | if (context) |
| 7044 | { |
| 7045 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7046 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7047 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7048 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7049 | } |
| 7050 | |
| 7051 | if (uniformCount < 0) |
| 7052 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7053 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7054 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7055 | } |
| 7056 | |
| 7057 | gl::Program *programObject = context->getProgram(program); |
| 7058 | |
| 7059 | if (!programObject) |
| 7060 | { |
| 7061 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7062 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7063 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7064 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7065 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7066 | else |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 7067 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7068 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7069 | return; |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 7070 | } |
shannonwoods@chromium.org | 2a9a9d2 | 2013-05-30 00:05:40 +0000 | [diff] [blame] | 7071 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7072 | |
| 7073 | switch (pname) |
| 7074 | { |
| 7075 | case GL_UNIFORM_TYPE: |
| 7076 | case GL_UNIFORM_SIZE: |
| 7077 | case GL_UNIFORM_NAME_LENGTH: |
| 7078 | case GL_UNIFORM_BLOCK_INDEX: |
| 7079 | case GL_UNIFORM_OFFSET: |
| 7080 | case GL_UNIFORM_ARRAY_STRIDE: |
| 7081 | case GL_UNIFORM_MATRIX_STRIDE: |
| 7082 | case GL_UNIFORM_IS_ROW_MAJOR: |
| 7083 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7084 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7085 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7086 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7087 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7088 | } |
| 7089 | |
| 7090 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7091 | |
| 7092 | if (!programBinary && uniformCount > 0) |
| 7093 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7094 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7095 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7096 | } |
| 7097 | |
| 7098 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 7099 | { |
| 7100 | const GLuint index = uniformIndices[uniformId]; |
| 7101 | |
| 7102 | if (index >= (GLuint)programBinary->getActiveUniformCount()) |
| 7103 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7104 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7105 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7106 | } |
| 7107 | } |
| 7108 | |
| 7109 | for (int uniformId = 0; uniformId < uniformCount; uniformId++) |
| 7110 | { |
| 7111 | const GLuint index = uniformIndices[uniformId]; |
| 7112 | params[uniformId] = programBinary->getActiveUniformi(index, pname); |
| 7113 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7114 | } |
| 7115 | } |
| 7116 | |
| 7117 | GLuint __stdcall glGetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) |
| 7118 | { |
| 7119 | EVENT("(GLuint program = %u, const GLchar* uniformBlockName = 0x%0.8p)", program, uniformBlockName); |
| 7120 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7121 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7122 | if (context) |
| 7123 | { |
| 7124 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7125 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7126 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7127 | return GL_INVALID_INDEX; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7128 | } |
| 7129 | |
| 7130 | gl::Program *programObject = context->getProgram(program); |
| 7131 | |
| 7132 | if (!programObject) |
| 7133 | { |
| 7134 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7135 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7136 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7137 | return GL_INVALID_INDEX; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7138 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7139 | else |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 7140 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7141 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7142 | return GL_INVALID_INDEX; |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 7143 | } |
shannonwoods@chromium.org | 4276625 | 2013-05-30 00:07:12 +0000 | [diff] [blame] | 7144 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7145 | |
| 7146 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7147 | if (!programBinary) |
| 7148 | { |
| 7149 | return GL_INVALID_INDEX; |
| 7150 | } |
| 7151 | |
| 7152 | return programBinary->getUniformBlockIndex(uniformBlockName); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7153 | } |
| 7154 | |
| 7155 | return 0; |
| 7156 | } |
| 7157 | |
| 7158 | void __stdcall glGetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) |
| 7159 | { |
| 7160 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", |
| 7161 | program, uniformBlockIndex, pname, params); |
| 7162 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7163 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7164 | if (context) |
| 7165 | { |
| 7166 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7167 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7168 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7169 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7170 | } |
| 7171 | gl::Program *programObject = context->getProgram(program); |
| 7172 | |
| 7173 | if (!programObject) |
| 7174 | { |
| 7175 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7176 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7177 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7178 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7179 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7180 | else |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 7181 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7182 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7183 | return; |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 7184 | } |
shannonwoods@chromium.org | e7317ca | 2013-05-30 00:07:35 +0000 | [diff] [blame] | 7185 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7186 | |
| 7187 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7188 | |
| 7189 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 7190 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7191 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7192 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7193 | } |
| 7194 | |
| 7195 | switch (pname) |
| 7196 | { |
| 7197 | case GL_UNIFORM_BLOCK_BINDING: |
| 7198 | *params = static_cast<GLint>(programObject->getUniformBlockBinding(uniformBlockIndex)); |
| 7199 | break; |
| 7200 | |
| 7201 | case GL_UNIFORM_BLOCK_DATA_SIZE: |
| 7202 | case GL_UNIFORM_BLOCK_NAME_LENGTH: |
| 7203 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS: |
| 7204 | case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: |
| 7205 | case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER: |
| 7206 | case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER: |
| 7207 | programBinary->getActiveUniformBlockiv(uniformBlockIndex, pname, params); |
| 7208 | break; |
| 7209 | |
| 7210 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7211 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7212 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7213 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7214 | } |
| 7215 | } |
| 7216 | |
| 7217 | void __stdcall glGetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) |
| 7218 | { |
| 7219 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLchar* uniformBlockName = 0x%0.8p)", |
| 7220 | program, uniformBlockIndex, bufSize, length, uniformBlockName); |
| 7221 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7222 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7223 | if (context) |
| 7224 | { |
| 7225 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7226 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7227 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7228 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7229 | } |
| 7230 | |
| 7231 | gl::Program *programObject = context->getProgram(program); |
| 7232 | |
| 7233 | if (!programObject) |
| 7234 | { |
| 7235 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7236 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7237 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7238 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7239 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7240 | else |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 7241 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7242 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7243 | return; |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 7244 | } |
shannonwoods@chromium.org | beb0278 | 2013-05-30 00:07:28 +0000 | [diff] [blame] | 7245 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7246 | |
| 7247 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7248 | |
| 7249 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 7250 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7251 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7252 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7253 | } |
| 7254 | |
| 7255 | programBinary->getActiveUniformBlockName(uniformBlockIndex, bufSize, length, uniformBlockName); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7256 | } |
| 7257 | } |
| 7258 | |
| 7259 | void __stdcall glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) |
| 7260 | { |
| 7261 | EVENT("(GLuint program = %u, GLuint uniformBlockIndex = %u, GLuint uniformBlockBinding = %u)", |
| 7262 | program, uniformBlockIndex, uniformBlockBinding); |
| 7263 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7264 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7265 | if (context) |
| 7266 | { |
| 7267 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7268 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7269 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7270 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7271 | } |
| 7272 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 7273 | if (uniformBlockBinding >= context->getCaps().maxUniformBufferBindings) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7274 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7275 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7276 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7277 | } |
| 7278 | |
| 7279 | gl::Program *programObject = context->getProgram(program); |
| 7280 | |
| 7281 | if (!programObject) |
| 7282 | { |
| 7283 | if (context->getShader(program)) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7284 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7285 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7286 | return; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7287 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7288 | else |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 7289 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7290 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7291 | return; |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 7292 | } |
shannonwoods@chromium.org | 70eb1ea | 2013-05-30 00:07:20 +0000 | [diff] [blame] | 7293 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7294 | |
| 7295 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 7296 | |
| 7297 | // if never linked, there won't be any uniform blocks |
| 7298 | if (!programBinary || uniformBlockIndex >= programBinary->getActiveUniformBlockCount()) |
| 7299 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7300 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7301 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7302 | } |
| 7303 | |
| 7304 | programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7305 | } |
| 7306 | } |
| 7307 | |
| 7308 | void __stdcall glDrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) |
| 7309 | { |
| 7310 | EVENT("(GLenum mode = 0x%X, GLint first = %d, GLsizei count = %d, GLsizei instanceCount = %d)", |
| 7311 | mode, first, count, instanceCount); |
| 7312 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7313 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7314 | if (context) |
| 7315 | { |
| 7316 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7317 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7318 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7319 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7320 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7321 | |
| 7322 | // glDrawArraysInstanced |
| 7323 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7324 | } |
| 7325 | } |
| 7326 | |
| 7327 | void __stdcall glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) |
| 7328 | { |
| 7329 | EVENT("(GLenum mode = 0x%X, GLsizei count = %d, GLenum type = 0x%X, const GLvoid* indices = 0x%0.8p, GLsizei instanceCount = %d)", |
| 7330 | mode, count, type, indices, instanceCount); |
| 7331 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7332 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7333 | if (context) |
| 7334 | { |
| 7335 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7336 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7337 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7338 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7339 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7340 | |
| 7341 | // glDrawElementsInstanced |
| 7342 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7343 | } |
| 7344 | } |
| 7345 | |
| 7346 | GLsync __stdcall glFenceSync(GLenum condition, GLbitfield flags) |
| 7347 | { |
| 7348 | EVENT("(GLenum condition = 0x%X, GLbitfield flags = 0x%X)", condition, flags); |
| 7349 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7350 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7351 | if (context) |
| 7352 | { |
| 7353 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7354 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7355 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7356 | return 0; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7357 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7358 | |
| 7359 | if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) |
| 7360 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7361 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7362 | return 0; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7363 | } |
| 7364 | |
| 7365 | if (flags != 0) |
| 7366 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7367 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7368 | return 0; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7369 | } |
| 7370 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 7371 | GLsync fenceSync = context->createFenceSync(); |
| 7372 | |
| 7373 | gl::FenceSync *fenceSyncObject = context->getFenceSync(fenceSync); |
| 7374 | gl::Error error = fenceSyncObject->set(condition); |
| 7375 | if (error.isError()) |
| 7376 | { |
| 7377 | context->deleteFenceSync(fenceSync); |
| 7378 | context->recordError(error); |
| 7379 | return NULL; |
| 7380 | } |
| 7381 | |
| 7382 | return fenceSync; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7383 | } |
| 7384 | |
| 7385 | return NULL; |
| 7386 | } |
| 7387 | |
| 7388 | GLboolean __stdcall glIsSync(GLsync sync) |
| 7389 | { |
| 7390 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 7391 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7392 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7393 | if (context) |
| 7394 | { |
| 7395 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7396 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7397 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7398 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7399 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7400 | |
| 7401 | return (context->getFenceSync(sync) != NULL); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7402 | } |
| 7403 | |
| 7404 | return GL_FALSE; |
| 7405 | } |
| 7406 | |
| 7407 | void __stdcall glDeleteSync(GLsync sync) |
| 7408 | { |
| 7409 | EVENT("(GLsync sync = 0x%0.8p)", sync); |
| 7410 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7411 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7412 | if (context) |
| 7413 | { |
| 7414 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7415 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7416 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7417 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7418 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7419 | |
| 7420 | if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync)) |
| 7421 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7422 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7423 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7424 | } |
| 7425 | |
| 7426 | context->deleteFenceSync(sync); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7427 | } |
| 7428 | } |
| 7429 | |
| 7430 | GLenum __stdcall glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 7431 | { |
| 7432 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 7433 | sync, flags, timeout); |
| 7434 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7435 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7436 | if (context) |
| 7437 | { |
| 7438 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7439 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7440 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7441 | return GL_WAIT_FAILED; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7442 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7443 | |
| 7444 | if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0) |
| 7445 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7446 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7447 | return GL_WAIT_FAILED; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7448 | } |
| 7449 | |
| 7450 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7451 | |
| 7452 | if (!fenceSync) |
| 7453 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7454 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7455 | return GL_WAIT_FAILED; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7456 | } |
| 7457 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 7458 | GLenum result = GL_WAIT_FAILED; |
| 7459 | gl::Error error = fenceSync->clientWait(flags, timeout, &result); |
| 7460 | if (error.isError()) |
| 7461 | { |
| 7462 | context->recordError(error); |
| 7463 | return GL_WAIT_FAILED; |
| 7464 | } |
| 7465 | |
| 7466 | return result; |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7467 | } |
| 7468 | |
| 7469 | return GL_FALSE; |
| 7470 | } |
| 7471 | |
| 7472 | void __stdcall glWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) |
| 7473 | { |
| 7474 | EVENT("(GLsync sync = 0x%0.8p, GLbitfield flags = 0x%X, GLuint64 timeout = %llu)", |
| 7475 | sync, flags, timeout); |
| 7476 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7477 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7478 | if (context) |
| 7479 | { |
| 7480 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7481 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7482 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7483 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7484 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7485 | |
| 7486 | if (flags != 0) |
| 7487 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7488 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7489 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7490 | } |
| 7491 | |
| 7492 | if (timeout != GL_TIMEOUT_IGNORED) |
| 7493 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7494 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7495 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7496 | } |
| 7497 | |
| 7498 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7499 | |
| 7500 | if (!fenceSync) |
| 7501 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7502 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7503 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7504 | } |
| 7505 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 7506 | gl::Error error = fenceSync->serverWait(); |
| 7507 | if (error.isError()) |
| 7508 | { |
| 7509 | context->recordError(error); |
| 7510 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7511 | } |
| 7512 | } |
| 7513 | |
| 7514 | void __stdcall glGetInteger64v(GLenum pname, GLint64* params) |
| 7515 | { |
| 7516 | EVENT("(GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 7517 | pname, params); |
| 7518 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7519 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7520 | if (context) |
| 7521 | { |
| 7522 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7523 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7524 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7525 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7526 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7527 | |
| 7528 | GLenum nativeType; |
| 7529 | unsigned int numParams = 0; |
| 7530 | if (!ValidateStateQuery(context, pname, &nativeType, &numParams)) |
| 7531 | { |
| 7532 | return; |
| 7533 | } |
| 7534 | |
| 7535 | if (nativeType == GL_INT_64_ANGLEX) |
| 7536 | { |
| 7537 | context->getInteger64v(pname, params); |
| 7538 | } |
| 7539 | else |
| 7540 | { |
| 7541 | CastStateValues(context, nativeType, pname, numParams, params); |
| 7542 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7543 | } |
| 7544 | } |
| 7545 | |
| 7546 | void __stdcall glGetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) |
| 7547 | { |
| 7548 | EVENT("(GLsync sync = 0x%0.8p, GLenum pname = 0x%X, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLint* values = 0x%0.8p)", |
| 7549 | sync, pname, bufSize, length, values); |
| 7550 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7551 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7552 | if (context) |
| 7553 | { |
| 7554 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7555 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7556 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7557 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7558 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7559 | |
| 7560 | if (bufSize < 0) |
| 7561 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7562 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7563 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7564 | } |
| 7565 | |
| 7566 | gl::FenceSync *fenceSync = context->getFenceSync(sync); |
| 7567 | |
| 7568 | if (!fenceSync) |
| 7569 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7570 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7571 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7572 | } |
| 7573 | |
| 7574 | switch (pname) |
| 7575 | { |
| 7576 | case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7577 | case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break; |
| 7578 | case GL_SYNC_FLAGS: values[0] = 0; break; |
| 7579 | |
Geoff Lang | 882033e | 2014-09-30 11:26:07 -0400 | [diff] [blame^] | 7580 | case GL_SYNC_STATUS: |
| 7581 | { |
| 7582 | gl::Error error = fenceSync->getStatus(values); |
| 7583 | if (error.isError()) |
| 7584 | { |
| 7585 | context->recordError(error); |
| 7586 | return; |
| 7587 | } |
| 7588 | break; |
| 7589 | } |
| 7590 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7591 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7592 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7593 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7594 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7595 | } |
| 7596 | } |
| 7597 | |
| 7598 | void __stdcall glGetInteger64i_v(GLenum target, GLuint index, GLint64* data) |
| 7599 | { |
| 7600 | EVENT("(GLenum target = 0x%X, GLuint index = %u, GLint64* data = 0x%0.8p)", |
| 7601 | target, index, data); |
| 7602 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7603 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7604 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7605 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7606 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7607 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7608 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7609 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7610 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7611 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 7612 | const gl::Caps &caps = context->getCaps(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7613 | switch (target) |
| 7614 | { |
| 7615 | case GL_TRANSFORM_FEEDBACK_BUFFER_START: |
| 7616 | case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: |
| 7617 | case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 7618 | if (index >= caps.maxTransformFeedbackSeparateAttributes) |
| 7619 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7620 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7621 | return; |
Geoff Lang | 05881a0 | 2014-07-10 14:05:30 -0400 | [diff] [blame] | 7622 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7623 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7624 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7625 | case GL_UNIFORM_BUFFER_START: |
| 7626 | case GL_UNIFORM_BUFFER_SIZE: |
| 7627 | case GL_UNIFORM_BUFFER_BINDING: |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 7628 | if (index >= caps.maxUniformBufferBindings) |
| 7629 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7630 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7631 | return; |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 7632 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7633 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7634 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7635 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7636 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7637 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7638 | } |
| 7639 | |
| 7640 | if (!(context->getIndexedInteger64v(target, index, data))) |
| 7641 | { |
| 7642 | GLenum nativeType; |
| 7643 | unsigned int numParams = 0; |
| 7644 | if (!context->getIndexedQueryParameterInfo(target, &nativeType, &numParams)) |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7645 | { |
| 7646 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7647 | return; |
| 7648 | } |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7649 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7650 | if (numParams == 0) |
| 7651 | return; // it is known that pname is valid, but there are no parameters to return |
| 7652 | |
| 7653 | if (nativeType == GL_INT) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7654 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7655 | GLint *intParams = new GLint[numParams]; |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7656 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7657 | context->getIndexedIntegerv(target, index, intParams); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7658 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7659 | for (unsigned int i = 0; i < numParams; ++i) |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7660 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7661 | data[i] = static_cast<GLint64>(intParams[i]); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7662 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7663 | |
| 7664 | delete [] intParams; |
| 7665 | } |
| 7666 | else |
| 7667 | { |
| 7668 | UNREACHABLE(); |
Shannon Woods | 15934d5 | 2013-08-19 14:28:49 -0400 | [diff] [blame] | 7669 | } |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7670 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7671 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7672 | } |
| 7673 | |
| 7674 | void __stdcall glGetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) |
| 7675 | { |
| 7676 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64* params = 0x%0.8p)", |
| 7677 | target, pname, params); |
| 7678 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7679 | gl::Context *context = gl::getNonLostContext(); |
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 | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7684 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7685 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7686 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7687 | |
| 7688 | if (!gl::ValidBufferTarget(context, target)) |
| 7689 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7690 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7691 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7692 | } |
| 7693 | |
| 7694 | if (!gl::ValidBufferParameter(context, pname)) |
| 7695 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7696 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 7697 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7698 | } |
| 7699 | |
| 7700 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 7701 | |
| 7702 | if (!buffer) |
| 7703 | { |
| 7704 | // A null buffer means that "0" is bound to the requested buffer target |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7705 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7706 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7707 | } |
| 7708 | |
| 7709 | switch (pname) |
| 7710 | { |
| 7711 | case GL_BUFFER_USAGE: |
| 7712 | *params = static_cast<GLint64>(buffer->getUsage()); |
| 7713 | break; |
| 7714 | case GL_BUFFER_SIZE: |
| 7715 | *params = buffer->getSize(); |
| 7716 | break; |
| 7717 | case GL_BUFFER_ACCESS_FLAGS: |
| 7718 | *params = static_cast<GLint64>(buffer->getAccessFlags()); |
| 7719 | break; |
| 7720 | case GL_BUFFER_MAPPED: |
| 7721 | *params = static_cast<GLint64>(buffer->isMapped()); |
| 7722 | break; |
| 7723 | case GL_BUFFER_MAP_OFFSET: |
| 7724 | *params = buffer->getMapOffset(); |
| 7725 | break; |
| 7726 | case GL_BUFFER_MAP_LENGTH: |
| 7727 | *params = buffer->getMapLength(); |
| 7728 | break; |
| 7729 | default: UNREACHABLE(); break; |
| 7730 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7731 | } |
| 7732 | } |
| 7733 | |
| 7734 | void __stdcall glGenSamplers(GLsizei count, GLuint* samplers) |
| 7735 | { |
| 7736 | EVENT("(GLsizei count = %d, GLuint* samplers = 0x%0.8p)", count, samplers); |
| 7737 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7738 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7739 | if (context) |
| 7740 | { |
| 7741 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7742 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7743 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7744 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7745 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7746 | |
| 7747 | if (count < 0) |
| 7748 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7749 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7750 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7751 | } |
| 7752 | |
| 7753 | for (int i = 0; i < count; i++) |
| 7754 | { |
| 7755 | samplers[i] = context->createSampler(); |
| 7756 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7757 | } |
| 7758 | } |
| 7759 | |
| 7760 | void __stdcall glDeleteSamplers(GLsizei count, const GLuint* samplers) |
| 7761 | { |
| 7762 | EVENT("(GLsizei count = %d, const GLuint* samplers = 0x%0.8p)", count, samplers); |
| 7763 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7764 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7765 | if (context) |
| 7766 | { |
| 7767 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7768 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7769 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7770 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7771 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7772 | |
| 7773 | if (count < 0) |
| 7774 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7775 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7776 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7777 | } |
| 7778 | |
| 7779 | for (int i = 0; i < count; i++) |
| 7780 | { |
| 7781 | context->deleteSampler(samplers[i]); |
| 7782 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7783 | } |
| 7784 | } |
| 7785 | |
| 7786 | GLboolean __stdcall glIsSampler(GLuint sampler) |
| 7787 | { |
| 7788 | EVENT("(GLuint sampler = %u)", sampler); |
| 7789 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7790 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7791 | if (context) |
| 7792 | { |
| 7793 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7794 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7795 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7796 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7797 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7798 | |
| 7799 | return context->isSampler(sampler); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7800 | } |
| 7801 | |
| 7802 | return GL_FALSE; |
| 7803 | } |
| 7804 | |
| 7805 | void __stdcall glBindSampler(GLuint unit, GLuint sampler) |
| 7806 | { |
| 7807 | EVENT("(GLuint unit = %u, GLuint sampler = %u)", unit, sampler); |
| 7808 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7809 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7810 | if (context) |
| 7811 | { |
| 7812 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7813 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7814 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7815 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7816 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7817 | |
| 7818 | if (sampler != 0 && !context->isSampler(sampler)) |
| 7819 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7820 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7821 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7822 | } |
| 7823 | |
Geoff Lang | 3a61c32 | 2014-07-10 13:01:54 -0400 | [diff] [blame] | 7824 | if (unit >= context->getCaps().maxCombinedTextureImageUnits) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7825 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7826 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7827 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7828 | } |
| 7829 | |
| 7830 | context->bindSampler(unit, sampler); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7831 | } |
| 7832 | } |
| 7833 | |
| 7834 | void __stdcall glSamplerParameteri(GLuint sampler, GLenum pname, GLint param) |
| 7835 | { |
| 7836 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint param = %d)", sampler, pname, param); |
| 7837 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7838 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7839 | if (context) |
| 7840 | { |
| 7841 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7842 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7843 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7844 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7845 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7846 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7847 | if (!gl::ValidateSamplerObjectParameter(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7848 | { |
| 7849 | return; |
| 7850 | } |
| 7851 | |
| 7852 | if (!gl::ValidateTexParamParameters(context, pname, param)) |
| 7853 | { |
| 7854 | return; |
| 7855 | } |
| 7856 | |
| 7857 | if (!context->isSampler(sampler)) |
| 7858 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7859 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7860 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7861 | } |
| 7862 | |
| 7863 | context->samplerParameteri(sampler, pname, param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7864 | } |
| 7865 | } |
| 7866 | |
| 7867 | void __stdcall glSamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) |
| 7868 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 7869 | glSamplerParameteri(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7870 | } |
| 7871 | |
| 7872 | void __stdcall glSamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) |
| 7873 | { |
| 7874 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLfloat param = %g)", sampler, pname, param); |
| 7875 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7876 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7877 | if (context) |
| 7878 | { |
| 7879 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7880 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7881 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7882 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7883 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7884 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7885 | if (!gl::ValidateSamplerObjectParameter(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7886 | { |
| 7887 | return; |
| 7888 | } |
| 7889 | |
| 7890 | if (!gl::ValidateTexParamParameters(context, pname, static_cast<GLint>(param))) |
| 7891 | { |
| 7892 | return; |
| 7893 | } |
| 7894 | |
| 7895 | if (!context->isSampler(sampler)) |
| 7896 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7897 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7898 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7899 | } |
| 7900 | |
| 7901 | context->samplerParameterf(sampler, pname, param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7902 | } |
| 7903 | } |
| 7904 | |
| 7905 | void __stdcall glSamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) |
| 7906 | { |
Jamie Madill | f6cc8cc | 2013-07-03 12:44:15 -0400 | [diff] [blame] | 7907 | glSamplerParameterf(sampler, pname, *param); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7908 | } |
| 7909 | |
| 7910 | void __stdcall glGetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) |
| 7911 | { |
| 7912 | EVENT("(GLuint sampler = %u, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", sampler, pname, params); |
| 7913 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7914 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7915 | if (context) |
| 7916 | { |
| 7917 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7918 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7919 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7920 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7921 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7922 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7923 | if (!gl::ValidateSamplerObjectParameter(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7924 | { |
| 7925 | return; |
| 7926 | } |
| 7927 | |
| 7928 | if (!context->isSampler(sampler)) |
| 7929 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7930 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7931 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7932 | } |
| 7933 | |
| 7934 | *params = context->getSamplerParameteri(sampler, pname); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7935 | } |
| 7936 | } |
| 7937 | |
| 7938 | void __stdcall glGetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) |
| 7939 | { |
| 7940 | EVENT("(GLuint sample = %ur, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", sampler, pname, params); |
| 7941 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7942 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7943 | if (context) |
| 7944 | { |
| 7945 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7946 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7947 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7948 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 7949 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7950 | |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7951 | if (!gl::ValidateSamplerObjectParameter(context, pname)) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7952 | { |
| 7953 | return; |
| 7954 | } |
| 7955 | |
| 7956 | if (!context->isSampler(sampler)) |
| 7957 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7958 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7959 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7960 | } |
| 7961 | |
| 7962 | *params = context->getSamplerParameterf(sampler, pname); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7963 | } |
| 7964 | } |
| 7965 | |
| 7966 | void __stdcall glVertexAttribDivisor(GLuint index, GLuint divisor) |
| 7967 | { |
| 7968 | EVENT("(GLuint index = %u, GLuint divisor = %u)", index, divisor); |
| 7969 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7970 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7971 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7972 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7973 | if (context->getClientVersion() < 3) |
| 7974 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7975 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7976 | return; |
| 7977 | } |
| 7978 | |
| 7979 | if (index >= gl::MAX_VERTEX_ATTRIBS) |
| 7980 | { |
| 7981 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 7982 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7983 | } |
| 7984 | |
| 7985 | context->setVertexAttribDivisor(index, divisor); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7986 | } |
| 7987 | } |
| 7988 | |
| 7989 | void __stdcall glBindTransformFeedback(GLenum target, GLuint id) |
| 7990 | { |
| 7991 | EVENT("(GLenum target = 0x%X, GLuint id = %u)", target, id); |
| 7992 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7993 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 7994 | if (context) |
| 7995 | { |
| 7996 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 7997 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 7998 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 7999 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8000 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8001 | |
| 8002 | switch (target) |
| 8003 | { |
| 8004 | case GL_TRANSFORM_FEEDBACK: |
| 8005 | { |
| 8006 | // Cannot bind a transform feedback object if the current one is started and not paused (3.0.2 pg 85 section 2.14.1) |
| 8007 | gl::TransformFeedback *curTransformFeedback = context->getState().getCurrentTransformFeedback(); |
| 8008 | if (curTransformFeedback && curTransformFeedback->isStarted() && !curTransformFeedback->isPaused()) |
| 8009 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8010 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8011 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8012 | } |
| 8013 | |
| 8014 | // Cannot bind a transform feedback object that does not exist (3.0.2 pg 85 section 2.14.1) |
| 8015 | if (context->getTransformFeedback(id) == NULL) |
| 8016 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8017 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8018 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8019 | } |
| 8020 | |
| 8021 | context->bindTransformFeedback(id); |
| 8022 | } |
| 8023 | break; |
| 8024 | |
| 8025 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8026 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8027 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8028 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8029 | } |
| 8030 | } |
| 8031 | |
| 8032 | void __stdcall glDeleteTransformFeedbacks(GLsizei n, const GLuint* ids) |
| 8033 | { |
| 8034 | EVENT("(GLsizei n = %d, const GLuint* ids = 0x%0.8p)", n, ids); |
| 8035 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8036 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8037 | if (context) |
| 8038 | { |
| 8039 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8040 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8041 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8042 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8043 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8044 | |
| 8045 | for (int i = 0; i < n; i++) |
| 8046 | { |
| 8047 | context->deleteTransformFeedback(ids[i]); |
| 8048 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8049 | } |
| 8050 | } |
| 8051 | |
| 8052 | void __stdcall glGenTransformFeedbacks(GLsizei n, GLuint* ids) |
| 8053 | { |
| 8054 | EVENT("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids); |
| 8055 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8056 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8057 | if (context) |
| 8058 | { |
| 8059 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8060 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8061 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8062 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8063 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8064 | |
| 8065 | for (int i = 0; i < n; i++) |
| 8066 | { |
| 8067 | ids[i] = context->createTransformFeedback(); |
| 8068 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8069 | } |
| 8070 | } |
| 8071 | |
| 8072 | GLboolean __stdcall glIsTransformFeedback(GLuint id) |
| 8073 | { |
| 8074 | EVENT("(GLuint id = %u)", id); |
| 8075 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8076 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8077 | if (context) |
| 8078 | { |
| 8079 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8080 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8081 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8082 | return GL_FALSE; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8083 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8084 | |
| 8085 | 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] | 8086 | } |
| 8087 | |
| 8088 | return GL_FALSE; |
| 8089 | } |
| 8090 | |
| 8091 | void __stdcall glPauseTransformFeedback(void) |
| 8092 | { |
| 8093 | EVENT("(void)"); |
| 8094 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8095 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8096 | if (context) |
| 8097 | { |
| 8098 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8099 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8100 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8101 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8102 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8103 | |
| 8104 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 8105 | ASSERT(transformFeedback != NULL); |
| 8106 | |
| 8107 | // Current transform feedback must be started and not paused in order to pause (3.0.2 pg 86) |
| 8108 | if (!transformFeedback->isStarted() || transformFeedback->isPaused()) |
| 8109 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8110 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8111 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8112 | } |
| 8113 | |
| 8114 | transformFeedback->pause(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8115 | } |
| 8116 | } |
| 8117 | |
| 8118 | void __stdcall glResumeTransformFeedback(void) |
| 8119 | { |
| 8120 | EVENT("(void)"); |
| 8121 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8122 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8123 | if (context) |
| 8124 | { |
| 8125 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8126 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8127 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8128 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8129 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8130 | |
| 8131 | gl::TransformFeedback *transformFeedback = context->getState().getCurrentTransformFeedback(); |
| 8132 | ASSERT(transformFeedback != NULL); |
| 8133 | |
| 8134 | // Current transform feedback must be started and paused in order to resume (3.0.2 pg 86) |
| 8135 | if (!transformFeedback->isStarted() || !transformFeedback->isPaused()) |
| 8136 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8137 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8138 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8139 | } |
| 8140 | |
| 8141 | transformFeedback->resume(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8142 | } |
| 8143 | } |
| 8144 | |
| 8145 | void __stdcall glGetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) |
| 8146 | { |
| 8147 | EVENT("(GLuint program = %u, GLsizei bufSize = %d, GLsizei* length = 0x%0.8p, GLenum* binaryFormat = 0x%0.8p, GLvoid* binary = 0x%0.8p)", |
| 8148 | program, bufSize, length, binaryFormat, binary); |
| 8149 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8150 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8151 | if (context) |
| 8152 | { |
| 8153 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8154 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8155 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8156 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8157 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8158 | |
| 8159 | // glGetProgramBinary |
| 8160 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8161 | } |
| 8162 | } |
| 8163 | |
| 8164 | void __stdcall glProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) |
| 8165 | { |
| 8166 | EVENT("(GLuint program = %u, GLenum binaryFormat = 0x%X, const GLvoid* binary = 0x%0.8p, GLsizei length = %d)", |
| 8167 | program, binaryFormat, binary, length); |
| 8168 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8169 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8170 | if (context) |
| 8171 | { |
| 8172 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8173 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8174 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8175 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8176 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8177 | |
| 8178 | // glProgramBinary |
| 8179 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8180 | } |
| 8181 | } |
| 8182 | |
| 8183 | void __stdcall glProgramParameteri(GLuint program, GLenum pname, GLint value) |
| 8184 | { |
| 8185 | EVENT("(GLuint program = %u, GLenum pname = 0x%X, GLint value = %d)", |
| 8186 | program, pname, value); |
| 8187 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8188 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8189 | if (context) |
| 8190 | { |
| 8191 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8192 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8193 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8194 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8195 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8196 | |
| 8197 | // glProgramParameteri |
| 8198 | UNIMPLEMENTED(); |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8199 | } |
| 8200 | } |
| 8201 | |
| 8202 | void __stdcall glInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) |
| 8203 | { |
| 8204 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p)", |
| 8205 | target, numAttachments, attachments); |
| 8206 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8207 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8208 | if (context) |
| 8209 | { |
| 8210 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8211 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8212 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8213 | return; |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 8214 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8215 | |
| 8216 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 8217 | { |
| 8218 | return; |
| 8219 | } |
| 8220 | |
Jamie Madill | 2d96b9e | 2014-08-29 15:46:47 -0400 | [diff] [blame] | 8221 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 8222 | if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE) |
| 8223 | { |
| 8224 | framebuffer->invalidate(context->getCaps(), numAttachments, attachments); |
| 8225 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8226 | } |
| 8227 | } |
| 8228 | |
| 8229 | void __stdcall glInvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) |
| 8230 | { |
| 8231 | EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum* attachments = 0x%0.8p, GLint x = %d, " |
| 8232 | "GLint y = %d, GLsizei width = %d, GLsizei height = %d)", |
| 8233 | target, numAttachments, attachments, x, y, width, height); |
| 8234 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8235 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8236 | if (context) |
| 8237 | { |
| 8238 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8239 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8240 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8241 | return; |
shannonwoods@chromium.org | d63ef89 | 2013-05-30 00:10:56 +0000 | [diff] [blame] | 8242 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8243 | |
| 8244 | if (!ValidateInvalidateFramebufferParameters(context, target, numAttachments, attachments)) |
| 8245 | { |
| 8246 | return; |
| 8247 | } |
| 8248 | |
Jamie Madill | 2d96b9e | 2014-08-29 15:46:47 -0400 | [diff] [blame] | 8249 | gl::Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target); |
| 8250 | if (framebuffer && framebuffer->completeness() == GL_FRAMEBUFFER_COMPLETE) |
| 8251 | { |
| 8252 | framebuffer->invalidateSub(context->getCaps(), numAttachments, attachments, x, y, width, height); |
| 8253 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8254 | } |
| 8255 | } |
| 8256 | |
| 8257 | void __stdcall glTexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) |
| 8258 | { |
| 8259 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)", |
| 8260 | target, levels, internalformat, width, height); |
| 8261 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8262 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8263 | if (context) |
| 8264 | { |
| 8265 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8266 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8267 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8268 | return; |
shannonwoods@chromium.org | 8757c06 | 2013-05-30 00:14:24 +0000 | [diff] [blame] | 8269 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8270 | |
| 8271 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, 1)) |
| 8272 | { |
| 8273 | return; |
| 8274 | } |
| 8275 | |
| 8276 | switch (target) |
| 8277 | { |
| 8278 | case GL_TEXTURE_2D: |
| 8279 | { |
| 8280 | gl::Texture2D *texture2d = context->getTexture2D(); |
| 8281 | texture2d->storage(levels, internalformat, width, height); |
| 8282 | } |
| 8283 | break; |
| 8284 | |
| 8285 | case GL_TEXTURE_CUBE_MAP: |
| 8286 | { |
| 8287 | gl::TextureCubeMap *textureCube = context->getTextureCubeMap(); |
| 8288 | textureCube->storage(levels, internalformat, width); |
| 8289 | } |
| 8290 | break; |
| 8291 | |
| 8292 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8293 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8294 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8295 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8296 | } |
| 8297 | } |
| 8298 | |
| 8299 | void __stdcall glTexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) |
| 8300 | { |
| 8301 | EVENT("(GLenum target = 0x%X, GLsizei levels = %d, GLenum internalformat = 0x%X, GLsizei width = %d, " |
| 8302 | "GLsizei height = %d, GLsizei depth = %d)", |
| 8303 | target, levels, internalformat, width, height, depth); |
| 8304 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8305 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8306 | if (context) |
| 8307 | { |
| 8308 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8309 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8310 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8311 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 14eb55e | 2013-04-13 03:35:06 +0000 | [diff] [blame] | 8312 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8313 | |
| 8314 | if (!ValidateES3TexStorageParameters(context, target, levels, internalformat, width, height, depth)) |
| 8315 | { |
| 8316 | return; |
| 8317 | } |
| 8318 | |
| 8319 | switch (target) |
| 8320 | { |
| 8321 | case GL_TEXTURE_3D: |
| 8322 | { |
| 8323 | gl::Texture3D *texture3d = context->getTexture3D(); |
| 8324 | texture3d->storage(levels, internalformat, width, height, depth); |
| 8325 | } |
| 8326 | break; |
| 8327 | |
| 8328 | case GL_TEXTURE_2D_ARRAY: |
| 8329 | { |
| 8330 | gl::Texture2DArray *texture2darray = context->getTexture2DArray(); |
| 8331 | texture2darray->storage(levels, internalformat, width, height, depth); |
| 8332 | } |
| 8333 | break; |
| 8334 | |
| 8335 | default: |
| 8336 | UNREACHABLE(); |
| 8337 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8338 | } |
| 8339 | } |
| 8340 | |
| 8341 | void __stdcall glGetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) |
| 8342 | { |
| 8343 | EVENT("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLenum pname = 0x%X, GLsizei bufSize = %d, " |
| 8344 | "GLint* params = 0x%0.8p)", |
| 8345 | target, internalformat, pname, bufSize, params); |
| 8346 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8347 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8348 | if (context) |
| 8349 | { |
| 8350 | if (context->getClientVersion() < 3) |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8351 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8352 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8353 | return; |
shannonwoods@chromium.org | 705fc2f | 2013-05-30 00:17:14 +0000 | [diff] [blame] | 8354 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8355 | |
| 8356 | const gl::TextureCaps &formatCaps = context->getTextureCaps().get(internalformat); |
| 8357 | if (!formatCaps.renderable) |
| 8358 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8359 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8360 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8361 | } |
| 8362 | |
| 8363 | if (target != GL_RENDERBUFFER) |
| 8364 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8365 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8366 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8367 | } |
| 8368 | |
| 8369 | if (bufSize < 0) |
| 8370 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8371 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8372 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8373 | } |
| 8374 | |
| 8375 | switch (pname) |
| 8376 | { |
| 8377 | case GL_NUM_SAMPLE_COUNTS: |
| 8378 | if (bufSize != 0) |
Geoff Lang | 5f4c463 | 2014-07-03 13:46:52 -0400 | [diff] [blame] | 8379 | { |
| 8380 | *params = formatCaps.sampleCounts.size(); |
| 8381 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8382 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8383 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8384 | case GL_SAMPLES: |
Geoff Lang | 5f4c463 | 2014-07-03 13:46:52 -0400 | [diff] [blame] | 8385 | 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] | 8386 | break; |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8387 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8388 | default: |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8389 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8390 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8391 | } |
shannon.woods%transgaming.com@gtempaccount.com | a817175 | 2013-04-13 03:29:28 +0000 | [diff] [blame] | 8392 | } |
| 8393 | } |
| 8394 | |
| 8395 | // Extension functions |
| 8396 | |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 8397 | void __stdcall glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, |
| 8398 | GLbitfield mask, GLenum filter) |
| 8399 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8400 | 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] | 8401 | "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, " |
| 8402 | "GLbitfield mask = 0x%X, GLenum filter = 0x%X)", |
| 8403 | srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 8404 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8405 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8406 | if (context) |
| 8407 | { |
| 8408 | if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1, |
| 8409 | dstX0, dstY0, dstX1, dstY1, mask, filter, |
| 8410 | true)) |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 8411 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8412 | return; |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 8413 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8414 | |
Geoff Lang | 6483915 | 2014-08-26 16:23:25 -0400 | [diff] [blame] | 8415 | gl::Error error = context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, |
| 8416 | mask, filter); |
| 8417 | if (error.isError()) |
| 8418 | { |
| 8419 | context->recordError(error); |
| 8420 | return; |
| 8421 | } |
daniel@transgaming.com | 4cbc590 | 2010-08-24 19:20:26 +0000 | [diff] [blame] | 8422 | } |
| 8423 | } |
| 8424 | |
daniel@transgaming.com | fe4b827 | 2010-04-08 03:51:20 +0000 | [diff] [blame] | 8425 | void __stdcall glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, |
| 8426 | GLint border, GLenum format, GLenum type, const GLvoid* pixels) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8427 | { |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 8428 | 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] | 8429 | "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] | 8430 | "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] | 8431 | target, level, internalformat, width, height, depth, border, format, type, pixels); |
| 8432 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8433 | UNIMPLEMENTED(); // FIXME |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8434 | } |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8435 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8436 | void __stdcall glGetProgramBinaryOES(GLuint program, GLsizei bufSize, GLsizei *length, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8437 | GLenum *binaryFormat, void *binary) |
| 8438 | { |
apatrick@chromium.org | 90080e3 | 2012-07-09 22:15:33 +0000 | [diff] [blame] | 8439 | 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] | 8440 | program, bufSize, length, binaryFormat, binary); |
| 8441 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8442 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8443 | if (context) |
| 8444 | { |
| 8445 | gl::Program *programObject = context->getProgram(program); |
| 8446 | |
| 8447 | if (!programObject || !programObject->isLinked()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8448 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8449 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8450 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8451 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8452 | |
| 8453 | gl::ProgramBinary *programBinary = programObject->getProgramBinary(); |
| 8454 | |
| 8455 | if (!programBinary) |
| 8456 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8457 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8458 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8459 | } |
| 8460 | |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 8461 | gl::Error error = programBinary->save(binaryFormat, binary, bufSize, length); |
| 8462 | if (error.isError()) |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8463 | { |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 8464 | context->recordError(error); |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8465 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8466 | } |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8467 | } |
| 8468 | } |
| 8469 | |
| 8470 | void __stdcall glProgramBinaryOES(GLuint program, GLenum binaryFormat, |
| 8471 | const void *binary, GLint length) |
| 8472 | { |
| 8473 | EVENT("(GLenum program = 0x%X, binaryFormat = 0x%x, binary = 0x%0.8p, length = %d)", |
| 8474 | program, binaryFormat, binary, length); |
| 8475 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8476 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8477 | if (context) |
| 8478 | { |
Geoff Lang | 900013c | 2014-07-07 11:32:19 -0400 | [diff] [blame] | 8479 | const std::vector<GLenum> &programBinaryFormats = context->getCaps().programBinaryFormats; |
| 8480 | if (std::find(programBinaryFormats.begin(), programBinaryFormats.end(), binaryFormat) == programBinaryFormats.end()) |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8481 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8482 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8483 | return; |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8484 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8485 | |
| 8486 | gl::Program *programObject = context->getProgram(program); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8487 | if (!programObject) |
| 8488 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8489 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8490 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8491 | } |
| 8492 | |
Geoff Lang | b543aff | 2014-09-30 14:52:54 -0400 | [diff] [blame] | 8493 | gl::Error error = context->setProgramBinary(program, binaryFormat, binary, length); |
| 8494 | if (error.isError()) |
| 8495 | { |
| 8496 | context->recordError(error); |
| 8497 | return; |
| 8498 | } |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8499 | } |
| 8500 | } |
| 8501 | |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8502 | void __stdcall glDrawBuffersEXT(GLsizei n, const GLenum *bufs) |
| 8503 | { |
| 8504 | EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs); |
| 8505 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8506 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8507 | if (context) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8508 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8509 | 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] | 8510 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8511 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8512 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8513 | } |
| 8514 | |
| 8515 | if (context->getState().getDrawFramebuffer()->id() == 0) |
| 8516 | { |
| 8517 | if (n != 1) |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8518 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8519 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8520 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8521 | } |
| 8522 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8523 | 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] | 8524 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8525 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8526 | return; |
shannon.woods%transgaming.com@gtempaccount.com | 2fa73c5 | 2013-04-13 03:37:20 +0000 | [diff] [blame] | 8527 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8528 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8529 | else |
| 8530 | { |
| 8531 | for (int colorAttachment = 0; colorAttachment < n; colorAttachment++) |
| 8532 | { |
| 8533 | const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment; |
| 8534 | if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment) |
| 8535 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8536 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8537 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8538 | } |
| 8539 | } |
| 8540 | } |
| 8541 | |
| 8542 | gl::Framebuffer *framebuffer = context->getState().getDrawFramebuffer(); |
| 8543 | |
| 8544 | for (unsigned int colorAttachment = 0; colorAttachment < static_cast<unsigned int>(n); colorAttachment++) |
| 8545 | { |
| 8546 | framebuffer->setDrawBufferState(colorAttachment, bufs[colorAttachment]); |
| 8547 | } |
| 8548 | |
| 8549 | for (unsigned int colorAttachment = n; colorAttachment < context->getCaps().maxDrawBuffers; colorAttachment++) |
| 8550 | { |
| 8551 | framebuffer->setDrawBufferState(colorAttachment, GL_NONE); |
| 8552 | } |
shannon.woods%transgaming.com@gtempaccount.com | 4059a38 | 2013-04-13 03:31:16 +0000 | [diff] [blame] | 8553 | } |
| 8554 | } |
| 8555 | |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8556 | void __stdcall glGetBufferPointervOES(GLenum target, GLenum pname, void** params) |
| 8557 | { |
| 8558 | EVENT("(GLenum target = 0x%X, GLenum pname = 0x%X, GLvoid** params = 0x%0.8p)", target, pname, params); |
| 8559 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8560 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8561 | if (context) |
| 8562 | { |
| 8563 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8564 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8565 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8566 | return; |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8567 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8568 | |
| 8569 | if (pname != GL_BUFFER_MAP_POINTER) |
| 8570 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8571 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8572 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8573 | } |
| 8574 | |
| 8575 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8576 | |
| 8577 | if (!buffer || !buffer->isMapped()) |
| 8578 | { |
| 8579 | *params = NULL; |
| 8580 | } |
| 8581 | else |
| 8582 | { |
| 8583 | *params = buffer->getMapPointer(); |
| 8584 | } |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8585 | } |
| 8586 | } |
| 8587 | |
| 8588 | void * __stdcall glMapBufferOES(GLenum target, GLenum access) |
| 8589 | { |
| 8590 | EVENT("(GLenum target = 0x%X, GLbitfield access = 0x%X)", target, access); |
| 8591 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8592 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8593 | if (context) |
| 8594 | { |
| 8595 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8596 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8597 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8598 | return NULL; |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8599 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8600 | |
| 8601 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8602 | |
| 8603 | if (buffer == NULL) |
| 8604 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8605 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8606 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8607 | } |
| 8608 | |
| 8609 | if (access != GL_WRITE_ONLY_OES) |
| 8610 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8611 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8612 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8613 | } |
| 8614 | |
| 8615 | if (buffer->isMapped()) |
| 8616 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8617 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8618 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8619 | } |
| 8620 | |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 8621 | gl::Error error = buffer->mapRange(0, buffer->getSize(), GL_MAP_WRITE_BIT); |
| 8622 | if (error.isError()) |
| 8623 | { |
| 8624 | context->recordError(error); |
| 8625 | return NULL; |
| 8626 | } |
| 8627 | |
| 8628 | return buffer->getMapPointer(); |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8629 | } |
| 8630 | |
| 8631 | return NULL; |
| 8632 | } |
| 8633 | |
| 8634 | GLboolean __stdcall glUnmapBufferOES(GLenum target) |
| 8635 | { |
| 8636 | EVENT("(GLenum target = 0x%X)", target); |
| 8637 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8638 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8639 | if (context) |
| 8640 | { |
| 8641 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8642 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8643 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8644 | return GL_FALSE; |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8645 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8646 | |
| 8647 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8648 | |
| 8649 | if (buffer == NULL || !buffer->isMapped()) |
| 8650 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8651 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8652 | return GL_FALSE; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8653 | } |
| 8654 | |
| 8655 | // TODO: detect if we had corruption. if so, throw an error and return false. |
| 8656 | |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 8657 | gl::Error error = buffer->unmap(); |
| 8658 | if (error.isError()) |
| 8659 | { |
| 8660 | context->recordError(error); |
| 8661 | return GL_FALSE; |
| 8662 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8663 | |
| 8664 | return GL_TRUE; |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8665 | } |
| 8666 | |
| 8667 | return GL_FALSE; |
| 8668 | } |
| 8669 | |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8670 | void* __stdcall glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) |
| 8671 | { |
| 8672 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)", |
| 8673 | target, offset, length, access); |
| 8674 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8675 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8676 | if (context) |
| 8677 | { |
| 8678 | if (!gl::ValidBufferTarget(context, target)) |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8679 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8680 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8681 | return NULL; |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8682 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8683 | |
| 8684 | if (offset < 0 || length < 0) |
| 8685 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8686 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8687 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8688 | } |
| 8689 | |
| 8690 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8691 | |
| 8692 | if (buffer == NULL) |
| 8693 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8694 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8695 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8696 | } |
| 8697 | |
| 8698 | // Check for buffer overflow |
| 8699 | size_t offsetSize = static_cast<size_t>(offset); |
| 8700 | size_t lengthSize = static_cast<size_t>(length); |
| 8701 | |
| 8702 | if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || |
| 8703 | offsetSize + lengthSize > static_cast<size_t>(buffer->getSize())) |
| 8704 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8705 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8706 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8707 | } |
| 8708 | |
| 8709 | // Check for invalid bits in the mask |
| 8710 | GLbitfield allAccessBits = GL_MAP_READ_BIT | |
| 8711 | GL_MAP_WRITE_BIT | |
| 8712 | GL_MAP_INVALIDATE_RANGE_BIT | |
| 8713 | GL_MAP_INVALIDATE_BUFFER_BIT | |
| 8714 | GL_MAP_FLUSH_EXPLICIT_BIT | |
| 8715 | GL_MAP_UNSYNCHRONIZED_BIT; |
| 8716 | |
| 8717 | if (access & ~(allAccessBits)) |
| 8718 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8719 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8720 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8721 | } |
| 8722 | |
| 8723 | if (length == 0 || buffer->isMapped()) |
| 8724 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8725 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8726 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8727 | } |
| 8728 | |
| 8729 | // Check for invalid bit combinations |
| 8730 | if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0) |
| 8731 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8732 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8733 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8734 | } |
| 8735 | |
| 8736 | GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT | |
| 8737 | GL_MAP_INVALIDATE_BUFFER_BIT | |
| 8738 | GL_MAP_UNSYNCHRONIZED_BIT; |
| 8739 | |
| 8740 | if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0) |
| 8741 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8742 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8743 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8744 | } |
| 8745 | |
| 8746 | if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0) |
| 8747 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8748 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8749 | return NULL; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8750 | } |
| 8751 | |
Geoff Lang | 2a1c15a | 2014-07-25 11:43:00 -0400 | [diff] [blame] | 8752 | gl::Error error = buffer->mapRange(offset, length, access); |
| 8753 | if (error.isError()) |
| 8754 | { |
| 8755 | context->recordError(error); |
| 8756 | return NULL; |
| 8757 | } |
| 8758 | |
| 8759 | return buffer->getMapPointer(); |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8760 | } |
| 8761 | |
| 8762 | return NULL; |
| 8763 | } |
| 8764 | |
| 8765 | void __stdcall glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length) |
| 8766 | { |
| 8767 | EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d)", target, offset, length); |
| 8768 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8769 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8770 | if (context) |
| 8771 | { |
| 8772 | if (offset < 0 || length < 0) |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8773 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8774 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8775 | return; |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8776 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8777 | |
| 8778 | if (!gl::ValidBufferTarget(context, target)) |
| 8779 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8780 | context->recordError(gl::Error(GL_INVALID_ENUM)); |
| 8781 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8782 | } |
| 8783 | |
| 8784 | gl::Buffer *buffer = context->getState().getTargetBuffer(target); |
| 8785 | |
| 8786 | if (buffer == NULL) |
| 8787 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8788 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8789 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8790 | } |
| 8791 | |
| 8792 | if (!buffer->isMapped() || (buffer->getAccessFlags() & GL_MAP_FLUSH_EXPLICIT_BIT) == 0) |
| 8793 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8794 | context->recordError(gl::Error(GL_INVALID_OPERATION)); |
| 8795 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8796 | } |
| 8797 | |
| 8798 | // Check for buffer overflow |
| 8799 | size_t offsetSize = static_cast<size_t>(offset); |
| 8800 | size_t lengthSize = static_cast<size_t>(length); |
| 8801 | |
| 8802 | if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) || |
| 8803 | offsetSize + lengthSize > static_cast<size_t>(buffer->getMapLength())) |
| 8804 | { |
Geoff Lang | b119668 | 2014-07-23 13:47:29 -0400 | [diff] [blame] | 8805 | context->recordError(gl::Error(GL_INVALID_VALUE)); |
| 8806 | return; |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8807 | } |
| 8808 | |
| 8809 | // We do not currently support a non-trivial implementation of FlushMappedBufferRange |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8810 | } |
| 8811 | } |
| 8812 | |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8813 | __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname) |
| 8814 | { |
| 8815 | struct Extension |
| 8816 | { |
| 8817 | const char *name; |
| 8818 | __eglMustCastToProperFunctionPointerType address; |
| 8819 | }; |
| 8820 | |
| 8821 | static const Extension glExtensions[] = |
| 8822 | { |
| 8823 | {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES}, |
daniel@transgaming.com | 0186813 | 2010-08-24 19:21:17 +0000 | [diff] [blame] | 8824 | {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE}, |
daniel@transgaming.com | 1fe96c9 | 2011-01-14 15:08:44 +0000 | [diff] [blame] | 8825 | {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE}, |
apatrick@chromium.org | d3bd0ad | 2010-08-30 18:55:36 +0000 | [diff] [blame] | 8826 | {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV}, |
| 8827 | {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV}, |
| 8828 | {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV}, |
| 8829 | {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV}, |
| 8830 | {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV}, |
| 8831 | {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV}, |
| 8832 | {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV}, |
zmo@google.com | a574f78 | 2011-10-03 21:45:23 +0000 | [diff] [blame] | 8833 | {"glGetTranslatedShaderSourceANGLE", (__eglMustCastToProperFunctionPointerType)glGetTranslatedShaderSourceANGLE}, |
daniel@transgaming.com | 0bd1f2f | 2011-11-11 04:19:03 +0000 | [diff] [blame] | 8834 | {"glTexStorage2DEXT", (__eglMustCastToProperFunctionPointerType)glTexStorage2DEXT}, |
daniel@transgaming.com | 709ed11 | 2011-11-12 03:18:10 +0000 | [diff] [blame] | 8835 | {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT}, |
| 8836 | {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT}, |
| 8837 | {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT}, |
| 8838 | {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT}, |
daniel@transgaming.com | 86bdb82 | 2012-01-20 18:24:39 +0000 | [diff] [blame] | 8839 | {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT}, |
| 8840 | {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT}, |
| 8841 | {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT}, |
| 8842 | {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT}, |
| 8843 | {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT}, |
| 8844 | {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT}, |
| 8845 | {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT}, |
shannon.woods%transgaming.com@gtempaccount.com | 77d9472 | 2013-04-13 03:34:22 +0000 | [diff] [blame] | 8846 | {"glDrawBuffersEXT", (__eglMustCastToProperFunctionPointerType)glDrawBuffersEXT}, |
daniel@transgaming.com | dce02fd | 2012-01-27 15:39:51 +0000 | [diff] [blame] | 8847 | {"glVertexAttribDivisorANGLE", (__eglMustCastToProperFunctionPointerType)glVertexAttribDivisorANGLE}, |
| 8848 | {"glDrawArraysInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawArraysInstancedANGLE}, |
| 8849 | {"glDrawElementsInstancedANGLE", (__eglMustCastToProperFunctionPointerType)glDrawElementsInstancedANGLE}, |
apatrick@chromium.org | 3ce8dbc | 2012-06-08 17:52:30 +0000 | [diff] [blame] | 8850 | {"glGetProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glGetProgramBinaryOES}, |
Shannon Woods | b380174 | 2014-03-27 14:59:19 -0400 | [diff] [blame] | 8851 | {"glProgramBinaryOES", (__eglMustCastToProperFunctionPointerType)glProgramBinaryOES}, |
| 8852 | {"glGetBufferPointervOES", (__eglMustCastToProperFunctionPointerType)glGetBufferPointervOES}, |
| 8853 | {"glMapBufferOES", (__eglMustCastToProperFunctionPointerType)glMapBufferOES}, |
Shannon Woods | 916e769 | 2014-03-27 16:58:22 -0400 | [diff] [blame] | 8854 | {"glUnmapBufferOES", (__eglMustCastToProperFunctionPointerType)glUnmapBufferOES}, |
| 8855 | {"glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glMapBufferRangeEXT}, |
| 8856 | {"glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)glFlushMappedBufferRangeEXT}, }; |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8857 | |
shannon.woods@transgaming.com | d438fd4 | 2013-02-28 23:17:45 +0000 | [diff] [blame] | 8858 | for (unsigned int ext = 0; ext < ArraySize(glExtensions); ext++) |
daniel@transgaming.com | ce3d0f2 | 2010-05-04 03:35:14 +0000 | [diff] [blame] | 8859 | { |
| 8860 | if (strcmp(procname, glExtensions[ext].name) == 0) |
| 8861 | { |
| 8862 | return (__eglMustCastToProperFunctionPointerType)glExtensions[ext].address; |
| 8863 | } |
| 8864 | } |
| 8865 | |
| 8866 | return NULL; |
| 8867 | } |
| 8868 | |
daniel@transgaming.com | 17f548c | 2011-11-09 17:47:02 +0000 | [diff] [blame] | 8869 | // Non-public functions used by EGL |
| 8870 | |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 8871 | bool __stdcall glBindTexImage(egl::Surface *surface) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8872 | { |
| 8873 | EVENT("(egl::Surface* surface = 0x%0.8p)", |
| 8874 | surface); |
| 8875 | |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8876 | gl::Context *context = gl::getNonLostContext(); |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8877 | if (context) |
| 8878 | { |
| 8879 | gl::Texture2D *textureObject = context->getTexture2D(); |
| 8880 | ASSERT(textureObject != NULL); |
| 8881 | |
| 8882 | if (textureObject->isImmutable()) |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8883 | { |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8884 | return false; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8885 | } |
Geoff Lang | bfdea66 | 2014-07-23 14:16:32 -0400 | [diff] [blame] | 8886 | |
| 8887 | textureObject->bindTexImage(surface); |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8888 | } |
daniel@transgaming.com | 64a0fb2 | 2011-11-11 04:10:40 +0000 | [diff] [blame] | 8889 | |
| 8890 | return true; |
jbauman@chromium.org | ae34580 | 2011-03-30 22:04:25 +0000 | [diff] [blame] | 8891 | } |
| 8892 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 8893 | } |