Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2016 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 | |
| 7 | // CopyTextureTest.cpp: Tests of the GL_CHROMIUM_copy_texture extension |
| 8 | |
| 9 | #include "test_utils/ANGLETest.h" |
| 10 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 11 | #include "test_utils/gl_raii.h" |
| 12 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 13 | namespace angle |
| 14 | { |
| 15 | |
| 16 | class CopyTextureTest : public ANGLETest |
| 17 | { |
| 18 | protected: |
| 19 | CopyTextureTest() |
| 20 | { |
| 21 | setWindowWidth(256); |
| 22 | setWindowHeight(256); |
| 23 | setConfigRedBits(8); |
| 24 | setConfigGreenBits(8); |
| 25 | setConfigBlueBits(8); |
| 26 | setConfigAlphaBits(8); |
| 27 | } |
| 28 | |
| 29 | void SetUp() override |
| 30 | { |
| 31 | ANGLETest::SetUp(); |
| 32 | |
| 33 | glGenTextures(2, mTextures); |
| 34 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 35 | |
| 36 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 37 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 38 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 39 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 40 | |
| 41 | glGenFramebuffers(1, &mFramebuffer); |
| 42 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); |
| 43 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1], |
| 44 | 0); |
| 45 | |
| 46 | if (extensionEnabled("GL_CHROMIUM_copy_texture")) |
| 47 | { |
| 48 | glCopyTextureCHROMIUM = reinterpret_cast<PFNGLCOPYTEXTURECHROMIUMPROC>( |
| 49 | eglGetProcAddress("glCopyTextureCHROMIUM")); |
| 50 | glCopySubTextureCHROMIUM = reinterpret_cast<PFNGLCOPYSUBTEXTURECHROMIUMPROC>( |
| 51 | eglGetProcAddress("glCopySubTextureCHROMIUM")); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void TearDown() override |
| 56 | { |
| 57 | glDeleteTextures(2, mTextures); |
| 58 | glDeleteFramebuffers(1, &mFramebuffer); |
| 59 | |
| 60 | ANGLETest::TearDown(); |
| 61 | } |
| 62 | |
| 63 | bool checkExtensions() const |
| 64 | { |
| 65 | if (!extensionEnabled("GL_CHROMIUM_copy_texture")) |
| 66 | { |
| 67 | std::cout << "Test skipped because GL_CHROMIUM_copy_texture is not available." |
| 68 | << std::endl; |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | EXPECT_NE(nullptr, glCopyTextureCHROMIUM); |
| 73 | EXPECT_NE(nullptr, glCopySubTextureCHROMIUM); |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | GLuint mTextures[2] = { |
| 78 | 0, 0, |
| 79 | }; |
| 80 | GLuint mFramebuffer = 0; |
| 81 | |
| 82 | PFNGLCOPYTEXTURECHROMIUMPROC glCopyTextureCHROMIUM = nullptr; |
| 83 | PFNGLCOPYSUBTEXTURECHROMIUMPROC glCopySubTextureCHROMIUM = nullptr; |
| 84 | }; |
| 85 | |
Brandon Jones | 340b7b8 | 2017-06-26 13:02:31 -0700 | [diff] [blame] | 86 | class CopyTextureTestDest : public CopyTextureTest |
| 87 | { |
| 88 | }; |
| 89 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 90 | class CopyTextureTestES3 : public CopyTextureTest |
| 91 | { |
| 92 | }; |
| 93 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 94 | // Test to ensure that the basic functionality of the extension works. |
| 95 | TEST_P(CopyTextureTest, BasicCopyTexture) |
| 96 | { |
| 97 | if (!checkExtensions()) |
| 98 | { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | GLColor pixels = GLColor::red; |
| 103 | |
| 104 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 105 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 106 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 107 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 108 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 109 | |
| 110 | EXPECT_GL_NO_ERROR(); |
| 111 | |
| 112 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 113 | } |
| 114 | |
| 115 | // Test to ensure that the basic functionality of the extension works. |
| 116 | TEST_P(CopyTextureTest, BasicCopySubTexture) |
| 117 | { |
| 118 | if (!checkExtensions()) |
| 119 | { |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | GLColor pixels = GLColor::red; |
| 124 | |
| 125 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 126 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 127 | |
| 128 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 129 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 130 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 131 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1, |
| 132 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 133 | |
| 134 | EXPECT_GL_NO_ERROR(); |
| 135 | |
| 136 | // Check that FB is complete. |
| 137 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 138 | |
| 139 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 140 | |
| 141 | EXPECT_GL_NO_ERROR(); |
| 142 | } |
| 143 | |
| 144 | // Test that CopyTexture cannot redefine an immutable texture and CopySubTexture can copy data to |
| 145 | // immutable textures |
| 146 | TEST_P(CopyTextureTest, ImmutableTexture) |
| 147 | { |
| 148 | if (!checkExtensions()) |
| 149 | { |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | if (getClientMajorVersion() < 3 && |
| 154 | (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8"))) |
| 155 | { |
| 156 | std::cout |
| 157 | << "Test skipped due to missing ES3 or GL_EXT_texture_storage or GL_OES_rgb8_rgba8" |
| 158 | << std::endl; |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | GLColor pixels = GLColor::red; |
| 163 | |
| 164 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 165 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 166 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 167 | |
| 168 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 169 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 170 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1], 0); |
| 171 | EXPECT_GL_NO_ERROR(); |
| 172 | |
| 173 | // Should generate an error when the texture is redefined |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 174 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 175 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 176 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 177 | |
| 178 | // Should succeed when using CopySubTexture |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 179 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1, |
| 180 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 181 | EXPECT_GL_NO_ERROR(); |
| 182 | |
| 183 | // Check that FB is complete. |
| 184 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 185 | |
| 186 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 187 | |
| 188 | EXPECT_GL_NO_ERROR(); |
| 189 | } |
| 190 | |
| 191 | // Test validation of internal formats in CopyTexture and CopySubTexture |
| 192 | TEST_P(CopyTextureTest, InternalFormat) |
| 193 | { |
| 194 | if (!checkExtensions()) |
| 195 | { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | std::vector<GLint> sourceFormats; |
| 200 | sourceFormats.push_back(GL_ALPHA); |
| 201 | sourceFormats.push_back(GL_RGB); |
| 202 | sourceFormats.push_back(GL_RGBA); |
| 203 | sourceFormats.push_back(GL_LUMINANCE); |
| 204 | sourceFormats.push_back(GL_LUMINANCE_ALPHA); |
| 205 | |
| 206 | std::vector<GLint> destFormats; |
| 207 | destFormats.push_back(GL_RGB); |
| 208 | destFormats.push_back(GL_RGBA); |
| 209 | |
| 210 | if (extensionEnabled("GL_EXT_texture_format_BGRA8888")) |
| 211 | { |
| 212 | sourceFormats.push_back(GL_BGRA_EXT); |
| 213 | destFormats.push_back(GL_BGRA_EXT); |
| 214 | } |
| 215 | |
| 216 | // Test with glCopyTexture |
| 217 | for (GLint sourceFormat : sourceFormats) |
| 218 | { |
| 219 | for (GLint destFormat : destFormats) |
| 220 | { |
| 221 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 222 | glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE, |
| 223 | nullptr); |
| 224 | EXPECT_GL_NO_ERROR(); |
| 225 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 226 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, destFormat, |
| 227 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 228 | |
| 229 | EXPECT_GL_NO_ERROR(); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | // Test with glCopySubTexture |
| 234 | for (GLint sourceFormat : sourceFormats) |
| 235 | { |
| 236 | for (GLint destFormat : destFormats) |
| 237 | { |
| 238 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 239 | glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE, |
| 240 | nullptr); |
| 241 | EXPECT_GL_NO_ERROR(); |
| 242 | |
| 243 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 244 | glTexImage2D(GL_TEXTURE_2D, 0, destFormat, 1, 1, 0, destFormat, GL_UNSIGNED_BYTE, |
| 245 | nullptr); |
| 246 | EXPECT_GL_NO_ERROR(); |
| 247 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 248 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, |
| 249 | 1, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 250 | |
| 251 | EXPECT_GL_NO_ERROR(); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 256 | // Test to ensure that the destination texture is redefined if the properties are different. |
| 257 | TEST_P(CopyTextureTest, RedefineDestinationTexture) |
| 258 | { |
| 259 | if (!checkExtensions()) |
| 260 | { |
| 261 | return; |
| 262 | } |
| 263 | |
| 264 | GLColor pixels[4] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red}; |
| 265 | |
| 266 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 267 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 268 | |
| 269 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 270 | glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 1, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 271 | EXPECT_GL_NO_ERROR(); |
| 272 | |
| 273 | // GL_INVALID_OPERATION due to "intrinsic format" != "internal format". |
| 274 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 275 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 276 | // GL_INVALID_VALUE due to bad dimensions. |
| 277 | glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 278 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 279 | |
| 280 | // If the dest texture has different properties, glCopyTextureCHROMIUM() |
| 281 | // redefines them. |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 282 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 283 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 284 | EXPECT_GL_NO_ERROR(); |
| 285 | |
| 286 | // glTexSubImage2D() succeeds because mTextures[1] is redefined into 2x2 |
| 287 | // dimension and GL_RGBA format. |
| 288 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 289 | glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 290 | EXPECT_GL_NO_ERROR(); |
| 291 | |
| 292 | // Check that FB is complete. |
| 293 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 294 | |
| 295 | EXPECT_PIXEL_COLOR_EQ(1, 1, pixels[3]); |
| 296 | EXPECT_GL_NO_ERROR(); |
| 297 | } |
| 298 | |
| 299 | // Test that invalid dimensions in CopySubTexture are validated |
| 300 | TEST_P(CopyTextureTest, CopySubTextureDimension) |
| 301 | { |
| 302 | if (!checkExtensions()) |
| 303 | { |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 308 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 309 | |
| 310 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 311 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 312 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 313 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 314 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 315 | EXPECT_GL_NO_ERROR(); |
| 316 | |
| 317 | // xoffset < 0 |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 318 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, -1, 1, 0, 0, 1, 1, |
| 319 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 320 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 321 | |
| 322 | // x < 0 |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 323 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, -1, 0, 1, 1, |
| 324 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 325 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 326 | |
| 327 | // xoffset + width > dest_width |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 328 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 2, 2, 0, 0, 2, 2, |
| 329 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 330 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 331 | |
| 332 | // x + width > source_width |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 333 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 1, 1, 2, 2, |
| 334 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 335 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 336 | } |
| 337 | |
| 338 | // Test that invalid IDs in CopyTexture are validated |
| 339 | TEST_P(CopyTextureTest, CopyTextureInvalidTextureIds) |
| 340 | { |
| 341 | if (!checkExtensions()) |
| 342 | { |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 347 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 348 | |
| 349 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 350 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 351 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 352 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 353 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 354 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 355 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 356 | glCopyTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 357 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 358 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 359 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 360 | glCopyTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false, |
| 361 | false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 362 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 363 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 364 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 365 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 366 | EXPECT_GL_NO_ERROR(); |
| 367 | } |
| 368 | |
| 369 | // Test that invalid IDs in CopySubTexture are validated |
| 370 | TEST_P(CopyTextureTest, CopySubTextureInvalidTextureIds) |
| 371 | { |
| 372 | if (!checkExtensions()) |
| 373 | { |
| 374 | return; |
| 375 | } |
| 376 | |
| 377 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 378 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 379 | |
| 380 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 381 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 382 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 383 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, 1, 1, 0, 0, 1, 1, false, |
| 384 | false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 385 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 386 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 387 | glCopySubTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, false, |
| 388 | false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 389 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 390 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 391 | glCopySubTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, 1, 1, 0, 0, 1, 1, false, false, |
| 392 | false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 393 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 394 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 395 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 396 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 397 | EXPECT_GL_NO_ERROR(); |
| 398 | } |
| 399 | |
| 400 | // Test that using an offset in CopySubTexture works correctly |
| 401 | TEST_P(CopyTextureTest, CopySubTextureOffset) |
| 402 | { |
| 403 | if (!checkExtensions()) |
| 404 | { |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | GLColor rgbaPixels[4 * 4] = {GLColor::red, GLColor::green, GLColor::blue, GLColor::black}; |
| 409 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 410 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 411 | |
| 412 | GLColor transparentPixels[4 * 4] = {GLColor::transparentBlack, GLColor::transparentBlack, |
| 413 | GLColor::transparentBlack, GLColor::transparentBlack}; |
| 414 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 415 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, transparentPixels); |
| 416 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 417 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 418 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 419 | EXPECT_GL_NO_ERROR(); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 420 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 0, 1, 0, 1, 1, |
| 421 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 422 | EXPECT_GL_NO_ERROR(); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 423 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 1, 0, 1, 1, 1, |
| 424 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 425 | EXPECT_GL_NO_ERROR(); |
| 426 | |
| 427 | // Check that FB is complete. |
| 428 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 429 | |
| 430 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::transparentBlack); |
| 431 | EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red); |
| 432 | EXPECT_PIXEL_COLOR_EQ(1, 0, GLColor::green); |
| 433 | EXPECT_PIXEL_COLOR_EQ(0, 1, GLColor::blue); |
| 434 | EXPECT_GL_NO_ERROR(); |
| 435 | } |
| 436 | |
| 437 | // Test that flipping the Y component works correctly |
| 438 | TEST_P(CopyTextureTest, FlipY) |
| 439 | { |
| 440 | if (!checkExtensions()) |
| 441 | { |
| 442 | return; |
| 443 | } |
| 444 | |
| 445 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 446 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 447 | |
| 448 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 449 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 450 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 451 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 452 | GL_UNSIGNED_BYTE, GL_TRUE, GL_FALSE, GL_FALSE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 453 | EXPECT_GL_NO_ERROR(); |
| 454 | |
| 455 | // Check that FB is complete. |
| 456 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 457 | |
| 458 | EXPECT_PIXEL_COLOR_EQ(0, 0, rgbaPixels[2]); |
| 459 | EXPECT_PIXEL_COLOR_EQ(1, 0, rgbaPixels[3]); |
| 460 | EXPECT_PIXEL_COLOR_EQ(0, 1, rgbaPixels[0]); |
| 461 | EXPECT_PIXEL_COLOR_EQ(1, 1, rgbaPixels[1]); |
| 462 | EXPECT_GL_NO_ERROR(); |
| 463 | } |
| 464 | |
| 465 | // Test that premultipying the alpha on copy works correctly |
| 466 | TEST_P(CopyTextureTest, PremultiplyAlpha) |
| 467 | { |
| 468 | if (!checkExtensions()) |
| 469 | { |
| 470 | return; |
| 471 | } |
| 472 | |
| 473 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(255u, 255u, 255u, 127u), |
| 474 | GLColor(127u, 127u, 127u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 475 | |
| 476 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 477 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 478 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 479 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 480 | GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_FALSE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 481 | EXPECT_GL_NO_ERROR(); |
| 482 | |
| 483 | // Check that FB is complete. |
| 484 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 485 | |
| 486 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 487 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0); |
| 488 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0); |
| 489 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(0, 0, 0, 0), 1.0); |
| 490 | EXPECT_GL_NO_ERROR(); |
| 491 | } |
| 492 | |
| 493 | // Test that unmultipying the alpha on copy works correctly |
| 494 | TEST_P(CopyTextureTest, UnmultiplyAlpha) |
| 495 | { |
| 496 | if (!checkExtensions()) |
| 497 | { |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 502 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 503 | |
| 504 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 505 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 506 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 507 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 508 | GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_TRUE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 509 | EXPECT_GL_NO_ERROR(); |
| 510 | |
| 511 | // Check that FB is complete. |
| 512 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 513 | |
| 514 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 515 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(255, 255, 255, 127), 1.0); |
| 516 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(127, 127, 127, 127), 1.0); |
| 517 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0); |
| 518 | EXPECT_GL_NO_ERROR(); |
| 519 | } |
| 520 | |
| 521 | // Test that unmultipying and premultiplying the alpha is the same as doing neither |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 522 | TEST_P(CopyTextureTest, UnmultiplyAndPremultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 523 | { |
| 524 | if (!checkExtensions()) |
| 525 | { |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 530 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 531 | |
| 532 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 533 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 534 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 535 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 536 | GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_TRUE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 537 | EXPECT_GL_NO_ERROR(); |
| 538 | |
| 539 | // Check that FB is complete. |
| 540 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 541 | |
| 542 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 543 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0); |
| 544 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0); |
| 545 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0); |
| 546 | EXPECT_GL_NO_ERROR(); |
| 547 | } |
| 548 | |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 549 | // Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture |
| 550 | TEST_P(CopyTextureTest, LuminanceAlpha) |
| 551 | { |
| 552 | if (!checkExtensions()) |
| 553 | { |
| 554 | return; |
| 555 | } |
| 556 | |
| 557 | uint8_t originalPixels[] = {163u, 67u}; |
| 558 | GLColor expectedPixels(163u, 163u, 163u, 67u); |
| 559 | |
| 560 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 561 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA, |
| 562 | GL_UNSIGNED_BYTE, &originalPixels); |
| 563 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 564 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 565 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 566 | |
| 567 | EXPECT_GL_NO_ERROR(); |
| 568 | |
| 569 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 570 | } |
| 571 | |
| 572 | // Test to ensure that CopyTexture works with LUMINANCE texture |
| 573 | TEST_P(CopyTextureTest, Luminance) |
| 574 | { |
| 575 | if (!checkExtensions()) |
| 576 | { |
| 577 | return; |
| 578 | } |
| 579 | |
| 580 | uint8_t originalPixels[] = {57u}; |
| 581 | GLColor expectedPixels(57u, 57u, 57u, 255u); |
| 582 | |
| 583 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 584 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, |
| 585 | &originalPixels); |
| 586 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 587 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 588 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 589 | |
| 590 | EXPECT_GL_NO_ERROR(); |
| 591 | |
| 592 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 593 | } |
| 594 | |
| 595 | // Test to ensure that CopyTexture works with ALPHA texture |
| 596 | TEST_P(CopyTextureTest, Alpha) |
| 597 | { |
| 598 | if (!checkExtensions()) |
| 599 | { |
| 600 | return; |
| 601 | } |
| 602 | |
| 603 | uint8_t originalPixels[] = {77u}; |
| 604 | GLColor expectedPixels(0u, 0u, 0u, 77u); |
| 605 | |
| 606 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 607 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &originalPixels); |
| 608 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 609 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 610 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 611 | |
| 612 | EXPECT_GL_NO_ERROR(); |
| 613 | |
| 614 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 615 | } |
| 616 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 617 | // Test that copying to cube maps works |
| 618 | TEST_P(CopyTextureTest, CubeMapTarget) |
| 619 | { |
| 620 | if (!checkExtensions()) |
| 621 | { |
| 622 | return; |
| 623 | } |
| 624 | |
| 625 | GLColor pixels = GLColor::red; |
| 626 | |
| 627 | GLTexture textures[2]; |
| 628 | |
| 629 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 630 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 631 | |
| 632 | glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]); |
| 633 | for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; |
| 634 | face++) |
| 635 | { |
| 636 | glTexImage2D(face, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 637 | } |
| 638 | |
| 639 | glCopySubTextureCHROMIUM(textures[0], 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, textures[1], 0, 0, 0, |
| 640 | 0, 0, 1, 1, false, false, false); |
| 641 | |
| 642 | EXPECT_GL_NO_ERROR(); |
| 643 | |
| 644 | GLFramebuffer fbo; |
| 645 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 646 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 647 | textures[1], 0); |
| 648 | |
| 649 | // Check that FB is complete. |
| 650 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 651 | |
| 652 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 653 | |
| 654 | EXPECT_GL_NO_ERROR(); |
| 655 | } |
| 656 | |
| 657 | // Test that copying to non-zero mipmaps works |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 658 | TEST_P(CopyTextureTest, CopyToMipmap) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 659 | { |
| 660 | if (!checkExtensions()) |
| 661 | { |
| 662 | return; |
| 663 | } |
| 664 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 665 | if (getClientMajorVersion() < 3 && !extensionEnabled("GL_OES_fbo_render_mipmap")) |
| 666 | { |
| 667 | std::cout << "Test skipped because ES3 or GL_OES_fbo_render_mipmap is missing." |
| 668 | << std::endl; |
| 669 | return; |
| 670 | } |
| 671 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 672 | if (IsOSX() && IsIntel()) |
| 673 | { |
| 674 | std::cout << "Test skipped on Mac Intel." << std::endl; |
| 675 | return; |
| 676 | } |
| 677 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 678 | GLColor pixels[] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red}; |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 679 | |
| 680 | GLTexture textures[2]; |
| 681 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 682 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 683 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 684 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 685 | |
| 686 | glBindTexture(GL_TEXTURE_2D, textures[1]); |
| 687 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 688 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 689 | glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 690 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 691 | std::vector<std::pair<GLint, GLint>> soureDestPairs; |
| 692 | soureDestPairs.push_back(std::make_pair(0, 1)); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 693 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 694 | // ES3 allows copying from non-zero mips |
| 695 | if (getClientMajorVersion() >= 3) |
| 696 | { |
| 697 | soureDestPairs.push_back(std::make_pair(1, 2)); |
| 698 | } |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 699 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 700 | for (const auto &sourceDestPair : soureDestPairs) |
| 701 | { |
| 702 | const GLint sourceLevel = sourceDestPair.first; |
| 703 | const GLint destLevel = sourceDestPair.second; |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 704 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 705 | glCopyTextureCHROMIUM(textures[0], sourceLevel, GL_TEXTURE_2D, textures[1], destLevel, |
| 706 | GL_RGBA, GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 707 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 708 | EXPECT_GL_NO_ERROR(); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 709 | |
Geoff Lang | 165dcf1 | 2017-06-07 15:05:14 -0400 | [diff] [blame] | 710 | GLFramebuffer fbo; |
| 711 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 712 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], |
| 713 | destLevel); |
| 714 | |
| 715 | // Check that FB is complete. |
| 716 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 717 | |
| 718 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels[0]); |
| 719 | |
| 720 | EXPECT_GL_NO_ERROR(); |
| 721 | } |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 722 | } |
| 723 | |
Brandon Jones | 340b7b8 | 2017-06-26 13:02:31 -0700 | [diff] [blame] | 724 | // Test to ensure that CopyTexture works with LUMINANCE texture as a destination |
| 725 | TEST_P(CopyTextureTestDest, Luminance) |
| 726 | { |
| 727 | if (!checkExtensions()) |
| 728 | { |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 733 | GLColor expectedPixels(50u, 50u, 50u, 255u); |
| 734 | |
| 735 | // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA |
| 736 | // texture to verify contents. |
| 737 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 738 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 739 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 740 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr); |
| 741 | |
| 742 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE, |
| 743 | GL_UNSIGNED_BYTE, false, false, false); |
| 744 | |
| 745 | EXPECT_GL_NO_ERROR(); |
| 746 | |
| 747 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 748 | GL_UNSIGNED_BYTE, false, false, false); |
| 749 | |
| 750 | EXPECT_GL_NO_ERROR(); |
| 751 | |
| 752 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 753 | } |
| 754 | |
| 755 | // Test to ensure that CopyTexture works with LUMINANCE texture as a destination with |
| 756 | // UnpackPremultiply parameter |
| 757 | TEST_P(CopyTextureTestDest, LuminanceMultiply) |
| 758 | { |
| 759 | if (!checkExtensions()) |
| 760 | { |
| 761 | return; |
| 762 | } |
| 763 | |
| 764 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 765 | GLColor expectedPixels(39u, 39u, 39u, 255u); |
| 766 | |
| 767 | // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA |
| 768 | // texture to verify contents. |
| 769 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 770 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 771 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 772 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr); |
| 773 | |
| 774 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE, |
| 775 | GL_UNSIGNED_BYTE, false, true, false); |
| 776 | |
| 777 | EXPECT_GL_NO_ERROR(); |
| 778 | |
| 779 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 780 | GL_UNSIGNED_BYTE, false, false, false); |
| 781 | |
| 782 | EXPECT_GL_NO_ERROR(); |
| 783 | |
| 784 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 785 | } |
| 786 | |
| 787 | // Test to ensure that CopyTexture works with LUMINANCE texture as a destination with |
| 788 | // UnpackUnmultiply parameter |
| 789 | TEST_P(CopyTextureTestDest, LuminanceUnmultiply) |
| 790 | { |
| 791 | if (!checkExtensions()) |
| 792 | { |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 797 | GLColor expectedPixels(64u, 64u, 64u, 255u); |
| 798 | |
| 799 | // ReadPixels doesn't work with LUMINANCE (non-renderable), so we copy again back to an RGBA |
| 800 | // texture to verify contents. |
| 801 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 802 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 803 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 804 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, nullptr); |
| 805 | |
| 806 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE, |
| 807 | GL_UNSIGNED_BYTE, false, false, true); |
| 808 | |
| 809 | EXPECT_GL_NO_ERROR(); |
| 810 | |
| 811 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 812 | GL_UNSIGNED_BYTE, false, false, false); |
| 813 | |
| 814 | EXPECT_GL_NO_ERROR(); |
| 815 | |
| 816 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 817 | } |
| 818 | |
| 819 | // Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination |
| 820 | TEST_P(CopyTextureTestDest, LuminanceAlpha) |
| 821 | { |
| 822 | if (!checkExtensions()) |
| 823 | { |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 828 | GLColor expectedPixels(50u, 50u, 50u, 200u); |
| 829 | |
| 830 | // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an |
| 831 | // RGBA texture to verify contents. |
| 832 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 833 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 834 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 835 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA, |
| 836 | GL_UNSIGNED_BYTE, nullptr); |
| 837 | |
| 838 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA, |
| 839 | GL_UNSIGNED_BYTE, false, false, false); |
| 840 | |
| 841 | EXPECT_GL_NO_ERROR(); |
| 842 | |
| 843 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 844 | GL_UNSIGNED_BYTE, false, false, false); |
| 845 | |
| 846 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 847 | } |
| 848 | |
| 849 | // Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination with |
| 850 | // UnpackPremultiply parameter |
| 851 | TEST_P(CopyTextureTestDest, LuminanceAlphaMultiply) |
| 852 | { |
| 853 | if (!checkExtensions()) |
| 854 | { |
| 855 | return; |
| 856 | } |
| 857 | |
| 858 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 859 | GLColor expectedPixels(39u, 39u, 39u, 200u); |
| 860 | |
| 861 | // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an |
| 862 | // RGBA texture to verify contents. |
| 863 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 864 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 865 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 866 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA, |
| 867 | GL_UNSIGNED_BYTE, nullptr); |
| 868 | |
| 869 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA, |
| 870 | GL_UNSIGNED_BYTE, false, true, false); |
| 871 | |
| 872 | EXPECT_GL_NO_ERROR(); |
| 873 | |
| 874 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 875 | GL_UNSIGNED_BYTE, false, false, false); |
| 876 | |
| 877 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 878 | } |
| 879 | |
| 880 | // Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture as a destination with |
| 881 | // UnpackUnmultiplyAlpha parameter |
| 882 | TEST_P(CopyTextureTestDest, LuminanceAlphaUnmultiply) |
| 883 | { |
| 884 | if (!checkExtensions()) |
| 885 | { |
| 886 | return; |
| 887 | } |
| 888 | |
| 889 | GLColor originalPixels(50u, 100u, 150u, 200u); |
| 890 | GLColor expectedPixels(64u, 64u, 64u, 200u); |
| 891 | |
| 892 | // ReadPixels doesn't work with LUMINANCE_ALPHA (non-renderable), so we copy again back to an |
| 893 | // RGBA texture to verify contents. |
| 894 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 895 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 896 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 897 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA, |
| 898 | GL_UNSIGNED_BYTE, nullptr); |
| 899 | |
| 900 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_LUMINANCE_ALPHA, |
| 901 | GL_UNSIGNED_BYTE, false, false, true); |
| 902 | |
| 903 | EXPECT_GL_NO_ERROR(); |
| 904 | |
| 905 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 906 | GL_UNSIGNED_BYTE, false, false, false); |
| 907 | |
| 908 | EXPECT_GL_NO_ERROR(); |
| 909 | |
| 910 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 911 | } |
| 912 | |
| 913 | // Test to ensure that CopyTexture works with ALPHA texture as a destination |
| 914 | TEST_P(CopyTextureTestDest, Alpha) |
| 915 | { |
| 916 | if (!checkExtensions()) |
| 917 | { |
| 918 | return; |
| 919 | } |
| 920 | |
| 921 | GLColor originalPixels(50u, 100u, 150u, 155u); |
| 922 | GLColor expectedPixels(0u, 0u, 0u, 155u); |
| 923 | |
| 924 | // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA |
| 925 | // texture to verify contents. |
| 926 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 927 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 928 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 929 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr); |
| 930 | |
| 931 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA, |
| 932 | GL_UNSIGNED_BYTE, false, false, false); |
| 933 | |
| 934 | EXPECT_GL_NO_ERROR(); |
| 935 | |
| 936 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 937 | GL_UNSIGNED_BYTE, false, false, false); |
| 938 | |
| 939 | EXPECT_GL_NO_ERROR(); |
| 940 | |
| 941 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 942 | } |
| 943 | |
| 944 | // Test to ensure that CopyTexture works with ALPHA texture as a destination with |
| 945 | // UnpackPremultiplyAlpha parameter |
| 946 | TEST_P(CopyTextureTestDest, AlphaMultiply) |
| 947 | { |
| 948 | if (!checkExtensions()) |
| 949 | { |
| 950 | return; |
| 951 | } |
| 952 | |
| 953 | GLColor originalPixels(50u, 100u, 150u, 155u); |
| 954 | GLColor expectedPixels(0u, 0u, 0u, 155u); |
| 955 | |
| 956 | // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA |
| 957 | // texture to verify contents. |
| 958 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 959 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 960 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 961 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr); |
| 962 | |
| 963 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA, |
| 964 | GL_UNSIGNED_BYTE, false, true, false); |
| 965 | |
| 966 | EXPECT_GL_NO_ERROR(); |
| 967 | |
| 968 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 969 | GL_UNSIGNED_BYTE, false, false, false); |
| 970 | |
| 971 | EXPECT_GL_NO_ERROR(); |
| 972 | |
| 973 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 974 | } |
| 975 | |
| 976 | // Test to ensure that CopyTexture works with ALPHA texture as a destination with |
| 977 | // UnpackUnmultiplyAlpha parameter |
| 978 | TEST_P(CopyTextureTestDest, AlphaUnmultiply) |
| 979 | { |
| 980 | if (!checkExtensions()) |
| 981 | { |
| 982 | return; |
| 983 | } |
| 984 | |
| 985 | GLColor originalPixels(50u, 100u, 150u, 155u); |
| 986 | GLColor expectedPixels(0u, 0u, 0u, 155u); |
| 987 | |
| 988 | // ReadPixels doesn't work with ALPHA (non-renderable), so we copy again back to an RGBA |
| 989 | // texture to verify contents. |
| 990 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 991 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &originalPixels); |
| 992 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 993 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, nullptr); |
| 994 | |
| 995 | glCopyTextureCHROMIUM(mTextures[1], 0, GL_TEXTURE_2D, mTextures[0], 0, GL_ALPHA, |
| 996 | GL_UNSIGNED_BYTE, false, false, true); |
| 997 | |
| 998 | EXPECT_GL_NO_ERROR(); |
| 999 | |
| 1000 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 1001 | GL_UNSIGNED_BYTE, false, false, false); |
| 1002 | |
| 1003 | EXPECT_GL_NO_ERROR(); |
| 1004 | |
| 1005 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 1006 | } |
| 1007 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1008 | // Test the newly added ES3 unorm formats |
| 1009 | TEST_P(CopyTextureTestES3, ES3UnormFormats) |
| 1010 | { |
| 1011 | if (!checkExtensions()) |
| 1012 | { |
| 1013 | return; |
| 1014 | } |
| 1015 | |
| 1016 | auto testOutput = [this](GLuint texture, const GLColor &expectedColor) { |
| 1017 | const std::string vs = |
| 1018 | "#version 300 es\n" |
| 1019 | "in vec4 position;\n" |
| 1020 | "out vec2 texcoord;\n" |
| 1021 | "void main()\n" |
| 1022 | "{\n" |
| 1023 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 1024 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 1025 | "}\n"; |
| 1026 | |
| 1027 | const std::string fs = |
| 1028 | "#version 300 es\n" |
| 1029 | "precision mediump float;\n" |
| 1030 | "uniform sampler2D tex;\n" |
| 1031 | "in vec2 texcoord;\n" |
| 1032 | "out vec4 color;\n" |
| 1033 | "void main()\n" |
| 1034 | "{\n" |
| 1035 | " color = texture(tex, texcoord);\n" |
| 1036 | "}\n"; |
| 1037 | |
| 1038 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 1039 | glUseProgram(program); |
| 1040 | |
| 1041 | GLRenderbuffer rbo; |
| 1042 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 1043 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 1044 | |
| 1045 | GLFramebuffer fbo; |
| 1046 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1047 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 1048 | |
| 1049 | glActiveTexture(GL_TEXTURE0); |
| 1050 | glBindTexture(GL_TEXTURE_2D, texture); |
| 1051 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1052 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1053 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 1054 | |
| 1055 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 1056 | |
| 1057 | EXPECT_PIXEL_COLOR_NEAR(0, 0, expectedColor, 1.0); |
| 1058 | }; |
| 1059 | |
| 1060 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 1061 | GLenum sourceType, const GLColor &sourceColor, |
| 1062 | GLenum destInternalFormat, GLenum destType, |
| 1063 | bool flipY, bool premultiplyAlpha, |
| 1064 | bool unmultiplyAlpha, |
| 1065 | const GLColor &expectedColor) { |
| 1066 | |
| 1067 | GLTexture sourceTexture; |
| 1068 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 1069 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 1070 | &sourceColor); |
| 1071 | |
| 1072 | GLTexture destTexture; |
| 1073 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 1074 | |
| 1075 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 1076 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 1077 | ASSERT_GL_NO_ERROR(); |
| 1078 | |
| 1079 | testOutput(destTexture, expectedColor); |
| 1080 | }; |
| 1081 | |
| 1082 | // New LUMA source formats |
| 1083 | testCopyCombination(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGB, |
| 1084 | GL_UNSIGNED_BYTE, false, false, false, GLColor(128, 128, 128, 255)); |
| 1085 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 1086 | GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, false, |
| 1087 | GLColor(128, 128, 128, 255)); |
| 1088 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 1089 | GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, true, false, |
| 1090 | GLColor(32, 32, 32, 255)); |
| 1091 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 1092 | GLColor(128, 128, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, true, |
| 1093 | GLColor(255, 255, 255, 255)); |
| 1094 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 1095 | GL_UNSIGNED_BYTE, false, false, false, GLColor(0, 0, 0, 128)); |
| 1096 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 1097 | GL_UNSIGNED_BYTE, false, false, true, GLColor(0, 0, 0, 128)); |
| 1098 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 1099 | GL_UNSIGNED_BYTE, false, true, false, GLColor(0, 0, 0, 128)); |
| 1100 | |
| 1101 | // New sRGB dest formats |
Geoff Lang | 88318b4 | 2017-07-05 14:39:01 -0400 | [diff] [blame] | 1102 | if (IsOpenGLES() || IsOpenGL()) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1103 | { |
| 1104 | std::cout << "Skipping GL_SRGB and GL_SRGB_ALPHA because it is not implemented yet." |
| 1105 | << std::endl; |
| 1106 | } |
| 1107 | else |
| 1108 | { |
| 1109 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB, |
Geoff Lang | 88318b4 | 2017-07-05 14:39:01 -0400 | [diff] [blame] | 1110 | GL_UNSIGNED_BYTE, false, false, false, GLColor(55, 13, 4, 255)); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1111 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB, |
Geoff Lang | 88318b4 | 2017-07-05 14:39:01 -0400 | [diff] [blame] | 1112 | GL_UNSIGNED_BYTE, false, true, false, GLColor(13, 4, 1, 255)); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1113 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1114 | GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, false, false, false, |
Geoff Lang | 88318b4 | 2017-07-05 14:39:01 -0400 | [diff] [blame] | 1115 | GLColor(55, 13, 4, 128)); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | // Test the newly added ES3 float formats |
| 1120 | TEST_P(CopyTextureTestES3, ES3FloatFormats) |
| 1121 | { |
| 1122 | if (!checkExtensions()) |
| 1123 | { |
| 1124 | return; |
| 1125 | } |
| 1126 | |
| 1127 | if (!extensionEnabled("GL_EXT_color_buffer_float")) |
| 1128 | { |
| 1129 | std::cout << "Test skipped due to missing GL_EXT_color_buffer_float." << std::endl; |
| 1130 | return; |
| 1131 | } |
| 1132 | |
| 1133 | auto testOutput = [this](GLuint texture, const GLColor32F &expectedColor) { |
| 1134 | const std::string vs = |
| 1135 | "#version 300 es\n" |
| 1136 | "in vec4 position;\n" |
| 1137 | "out vec2 texcoord;\n" |
| 1138 | "void main()\n" |
| 1139 | "{\n" |
| 1140 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 1141 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 1142 | "}\n"; |
| 1143 | |
| 1144 | const std::string fs = |
| 1145 | "#version 300 es\n" |
| 1146 | "precision mediump float;\n" |
| 1147 | "uniform sampler2D tex;\n" |
| 1148 | "in vec2 texcoord;\n" |
| 1149 | "out vec4 color;\n" |
| 1150 | "void main()\n" |
| 1151 | "{\n" |
| 1152 | " color = texture(tex, texcoord);\n" |
| 1153 | "}\n"; |
| 1154 | |
| 1155 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 1156 | glUseProgram(program); |
| 1157 | |
| 1158 | GLRenderbuffer rbo; |
| 1159 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 1160 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1); |
| 1161 | |
| 1162 | GLFramebuffer fbo; |
| 1163 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1164 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 1165 | |
| 1166 | glActiveTexture(GL_TEXTURE0); |
| 1167 | glBindTexture(GL_TEXTURE_2D, texture); |
| 1168 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1169 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1170 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 1171 | |
| 1172 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 1173 | |
| 1174 | EXPECT_PIXEL_COLOR32F_NEAR(0, 0, expectedColor, 0.05); |
| 1175 | }; |
| 1176 | |
| 1177 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 1178 | GLenum sourceType, const GLColor &sourceColor, |
| 1179 | GLenum destInternalFormat, GLenum destType, |
| 1180 | bool flipY, bool premultiplyAlpha, |
| 1181 | bool unmultiplyAlpha, |
| 1182 | const GLColor32F &expectedColor) { |
| 1183 | |
| 1184 | GLTexture sourceTexture; |
| 1185 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 1186 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 1187 | &sourceColor); |
| 1188 | |
| 1189 | GLTexture destTexture; |
| 1190 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 1191 | |
| 1192 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 1193 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 1194 | ASSERT_GL_NO_ERROR(); |
| 1195 | |
| 1196 | testOutput(destTexture, expectedColor); |
| 1197 | }; |
| 1198 | |
| 1199 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 1200 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 0.5f)); |
| 1201 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 1202 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 0.5f)); |
| 1203 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 1204 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 0.5f)); |
| 1205 | |
| 1206 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 1207 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.0f, 0.0f, 1.0f)); |
| 1208 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 1209 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.0f, 0.0f, 1.0f)); |
| 1210 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 1211 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.0f, 0.0f, 1.0f)); |
| 1212 | |
| 1213 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 1214 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.0f, 1.0f)); |
| 1215 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 1216 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0f, 1.0f)); |
| 1217 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 1218 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.0f, 1.0f)); |
| 1219 | |
| 1220 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 1221 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 1222 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 1223 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 1224 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 1225 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 1226 | |
| 1227 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1228 | GL_R11F_G11F_B10F, GL_FLOAT, false, false, false, |
| 1229 | GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 1230 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1231 | GL_R11F_G11F_B10F, GL_FLOAT, false, true, false, |
| 1232 | GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 1233 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1234 | GL_R11F_G11F_B10F, GL_FLOAT, false, false, true, |
| 1235 | GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 1236 | |
Geoff Lang | 8061621 | 2017-05-17 15:40:03 -0400 | [diff] [blame] | 1237 | if (IsOpenGL() || IsOpenGLES()) |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1238 | { |
| 1239 | std::cout << "Skipping GL_RGB9_E5 because it is not implemented yet." << std::endl; |
| 1240 | } |
| 1241 | else |
| 1242 | { |
| 1243 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1244 | GL_RGB9_E5, GL_FLOAT, false, false, false, |
| 1245 | GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 1246 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1247 | GL_RGB9_E5, GL_FLOAT, false, true, false, |
| 1248 | GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 1249 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1250 | GL_RGB9_E5, GL_FLOAT, false, false, true, |
| 1251 | GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | // Test the newly added ES3 unsigned integer formats |
| 1256 | TEST_P(CopyTextureTestES3, ES3UintFormats) |
| 1257 | { |
| 1258 | if (!checkExtensions()) |
| 1259 | { |
| 1260 | return; |
| 1261 | } |
| 1262 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1263 | using GLColor32U = std::tuple<GLuint, GLuint, GLuint, GLuint>; |
| 1264 | |
| 1265 | auto testOutput = [this](GLuint texture, const GLColor32U &expectedColor) { |
| 1266 | const std::string vs = |
| 1267 | "#version 300 es\n" |
| 1268 | "in vec4 position;\n" |
| 1269 | "out vec2 texcoord;\n" |
| 1270 | "void main()\n" |
| 1271 | "{\n" |
| 1272 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 1273 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 1274 | "}\n"; |
| 1275 | |
| 1276 | std::string fs = |
| 1277 | "#version 300 es\n" |
| 1278 | "precision mediump float;\n" |
| 1279 | "precision mediump usampler2D;\n" |
| 1280 | "in vec2 texcoord;\n" |
| 1281 | "uniform usampler2D tex;\n" |
| 1282 | "out uvec4 color;\n" |
| 1283 | "void main()\n" |
| 1284 | "{\n" |
| 1285 | " color = texture(tex, texcoord);\n" |
| 1286 | "}\n"; |
| 1287 | |
| 1288 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 1289 | glUseProgram(program); |
| 1290 | |
| 1291 | GLRenderbuffer rbo; |
| 1292 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 1293 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8UI, 1, 1); |
| 1294 | |
| 1295 | GLFramebuffer fbo; |
| 1296 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1297 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 1298 | |
| 1299 | glActiveTexture(GL_TEXTURE0); |
| 1300 | glBindTexture(GL_TEXTURE_2D, texture); |
| 1301 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1302 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1303 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 1304 | |
| 1305 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 1306 | ASSERT_GL_NO_ERROR(); |
| 1307 | |
| 1308 | GLuint pixel[4] = {0}; |
| 1309 | glReadPixels(0, 0, 1, 1, GL_RGBA_INTEGER, GL_UNSIGNED_INT, pixel); |
| 1310 | ASSERT_GL_NO_ERROR(); |
| 1311 | EXPECT_NEAR(std::get<0>(expectedColor), pixel[0], 1); |
| 1312 | EXPECT_NEAR(std::get<1>(expectedColor), pixel[1], 1); |
| 1313 | EXPECT_NEAR(std::get<2>(expectedColor), pixel[2], 1); |
| 1314 | EXPECT_NEAR(std::get<3>(expectedColor), pixel[3], 1); |
| 1315 | }; |
| 1316 | |
| 1317 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 1318 | GLenum sourceType, const GLColor &sourceColor, |
| 1319 | GLenum destInternalFormat, GLenum destType, |
| 1320 | bool flipY, bool premultiplyAlpha, |
| 1321 | bool unmultiplyAlpha, |
| 1322 | const GLColor32U &expectedColor) { |
| 1323 | |
| 1324 | GLTexture sourceTexture; |
| 1325 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 1326 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 1327 | &sourceColor); |
| 1328 | |
| 1329 | GLTexture destTexture; |
| 1330 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 1331 | |
| 1332 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 1333 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 1334 | ASSERT_GL_NO_ERROR(); |
| 1335 | |
| 1336 | testOutput(destTexture, expectedColor); |
| 1337 | }; |
| 1338 | |
| 1339 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1340 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 32, 128)); |
| 1341 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1342 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 16, 128)); |
| 1343 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1344 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 64, 128)); |
| 1345 | |
Geoff Lang | 47bb493 | 2017-08-03 11:52:13 -0400 | [diff] [blame] | 1346 | if (IsOpenGL() || IsOpenGLES()) |
| 1347 | { |
| 1348 | std::cout << "Skipping GL_RGB8UI because it is not implemented yet." << std::endl; |
| 1349 | } |
| 1350 | else |
| 1351 | { |
| 1352 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1353 | GL_RGB8UI, GL_UNSIGNED_BYTE, false, false, false, |
| 1354 | GLColor32U(128, 64, 32, 1)); |
| 1355 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1356 | GL_RGB8UI, GL_UNSIGNED_BYTE, false, true, false, |
| 1357 | GLColor32U(64, 32, 16, 1)); |
| 1358 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 1359 | GL_RGB8UI, GL_UNSIGNED_BYTE, false, false, true, |
| 1360 | GLColor32U(255, 128, 64, 1)); |
| 1361 | } |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1362 | |
| 1363 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1364 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 0, 1)); |
| 1365 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1366 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 0, 1)); |
| 1367 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1368 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 0, 1)); |
| 1369 | |
| 1370 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI, |
| 1371 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 0, 0, 1)); |
| 1372 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI, |
| 1373 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 0, 0, 1)); |
| 1374 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(120, 64, 32, 128), GL_R8UI, |
| 1375 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(240, 0, 0, 1)); |
| 1376 | } |
| 1377 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 1378 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these |
| 1379 | // tests should be run against. |
| 1380 | ANGLE_INSTANTIATE_TEST(CopyTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES()); |
Brandon Jones | 340b7b8 | 2017-06-26 13:02:31 -0700 | [diff] [blame] | 1381 | ANGLE_INSTANTIATE_TEST(CopyTextureTestDest, ES2_D3D11()); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1382 | ANGLE_INSTANTIATE_TEST(CopyTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 1383 | |
| 1384 | } // namespace angle |