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 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 86 | class CopyTextureTestES3 : public CopyTextureTest |
| 87 | { |
| 88 | }; |
| 89 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 90 | // Test to ensure that the basic functionality of the extension works. |
| 91 | TEST_P(CopyTextureTest, BasicCopyTexture) |
| 92 | { |
| 93 | if (!checkExtensions()) |
| 94 | { |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | GLColor pixels = GLColor::red; |
| 99 | |
| 100 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 101 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 102 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 103 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 104 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 105 | |
| 106 | EXPECT_GL_NO_ERROR(); |
| 107 | |
| 108 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 109 | } |
| 110 | |
| 111 | // Test to ensure that the basic functionality of the extension works. |
| 112 | TEST_P(CopyTextureTest, BasicCopySubTexture) |
| 113 | { |
| 114 | if (!checkExtensions()) |
| 115 | { |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | GLColor pixels = GLColor::red; |
| 120 | |
| 121 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 122 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 123 | |
| 124 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 125 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 126 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 127 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1, |
| 128 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 129 | |
| 130 | EXPECT_GL_NO_ERROR(); |
| 131 | |
| 132 | // Check that FB is complete. |
| 133 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 134 | |
| 135 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 136 | |
| 137 | EXPECT_GL_NO_ERROR(); |
| 138 | } |
| 139 | |
| 140 | // Test that CopyTexture cannot redefine an immutable texture and CopySubTexture can copy data to |
| 141 | // immutable textures |
| 142 | TEST_P(CopyTextureTest, ImmutableTexture) |
| 143 | { |
| 144 | if (!checkExtensions()) |
| 145 | { |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | if (getClientMajorVersion() < 3 && |
| 150 | (!extensionEnabled("GL_EXT_texture_storage") || !extensionEnabled("GL_OES_rgb8_rgba8"))) |
| 151 | { |
| 152 | std::cout |
| 153 | << "Test skipped due to missing ES3 or GL_EXT_texture_storage or GL_OES_rgb8_rgba8" |
| 154 | << std::endl; |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | GLColor pixels = GLColor::red; |
| 159 | |
| 160 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 161 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 162 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 163 | |
| 164 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 165 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 166 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1], 0); |
| 167 | EXPECT_GL_NO_ERROR(); |
| 168 | |
| 169 | // Should generate an error when the texture is redefined |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 170 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 171 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 172 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 173 | |
| 174 | // Should succeed when using CopySubTexture |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 175 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, 1, |
| 176 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 177 | EXPECT_GL_NO_ERROR(); |
| 178 | |
| 179 | // Check that FB is complete. |
| 180 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 181 | |
| 182 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 183 | |
| 184 | EXPECT_GL_NO_ERROR(); |
| 185 | } |
| 186 | |
| 187 | // Test validation of internal formats in CopyTexture and CopySubTexture |
| 188 | TEST_P(CopyTextureTest, InternalFormat) |
| 189 | { |
| 190 | if (!checkExtensions()) |
| 191 | { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | std::vector<GLint> sourceFormats; |
| 196 | sourceFormats.push_back(GL_ALPHA); |
| 197 | sourceFormats.push_back(GL_RGB); |
| 198 | sourceFormats.push_back(GL_RGBA); |
| 199 | sourceFormats.push_back(GL_LUMINANCE); |
| 200 | sourceFormats.push_back(GL_LUMINANCE_ALPHA); |
| 201 | |
| 202 | std::vector<GLint> destFormats; |
| 203 | destFormats.push_back(GL_RGB); |
| 204 | destFormats.push_back(GL_RGBA); |
| 205 | |
| 206 | if (extensionEnabled("GL_EXT_texture_format_BGRA8888")) |
| 207 | { |
| 208 | sourceFormats.push_back(GL_BGRA_EXT); |
| 209 | destFormats.push_back(GL_BGRA_EXT); |
| 210 | } |
| 211 | |
| 212 | // Test with glCopyTexture |
| 213 | for (GLint sourceFormat : sourceFormats) |
| 214 | { |
| 215 | for (GLint destFormat : destFormats) |
| 216 | { |
| 217 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 218 | glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE, |
| 219 | nullptr); |
| 220 | EXPECT_GL_NO_ERROR(); |
| 221 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 222 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, destFormat, |
| 223 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 224 | |
| 225 | EXPECT_GL_NO_ERROR(); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | // Test with glCopySubTexture |
| 230 | for (GLint sourceFormat : sourceFormats) |
| 231 | { |
| 232 | for (GLint destFormat : destFormats) |
| 233 | { |
| 234 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 235 | glTexImage2D(GL_TEXTURE_2D, 0, sourceFormat, 1, 1, 0, sourceFormat, GL_UNSIGNED_BYTE, |
| 236 | nullptr); |
| 237 | EXPECT_GL_NO_ERROR(); |
| 238 | |
| 239 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 240 | glTexImage2D(GL_TEXTURE_2D, 0, destFormat, 1, 1, 0, destFormat, GL_UNSIGNED_BYTE, |
| 241 | nullptr); |
| 242 | EXPECT_GL_NO_ERROR(); |
| 243 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 244 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 0, 0, 1, |
| 245 | 1, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 246 | |
| 247 | EXPECT_GL_NO_ERROR(); |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 252 | // Test to ensure that the destination texture is redefined if the properties are different. |
| 253 | TEST_P(CopyTextureTest, RedefineDestinationTexture) |
| 254 | { |
| 255 | if (!checkExtensions()) |
| 256 | { |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | GLColor pixels[4] = {GLColor::red, GLColor::red, GLColor::red, GLColor::red}; |
| 261 | |
| 262 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 263 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 264 | |
| 265 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 266 | glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, 1, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 267 | EXPECT_GL_NO_ERROR(); |
| 268 | |
| 269 | // GL_INVALID_OPERATION due to "intrinsic format" != "internal format". |
| 270 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 271 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 272 | // GL_INVALID_VALUE due to bad dimensions. |
| 273 | glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 274 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 275 | |
| 276 | // If the dest texture has different properties, glCopyTextureCHROMIUM() |
| 277 | // redefines them. |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 278 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 279 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 280 | EXPECT_GL_NO_ERROR(); |
| 281 | |
| 282 | // glTexSubImage2D() succeeds because mTextures[1] is redefined into 2x2 |
| 283 | // dimension and GL_RGBA format. |
| 284 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 285 | glTexSubImage2D(GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 286 | EXPECT_GL_NO_ERROR(); |
| 287 | |
| 288 | // Check that FB is complete. |
| 289 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 290 | |
| 291 | EXPECT_PIXEL_COLOR_EQ(1, 1, pixels[3]); |
| 292 | EXPECT_GL_NO_ERROR(); |
| 293 | } |
| 294 | |
| 295 | // Test that invalid dimensions in CopySubTexture are validated |
| 296 | TEST_P(CopyTextureTest, CopySubTextureDimension) |
| 297 | { |
| 298 | if (!checkExtensions()) |
| 299 | { |
| 300 | return; |
| 301 | } |
| 302 | |
| 303 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 304 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 305 | |
| 306 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 307 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 308 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 309 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 310 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 311 | EXPECT_GL_NO_ERROR(); |
| 312 | |
| 313 | // xoffset < 0 |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 314 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, -1, 1, 0, 0, 1, 1, |
| 315 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 316 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 317 | |
| 318 | // x < 0 |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 319 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, -1, 0, 1, 1, |
| 320 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 321 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 322 | |
| 323 | // xoffset + width > dest_width |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 324 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 2, 2, 0, 0, 2, 2, |
| 325 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 326 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 327 | |
| 328 | // x + width > source_width |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 329 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 0, 1, 1, 2, 2, |
| 330 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 331 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 332 | } |
| 333 | |
| 334 | // Test that invalid IDs in CopyTexture are validated |
| 335 | TEST_P(CopyTextureTest, CopyTextureInvalidTextureIds) |
| 336 | { |
| 337 | if (!checkExtensions()) |
| 338 | { |
| 339 | return; |
| 340 | } |
| 341 | |
| 342 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 343 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 344 | |
| 345 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 346 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 347 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 348 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 349 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 350 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 351 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 352 | glCopyTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 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(99995, 0, GL_TEXTURE_2D, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false, |
| 357 | 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(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 361 | GL_UNSIGNED_BYTE, false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 362 | EXPECT_GL_NO_ERROR(); |
| 363 | } |
| 364 | |
| 365 | // Test that invalid IDs in CopySubTexture are validated |
| 366 | TEST_P(CopyTextureTest, CopySubTextureInvalidTextureIds) |
| 367 | { |
| 368 | if (!checkExtensions()) |
| 369 | { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 374 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 375 | |
| 376 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 377 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 378 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 379 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, 99993, 0, 1, 1, 0, 0, 1, 1, false, |
| 380 | false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 381 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 382 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 383 | glCopySubTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, mTextures[1], 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(99995, 0, GL_TEXTURE_2D, 99996, 0, 1, 1, 0, 0, 1, 1, false, false, |
| 388 | 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(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 392 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 393 | EXPECT_GL_NO_ERROR(); |
| 394 | } |
| 395 | |
| 396 | // Test that using an offset in CopySubTexture works correctly |
| 397 | TEST_P(CopyTextureTest, CopySubTextureOffset) |
| 398 | { |
| 399 | if (!checkExtensions()) |
| 400 | { |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | GLColor rgbaPixels[4 * 4] = {GLColor::red, GLColor::green, GLColor::blue, GLColor::black}; |
| 405 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 406 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 407 | |
| 408 | GLColor transparentPixels[4 * 4] = {GLColor::transparentBlack, GLColor::transparentBlack, |
| 409 | GLColor::transparentBlack, GLColor::transparentBlack}; |
| 410 | glBindTexture(GL_TEXTURE_2D, mTextures[1]); |
| 411 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, transparentPixels); |
| 412 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 413 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 1, 0, 0, 1, 1, |
| 414 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 415 | EXPECT_GL_NO_ERROR(); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 416 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 1, 0, 1, 0, 1, 1, |
| 417 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 418 | EXPECT_GL_NO_ERROR(); |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 419 | glCopySubTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, 0, 1, 0, 1, 1, 1, |
| 420 | false, false, false); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 421 | EXPECT_GL_NO_ERROR(); |
| 422 | |
| 423 | // Check that FB is complete. |
| 424 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 425 | |
| 426 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::transparentBlack); |
| 427 | EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red); |
| 428 | EXPECT_PIXEL_COLOR_EQ(1, 0, GLColor::green); |
| 429 | EXPECT_PIXEL_COLOR_EQ(0, 1, GLColor::blue); |
| 430 | EXPECT_GL_NO_ERROR(); |
| 431 | } |
| 432 | |
| 433 | // Test that flipping the Y component works correctly |
| 434 | TEST_P(CopyTextureTest, FlipY) |
| 435 | { |
| 436 | if (!checkExtensions()) |
| 437 | { |
| 438 | return; |
| 439 | } |
| 440 | |
| 441 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 442 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 443 | |
| 444 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 445 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 446 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 447 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 448 | GL_UNSIGNED_BYTE, GL_TRUE, GL_FALSE, GL_FALSE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 449 | EXPECT_GL_NO_ERROR(); |
| 450 | |
| 451 | // Check that FB is complete. |
| 452 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 453 | |
| 454 | EXPECT_PIXEL_COLOR_EQ(0, 0, rgbaPixels[2]); |
| 455 | EXPECT_PIXEL_COLOR_EQ(1, 0, rgbaPixels[3]); |
| 456 | EXPECT_PIXEL_COLOR_EQ(0, 1, rgbaPixels[0]); |
| 457 | EXPECT_PIXEL_COLOR_EQ(1, 1, rgbaPixels[1]); |
| 458 | EXPECT_GL_NO_ERROR(); |
| 459 | } |
| 460 | |
| 461 | // Test that premultipying the alpha on copy works correctly |
| 462 | TEST_P(CopyTextureTest, PremultiplyAlpha) |
| 463 | { |
| 464 | if (!checkExtensions()) |
| 465 | { |
| 466 | return; |
| 467 | } |
| 468 | |
| 469 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(255u, 255u, 255u, 127u), |
| 470 | GLColor(127u, 127u, 127u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 471 | |
| 472 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 473 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 474 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 475 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 476 | GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_FALSE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 477 | EXPECT_GL_NO_ERROR(); |
| 478 | |
| 479 | // Check that FB is complete. |
| 480 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 481 | |
| 482 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 483 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0); |
| 484 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0); |
| 485 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(0, 0, 0, 0), 1.0); |
| 486 | EXPECT_GL_NO_ERROR(); |
| 487 | } |
| 488 | |
| 489 | // Test that unmultipying the alpha on copy works correctly |
| 490 | TEST_P(CopyTextureTest, UnmultiplyAlpha) |
| 491 | { |
| 492 | if (!checkExtensions()) |
| 493 | { |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 498 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 499 | |
| 500 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 501 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 502 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 503 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 504 | GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_TRUE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 505 | EXPECT_GL_NO_ERROR(); |
| 506 | |
| 507 | // Check that FB is complete. |
| 508 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 509 | |
| 510 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 511 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(255, 255, 255, 127), 1.0); |
| 512 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(127, 127, 127, 127), 1.0); |
| 513 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0); |
| 514 | EXPECT_GL_NO_ERROR(); |
| 515 | } |
| 516 | |
| 517 | // 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] | 518 | TEST_P(CopyTextureTest, UnmultiplyAndPremultiplyAlpha) |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 519 | { |
| 520 | if (!checkExtensions()) |
| 521 | { |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | GLColor rgbaPixels[4] = {GLColor(255u, 255u, 255u, 255u), GLColor(127u, 127u, 127u, 127u), |
| 526 | GLColor(63u, 63u, 63u, 127u), GLColor(255u, 255u, 255u, 0u)}; |
| 527 | |
| 528 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 529 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbaPixels); |
| 530 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 531 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 532 | GL_UNSIGNED_BYTE, GL_FALSE, GL_TRUE, GL_TRUE); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 533 | EXPECT_GL_NO_ERROR(); |
| 534 | |
| 535 | // Check that FB is complete. |
| 536 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 537 | |
| 538 | EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 255, 255, 255), 1.0); |
| 539 | EXPECT_PIXEL_COLOR_NEAR(1, 0, GLColor(127, 127, 127, 127), 1.0); |
| 540 | EXPECT_PIXEL_COLOR_NEAR(0, 1, GLColor(63, 63, 63, 127), 1.0); |
| 541 | EXPECT_PIXEL_COLOR_NEAR(1, 1, GLColor(255, 255, 255, 0), 1.0); |
| 542 | EXPECT_GL_NO_ERROR(); |
| 543 | } |
| 544 | |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 545 | // Test to ensure that CopyTexture works with LUMINANCE_ALPHA texture |
| 546 | TEST_P(CopyTextureTest, LuminanceAlpha) |
| 547 | { |
| 548 | if (!checkExtensions()) |
| 549 | { |
| 550 | return; |
| 551 | } |
| 552 | |
| 553 | uint8_t originalPixels[] = {163u, 67u}; |
| 554 | GLColor expectedPixels(163u, 163u, 163u, 67u); |
| 555 | |
| 556 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 557 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 1, 1, 0, GL_LUMINANCE_ALPHA, |
| 558 | GL_UNSIGNED_BYTE, &originalPixels); |
| 559 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 560 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 561 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 562 | |
| 563 | EXPECT_GL_NO_ERROR(); |
| 564 | |
| 565 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 566 | } |
| 567 | |
| 568 | // Test to ensure that CopyTexture works with LUMINANCE texture |
| 569 | TEST_P(CopyTextureTest, Luminance) |
| 570 | { |
| 571 | if (!checkExtensions()) |
| 572 | { |
| 573 | return; |
| 574 | } |
| 575 | |
| 576 | uint8_t originalPixels[] = {57u}; |
| 577 | GLColor expectedPixels(57u, 57u, 57u, 255u); |
| 578 | |
| 579 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 580 | glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, |
| 581 | &originalPixels); |
| 582 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 583 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 584 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 585 | |
| 586 | EXPECT_GL_NO_ERROR(); |
| 587 | |
| 588 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 589 | } |
| 590 | |
| 591 | // Test to ensure that CopyTexture works with ALPHA texture |
| 592 | TEST_P(CopyTextureTest, Alpha) |
| 593 | { |
| 594 | if (!checkExtensions()) |
| 595 | { |
| 596 | return; |
| 597 | } |
| 598 | |
| 599 | uint8_t originalPixels[] = {77u}; |
| 600 | GLColor expectedPixels(0u, 0u, 0u, 77u); |
| 601 | |
| 602 | glBindTexture(GL_TEXTURE_2D, mTextures[0]); |
| 603 | glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &originalPixels); |
| 604 | |
Geoff Lang | fc72a07 | 2017-03-24 14:52:39 -0400 | [diff] [blame] | 605 | glCopyTextureCHROMIUM(mTextures[0], 0, GL_TEXTURE_2D, mTextures[1], 0, GL_RGBA, |
| 606 | GL_UNSIGNED_BYTE, false, false, false); |
Corentin Wallez | 133a2ec | 2016-11-17 16:28:03 -0500 | [diff] [blame] | 607 | |
| 608 | EXPECT_GL_NO_ERROR(); |
| 609 | |
| 610 | EXPECT_PIXEL_COLOR_EQ(0, 0, expectedPixels); |
| 611 | } |
| 612 | |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 613 | // Test that copying to cube maps works |
| 614 | TEST_P(CopyTextureTest, CubeMapTarget) |
| 615 | { |
| 616 | if (!checkExtensions()) |
| 617 | { |
| 618 | return; |
| 619 | } |
| 620 | |
| 621 | GLColor pixels = GLColor::red; |
| 622 | |
| 623 | GLTexture textures[2]; |
| 624 | |
| 625 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 626 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 627 | |
| 628 | glBindTexture(GL_TEXTURE_CUBE_MAP, textures[1]); |
| 629 | for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; |
| 630 | face++) |
| 631 | { |
| 632 | glTexImage2D(face, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 633 | } |
| 634 | |
| 635 | glCopySubTextureCHROMIUM(textures[0], 0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, textures[1], 0, 0, 0, |
| 636 | 0, 0, 1, 1, false, false, false); |
| 637 | |
| 638 | EXPECT_GL_NO_ERROR(); |
| 639 | |
| 640 | GLFramebuffer fbo; |
| 641 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 642 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 643 | textures[1], 0); |
| 644 | |
| 645 | // Check that FB is complete. |
| 646 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 647 | |
| 648 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 649 | |
| 650 | EXPECT_GL_NO_ERROR(); |
| 651 | } |
| 652 | |
| 653 | // Test that copying to non-zero mipmaps works |
| 654 | TEST_P(CopyTextureTestES3, CopyToMipmap) |
| 655 | { |
| 656 | if (!checkExtensions()) |
| 657 | { |
| 658 | return; |
| 659 | } |
| 660 | |
| 661 | if (IsOSX() && IsIntel()) |
| 662 | { |
| 663 | std::cout << "Test skipped on Mac Intel." << std::endl; |
| 664 | return; |
| 665 | } |
| 666 | |
| 667 | GLColor pixels = GLColor::red; |
| 668 | |
| 669 | GLTexture textures[2]; |
| 670 | |
| 671 | const GLint sourceLevel = 1; |
| 672 | const GLint destLevel = 2; |
| 673 | |
| 674 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 675 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 676 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels); |
| 677 | |
| 678 | glBindTexture(GL_TEXTURE_2D, textures[1]); |
| 679 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 680 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 681 | glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 682 | |
| 683 | glCopySubTextureCHROMIUM(textures[0], sourceLevel, GL_TEXTURE_2D, textures[1], destLevel, 0, 0, |
| 684 | 0, 0, 1, 1, false, false, false); |
| 685 | |
| 686 | EXPECT_GL_NO_ERROR(); |
| 687 | |
| 688 | GLFramebuffer fbo; |
| 689 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 690 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], |
| 691 | destLevel); |
| 692 | |
| 693 | // Check that FB is complete. |
| 694 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 695 | |
| 696 | EXPECT_PIXEL_COLOR_EQ(0, 0, pixels); |
| 697 | |
| 698 | EXPECT_GL_NO_ERROR(); |
| 699 | } |
| 700 | |
| 701 | // Test the newly added ES3 unorm formats |
| 702 | TEST_P(CopyTextureTestES3, ES3UnormFormats) |
| 703 | { |
| 704 | if (!checkExtensions()) |
| 705 | { |
| 706 | return; |
| 707 | } |
| 708 | |
| 709 | auto testOutput = [this](GLuint texture, const GLColor &expectedColor) { |
| 710 | const std::string vs = |
| 711 | "#version 300 es\n" |
| 712 | "in vec4 position;\n" |
| 713 | "out vec2 texcoord;\n" |
| 714 | "void main()\n" |
| 715 | "{\n" |
| 716 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 717 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 718 | "}\n"; |
| 719 | |
| 720 | const std::string fs = |
| 721 | "#version 300 es\n" |
| 722 | "precision mediump float;\n" |
| 723 | "uniform sampler2D tex;\n" |
| 724 | "in vec2 texcoord;\n" |
| 725 | "out vec4 color;\n" |
| 726 | "void main()\n" |
| 727 | "{\n" |
| 728 | " color = texture(tex, texcoord);\n" |
| 729 | "}\n"; |
| 730 | |
| 731 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 732 | glUseProgram(program); |
| 733 | |
| 734 | GLRenderbuffer rbo; |
| 735 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 736 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 737 | |
| 738 | GLFramebuffer fbo; |
| 739 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 740 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 741 | |
| 742 | glActiveTexture(GL_TEXTURE0); |
| 743 | glBindTexture(GL_TEXTURE_2D, texture); |
| 744 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 745 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 746 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 747 | |
| 748 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 749 | |
| 750 | EXPECT_PIXEL_COLOR_NEAR(0, 0, expectedColor, 1.0); |
| 751 | }; |
| 752 | |
| 753 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 754 | GLenum sourceType, const GLColor &sourceColor, |
| 755 | GLenum destInternalFormat, GLenum destType, |
| 756 | bool flipY, bool premultiplyAlpha, |
| 757 | bool unmultiplyAlpha, |
| 758 | const GLColor &expectedColor) { |
| 759 | |
| 760 | GLTexture sourceTexture; |
| 761 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 762 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 763 | &sourceColor); |
| 764 | |
| 765 | GLTexture destTexture; |
| 766 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 767 | |
| 768 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 769 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 770 | ASSERT_GL_NO_ERROR(); |
| 771 | |
| 772 | testOutput(destTexture, expectedColor); |
| 773 | }; |
| 774 | |
| 775 | // New LUMA source formats |
| 776 | testCopyCombination(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGB, |
| 777 | GL_UNSIGNED_BYTE, false, false, false, GLColor(128, 128, 128, 255)); |
| 778 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 779 | GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, false, |
| 780 | GLColor(128, 128, 128, 255)); |
| 781 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 782 | GLColor(128, 64, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, true, false, |
| 783 | GLColor(32, 32, 32, 255)); |
| 784 | testCopyCombination(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, |
| 785 | GLColor(128, 128, 0, 0), GL_RGB, GL_UNSIGNED_BYTE, false, false, true, |
| 786 | GLColor(255, 255, 255, 255)); |
| 787 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 788 | GL_UNSIGNED_BYTE, false, false, false, GLColor(0, 0, 0, 128)); |
| 789 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 790 | GL_UNSIGNED_BYTE, false, false, true, GLColor(0, 0, 0, 128)); |
| 791 | testCopyCombination(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, GLColor(128, 0, 0, 0), GL_RGBA, |
| 792 | GL_UNSIGNED_BYTE, false, true, false, GLColor(0, 0, 0, 128)); |
| 793 | |
| 794 | // New sRGB dest formats |
| 795 | if (IsOpenGLES()) |
| 796 | { |
| 797 | std::cout << "Skipping GL_SRGB and GL_SRGB_ALPHA because it is not implemented yet." |
| 798 | << std::endl; |
| 799 | } |
| 800 | else |
| 801 | { |
| 802 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB, |
| 803 | GL_UNSIGNED_BYTE, false, false, false, GLColor(128, 64, 32, 255)); |
| 804 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_SRGB, |
| 805 | GL_UNSIGNED_BYTE, false, true, false, GLColor(64, 32, 16, 255)); |
| 806 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 807 | GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, false, false, false, |
| 808 | GLColor(128, 64, 32, 128)); |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | // Test the newly added ES3 float formats |
| 813 | TEST_P(CopyTextureTestES3, ES3FloatFormats) |
| 814 | { |
| 815 | if (!checkExtensions()) |
| 816 | { |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | if (!extensionEnabled("GL_EXT_color_buffer_float")) |
| 821 | { |
| 822 | std::cout << "Test skipped due to missing GL_EXT_color_buffer_float." << std::endl; |
| 823 | return; |
| 824 | } |
| 825 | |
| 826 | auto testOutput = [this](GLuint texture, const GLColor32F &expectedColor) { |
| 827 | const std::string vs = |
| 828 | "#version 300 es\n" |
| 829 | "in vec4 position;\n" |
| 830 | "out vec2 texcoord;\n" |
| 831 | "void main()\n" |
| 832 | "{\n" |
| 833 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 834 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 835 | "}\n"; |
| 836 | |
| 837 | const std::string fs = |
| 838 | "#version 300 es\n" |
| 839 | "precision mediump float;\n" |
| 840 | "uniform sampler2D tex;\n" |
| 841 | "in vec2 texcoord;\n" |
| 842 | "out vec4 color;\n" |
| 843 | "void main()\n" |
| 844 | "{\n" |
| 845 | " color = texture(tex, texcoord);\n" |
| 846 | "}\n"; |
| 847 | |
| 848 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 849 | glUseProgram(program); |
| 850 | |
| 851 | GLRenderbuffer rbo; |
| 852 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 853 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 1, 1); |
| 854 | |
| 855 | GLFramebuffer fbo; |
| 856 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 857 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 858 | |
| 859 | glActiveTexture(GL_TEXTURE0); |
| 860 | glBindTexture(GL_TEXTURE_2D, texture); |
| 861 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 862 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 863 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 864 | |
| 865 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 866 | |
| 867 | EXPECT_PIXEL_COLOR32F_NEAR(0, 0, expectedColor, 0.05); |
| 868 | }; |
| 869 | |
| 870 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 871 | GLenum sourceType, const GLColor &sourceColor, |
| 872 | GLenum destInternalFormat, GLenum destType, |
| 873 | bool flipY, bool premultiplyAlpha, |
| 874 | bool unmultiplyAlpha, |
| 875 | const GLColor32F &expectedColor) { |
| 876 | |
| 877 | GLTexture sourceTexture; |
| 878 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 879 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 880 | &sourceColor); |
| 881 | |
| 882 | GLTexture destTexture; |
| 883 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 884 | |
| 885 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 886 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 887 | ASSERT_GL_NO_ERROR(); |
| 888 | |
| 889 | testOutput(destTexture, expectedColor); |
| 890 | }; |
| 891 | |
| 892 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 893 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 0.5f)); |
| 894 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 895 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 0.5f)); |
| 896 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA32F, |
| 897 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 0.5f)); |
| 898 | |
| 899 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 900 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.0f, 0.0f, 1.0f)); |
| 901 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 902 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.0f, 0.0f, 1.0f)); |
| 903 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R16F, |
| 904 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.0f, 0.0f, 1.0f)); |
| 905 | |
| 906 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 907 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.0f, 1.0f)); |
| 908 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 909 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0f, 1.0f)); |
| 910 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG16F, |
| 911 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.0f, 1.0f)); |
| 912 | |
| 913 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 914 | GL_FLOAT, false, false, false, GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 915 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 916 | GL_FLOAT, false, true, false, GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 917 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB16F, |
| 918 | GL_FLOAT, false, false, true, GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 919 | |
| 920 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 921 | GL_R11F_G11F_B10F, GL_FLOAT, false, false, false, |
| 922 | GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 923 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 924 | GL_R11F_G11F_B10F, GL_FLOAT, false, true, false, |
| 925 | GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 926 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 927 | GL_R11F_G11F_B10F, GL_FLOAT, false, false, true, |
| 928 | GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 929 | |
| 930 | if (IsD3D11() || IsOpenGL() || IsOpenGLES()) |
| 931 | { |
| 932 | std::cout << "Skipping GL_RGB9_E5 because it is not implemented yet." << std::endl; |
| 933 | } |
| 934 | else |
| 935 | { |
| 936 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 937 | GL_RGB9_E5, GL_FLOAT, false, false, false, |
| 938 | GLColor32F(0.5f, 0.25f, 0.125f, 1.0f)); |
| 939 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 940 | GL_RGB9_E5, GL_FLOAT, false, true, false, |
| 941 | GLColor32F(0.25f, 0.125f, 0.0625f, 1.0f)); |
| 942 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), |
| 943 | GL_RGB9_E5, GL_FLOAT, false, false, true, |
| 944 | GLColor32F(1.0f, 0.5f, 0.25f, 1.0f)); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | // Test the newly added ES3 unsigned integer formats |
| 949 | TEST_P(CopyTextureTestES3, ES3UintFormats) |
| 950 | { |
| 951 | if (!checkExtensions()) |
| 952 | { |
| 953 | return; |
| 954 | } |
| 955 | |
| 956 | if (IsOpenGL() || IsOpenGLES()) |
| 957 | { |
| 958 | std::cout << "Test on OpenGL and OpenGLES because not all formats are implemented yet." |
| 959 | << std::endl; |
| 960 | return; |
| 961 | } |
| 962 | |
| 963 | using GLColor32U = std::tuple<GLuint, GLuint, GLuint, GLuint>; |
| 964 | |
| 965 | auto testOutput = [this](GLuint texture, const GLColor32U &expectedColor) { |
| 966 | const std::string vs = |
| 967 | "#version 300 es\n" |
| 968 | "in vec4 position;\n" |
| 969 | "out vec2 texcoord;\n" |
| 970 | "void main()\n" |
| 971 | "{\n" |
| 972 | " gl_Position = vec4(position.xy, 0.0, 1.0);\n" |
| 973 | " texcoord = (position.xy * 0.5) + 0.5;\n" |
| 974 | "}\n"; |
| 975 | |
| 976 | std::string fs = |
| 977 | "#version 300 es\n" |
| 978 | "precision mediump float;\n" |
| 979 | "precision mediump usampler2D;\n" |
| 980 | "in vec2 texcoord;\n" |
| 981 | "uniform usampler2D tex;\n" |
| 982 | "out uvec4 color;\n" |
| 983 | "void main()\n" |
| 984 | "{\n" |
| 985 | " color = texture(tex, texcoord);\n" |
| 986 | "}\n"; |
| 987 | |
| 988 | ANGLE_GL_PROGRAM(program, vs, fs); |
| 989 | glUseProgram(program); |
| 990 | |
| 991 | GLRenderbuffer rbo; |
| 992 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 993 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8UI, 1, 1); |
| 994 | |
| 995 | GLFramebuffer fbo; |
| 996 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 997 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 998 | |
| 999 | glActiveTexture(GL_TEXTURE0); |
| 1000 | glBindTexture(GL_TEXTURE_2D, texture); |
| 1001 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1002 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1003 | glUniform1i(glGetUniformLocation(program.get(), "tex"), 0); |
| 1004 | |
| 1005 | drawQuad(program, "position", 0.5f, 1.0f, true); |
| 1006 | ASSERT_GL_NO_ERROR(); |
| 1007 | |
| 1008 | GLuint pixel[4] = {0}; |
| 1009 | glReadPixels(0, 0, 1, 1, GL_RGBA_INTEGER, GL_UNSIGNED_INT, pixel); |
| 1010 | ASSERT_GL_NO_ERROR(); |
| 1011 | EXPECT_NEAR(std::get<0>(expectedColor), pixel[0], 1); |
| 1012 | EXPECT_NEAR(std::get<1>(expectedColor), pixel[1], 1); |
| 1013 | EXPECT_NEAR(std::get<2>(expectedColor), pixel[2], 1); |
| 1014 | EXPECT_NEAR(std::get<3>(expectedColor), pixel[3], 1); |
| 1015 | }; |
| 1016 | |
| 1017 | auto testCopyCombination = [this, testOutput](GLenum sourceInternalFormat, GLenum sourceFormat, |
| 1018 | GLenum sourceType, const GLColor &sourceColor, |
| 1019 | GLenum destInternalFormat, GLenum destType, |
| 1020 | bool flipY, bool premultiplyAlpha, |
| 1021 | bool unmultiplyAlpha, |
| 1022 | const GLColor32U &expectedColor) { |
| 1023 | |
| 1024 | GLTexture sourceTexture; |
| 1025 | glBindTexture(GL_TEXTURE_2D, sourceTexture); |
| 1026 | glTexImage2D(GL_TEXTURE_2D, 0, sourceInternalFormat, 1, 1, 0, sourceFormat, sourceType, |
| 1027 | &sourceColor); |
| 1028 | |
| 1029 | GLTexture destTexture; |
| 1030 | glBindTexture(GL_TEXTURE_2D, destTexture); |
| 1031 | |
| 1032 | glCopyTextureCHROMIUM(sourceTexture, 0, GL_TEXTURE_2D, destTexture, 0, destInternalFormat, |
| 1033 | destType, flipY, premultiplyAlpha, unmultiplyAlpha); |
| 1034 | ASSERT_GL_NO_ERROR(); |
| 1035 | |
| 1036 | testOutput(destTexture, expectedColor); |
| 1037 | }; |
| 1038 | |
| 1039 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1040 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 32, 128)); |
| 1041 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1042 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 16, 128)); |
| 1043 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGBA8UI, |
| 1044 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 64, 128)); |
| 1045 | |
| 1046 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI, |
| 1047 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 32, 1)); |
| 1048 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI, |
| 1049 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 16, 1)); |
| 1050 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RGB8UI, |
| 1051 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 64, 1)); |
| 1052 | |
| 1053 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1054 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 64, 0, 1)); |
| 1055 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1056 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 32, 0, 1)); |
| 1057 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_RG8UI, |
| 1058 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(255, 128, 0, 1)); |
| 1059 | |
| 1060 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI, |
| 1061 | GL_UNSIGNED_BYTE, false, false, false, GLColor32U(128, 0, 0, 1)); |
| 1062 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(128, 64, 32, 128), GL_R8UI, |
| 1063 | GL_UNSIGNED_BYTE, false, true, false, GLColor32U(64, 0, 0, 1)); |
| 1064 | testCopyCombination(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, GLColor(120, 64, 32, 128), GL_R8UI, |
| 1065 | GL_UNSIGNED_BYTE, false, false, true, GLColor32U(240, 0, 0, 1)); |
| 1066 | } |
| 1067 | |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 1068 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these |
| 1069 | // tests should be run against. |
| 1070 | ANGLE_INSTANTIATE_TEST(CopyTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL(), ES2_OPENGLES()); |
Geoff Lang | 4f0e003 | 2017-05-01 16:04:35 -0400 | [diff] [blame] | 1071 | ANGLE_INSTANTIATE_TEST(CopyTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES()); |
Geoff Lang | 97073d1 | 2016-04-20 10:42:34 -0700 | [diff] [blame] | 1072 | |
| 1073 | } // namespace angle |