Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Corentin Wallez | d3970de | 2015-05-14 11:07:48 -0400 | [diff] [blame] | 7 | #include "test_utils/ANGLETest.h" |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 8 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 9 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 10 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 11 | namespace |
| 12 | { |
| 13 | |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 14 | class TextureTest : public ANGLETest |
| 15 | { |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 16 | protected: |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 17 | TextureTest() |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 18 | { |
| 19 | setWindowWidth(128); |
| 20 | setWindowHeight(128); |
| 21 | setConfigRedBits(8); |
| 22 | setConfigGreenBits(8); |
| 23 | setConfigBlueBits(8); |
| 24 | setConfigAlphaBits(8); |
| 25 | } |
| 26 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 27 | void SetUp() override |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 28 | { |
| 29 | ANGLETest::SetUp(); |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 30 | glGenTextures(1, &mTexture2D); |
| 31 | glGenTextures(1, &mTextureCube); |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 32 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 33 | glBindTexture(GL_TEXTURE_2D, mTexture2D); |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 34 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 35 | EXPECT_GL_NO_ERROR(); |
| 36 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 37 | glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube); |
| 38 | glTexStorage2DEXT(GL_TEXTURE_CUBE_MAP, 1, GL_RGBA8, 1, 1); |
| 39 | EXPECT_GL_NO_ERROR(); |
| 40 | |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 41 | ASSERT_GL_NO_ERROR(); |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 42 | |
| 43 | const std::string vertexShaderSource = SHADER_SOURCE |
| 44 | ( |
| 45 | precision highp float; |
| 46 | attribute vec4 position; |
| 47 | varying vec2 texcoord; |
| 48 | |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 49 | uniform vec2 textureScale; |
| 50 | |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 51 | void main() |
| 52 | { |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 53 | gl_Position = vec4(position.xy * textureScale, 0.0, 1.0); |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 54 | texcoord = (position.xy * 0.5) + 0.5; |
| 55 | } |
| 56 | ); |
| 57 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 58 | const std::string fragmentShaderSource2D = SHADER_SOURCE |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 59 | ( |
| 60 | precision highp float; |
| 61 | uniform sampler2D tex; |
| 62 | varying vec2 texcoord; |
| 63 | |
| 64 | void main() |
| 65 | { |
| 66 | gl_FragColor = texture2D(tex, texcoord); |
| 67 | } |
| 68 | ); |
| 69 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 70 | const std::string fragmentShaderSourceCube = SHADER_SOURCE |
| 71 | ( |
| 72 | precision highp float; |
| 73 | uniform sampler2D tex2D; |
| 74 | uniform samplerCube texCube; |
| 75 | varying vec2 texcoord; |
| 76 | |
| 77 | void main() |
| 78 | { |
| 79 | gl_FragColor = texture2D(tex2D, texcoord); |
| 80 | gl_FragColor += textureCube(texCube, vec3(texcoord, 0)); |
| 81 | } |
| 82 | ); |
| 83 | |
Jamie Madill | 5599c8f | 2014-08-26 13:16:39 -0400 | [diff] [blame] | 84 | m2DProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2D); |
| 85 | mCubeProgram = CompileProgram(vertexShaderSource, fragmentShaderSourceCube); |
Jamie Madill | 2453dbc | 2015-07-14 11:35:42 -0400 | [diff] [blame^] | 86 | ASSERT_NE(0u, m2DProgram); |
| 87 | ASSERT_NE(0u, mCubeProgram); |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 88 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 89 | mTexture2DUniformLocation = glGetUniformLocation(m2DProgram, "tex"); |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 90 | ASSERT_NE(-1, mTexture2DUniformLocation); |
| 91 | |
| 92 | mTextureScaleUniformLocation = glGetUniformLocation(m2DProgram, "textureScale"); |
| 93 | ASSERT_NE(-1, mTextureScaleUniformLocation); |
| 94 | |
| 95 | glUseProgram(m2DProgram); |
| 96 | glUniform2f(mTextureScaleUniformLocation, 1.0f, 1.0f); |
| 97 | glUseProgram(0); |
| 98 | ASSERT_GL_NO_ERROR(); |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 99 | } |
| 100 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 101 | void TearDown() override |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 102 | { |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 103 | glDeleteTextures(1, &mTexture2D); |
| 104 | glDeleteTextures(1, &mTextureCube); |
| 105 | glDeleteProgram(m2DProgram); |
| 106 | glDeleteProgram(mCubeProgram); |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 107 | |
| 108 | ANGLETest::TearDown(); |
| 109 | } |
| 110 | |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 111 | // Tests CopyTexSubImage with floating point textures of various formats. |
| 112 | void testFloatCopySubImage(int sourceImageChannels, int destImageChannels) |
| 113 | { |
Geoff Lang | bde666a | 2015-04-07 17:17:08 -0400 | [diff] [blame] | 114 | // TODO(jmadill): Figure out why this is broken on Intel D3D11 |
| 115 | if (isIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE) |
| 116 | { |
| 117 | std::cout << "Test skipped on Intel D3D11." << std::endl; |
| 118 | return; |
| 119 | } |
| 120 | |
Geoff Lang | fbfa47c | 2015-03-31 11:26:00 -0400 | [diff] [blame] | 121 | if (getClientVersion() < 3) |
| 122 | { |
| 123 | if (!extensionEnabled("GL_OES_texture_float")) |
| 124 | { |
| 125 | std::cout << "Test skipped due to missing GL_OES_texture_float." << std::endl; |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | if ((sourceImageChannels < 3 || destImageChannels < 3) && !extensionEnabled("GL_EXT_texture_rg")) |
| 130 | { |
| 131 | std::cout << "Test skipped due to missing GL_EXT_texture_rg." << std::endl; |
| 132 | return; |
| 133 | } |
| 134 | } |
| 135 | |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 136 | GLfloat sourceImageData[4][16] = |
| 137 | { |
| 138 | { // R |
| 139 | 1.0f, |
| 140 | 0.0f, |
| 141 | 0.0f, |
| 142 | 1.0f |
| 143 | }, |
| 144 | { // RG |
| 145 | 1.0f, 0.0f, |
| 146 | 0.0f, 1.0f, |
| 147 | 0.0f, 0.0f, |
| 148 | 1.0f, 1.0f |
| 149 | }, |
| 150 | { // RGB |
| 151 | 1.0f, 0.0f, 0.0f, |
| 152 | 0.0f, 1.0f, 0.0f, |
| 153 | 0.0f, 0.0f, 1.0f, |
| 154 | 1.0f, 1.0f, 0.0f |
| 155 | }, |
| 156 | { // RGBA |
| 157 | 1.0f, 0.0f, 0.0f, 1.0f, |
| 158 | 0.0f, 1.0f, 0.0f, 1.0f, |
| 159 | 0.0f, 0.0f, 1.0f, 1.0f, |
| 160 | 1.0f, 1.0f, 0.0f, 1.0f |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | GLenum imageFormats[] = |
| 165 | { |
| 166 | GL_R32F, |
| 167 | GL_RG32F, |
| 168 | GL_RGB32F, |
| 169 | GL_RGBA32F, |
| 170 | }; |
| 171 | |
| 172 | GLenum sourceUnsizedFormats[] = |
| 173 | { |
| 174 | GL_RED, |
| 175 | GL_RG, |
| 176 | GL_RGB, |
| 177 | GL_RGBA, |
| 178 | }; |
| 179 | |
| 180 | GLuint textures[2]; |
| 181 | |
| 182 | glGenTextures(2, textures); |
| 183 | |
| 184 | GLfloat *imageData = sourceImageData[sourceImageChannels - 1]; |
| 185 | GLenum sourceImageFormat = imageFormats[sourceImageChannels - 1]; |
| 186 | GLenum sourceUnsizedFormat = sourceUnsizedFormats[sourceImageChannels - 1]; |
| 187 | GLenum destImageFormat = imageFormats[destImageChannels - 1]; |
| 188 | |
| 189 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 190 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, sourceImageFormat, 2, 2); |
| 191 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 192 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 193 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, sourceUnsizedFormat, GL_FLOAT, imageData); |
| 194 | |
hendrikw | b27f79a | 2015-03-04 11:26:46 -0800 | [diff] [blame] | 195 | if (sourceImageChannels < 3 && !extensionEnabled("GL_EXT_texture_rg")) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 196 | { |
| 197 | // This is not supported |
| 198 | ASSERT_GL_ERROR(GL_INVALID_OPERATION); |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | ASSERT_GL_NO_ERROR(); |
| 203 | } |
| 204 | |
| 205 | GLuint fbo; |
| 206 | glGenFramebuffers(1, &fbo); |
| 207 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 208 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0); |
| 209 | |
| 210 | glBindTexture(GL_TEXTURE_2D, textures[1]); |
| 211 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, destImageFormat, 2, 2); |
| 212 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 213 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 214 | |
| 215 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2); |
| 216 | ASSERT_GL_NO_ERROR(); |
| 217 | |
| 218 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 219 | drawQuad(m2DProgram, "position", 0.5f); |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 220 | |
| 221 | int testImageChannels = std::min(sourceImageChannels, destImageChannels); |
| 222 | |
| 223 | EXPECT_PIXEL_EQ(0, 0, 255, 0, 0, 255); |
| 224 | if (testImageChannels > 1) |
| 225 | { |
| 226 | EXPECT_PIXEL_EQ(getWindowHeight() - 1, 0, 0, 255, 0, 255); |
| 227 | EXPECT_PIXEL_EQ(getWindowHeight() - 1, getWindowWidth() - 1, 255, 255, 0, 255); |
| 228 | if (testImageChannels > 2) |
| 229 | { |
| 230 | EXPECT_PIXEL_EQ(0, getWindowWidth() - 1, 0, 0, 255, 255); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | glDeleteFramebuffers(1, &fbo); |
| 235 | glDeleteTextures(2, textures); |
| 236 | |
| 237 | ASSERT_GL_NO_ERROR(); |
| 238 | } |
| 239 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 240 | GLuint mTexture2D; |
| 241 | GLuint mTextureCube; |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 242 | |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 243 | GLuint m2DProgram; |
| 244 | GLuint mCubeProgram; |
| 245 | GLint mTexture2DUniformLocation; |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 246 | GLint mTextureScaleUniformLocation; |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 247 | }; |
| 248 | |
Jamie Madill | 2453dbc | 2015-07-14 11:35:42 -0400 | [diff] [blame^] | 249 | class TextureTestES3 : public ANGLETest |
| 250 | { |
| 251 | protected: |
| 252 | TextureTestES3() |
| 253 | : m2DArrayTexture(0), |
| 254 | m2DArrayProgram(0), |
| 255 | mTextureArrayLocation(-1) |
| 256 | { |
| 257 | setWindowWidth(128); |
| 258 | setWindowHeight(128); |
| 259 | setConfigRedBits(8); |
| 260 | setConfigGreenBits(8); |
| 261 | setConfigBlueBits(8); |
| 262 | setConfigAlphaBits(8); |
| 263 | } |
| 264 | |
| 265 | void SetUp() override |
| 266 | { |
| 267 | ANGLETest::SetUp(); |
| 268 | |
| 269 | const std::string vertexShaderSource = |
| 270 | "#version 300 es\n" |
| 271 | "out vec2 texcoord;\n" |
| 272 | "in vec4 position;\n" |
| 273 | "void main() {\n" |
| 274 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 275 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 276 | "}"; |
| 277 | |
| 278 | const std::string fragmentShaderSource2DArray = |
| 279 | "#version 300 es\n" |
| 280 | "precision highp float;\n" |
| 281 | "uniform sampler2DArray tex2DArray;\n" |
| 282 | "in vec2 texcoord;\n" |
| 283 | "out vec4 fragColor;\n" |
| 284 | "void main()\n" |
| 285 | "{\n" |
| 286 | " fragColor = texture(tex2DArray, vec3(texcoord.x, texcoord.y, 0.0));\n" |
| 287 | "}\n"; |
| 288 | |
| 289 | m2DArrayProgram = CompileProgram(vertexShaderSource, fragmentShaderSource2DArray); |
| 290 | ASSERT_NE(0u, m2DArrayProgram); |
| 291 | |
| 292 | mTextureArrayLocation = glGetUniformLocation(m2DArrayProgram, "tex2DArray"); |
| 293 | ASSERT_NE(-1, mTextureArrayLocation); |
| 294 | |
| 295 | glGenTextures(1, &m2DArrayTexture); |
| 296 | ASSERT_GL_NO_ERROR(); |
| 297 | } |
| 298 | |
| 299 | void TearDown() override |
| 300 | { |
| 301 | glDeleteTextures(1, &m2DArrayTexture); |
| 302 | glDeleteProgram(m2DArrayProgram); |
| 303 | } |
| 304 | |
| 305 | GLuint m2DArrayTexture; |
| 306 | GLuint m2DArrayProgram; |
| 307 | GLint mTextureArrayLocation; |
| 308 | }; |
| 309 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 310 | TEST_P(TextureTest, NegativeAPISubImage) |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 311 | { |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 312 | glBindTexture(GL_TEXTURE_2D, mTexture2D); |
Jamie Madill | f67115c | 2014-04-22 13:14:05 -0400 | [diff] [blame] | 313 | EXPECT_GL_ERROR(GL_NO_ERROR); |
| 314 | |
| 315 | const GLubyte *pixels[20] = { 0 }; |
| 316 | glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 317 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 318 | } |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 319 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 320 | TEST_P(TextureTest, ZeroSizedUploads) |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 321 | { |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 322 | glBindTexture(GL_TEXTURE_2D, mTexture2D); |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 323 | EXPECT_GL_ERROR(GL_NO_ERROR); |
| 324 | |
| 325 | // Use the texture first to make sure it's in video memory |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 326 | glUseProgram(m2DProgram); |
| 327 | glUniform1i(mTexture2DUniformLocation, 0); |
| 328 | drawQuad(m2DProgram, "position", 0.5f); |
Geoff Lang | c41e42d | 2014-04-28 10:58:16 -0400 | [diff] [blame] | 329 | |
| 330 | const GLubyte *pixel[4] = { 0 }; |
| 331 | |
| 332 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
| 333 | EXPECT_GL_NO_ERROR(); |
| 334 | |
| 335 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
| 336 | EXPECT_GL_NO_ERROR(); |
| 337 | |
| 338 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
| 339 | EXPECT_GL_NO_ERROR(); |
| 340 | } |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 341 | |
| 342 | // Test drawing with two texture types, to trigger an ANGLE bug in validation |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 343 | TEST_P(TextureTest, CubeMapBug) |
Jamie Madill | d4cfa57 | 2014-07-08 10:00:32 -0400 | [diff] [blame] | 344 | { |
| 345 | glActiveTexture(GL_TEXTURE0); |
| 346 | glBindTexture(GL_TEXTURE_2D, mTexture2D); |
| 347 | glActiveTexture(GL_TEXTURE1); |
| 348 | glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube); |
| 349 | EXPECT_GL_ERROR(GL_NO_ERROR); |
| 350 | |
| 351 | glUseProgram(mCubeProgram); |
| 352 | GLint tex2DUniformLocation = glGetUniformLocation(mCubeProgram, "tex2D"); |
| 353 | GLint texCubeUniformLocation = glGetUniformLocation(mCubeProgram, "texCube"); |
| 354 | EXPECT_NE(-1, tex2DUniformLocation); |
| 355 | EXPECT_NE(-1, texCubeUniformLocation); |
| 356 | glUniform1i(tex2DUniformLocation, 0); |
| 357 | glUniform1i(texCubeUniformLocation, 1); |
| 358 | drawQuad(mCubeProgram, "position", 0.5f); |
| 359 | EXPECT_GL_NO_ERROR(); |
| 360 | } |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 361 | |
| 362 | // Copy of a test in conformance/textures/texture-mips, to test generate mipmaps |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 363 | TEST_P(TextureTest, MipmapsTwice) |
Jamie Madill | 9aca059 | 2014-10-06 16:26:59 -0400 | [diff] [blame] | 364 | { |
| 365 | int px = getWindowWidth() / 2; |
| 366 | int py = getWindowHeight() / 2; |
| 367 | |
| 368 | glActiveTexture(GL_TEXTURE0); |
| 369 | glBindTexture(GL_TEXTURE_2D, mTexture2D); |
| 370 | |
| 371 | // Fill with red |
| 372 | std::vector<GLubyte> pixels(4 * 16 * 16); |
| 373 | for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId) |
| 374 | { |
| 375 | pixels[pixelId * 4 + 0] = 255; |
| 376 | pixels[pixelId * 4 + 1] = 0; |
| 377 | pixels[pixelId * 4 + 2] = 0; |
| 378 | pixels[pixelId * 4 + 3] = 255; |
| 379 | } |
| 380 | |
| 381 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()); |
| 382 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); |
| 383 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 384 | glGenerateMipmap(GL_TEXTURE_2D); |
| 385 | |
| 386 | glUseProgram(m2DProgram); |
| 387 | glUniform1i(mTexture2DUniformLocation, 0); |
| 388 | glUniform2f(mTextureScaleUniformLocation, 0.0625f, 0.0625f); |
| 389 | drawQuad(m2DProgram, "position", 0.5f); |
| 390 | EXPECT_GL_NO_ERROR(); |
| 391 | EXPECT_PIXEL_EQ(px, py, 255, 0, 0, 255); |
| 392 | |
| 393 | // Fill with blue |
| 394 | for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId) |
| 395 | { |
| 396 | pixels[pixelId * 4 + 0] = 0; |
| 397 | pixels[pixelId * 4 + 1] = 0; |
| 398 | pixels[pixelId * 4 + 2] = 255; |
| 399 | pixels[pixelId * 4 + 3] = 255; |
| 400 | } |
| 401 | |
| 402 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()); |
| 403 | glGenerateMipmap(GL_TEXTURE_2D); |
| 404 | |
| 405 | // Fill with green |
| 406 | for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId) |
| 407 | { |
| 408 | pixels[pixelId * 4 + 0] = 0; |
| 409 | pixels[pixelId * 4 + 1] = 255; |
| 410 | pixels[pixelId * 4 + 2] = 0; |
| 411 | pixels[pixelId * 4 + 3] = 255; |
| 412 | } |
| 413 | |
| 414 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()); |
| 415 | glGenerateMipmap(GL_TEXTURE_2D); |
| 416 | |
| 417 | drawQuad(m2DProgram, "position", 0.5f); |
| 418 | |
| 419 | EXPECT_GL_NO_ERROR(); |
| 420 | EXPECT_PIXEL_EQ(px, py, 0, 255, 0, 255); |
| 421 | } |
Jamie Madill | f8fccb3 | 2014-11-12 15:05:26 -0500 | [diff] [blame] | 422 | |
Jamie Madill | eb32a2e | 2014-12-10 14:27:53 -0500 | [diff] [blame] | 423 | // Test creating a FBO with a cube map render target, to test an ANGLE bug |
| 424 | // https://code.google.com/p/angleproject/issues/detail?id=849 |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 425 | TEST_P(TextureTest, CubeMapFBO) |
Jamie Madill | eb32a2e | 2014-12-10 14:27:53 -0500 | [diff] [blame] | 426 | { |
| 427 | GLuint fbo; |
| 428 | glGenFramebuffers(1, &fbo); |
| 429 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 430 | |
| 431 | glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube); |
| 432 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mTextureCube, 0); |
| 433 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 434 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Jamie Madill | eb32a2e | 2014-12-10 14:27:53 -0500 | [diff] [blame] | 435 | |
| 436 | glDeleteFramebuffers(1, &fbo); |
| 437 | |
| 438 | EXPECT_GL_NO_ERROR(); |
| 439 | } |
Gregoire Payen de La Garanderie | 88fe1ad | 2015-01-19 15:09:26 +0000 | [diff] [blame] | 440 | |
| 441 | // Test that glTexSubImage2D works properly when glTexStorage2DEXT has initialized the image with a default color. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 442 | TEST_P(TextureTest, TexStorage) |
Gregoire Payen de La Garanderie | 88fe1ad | 2015-01-19 15:09:26 +0000 | [diff] [blame] | 443 | { |
| 444 | int width = getWindowWidth(); |
| 445 | int height = getWindowHeight(); |
| 446 | |
| 447 | GLuint tex2D; |
| 448 | glGenTextures(1, &tex2D); |
| 449 | glActiveTexture(GL_TEXTURE0); |
| 450 | glBindTexture(GL_TEXTURE_2D, tex2D); |
| 451 | |
| 452 | // Fill with red |
| 453 | std::vector<GLubyte> pixels(3 * 16 * 16); |
| 454 | for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId) |
| 455 | { |
| 456 | pixels[pixelId * 3 + 0] = 255; |
| 457 | pixels[pixelId * 3 + 1] = 0; |
| 458 | pixels[pixelId * 3 + 2] = 0; |
| 459 | } |
| 460 | |
| 461 | // ANGLE internally uses RGBA as the DirectX format for RGB images |
| 462 | // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color. |
| 463 | // The data is kept in a CPU-side image and the image is marked as dirty. |
| 464 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16); |
| 465 | |
| 466 | // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched. |
| 467 | // glTexSubImage2D should take into account that the image is dirty. |
| 468 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, pixels.data()); |
| 469 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 470 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 471 | |
| 472 | glUseProgram(m2DProgram); |
| 473 | glUniform1i(mTexture2DUniformLocation, 0); |
| 474 | glUniform2f(mTextureScaleUniformLocation, 1.f, 1.f); |
| 475 | drawQuad(m2DProgram, "position", 0.5f); |
| 476 | glDeleteTextures(1, &tex2D); |
| 477 | EXPECT_GL_NO_ERROR(); |
Gregoire Payen de La Garanderie | 88fe1ad | 2015-01-19 15:09:26 +0000 | [diff] [blame] | 478 | EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255); |
Geoff Lang | fbfa47c | 2015-03-31 11:26:00 -0400 | [diff] [blame] | 479 | |
| 480 | // Validate that the region of the texture without data has an alpha of 1.0 |
| 481 | GLubyte pixel[4]; |
| 482 | glReadPixels(3 * width / 4, 3 * height / 4, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
| 483 | EXPECT_EQ(pixel[3], 255); |
Gregoire Payen de La Garanderie | 88fe1ad | 2015-01-19 15:09:26 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | // Test that glTexSubImage2D combined with a PBO works properly when glTexStorage2DEXT has initialized the image with a default color. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 487 | TEST_P(TextureTest, TexStorageWithPBO) |
Gregoire Payen de La Garanderie | 88fe1ad | 2015-01-19 15:09:26 +0000 | [diff] [blame] | 488 | { |
| 489 | if (extensionEnabled("NV_pixel_buffer_object")) |
| 490 | { |
| 491 | int width = getWindowWidth(); |
| 492 | int height = getWindowHeight(); |
| 493 | |
| 494 | GLuint tex2D; |
| 495 | glGenTextures(1, &tex2D); |
| 496 | glActiveTexture(GL_TEXTURE0); |
| 497 | glBindTexture(GL_TEXTURE_2D, tex2D); |
| 498 | |
| 499 | // Fill with red |
| 500 | std::vector<GLubyte> pixels(3 * 16 * 16); |
| 501 | for (size_t pixelId = 0; pixelId < 16 * 16; ++pixelId) |
| 502 | { |
| 503 | pixels[pixelId * 3 + 0] = 255; |
| 504 | pixels[pixelId * 3 + 1] = 0; |
| 505 | pixels[pixelId * 3 + 2] = 0; |
| 506 | } |
| 507 | |
| 508 | // Read 16x16 region from red backbuffer to PBO |
| 509 | GLuint pbo; |
| 510 | glGenBuffers(1, &pbo); |
| 511 | glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo); |
| 512 | glBufferData(GL_PIXEL_UNPACK_BUFFER, 3 * 16 * 16, pixels.data(), GL_STATIC_DRAW); |
| 513 | |
| 514 | // ANGLE internally uses RGBA as the DirectX format for RGB images |
| 515 | // therefore glTexStorage2DEXT initializes the image to a default color to get a consistent alpha color. |
| 516 | // The data is kept in a CPU-side image and the image is marked as dirty. |
| 517 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB8, 16, 16); |
| 518 | |
| 519 | // Initializes the color of the upper-left 8x8 pixels, leaves the other pixels untouched. |
| 520 | // glTexSubImage2D should take into account that the image is dirty. |
| 521 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 8, 8, GL_RGB, GL_UNSIGNED_BYTE, NULL); |
| 522 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 523 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 524 | |
| 525 | glUseProgram(m2DProgram); |
| 526 | glUniform1i(mTexture2DUniformLocation, 0); |
| 527 | glUniform2f(mTextureScaleUniformLocation, 1.f, 1.f); |
| 528 | drawQuad(m2DProgram, "position", 0.5f); |
| 529 | glDeleteTextures(1, &tex2D); |
| 530 | glDeleteTextures(1, &pbo); |
| 531 | EXPECT_GL_NO_ERROR(); |
| 532 | EXPECT_PIXEL_EQ(3 * width / 4, 3 * height / 4, 0, 0, 0, 255); |
| 533 | EXPECT_PIXEL_EQ(width / 4, height / 4, 255, 0, 0, 255); |
| 534 | } |
| 535 | } |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 536 | |
| 537 | // See description on testFloatCopySubImage |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 538 | TEST_P(TextureTest, CopySubImageFloat_R_R) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 539 | { |
| 540 | testFloatCopySubImage(1, 1); |
| 541 | } |
| 542 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 543 | TEST_P(TextureTest, CopySubImageFloat_RG_R) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 544 | { |
| 545 | testFloatCopySubImage(2, 1); |
| 546 | } |
| 547 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 548 | TEST_P(TextureTest, CopySubImageFloat_RG_RG) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 549 | { |
| 550 | testFloatCopySubImage(2, 2); |
| 551 | } |
| 552 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 553 | TEST_P(TextureTest, CopySubImageFloat_RGB_R) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 554 | { |
| 555 | testFloatCopySubImage(3, 1); |
| 556 | } |
| 557 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 558 | TEST_P(TextureTest, CopySubImageFloat_RGB_RG) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 559 | { |
| 560 | testFloatCopySubImage(3, 2); |
| 561 | } |
| 562 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 563 | TEST_P(TextureTest, CopySubImageFloat_RGB_RGB) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 564 | { |
| 565 | testFloatCopySubImage(3, 3); |
| 566 | } |
| 567 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 568 | TEST_P(TextureTest, CopySubImageFloat_RGBA_R) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 569 | { |
| 570 | testFloatCopySubImage(4, 1); |
| 571 | } |
| 572 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 573 | TEST_P(TextureTest, CopySubImageFloat_RGBA_RG) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 574 | { |
| 575 | testFloatCopySubImage(4, 2); |
| 576 | } |
| 577 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 578 | TEST_P(TextureTest, CopySubImageFloat_RGBA_RGB) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 579 | { |
| 580 | testFloatCopySubImage(4, 3); |
| 581 | } |
| 582 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 583 | TEST_P(TextureTest, CopySubImageFloat_RGBA_RGBA) |
Jamie Madill | bc393df | 2015-01-29 13:46:07 -0500 | [diff] [blame] | 584 | { |
| 585 | testFloatCopySubImage(4, 4); |
| 586 | } |
Austin Kinross | 0728514 | 2015-03-26 11:36:16 -0700 | [diff] [blame] | 587 | |
| 588 | // Port of https://www.khronos.org/registry/webgl/conformance-suites/1.0.3/conformance/textures/texture-npot.html |
| 589 | // Run against GL_ALPHA/UNSIGNED_BYTE format, to ensure that D3D11 Feature Level 9_3 correctly handles GL_ALPHA |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 590 | TEST_P(TextureTest, TextureNPOT_GL_ALPHA_UBYTE) |
Austin Kinross | 0728514 | 2015-03-26 11:36:16 -0700 | [diff] [blame] | 591 | { |
| 592 | const int npotTexSize = 5; |
| 593 | const int potTexSize = 4; // Should be less than npotTexSize |
| 594 | GLuint tex2D; |
| 595 | |
| 596 | if (extensionEnabled("GL_OES_texture_npot")) |
| 597 | { |
| 598 | // This test isn't applicable if texture_npot is enabled |
| 599 | return; |
| 600 | } |
| 601 | |
| 602 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 603 | |
| 604 | glActiveTexture(GL_TEXTURE0); |
| 605 | glGenTextures(1, &tex2D); |
| 606 | glBindTexture(GL_TEXTURE_2D, tex2D); |
| 607 | |
| 608 | std::vector<GLubyte> pixels(1 * npotTexSize * npotTexSize); |
| 609 | for (size_t pixelId = 0; pixelId < npotTexSize * npotTexSize; ++pixelId) |
| 610 | { |
| 611 | pixels[pixelId] = 64; |
| 612 | } |
| 613 | |
| 614 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 615 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 616 | |
| 617 | // Check that an NPOT texture not on level 0 generates INVALID_VALUE |
| 618 | glTexImage2D(GL_TEXTURE_2D, 1, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data()); |
| 619 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 620 | |
| 621 | // Check that an NPOT texture on level 0 succeeds |
| 622 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, npotTexSize, npotTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data()); |
| 623 | EXPECT_GL_NO_ERROR(); |
| 624 | |
| 625 | // Check that generateMipmap fails on NPOT |
| 626 | glGenerateMipmap(GL_TEXTURE_2D); |
| 627 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 628 | |
| 629 | // Check that nothing is drawn if filtering is not correct for NPOT |
| 630 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 631 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 632 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 633 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 634 | glClear(GL_COLOR_BUFFER_BIT); |
| 635 | drawQuad(m2DProgram, "position", 1.0f); |
| 636 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255); |
| 637 | |
| 638 | // NPOT texture with TEXTURE_MIN_FILTER not NEAREST or LINEAR should draw with 0,0,0,255 |
| 639 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 640 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 641 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); |
| 642 | glClear(GL_COLOR_BUFFER_BIT); |
| 643 | drawQuad(m2DProgram, "position", 1.0f); |
| 644 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 255); |
| 645 | |
| 646 | // NPOT texture with TEXTURE_MIN_FILTER set to LINEAR should draw |
| 647 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 648 | glClear(GL_COLOR_BUFFER_BIT); |
| 649 | drawQuad(m2DProgram, "position", 1.0f); |
| 650 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64); |
| 651 | |
| 652 | // Check that glTexImage2D for POT texture succeeds |
| 653 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, potTexSize, potTexSize, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels.data()); |
| 654 | EXPECT_GL_NO_ERROR(); |
| 655 | |
| 656 | // Check that generateMipmap for an POT texture succeeds |
| 657 | glGenerateMipmap(GL_TEXTURE_2D); |
| 658 | EXPECT_GL_NO_ERROR(); |
| 659 | |
| 660 | // POT texture with TEXTURE_MIN_FILTER set to LINEAR_MIPMAP_LINEAR should draw |
| 661 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); |
| 662 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 663 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 664 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 665 | glClear(GL_COLOR_BUFFER_BIT); |
| 666 | drawQuad(m2DProgram, "position", 1.0f); |
| 667 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 0, 64); |
| 668 | EXPECT_GL_NO_ERROR(); |
| 669 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 670 | |
Jamie Madill | 2453dbc | 2015-07-14 11:35:42 -0400 | [diff] [blame^] | 671 | // In the D3D11 renderer, we need to initialize some texture formats, to fill empty channels. EG RBA->RGBA8, with 1.0 |
| 672 | // in the alpha channel. This test covers a bug where redefining array textures with these formats does not work as |
| 673 | // expected. |
| 674 | TEST_P(TextureTestES3, RedefineInittableArray) |
| 675 | { |
| 676 | std::vector<GLubyte> pixelData; |
| 677 | for (size_t count = 0; count < 5000; count++) |
| 678 | { |
| 679 | pixelData.push_back(0u); |
| 680 | pixelData.push_back(255u); |
| 681 | pixelData.push_back(0u); |
| 682 | } |
| 683 | |
| 684 | glBindTexture(GL_TEXTURE_2D_ARRAY, m2DArrayTexture); |
| 685 | glUseProgram(m2DArrayProgram); |
| 686 | glUniform1i(mTextureArrayLocation, 0); |
| 687 | |
| 688 | // The first draw worked correctly. |
| 689 | glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 4, 4, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, &pixelData[0]); |
| 690 | |
| 691 | glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 692 | glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 693 | glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT); |
| 694 | glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT); |
| 695 | drawQuad(m2DArrayProgram, "position", 1.0f); |
| 696 | EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255); |
| 697 | |
| 698 | // The dimension of the respecification must match the original exactly to trigger the bug. |
| 699 | glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, 4, 4, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, &pixelData[0]); |
| 700 | drawQuad(m2DArrayProgram, "position", 1.0f); |
| 701 | EXPECT_PIXEL_EQ(0, 0, 0, 255, 0, 255); |
| 702 | |
| 703 | ASSERT_GL_NO_ERROR(); |
| 704 | } |
| 705 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 706 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Geoff Lang | c422207 | 2015-05-25 13:19:48 -0400 | [diff] [blame] | 707 | ANGLE_INSTANTIATE_TEST(TextureTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3()); // TODO(geofflang): Figure out why this test fails on Intel OpenGL |
Jamie Madill | 2453dbc | 2015-07-14 11:35:42 -0400 | [diff] [blame^] | 708 | ANGLE_INSTANTIATE_TEST(TextureTestES3, ES3_D3D11(), ES3_OPENGL()); |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 709 | |
| 710 | } // namespace |