Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1059)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 1203793003: Remove flip_y, premultiply_alpha, unmultiply_alpha support in command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Tests for GLES2Implementation. 5 // Tests for GLES2Implementation.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 GetExpectedResultMemory(sizeof(cmds::GetError::Result)); 2226 GetExpectedResultMemory(sizeof(cmds::GetError::Result));
2227 2227
2228 EXPECT_CALL(*command_buffer(), OnFlush()) 2228 EXPECT_CALL(*command_buffer(), OnFlush())
2229 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR))) 2229 .WillOnce(SetMemory(result1.ptr, GLuint(GL_NO_ERROR)))
2230 .RetiresOnSaturation(); 2230 .RetiresOnSaturation();
2231 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); 2231 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
2232 } 2232 }
2233 2233
2234 static bool CheckRect( 2234 static bool CheckRect(
2235 int width, int height, GLenum format, GLenum type, int alignment, 2235 int width, int height, GLenum format, GLenum type, int alignment,
2236 bool flip_y, const uint8* r1, const uint8* r2) { 2236 const uint8* r1, const uint8* r2) {
2237 uint32 size = 0; 2237 uint32 size = 0;
2238 uint32 unpadded_row_size = 0; 2238 uint32 unpadded_row_size = 0;
2239 uint32 padded_row_size = 0; 2239 uint32 padded_row_size = 0;
2240 if (!GLES2Util::ComputeImageDataSizes( 2240 if (!GLES2Util::ComputeImageDataSizes(
2241 width, height, 1, format, type, alignment, &size, &unpadded_row_size, 2241 width, height, 1, format, type, alignment, &size, &unpadded_row_size,
2242 &padded_row_size)) { 2242 &padded_row_size)) {
2243 return false; 2243 return false;
2244 } 2244 }
2245 2245
2246 int r2_stride = flip_y ? 2246 int r2_stride = static_cast<int>(padded_row_size);
2247 -static_cast<int>(padded_row_size) :
2248 static_cast<int>(padded_row_size);
2249 r2 = flip_y ? (r2 + (height - 1) * padded_row_size) : r2;
2250 2247
2251 for (int y = 0; y < height; ++y) { 2248 for (int y = 0; y < height; ++y) {
2252 if (memcmp(r1, r2, unpadded_row_size) != 0) { 2249 if (memcmp(r1, r2, unpadded_row_size) != 0) {
2253 return false; 2250 return false;
2254 } 2251 }
2255 r1 += padded_row_size; 2252 r1 += padded_row_size;
2256 r2 += r2_stride; 2253 r2 += r2_stride;
2257 } 2254 }
2258 return true; 2255 return true;
2259 } 2256 }
2260 2257
2261 ACTION_P8(CheckRectAction, width, height, format, type, alignment, flip_y, 2258 ACTION_P7(CheckRectAction, width, height, format, type, alignment, r1, r2) {
2262 r1, r2) {
2263 EXPECT_TRUE(CheckRect( 2259 EXPECT_TRUE(CheckRect(
2264 width, height, format, type, alignment, flip_y, r1, r2)); 2260 width, height, format, type, alignment, r1, r2));
2265 } 2261 }
2266 2262
2267 // Test TexImage2D with and without flip_y
2268 TEST_F(GLES2ImplementationTest, TexImage2D) { 2263 TEST_F(GLES2ImplementationTest, TexImage2D) {
2269 struct Cmds { 2264 struct Cmds {
2270 cmds::TexImage2D tex_image_2d; 2265 cmds::TexImage2D tex_image_2d;
2271 cmd::SetToken set_token; 2266 cmd::SetToken set_token;
2272 }; 2267 };
2273 struct Cmds2 { 2268 struct Cmds2 {
2274 cmds::TexImage2D tex_image_2d; 2269 cmds::TexImage2D tex_image_2d;
2275 cmd::SetToken set_token; 2270 cmd::SetToken set_token;
2276 }; 2271 };
2277 const GLenum kTarget = GL_TEXTURE_2D; 2272 const GLenum kTarget = GL_TEXTURE_2D;
(...skipping 16 matching lines...) Expand all
2294 Cmds expected; 2289 Cmds expected;
2295 expected.tex_image_2d.Init( 2290 expected.tex_image_2d.Init(
2296 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2291 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2297 mem1.id, mem1.offset); 2292 mem1.id, mem1.offset);
2298 expected.set_token.Init(GetNextToken()); 2293 expected.set_token.Init(GetNextToken());
2299 gl_->TexImage2D( 2294 gl_->TexImage2D(
2300 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, 2295 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2301 pixels); 2296 pixels);
2302 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2297 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2303 EXPECT_TRUE(CheckRect( 2298 EXPECT_TRUE(CheckRect(
2304 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, 2299 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment,
2305 pixels, mem1.ptr)); 2300 pixels, mem1.ptr));
2306
2307 ClearCommands();
2308 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
2309
2310 ExpectedMemoryInfo mem2 = GetExpectedMemory(sizeof(pixels));
2311 Cmds2 expected2;
2312 expected2.tex_image_2d.Init(
2313 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2314 mem2.id, mem2.offset);
2315 expected2.set_token.Init(GetNextToken());
2316 const void* commands2 = GetPut();
2317 gl_->TexImage2D(
2318 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2319 pixels);
2320 EXPECT_EQ(0, memcmp(&expected2, commands2, sizeof(expected2)));
2321 EXPECT_TRUE(CheckRect(
2322 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, true,
2323 pixels, mem2.ptr));
2324 } 2301 }
2325 2302
2326 TEST_F(GLES2ImplementationTest, TexImage2DViaMappedMem) { 2303 TEST_F(GLES2ImplementationTest, TexImage2DViaMappedMem) {
2327 struct Cmds { 2304 struct Cmds {
2328 cmds::TexImage2D tex_image_2d; 2305 cmds::TexImage2D tex_image_2d;
2329 cmd::SetToken set_token; 2306 cmd::SetToken set_token;
2330 }; 2307 };
2331 const GLenum kTarget = GL_TEXTURE_2D; 2308 const GLenum kTarget = GL_TEXTURE_2D;
2332 const GLint kLevel = 0; 2309 const GLint kLevel = 0;
2333 const GLenum kFormat = GL_RGB; 2310 const GLenum kFormat = GL_RGB;
(...skipping 24 matching lines...) Expand all
2358 Cmds expected; 2335 Cmds expected;
2359 expected.tex_image_2d.Init( 2336 expected.tex_image_2d.Init(
2360 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2337 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2361 mem1.id, mem1.offset); 2338 mem1.id, mem1.offset);
2362 expected.set_token.Init(GetNextToken()); 2339 expected.set_token.Init(GetNextToken());
2363 gl_->TexImage2D( 2340 gl_->TexImage2D(
2364 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, 2341 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2365 pixels.get()); 2342 pixels.get());
2366 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2343 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2367 EXPECT_TRUE(CheckRect( 2344 EXPECT_TRUE(CheckRect(
2368 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, 2345 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment,
2369 pixels.get(), mem1.ptr)); 2346 pixels.get(), mem1.ptr));
2370 } 2347 }
2371 2348
2372 // Test TexImage2D with 2 writes 2349 // Test TexImage2D with 2 writes
2373 TEST_F(GLES2ImplementationTest, TexImage2DViaTexSubImage2D) { 2350 TEST_F(GLES2ImplementationTest, TexImage2DViaTexSubImage2D) {
2374 // Set limit to 1 to effectively disable mapped memory. 2351 // Set limit to 1 to effectively disable mapped memory.
2375 SetMappedMemoryLimit(1); 2352 SetMappedMemoryLimit(1);
2376 2353
2377 struct Cmds { 2354 struct Cmds {
2378 cmds::TexImage2D tex_image_2d; 2355 cmds::TexImage2D tex_image_2d;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2431 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, 2408 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment,
2432 // false, pixels.get(), 2409 // false, pixels.get(),
2433 // GetExpectedTransferAddressFromOffsetAs<uint8>(offset1, half_size))) 2410 // GetExpectedTransferAddressFromOffsetAs<uint8>(offset1, half_size)))
2434 // .RetiresOnSaturation(); 2411 // .RetiresOnSaturation();
2435 2412
2436 gl_->TexImage2D( 2413 gl_->TexImage2D(
2437 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, 2414 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2438 pixels.get()); 2415 pixels.get());
2439 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2416 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2440 EXPECT_TRUE(CheckRect( 2417 EXPECT_TRUE(CheckRect(
2441 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, false, 2418 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment,
2442 pixels.get() + kHeight / 2 * padded_row_size, mem2.ptr)); 2419 pixels.get() + kHeight / 2 * padded_row_size, mem2.ptr));
2443
2444 ClearCommands();
2445 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
2446 const void* commands2 = GetPut();
2447 ExpectedMemoryInfo mem3 = GetExpectedMemory(half_size);
2448 ExpectedMemoryInfo mem4 = GetExpectedMemory(half_size);
2449 expected.tex_image_2d.Init(
2450 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2451 0, 0);
2452 expected.tex_sub_image_2d1.Init(
2453 kTarget, kLevel, 0, kHeight / 2, kWidth, kHeight / 2, kFormat, kType,
2454 mem3.id, mem3.offset, true);
2455 expected.set_token1.Init(GetNextToken());
2456 expected.tex_sub_image_2d2.Init(
2457 kTarget, kLevel, 0, 0, kWidth, kHeight / 2, kFormat, kType,
2458 mem4.id, mem4.offset, true);
2459 expected.set_token2.Init(GetNextToken());
2460
2461 // TODO(gman): Make it possible to run this test
2462 // EXPECT_CALL(*command_buffer(), OnFlush())
2463 // .WillOnce(CheckRectAction(
2464 // kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment,
2465 // true, pixels.get(),
2466 // GetExpectedTransferAddressFromOffsetAs<uint8>(offset3, half_size)))
2467 // .RetiresOnSaturation();
2468
2469 gl_->TexImage2D(
2470 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2471 pixels.get());
2472 EXPECT_EQ(0, memcmp(&expected, commands2, sizeof(expected)));
2473 EXPECT_TRUE(CheckRect(
2474 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, true,
2475 pixels.get() + kHeight / 2 * padded_row_size, mem4.ptr));
2476 }
2477
2478 // Test TexSubImage2D with GL_PACK_FLIP_Y set and partial multirow transfers
2479 TEST_F(GLES2ImplementationTest, TexSubImage2DFlipY) {
2480 const GLsizei kTextureWidth = MaxTransferBufferSize() / 4;
2481 const GLsizei kTextureHeight = 7;
2482 const GLsizei kSubImageWidth = MaxTransferBufferSize() / 8;
2483 const GLsizei kSubImageHeight = 4;
2484 const GLint kSubImageXOffset = 1;
2485 const GLint kSubImageYOffset = 2;
2486 const GLenum kFormat = GL_RGBA;
2487 const GLenum kType = GL_UNSIGNED_BYTE;
2488 const GLenum kTarget = GL_TEXTURE_2D;
2489 const GLint kLevel = 0;
2490 const GLint kBorder = 0;
2491 const GLint kPixelStoreUnpackAlignment = 4;
2492
2493 struct Cmds {
2494 cmds::PixelStorei pixel_store_i1;
2495 cmds::TexImage2D tex_image_2d;
2496 cmds::PixelStorei pixel_store_i2;
2497 cmds::TexSubImage2D tex_sub_image_2d1;
2498 cmd::SetToken set_token1;
2499 cmds::TexSubImage2D tex_sub_image_2d2;
2500 cmd::SetToken set_token2;
2501 };
2502
2503 uint32 sub_2_high_size = 0;
2504 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2505 kSubImageWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2506 &sub_2_high_size, NULL, NULL));
2507
2508 ExpectedMemoryInfo mem1 = GetExpectedMemory(sub_2_high_size);
2509 ExpectedMemoryInfo mem2 = GetExpectedMemory(sub_2_high_size);
2510
2511 Cmds expected;
2512 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
2513 expected.tex_image_2d.Init(
2514 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kFormat,
2515 kType, 0, 0);
2516 expected.pixel_store_i2.Init(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
2517 expected.tex_sub_image_2d1.Init(kTarget, kLevel, kSubImageXOffset,
2518 kSubImageYOffset + 2, kSubImageWidth, 2, kFormat, kType,
2519 mem1.id, mem1.offset, false);
2520 expected.set_token1.Init(GetNextToken());
2521 expected.tex_sub_image_2d2.Init(kTarget, kLevel, kSubImageXOffset,
2522 kSubImageYOffset, kSubImageWidth , 2, kFormat, kType,
2523 mem2.id, mem2.offset, false);
2524 expected.set_token2.Init(GetNextToken());
2525
2526 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
2527 gl_->TexImage2D(
2528 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kBorder, kFormat,
2529 kType, NULL);
2530 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
2531 scoped_ptr<uint32[]> pixels(new uint32[kSubImageWidth * kSubImageHeight]);
2532 for (int y = 0; y < kSubImageHeight; ++y) {
2533 for (int x = 0; x < kSubImageWidth; ++x) {
2534 pixels.get()[kSubImageWidth * y + x] = x | (y << 16);
2535 }
2536 }
2537 gl_->TexSubImage2D(
2538 GL_TEXTURE_2D, 0, kSubImageXOffset, kSubImageYOffset, kSubImageWidth,
2539 kSubImageHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
2540
2541 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2542 EXPECT_TRUE(CheckRect(
2543 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, true,
2544 reinterpret_cast<uint8*>(pixels.get() + 2 * kSubImageWidth),
2545 mem2.ptr));
2546 } 2420 }
2547 2421
2548 TEST_F(GLES2ImplementationTest, SubImageUnpack) { 2422 TEST_F(GLES2ImplementationTest, SubImageUnpack) {
2549 static const GLint unpack_alignments[] = { 1, 2, 4, 8 }; 2423 static const GLint unpack_alignments[] = { 1, 2, 4, 8 };
2550 2424
2551 static const GLenum kFormat = GL_RGB; 2425 static const GLenum kFormat = GL_RGB;
2552 static const GLenum kType = GL_UNSIGNED_BYTE; 2426 static const GLenum kType = GL_UNSIGNED_BYTE;
2553 static const GLint kLevel = 0; 2427 static const GLint kLevel = 0;
2554 static const GLint kBorder = 0; 2428 static const GLint kBorder = 0;
2555 // We're testing using the unpack params to pull a subimage out of a larger 2429 // We're testing using the unpack params to pull a subimage out of a larger
2556 // source of pixels. Here we specify the subimage by its border rows / 2430 // source of pixels. Here we specify the subimage by its border rows /
2557 // columns. 2431 // columns.
2558 static const GLint kSrcWidth = 33; 2432 static const GLint kSrcWidth = 33;
2559 static const GLint kSrcSubImageX0 = 11; 2433 static const GLint kSrcSubImageX0 = 11;
2560 static const GLint kSrcSubImageX1 = 20; 2434 static const GLint kSrcSubImageX1 = 20;
2561 static const GLint kSrcSubImageY0 = 18; 2435 static const GLint kSrcSubImageY0 = 18;
2562 static const GLint kSrcSubImageY1 = 23; 2436 static const GLint kSrcSubImageY1 = 23;
2563 static const GLint kSrcSubImageWidth = kSrcSubImageX1 - kSrcSubImageX0; 2437 static const GLint kSrcSubImageWidth = kSrcSubImageX1 - kSrcSubImageX0;
2564 static const GLint kSrcSubImageHeight = kSrcSubImageY1 - kSrcSubImageY0; 2438 static const GLint kSrcSubImageHeight = kSrcSubImageY1 - kSrcSubImageY0;
2565 2439
2566 // these are only used in the texsubimage tests 2440 // these are only used in the texsubimage tests
2567 static const GLint kTexWidth = 1023; 2441 static const GLint kTexWidth = 1023;
2568 static const GLint kTexHeight = 511; 2442 static const GLint kTexHeight = 511;
2569 static const GLint kTexSubXOffset = 419; 2443 static const GLint kTexSubXOffset = 419;
2570 static const GLint kTexSubYOffset = 103; 2444 static const GLint kTexSubYOffset = 103;
2571 2445
2572 struct { 2446 struct {
2573 cmds::PixelStorei pixel_store_i; 2447 cmds::PixelStorei pixel_store_i;
2574 cmds::PixelStorei pixel_store_i2;
2575 cmds::TexImage2D tex_image_2d; 2448 cmds::TexImage2D tex_image_2d;
2576 } texImageExpected; 2449 } texImageExpected;
2577 2450
2578 struct { 2451 struct {
2579 cmds::PixelStorei pixel_store_i; 2452 cmds::PixelStorei pixel_store_i;
2580 cmds::PixelStorei pixel_store_i2;
2581 cmds::TexImage2D tex_image_2d; 2453 cmds::TexImage2D tex_image_2d;
2582 cmds::TexSubImage2D tex_sub_image_2d; 2454 cmds::TexSubImage2D tex_sub_image_2d;
2583 } texSubImageExpected; 2455 } texSubImageExpected;
2584 2456
2585 uint32 src_size; 2457 uint32 src_size;
2586 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2458 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2587 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 8, &src_size, NULL, NULL)); 2459 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 8, &src_size, NULL, NULL));
2588 scoped_ptr<uint8[]> src_pixels; 2460 scoped_ptr<uint8[]> src_pixels;
2589 src_pixels.reset(new uint8[src_size]); 2461 src_pixels.reset(new uint8[src_size]);
2590 for (size_t i = 0; i < src_size; ++i) { 2462 for (size_t i = 0; i < src_size; ++i) {
2591 src_pixels[i] = static_cast<int8>(i); 2463 src_pixels[i] = static_cast<int8>(i);
2592 } 2464 }
2593 2465
2594 for (int sub = 0; sub < 2; ++sub) { 2466 for (int sub = 0; sub < 2; ++sub) {
2595 for (int flip_y = 0; flip_y < 2; ++flip_y) { 2467 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2596 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2468 GLint alignment = unpack_alignments[a];
2597 GLint alignment = unpack_alignments[a]; 2469 uint32 size;
2598 uint32 size; 2470 uint32 unpadded_row_size;
2599 uint32 unpadded_row_size; 2471 uint32 padded_row_size;
2600 uint32 padded_row_size; 2472 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2601 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2473 kSrcSubImageWidth, kSrcSubImageHeight, 1, kFormat, kType, alignment,
2602 kSrcSubImageWidth, kSrcSubImageHeight, 1, kFormat, kType, alignment, 2474 &size, &unpadded_row_size, &padded_row_size));
2603 &size, &unpadded_row_size, &padded_row_size)); 2475 ASSERT_TRUE(size <= MaxTransferBufferSize());
2604 ASSERT_TRUE(size <= MaxTransferBufferSize()); 2476 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2605 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2606 2477
2607 const void* commands = GetPut(); 2478 const void* commands = GetPut();
2608 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment); 2479 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment);
2609 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth); 2480 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth);
2610 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0); 2481 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0);
2611 gl_->PixelStorei(GL_UNPACK_SKIP_ROWS_EXT, kSrcSubImageY0); 2482 gl_->PixelStorei(GL_UNPACK_SKIP_ROWS_EXT, kSrcSubImageY0);
2612 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 2483 if (sub) {
2613 if (sub) { 2484 gl_->TexImage2D(
2614 gl_->TexImage2D( 2485 GL_TEXTURE_2D, kLevel, kFormat, kTexWidth, kTexHeight, kBorder,
2615 GL_TEXTURE_2D, kLevel, kFormat, kTexWidth, kTexHeight, kBorder, 2486 kFormat, kType, NULL);
2616 kFormat, kType, NULL); 2487 gl_->TexSubImage2D(
2617 gl_->TexSubImage2D( 2488 GL_TEXTURE_2D, kLevel, kTexSubXOffset, kTexSubYOffset,
2618 GL_TEXTURE_2D, kLevel, kTexSubXOffset, kTexSubYOffset, 2489 kSrcSubImageWidth, kSrcSubImageHeight, kFormat, kType,
2619 kSrcSubImageWidth, kSrcSubImageHeight, kFormat, kType, 2490 src_pixels.get());
2620 src_pixels.get()); 2491 texSubImageExpected.pixel_store_i.Init(
2621 texSubImageExpected.pixel_store_i.Init( 2492 GL_UNPACK_ALIGNMENT, alignment);
2622 GL_UNPACK_ALIGNMENT, alignment); 2493 texSubImageExpected.tex_image_2d.Init(
2623 texSubImageExpected.pixel_store_i2.Init( 2494 GL_TEXTURE_2D, kLevel, kFormat, kTexWidth, kTexHeight,
2624 GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 2495 kFormat, kType, 0, 0);
2625 texSubImageExpected.tex_image_2d.Init( 2496 texSubImageExpected.tex_sub_image_2d.Init(
2626 GL_TEXTURE_2D, kLevel, kFormat, kTexWidth, kTexHeight, 2497 GL_TEXTURE_2D, kLevel, kTexSubXOffset, kTexSubYOffset,
2627 kFormat, kType, 0, 0); 2498 kSrcSubImageWidth, kSrcSubImageHeight, kFormat, kType, mem.id,
2628 texSubImageExpected.tex_sub_image_2d.Init( 2499 mem.offset, GL_FALSE);
2629 GL_TEXTURE_2D, kLevel, kTexSubXOffset, kTexSubYOffset, 2500 EXPECT_EQ(0, memcmp(
2630 kSrcSubImageWidth, kSrcSubImageHeight, kFormat, kType, mem.id, 2501 &texSubImageExpected, commands, sizeof(texSubImageExpected)));
2631 mem.offset, GL_FALSE); 2502 } else {
2632 EXPECT_EQ(0, memcmp( 2503 gl_->TexImage2D(
2633 &texSubImageExpected, commands, sizeof(texSubImageExpected))); 2504 GL_TEXTURE_2D, kLevel, kFormat,
2634 } else { 2505 kSrcSubImageWidth, kSrcSubImageHeight, kBorder, kFormat, kType,
2635 gl_->TexImage2D( 2506 src_pixels.get());
2636 GL_TEXTURE_2D, kLevel, kFormat, 2507 texImageExpected.pixel_store_i.Init(GL_UNPACK_ALIGNMENT, alignment);
2637 kSrcSubImageWidth, kSrcSubImageHeight, kBorder, kFormat, kType, 2508 texImageExpected.tex_image_2d.Init(
2638 src_pixels.get()); 2509 GL_TEXTURE_2D, kLevel, kFormat, kSrcSubImageWidth,
2639 texImageExpected.pixel_store_i.Init(GL_UNPACK_ALIGNMENT, alignment); 2510 kSrcSubImageHeight, kFormat, kType, mem.id, mem.offset);
2640 texImageExpected.pixel_store_i2.Init( 2511 EXPECT_EQ(0, memcmp(
2641 GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 2512 &texImageExpected, commands, sizeof(texImageExpected)));
2642 texImageExpected.tex_image_2d.Init(
2643 GL_TEXTURE_2D, kLevel, kFormat, kSrcSubImageWidth,
2644 kSrcSubImageHeight, kFormat, kType, mem.id, mem.offset);
2645 EXPECT_EQ(0, memcmp(
2646 &texImageExpected, commands, sizeof(texImageExpected)));
2647 }
2648 uint32 src_padded_row_size;
2649 ASSERT_TRUE(GLES2Util::ComputeImagePaddedRowSize(
2650 kSrcWidth, kFormat, kType, alignment, &src_padded_row_size));
2651 uint32 bytes_per_group = GLES2Util::ComputeImageGroupSize(
2652 kFormat, kType);
2653 for (int y = 0; y < kSrcSubImageHeight; ++y) {
2654 GLint src_sub_y = flip_y ? kSrcSubImageHeight - y - 1 : y;
2655 const uint8* src_row = src_pixels.get() +
2656 (kSrcSubImageY0 + src_sub_y) * src_padded_row_size +
2657 bytes_per_group * kSrcSubImageX0;
2658 const uint8* dst_row = mem.ptr + y * padded_row_size;
2659 EXPECT_EQ(0, memcmp(src_row, dst_row, unpadded_row_size));
2660 }
2661 ClearCommands();
2662 } 2513 }
2514 uint32 src_padded_row_size;
2515 ASSERT_TRUE(GLES2Util::ComputeImagePaddedRowSize(
2516 kSrcWidth, kFormat, kType, alignment, &src_padded_row_size));
2517 uint32 bytes_per_group = GLES2Util::ComputeImageGroupSize(
2518 kFormat, kType);
2519 for (int y = 0; y < kSrcSubImageHeight; ++y) {
2520 const uint8* src_row = src_pixels.get() +
2521 (kSrcSubImageY0 + y) * src_padded_row_size +
2522 bytes_per_group * kSrcSubImageX0;
2523 const uint8* dst_row = mem.ptr + y * padded_row_size;
2524 EXPECT_EQ(0, memcmp(src_row, dst_row, unpadded_row_size));
2525 }
2526 ClearCommands();
2663 } 2527 }
2664 } 2528 }
2665 } 2529 }
2666 2530
2667 // Test texture related calls with invalid arguments. 2531 // Test texture related calls with invalid arguments.
2668 TEST_F(GLES2ImplementationTest, TextureInvalidArguments) { 2532 TEST_F(GLES2ImplementationTest, TextureInvalidArguments) {
2669 struct Cmds { 2533 struct Cmds {
2670 cmds::TexImage2D tex_image_2d; 2534 cmds::TexImage2D tex_image_2d;
2671 cmd::SetToken set_token; 2535 cmd::SetToken set_token;
2672 }; 2536 };
(...skipping 20 matching lines...) Expand all
2693 Cmds expected; 2557 Cmds expected;
2694 expected.tex_image_2d.Init( 2558 expected.tex_image_2d.Init(
2695 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType, 2559 kTarget, kLevel, kFormat, kWidth, kHeight, kFormat, kType,
2696 mem1.id, mem1.offset); 2560 mem1.id, mem1.offset);
2697 expected.set_token.Init(GetNextToken()); 2561 expected.set_token.Init(GetNextToken());
2698 gl_->TexImage2D( 2562 gl_->TexImage2D(
2699 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType, 2563 kTarget, kLevel, kFormat, kWidth, kHeight, kBorder, kFormat, kType,
2700 pixels); 2564 pixels);
2701 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2565 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2702 EXPECT_TRUE(CheckRect( 2566 EXPECT_TRUE(CheckRect(
2703 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, false, 2567 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment,
2704 pixels, mem1.ptr)); 2568 pixels, mem1.ptr));
2705 2569
2706 ClearCommands(); 2570 ClearCommands();
2707 2571
2708 // Use invalid border. 2572 // Use invalid border.
2709 gl_->TexImage2D( 2573 gl_->TexImage2D(
2710 kTarget, kLevel, kFormat, kWidth, kHeight, kInvalidBorder, kFormat, kType, 2574 kTarget, kLevel, kFormat, kWidth, kHeight, kInvalidBorder, kFormat, kType,
2711 pixels); 2575 pixels);
2712 2576
2713 EXPECT_TRUE(NoCommandsWritten()); 2577 EXPECT_TRUE(NoCommandsWritten());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2651 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2788 kFormat, kType, mem.id, mem.offset); 2652 kFormat, kType, mem.id, mem.offset);
2789 2653
2790 gl_->TexImage3D( 2654 gl_->TexImage3D(
2791 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, 2655 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder,
2792 kFormat, kType, pixels.get()); 2656 kFormat, kType, pixels.get());
2793 2657
2794 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2658 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2795 EXPECT_TRUE(CheckRect( 2659 EXPECT_TRUE(CheckRect(
2796 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2660 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2797 false, reinterpret_cast<uint8*>(pixels.get()), mem.ptr)); 2661 reinterpret_cast<uint8*>(pixels.get()), mem.ptr));
2798 } 2662 }
2799 2663
2800 TEST_F(GLES2ImplementationTest, TexImage3DViaMappedMem) { 2664 TEST_F(GLES2ImplementationTest, TexImage3DViaMappedMem) {
2801 struct Cmds { 2665 struct Cmds {
2802 cmds::TexImage3D tex_image_3d; 2666 cmds::TexImage3D tex_image_3d;
2803 }; 2667 };
2804 const GLenum kTarget = GL_TEXTURE_3D; 2668 const GLenum kTarget = GL_TEXTURE_3D;
2805 const GLint kLevel = 0; 2669 const GLint kLevel = 0;
2806 const GLint kBorder = 0; 2670 const GLint kBorder = 0;
2807 const GLenum kFormat = GL_RGB; 2671 const GLenum kFormat = GL_RGB;
(...skipping 27 matching lines...) Expand all
2835 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, 2699 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2836 kFormat, kType, mem.id, mem.offset); 2700 kFormat, kType, mem.id, mem.offset);
2837 2701
2838 gl_->TexImage3D( 2702 gl_->TexImage3D(
2839 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder, 2703 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder,
2840 kFormat, kType, pixels.get()); 2704 kFormat, kType, pixels.get());
2841 2705
2842 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2706 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2843 EXPECT_TRUE(CheckRect( 2707 EXPECT_TRUE(CheckRect(
2844 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment, 2708 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2845 false, reinterpret_cast<uint8*>(pixels.get()), mem.ptr)); 2709 reinterpret_cast<uint8*>(pixels.get()), mem.ptr));
2846 } 2710 }
2847 2711
2848 TEST_F(GLES2ImplementationTest, TexImage3DViaTexSubImage3D) { 2712 TEST_F(GLES2ImplementationTest, TexImage3DViaTexSubImage3D) {
2849 // Set limit to 1 to effectively disable mapped memory. 2713 // Set limit to 1 to effectively disable mapped memory.
2850 SetMappedMemoryLimit(1); 2714 SetMappedMemoryLimit(1);
2851 2715
2852 struct Cmds { 2716 struct Cmds {
2853 cmds::TexImage3D tex_image_3d; 2717 cmds::TexImage3D tex_image_3d;
2854 cmds::TexSubImage3D tex_sub_image_3d1; 2718 cmds::TexSubImage3D tex_sub_image_3d1;
2855 cmd::SetToken set_token; 2719 cmd::SetToken set_token;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 expected.set_token2.Init(GetNextToken()); 2833 expected.set_token2.Init(GetNextToken());
2970 expected.set_token3.Init(GetNextToken()); 2834 expected.set_token3.Init(GetNextToken());
2971 2835
2972 gl_->TexSubImage3D( 2836 gl_->TexSubImage3D(
2973 kTarget, kLevel, kXOffset, kYOffset, kZOffset, kWidth, kHeight, kDepth, 2837 kTarget, kLevel, kXOffset, kYOffset, kZOffset, kWidth, kHeight, kDepth,
2974 kFormat, kType, pixels.get()); 2838 kFormat, kType, pixels.get());
2975 2839
2976 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected))); 2840 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2977 uint32 offset_to_last = first_size + second_size + third_size; 2841 uint32 offset_to_last = first_size + second_size + third_size;
2978 EXPECT_TRUE(CheckRect( 2842 EXPECT_TRUE(CheckRect(
2979 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, false, 2843 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment,
2980 reinterpret_cast<uint8*>(pixels.get()) + offset_to_last, mem2_2.ptr)); 2844 reinterpret_cast<uint8*>(pixels.get()) + offset_to_last, mem2_2.ptr));
2981 } 2845 }
2982 2846
2983 // glGen* Ids must not be reused until glDelete* commands have been 2847 // glGen* Ids must not be reused until glDelete* commands have been
2984 // flushed by glFlush. 2848 // flushed by glFlush.
2985 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestBuffers) { 2849 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestBuffers) {
2986 FlushGenerationTest<GenBuffersAPI>(); 2850 FlushGenerationTest<GenBuffersAPI>();
2987 } 2851 }
2988 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestFramebuffers) { 2852 TEST_F(GLES2ImplementationStrictSharedTest, FlushGenerationTestFramebuffers) {
2989 FlushGenerationTest<GenFramebuffersAPI>(); 2853 FlushGenerationTest<GenFramebuffersAPI>();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 CrossContextGenerationAutoFlushTest<GenRenderbuffersAPI>(); 2892 CrossContextGenerationAutoFlushTest<GenRenderbuffersAPI>();
3029 } 2893 }
3030 TEST_F(GLES2ImplementationStrictSharedTest, 2894 TEST_F(GLES2ImplementationStrictSharedTest,
3031 CrossContextGenerationAutoFlushTestTextures) { 2895 CrossContextGenerationAutoFlushTestTextures) {
3032 CrossContextGenerationAutoFlushTest<GenTexturesAPI>(); 2896 CrossContextGenerationAutoFlushTest<GenTexturesAPI>();
3033 } 2897 }
3034 2898
3035 TEST_F(GLES2ImplementationTest, GetString) { 2899 TEST_F(GLES2ImplementationTest, GetString) {
3036 const uint32 kBucketId = GLES2Implementation::kResultBucketId; 2900 const uint32 kBucketId = GLES2Implementation::kResultBucketId;
3037 const Str7 kString = {"foobar"}; 2901 const Str7 kString = {"foobar"};
3038 // GL_CHROMIUM_map_sub GL_CHROMIUM_flipy are hard coded into 2902 // GL_CHROMIUM_map_sub is hard coded into GLES2Implementation.
3039 // GLES2Implementation.
3040 const char* expected_str = 2903 const char* expected_str =
3041 "foobar " 2904 "foobar "
3042 "GL_CHROMIUM_flipy "
3043 "GL_EXT_unpack_subimage " 2905 "GL_EXT_unpack_subimage "
3044 "GL_CHROMIUM_map_sub"; 2906 "GL_CHROMIUM_map_sub";
3045 const char kBad = 0x12; 2907 const char kBad = 0x12;
3046 struct Cmds { 2908 struct Cmds {
3047 cmd::SetBucketSize set_bucket_size1; 2909 cmd::SetBucketSize set_bucket_size1;
3048 cmds::GetString get_string; 2910 cmds::GetString get_string;
3049 cmd::GetBucketStart get_bucket_start; 2911 cmd::GetBucketStart get_bucket_start;
3050 cmd::SetToken set_token1; 2912 cmd::SetToken set_token1;
3051 cmd::SetBucketSize set_bucket_size2; 2913 cmd::SetBucketSize set_bucket_size2;
3052 }; 2914 };
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { 3801 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) {
3940 ContextInitOptions init_options; 3802 ContextInitOptions init_options;
3941 init_options.transfer_buffer_initialize_fail = true; 3803 init_options.transfer_buffer_initialize_fail = true;
3942 EXPECT_FALSE(Initialize(init_options)); 3804 EXPECT_FALSE(Initialize(init_options));
3943 } 3805 }
3944 3806
3945 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 3807 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
3946 3808
3947 } // namespace gles2 3809 } // namespace gles2
3948 } // namespace gpu 3810 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.cc ('k') | gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698