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

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

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError()); 2156 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), gl_->GetError());
2157 } 2157 }
2158 2158
2159 static bool CheckRect( 2159 static bool CheckRect(
2160 int width, int height, GLenum format, GLenum type, int alignment, 2160 int width, int height, GLenum format, GLenum type, int alignment,
2161 bool flip_y, const uint8* r1, const uint8* r2) { 2161 bool flip_y, const uint8* r1, const uint8* r2) {
2162 uint32 size = 0; 2162 uint32 size = 0;
2163 uint32 unpadded_row_size = 0; 2163 uint32 unpadded_row_size = 0;
2164 uint32 padded_row_size = 0; 2164 uint32 padded_row_size = 0;
2165 if (!GLES2Util::ComputeImageDataSizes( 2165 if (!GLES2Util::ComputeImageDataSizes(
2166 width, height, format, type, alignment, &size, &unpadded_row_size, 2166 width, height, 1, format, type, alignment, &size, &unpadded_row_size,
2167 &padded_row_size)) { 2167 &padded_row_size)) {
2168 return false; 2168 return false;
2169 } 2169 }
2170 2170
2171 int r2_stride = flip_y ? 2171 int r2_stride = flip_y ?
2172 -static_cast<int>(padded_row_size) : 2172 -static_cast<int>(padded_row_size) :
2173 static_cast<int>(padded_row_size); 2173 static_cast<int>(padded_row_size);
2174 r2 = flip_y ? (r2 + (height - 1) * padded_row_size) : r2; 2174 r2 = flip_y ? (r2 + (height - 1) * padded_row_size) : r2;
2175 2175
2176 for (int y = 0; y < height; ++y) { 2176 for (int y = 0; y < height; ++y) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 const GLenum kFormat = GL_RGB; 2262 const GLenum kFormat = GL_RGB;
2263 const GLint kBorder = 0; 2263 const GLint kBorder = 0;
2264 const GLenum kType = GL_UNSIGNED_BYTE; 2264 const GLenum kType = GL_UNSIGNED_BYTE;
2265 const GLint kPixelStoreUnpackAlignment = 4; 2265 const GLint kPixelStoreUnpackAlignment = 4;
2266 const GLsizei kWidth = 3; 2266 const GLsizei kWidth = 3;
2267 2267
2268 uint32 size = 0; 2268 uint32 size = 0;
2269 uint32 unpadded_row_size = 0; 2269 uint32 unpadded_row_size = 0;
2270 uint32 padded_row_size = 0; 2270 uint32 padded_row_size = 0;
2271 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2271 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2272 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, 2272 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2273 &size, &unpadded_row_size, &padded_row_size)); 2273 &size, &unpadded_row_size, &padded_row_size));
2274 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2; 2274 const GLsizei kHeight = (MaxTransferBufferSize() / padded_row_size) * 2;
2275 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2275 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2276 kWidth, kHeight, kFormat, kType, kPixelStoreUnpackAlignment, 2276 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2277 &size, NULL, NULL)); 2277 &size, NULL, NULL));
2278 uint32 half_size = 0; 2278 uint32 half_size = 0;
2279 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2279 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2280 kWidth, kHeight / 2, kFormat, kType, kPixelStoreUnpackAlignment, 2280 kWidth, kHeight / 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2281 &half_size, NULL, NULL)); 2281 &half_size, NULL, NULL));
2282 2282
2283 scoped_ptr<uint8[]> pixels(new uint8[size]); 2283 scoped_ptr<uint8[]> pixels(new uint8[size]);
2284 for (uint32 ii = 0; ii < size; ++ii) { 2284 for (uint32 ii = 0; ii < size; ++ii) {
2285 pixels[ii] = static_cast<uint8>(ii); 2285 pixels[ii] = static_cast<uint8>(ii);
2286 } 2286 }
2287 2287
2288 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size); 2288 ExpectedMemoryInfo mem1 = GetExpectedMemory(half_size);
2289 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size); 2289 ExpectedMemoryInfo mem2 = GetExpectedMemory(half_size);
2290 2290
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 cmds::TexImage2D tex_image_2d; 2371 cmds::TexImage2D tex_image_2d;
2372 cmds::PixelStorei pixel_store_i2; 2372 cmds::PixelStorei pixel_store_i2;
2373 cmds::TexSubImage2D tex_sub_image_2d1; 2373 cmds::TexSubImage2D tex_sub_image_2d1;
2374 cmd::SetToken set_token1; 2374 cmd::SetToken set_token1;
2375 cmds::TexSubImage2D tex_sub_image_2d2; 2375 cmds::TexSubImage2D tex_sub_image_2d2;
2376 cmd::SetToken set_token2; 2376 cmd::SetToken set_token2;
2377 }; 2377 };
2378 2378
2379 uint32 sub_2_high_size = 0; 2379 uint32 sub_2_high_size = 0;
2380 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2380 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2381 kSubImageWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, 2381 kSubImageWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2382 &sub_2_high_size, NULL, NULL)); 2382 &sub_2_high_size, NULL, NULL));
2383 2383
2384 ExpectedMemoryInfo mem1 = GetExpectedMemory(sub_2_high_size); 2384 ExpectedMemoryInfo mem1 = GetExpectedMemory(sub_2_high_size);
2385 ExpectedMemoryInfo mem2 = GetExpectedMemory(sub_2_high_size); 2385 ExpectedMemoryInfo mem2 = GetExpectedMemory(sub_2_high_size);
2386 2386
2387 Cmds expected; 2387 Cmds expected;
2388 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment); 2388 expected.pixel_store_i1.Init(GL_UNPACK_ALIGNMENT, kPixelStoreUnpackAlignment);
2389 expected.tex_image_2d.Init( 2389 expected.tex_image_2d.Init(
2390 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kFormat, 2390 kTarget, kLevel, kFormat, kTextureWidth, kTextureHeight, kFormat,
2391 kType, 0, 0); 2391 kType, 0, 0);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 2453
2454 struct { 2454 struct {
2455 cmds::PixelStorei pixel_store_i; 2455 cmds::PixelStorei pixel_store_i;
2456 cmds::PixelStorei pixel_store_i2; 2456 cmds::PixelStorei pixel_store_i2;
2457 cmds::TexImage2D tex_image_2d; 2457 cmds::TexImage2D tex_image_2d;
2458 cmds::TexSubImage2D tex_sub_image_2d; 2458 cmds::TexSubImage2D tex_sub_image_2d;
2459 } texSubImageExpected; 2459 } texSubImageExpected;
2460 2460
2461 uint32 src_size; 2461 uint32 src_size;
2462 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2462 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2463 kSrcWidth, kSrcSubImageY1, kFormat, kType, 8, &src_size, NULL, NULL)); 2463 kSrcWidth, kSrcSubImageY1, 1, kFormat, kType, 8, &src_size, NULL, NULL));
2464 scoped_ptr<uint8[]> src_pixels; 2464 scoped_ptr<uint8[]> src_pixels;
2465 src_pixels.reset(new uint8[src_size]); 2465 src_pixels.reset(new uint8[src_size]);
2466 for (size_t i = 0; i < src_size; ++i) { 2466 for (size_t i = 0; i < src_size; ++i) {
2467 src_pixels[i] = static_cast<int8>(i); 2467 src_pixels[i] = static_cast<int8>(i);
2468 } 2468 }
2469 2469
2470 for (int sub = 0; sub < 2; ++sub) { 2470 for (int sub = 0; sub < 2; ++sub) {
2471 for (int flip_y = 0; flip_y < 2; ++flip_y) { 2471 for (int flip_y = 0; flip_y < 2; ++flip_y) {
2472 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) { 2472 for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
2473 GLint alignment = unpack_alignments[a]; 2473 GLint alignment = unpack_alignments[a];
2474 uint32 size; 2474 uint32 size;
2475 uint32 unpadded_row_size; 2475 uint32 unpadded_row_size;
2476 uint32 padded_row_size; 2476 uint32 padded_row_size;
2477 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes( 2477 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2478 kSrcSubImageWidth, kSrcSubImageHeight, kFormat, kType, alignment, 2478 kSrcSubImageWidth, kSrcSubImageHeight, 1, kFormat, kType, alignment,
2479 &size, &unpadded_row_size, &padded_row_size)); 2479 &size, &unpadded_row_size, &padded_row_size));
2480 ASSERT_TRUE(size <= MaxTransferBufferSize()); 2480 ASSERT_TRUE(size <= MaxTransferBufferSize());
2481 ExpectedMemoryInfo mem = GetExpectedMemory(size); 2481 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2482 2482
2483 const void* commands = GetPut(); 2483 const void* commands = GetPut();
2484 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment); 2484 gl_->PixelStorei(GL_UNPACK_ALIGNMENT, alignment);
2485 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth); 2485 gl_->PixelStorei(GL_UNPACK_ROW_LENGTH_EXT, kSrcWidth);
2486 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0); 2486 gl_->PixelStorei(GL_UNPACK_SKIP_PIXELS_EXT, kSrcSubImageX0);
2487 gl_->PixelStorei(GL_UNPACK_SKIP_ROWS_EXT, kSrcSubImageY0); 2487 gl_->PixelStorei(GL_UNPACK_SKIP_ROWS_EXT, kSrcSubImageY0);
2488 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); 2488 gl_->PixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 2619
2620 // Changing border to invalid border should make the call fail at the client 2620 // Changing border to invalid border should make the call fail at the client
2621 // checks. 2621 // checks.
2622 gl_->CompressedTexImage2D( 2622 gl_->CompressedTexImage2D(
2623 kTarget, kLevel, kCompressedFormat, kWidth, kHeight, kInvalidBorder, 2623 kTarget, kLevel, kCompressedFormat, kWidth, kHeight, kInvalidBorder,
2624 arraysize(pixels), pixels); 2624 arraysize(pixels), pixels);
2625 EXPECT_TRUE(NoCommandsWritten()); 2625 EXPECT_TRUE(NoCommandsWritten());
2626 EXPECT_EQ(GL_INVALID_VALUE, CheckError()); 2626 EXPECT_EQ(GL_INVALID_VALUE, CheckError());
2627 } 2627 }
2628 2628
2629 TEST_F(GLES2ImplementationTest, TexImage3DSingleCommand) {
2630 struct Cmds {
2631 cmds::TexImage3D tex_image_3d;
2632 };
2633 const GLenum kTarget = GL_TEXTURE_3D;
2634 const GLint kLevel = 0;
2635 const GLint kBorder = 0;
2636 const GLenum kFormat = GL_RGB;
2637 const GLenum kType = GL_UNSIGNED_BYTE;
2638 const GLint kPixelStoreUnpackAlignment = 4;
2639 const GLsizei kWidth = 3;
2640 const GLsizei kDepth = 2;
2641
2642 uint32 size = 0;
2643 uint32 unpadded_row_size = 0;
2644 uint32 padded_row_size = 0;
2645 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2646 kWidth, 2, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2647 &size, &unpadded_row_size, &padded_row_size));
2648 // Makes sure we can just send over the data in one command.
2649 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size / kDepth;
2650
2651 scoped_ptr<uint8[]> pixels(new uint8[size]);
2652 for (uint32 ii = 0; ii < size; ++ii) {
2653 pixels[ii] = static_cast<uint8>(ii);
2654 }
2655
2656 ExpectedMemoryInfo mem = GetExpectedMemory(size);
2657
2658 Cmds expected;
2659 expected.tex_image_3d.Init(
2660 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth,
2661 kFormat, kType, mem.id, mem.offset);
2662
2663 gl_->TexImage3D(
2664 kTarget, kLevel, kFormat, kWidth, kHeight, kDepth, kBorder,
2665 kFormat, kType, pixels.get());
2666
2667 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2668 EXPECT_TRUE(CheckRect(
2669 kWidth, kHeight * kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2670 false, reinterpret_cast<uint8*>(pixels.get()), mem.ptr));
2671 }
2672
2673 TEST_F(GLES2ImplementationTest, TexImage3DViaTexSubImage3D) {
2674 struct Cmds {
2675 cmds::TexImage3D tex_image_3d;
2676 cmds::TexSubImage3D tex_sub_image_3d1;
2677 cmd::SetToken set_token;
2678 cmds::TexSubImage3D tex_sub_image_3d2;
2679 };
2680 const GLenum kTarget = GL_TEXTURE_3D;
2681 const GLint kLevel = 0;
2682 const GLint kBorder = 0;
2683 const GLenum kFormat = GL_RGB;
2684 const GLenum kType = GL_UNSIGNED_BYTE;
2685 const GLint kPixelStoreUnpackAlignment = 4;
2686 const GLsizei kWidth = 3;
2687
2688 uint32 size = 0;
2689 uint32 unpadded_row_size = 0;
2690 uint32 padded_row_size = 0;
2691 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2692 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2693 &size, &unpadded_row_size, &padded_row_size));
2694 // Makes sure the data is more than one command can hold.
2695 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 3;
2696 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2697 kWidth, kHeight, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2698 &size, NULL, NULL));
2699 uint32 first_size = padded_row_size * (kHeight - 3);
2700 uint32 second_size =
2701 padded_row_size * 3 - (padded_row_size - unpadded_row_size);
2702 EXPECT_EQ(size, first_size + second_size);
2703 ExpectedMemoryInfo mem1 = GetExpectedMemory(first_size);
2704 ExpectedMemoryInfo mem2 = GetExpectedMemory(second_size);
2705 scoped_ptr<uint8[]> pixels(new uint8[size]);
2706 for (uint32 ii = 0; ii < size; ++ii) {
2707 pixels[ii] = static_cast<uint8>(ii);
2708 }
2709
2710 Cmds expected;
2711 expected.tex_image_3d.Init(
2712 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kFormat, kType, 0, 0);
2713 expected.tex_sub_image_3d1.Init(
2714 kTarget, kLevel, 0, 0, 0, kWidth, kHeight - 3, 1, kFormat, kType,
2715 mem1.id, mem1.offset, GL_TRUE);
2716 expected.tex_sub_image_3d2.Init(
2717 kTarget, kLevel, 0, kHeight - 3, 0, kWidth, 3, 1, kFormat, kType,
2718 mem2.id, mem2.offset, GL_TRUE);
2719 expected.set_token.Init(GetNextToken());
2720
2721 gl_->TexImage3D(
2722 kTarget, kLevel, kFormat, kWidth, kHeight, 1, kBorder,
2723 kFormat, kType, pixels.get());
2724 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2725 }
2726
2727 // Test TexSubImage3D with 4 writes
2728 TEST_F(GLES2ImplementationTest, TexSubImage3D4Writes) {
2729 struct Cmds {
2730 cmds::TexSubImage3D tex_sub_image_3d1_1;
2731 cmd::SetToken set_token1;
2732 cmds::TexSubImage3D tex_sub_image_3d1_2;
2733 cmd::SetToken set_token2;
2734 cmds::TexSubImage3D tex_sub_image_3d2_1;
2735 cmd::SetToken set_token3;
2736 cmds::TexSubImage3D tex_sub_image_3d2_2;
2737 };
2738 const GLenum kTarget = GL_TEXTURE_3D;
2739 const GLint kLevel = 0;
2740 const GLint kXOffset = 0;
2741 const GLint kYOffset = 0;
2742 const GLint kZOffset = 0;
2743 const GLenum kFormat = GL_RGB;
2744 const GLenum kType = GL_UNSIGNED_BYTE;
2745 const GLint kPixelStoreUnpackAlignment = 4;
2746 const GLsizei kWidth = 3;
2747 const GLsizei kDepth = 2;
2748
2749 uint32 size = 0;
2750 uint32 unpadded_row_size = 0;
2751 uint32 padded_row_size = 0;
2752 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2753 kWidth, 2, 1, kFormat, kType, kPixelStoreUnpackAlignment,
2754 &size, &unpadded_row_size, &padded_row_size));
2755 const GLsizei kHeight = MaxTransferBufferSize() / padded_row_size + 2;
2756 ASSERT_TRUE(GLES2Util::ComputeImageDataSizes(
2757 kWidth, kHeight, kDepth, kFormat, kType, kPixelStoreUnpackAlignment,
2758 &size, NULL, NULL));
2759 uint32 first_size = (kHeight - 2) * padded_row_size;
2760 uint32 second_size = 2 * padded_row_size;
2761 uint32 third_size = first_size;
2762 uint32 fourth_size = second_size - (padded_row_size - unpadded_row_size);
2763 EXPECT_EQ(size, first_size + second_size + third_size + fourth_size);
2764
2765 scoped_ptr<uint8[]> pixels(new uint8[size]);
2766 for (uint32 ii = 0; ii < size; ++ii) {
2767 pixels[ii] = static_cast<uint8>(ii);
2768 }
2769
2770 ExpectedMemoryInfo mem1_1 = GetExpectedMemory(first_size);
2771 ExpectedMemoryInfo mem1_2 = GetExpectedMemory(second_size);
2772 ExpectedMemoryInfo mem2_1 = GetExpectedMemory(third_size);
2773 ExpectedMemoryInfo mem2_2 = GetExpectedMemory(fourth_size);
2774
2775 Cmds expected;
2776 expected.tex_sub_image_3d1_1.Init(
2777 kTarget, kLevel, kXOffset, kYOffset, kZOffset,
2778 kWidth, kHeight - 2, 1, kFormat, kType,
2779 mem1_1.id, mem1_1.offset, GL_FALSE);
2780 expected.tex_sub_image_3d1_2.Init(
2781 kTarget, kLevel, kXOffset, kYOffset + kHeight - 2, kZOffset,
2782 kWidth, 2, 1, kFormat, kType, mem1_2.id, mem1_2.offset, GL_FALSE);
2783 expected.tex_sub_image_3d2_1.Init(
2784 kTarget, kLevel, kXOffset, kYOffset, kZOffset + 1,
2785 kWidth, kHeight - 2, 1, kFormat, kType,
2786 mem2_1.id, mem2_1.offset, GL_FALSE);
2787 expected.tex_sub_image_3d2_2.Init(
2788 kTarget, kLevel, kXOffset, kYOffset + kHeight - 2, kZOffset + 1,
2789 kWidth, 2, 1, kFormat, kType, mem2_2.id, mem2_2.offset, GL_FALSE);
2790 expected.set_token1.Init(GetNextToken());
2791 expected.set_token2.Init(GetNextToken());
2792 expected.set_token3.Init(GetNextToken());
2793
2794 gl_->TexSubImage3D(
2795 kTarget, kLevel, kXOffset, kYOffset, kZOffset, kWidth, kHeight, kDepth,
2796 kFormat, kType, pixels.get());
2797
2798 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
2799 uint32 offset_to_last = first_size + second_size + third_size;
2800 EXPECT_TRUE(CheckRect(
2801 kWidth, 2, kFormat, kType, kPixelStoreUnpackAlignment, false,
2802 reinterpret_cast<uint8*>(pixels.get()) + offset_to_last, mem2_2.ptr));
2803 }
2629 2804
2630 // Binds can not be cached with bind_generates_resource = false because 2805 // Binds can not be cached with bind_generates_resource = false because
2631 // our id might not be valid. More specifically if you bind on contextA then 2806 // our id might not be valid. More specifically if you bind on contextA then
2632 // delete on contextB the resource is still bound on contextA but GetInterger 2807 // delete on contextB the resource is still bound on contextA but GetInterger
2633 // won't return an id. 2808 // won't return an id.
2634 TEST_F(GLES2ImplementationStrictSharedTest, BindsNotCached) { 2809 TEST_F(GLES2ImplementationStrictSharedTest, BindsNotCached) {
2635 struct PNameValue { 2810 struct PNameValue {
2636 GLenum pname; 2811 GLenum pname;
2637 GLint expected; 2812 GLint expected;
2638 }; 2813 };
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 EXPECT_EQ(GL_NO_ERROR, CheckError()); 3434 EXPECT_EQ(GL_NO_ERROR, CheckError());
3260 3435
3261 // VertexAttribPointer: offset 3436 // VertexAttribPointer: offset
3262 gl_->VertexAttribPointer( 3437 gl_->VertexAttribPointer(
3263 kAttribIndex, 1, GL_FLOAT, GL_FALSE, kStride, 3438 kAttribIndex, 1, GL_FLOAT, GL_FALSE, kStride,
3264 reinterpret_cast<void*>(offset)); 3439 reinterpret_cast<void*>(offset));
3265 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); 3440 EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
3266 EXPECT_STREQ(kOffsetOverflowMessage, GetLastError().c_str()); 3441 EXPECT_STREQ(kOffsetOverflowMessage, GetLastError().c_str());
3267 } 3442 }
3268 3443
3444 TEST_F(GLES2ImplementationTest, TraceBeginCHROMIUM) {
3445 const uint32 kCategoryBucketId = GLES2Implementation::kResultBucketId;
3446 const uint32 kNameBucketId = GLES2Implementation::kResultBucketId + 1;
3447 const std::string category_name = "test category";
3448 const std::string trace_name = "test trace";
3449 const size_t kPaddedString1Size =
3450 transfer_buffer_->RoundToAlignment(category_name.size() + 1);
3451 const size_t kPaddedString2Size =
3452 transfer_buffer_->RoundToAlignment(trace_name.size() + 1);
3453
3454 gl_->TraceBeginCHROMIUM(category_name.c_str(), trace_name.c_str());
3455 EXPECT_EQ(GL_NO_ERROR, CheckError());
3456
3457 struct Cmds {
3458 cmd::SetBucketSize category_size1;
3459 cmd::SetBucketData category_data;
3460 cmd::SetToken set_token1;
3461 cmd::SetBucketSize name_size1;
3462 cmd::SetBucketData name_data;
3463 cmd::SetToken set_token2;
3464 cmds::TraceBeginCHROMIUM trace_call_begin;
3465 cmd::SetBucketSize category_size2;
3466 cmd::SetBucketSize name_size2;
3467 };
3468
3469 ExpectedMemoryInfo mem1 = GetExpectedMemory(kPaddedString1Size);
3470 ExpectedMemoryInfo mem2 = GetExpectedMemory(kPaddedString2Size);
3471
3472 ASSERT_STREQ(category_name.c_str(), reinterpret_cast<char*>(mem1.ptr));
3473 ASSERT_STREQ(trace_name.c_str(), reinterpret_cast<char*>(mem2.ptr));
3474
3475 Cmds expected;
3476 expected.category_size1.Init(kCategoryBucketId, category_name.size() + 1);
3477 expected.category_data.Init(
3478 kCategoryBucketId, 0, category_name.size() + 1, mem1.id, mem1.offset);
3479 expected.set_token1.Init(GetNextToken());
3480 expected.name_size1.Init(kNameBucketId, trace_name.size() + 1);
3481 expected.name_data.Init(
3482 kNameBucketId, 0, trace_name.size() + 1, mem2.id, mem2.offset);
3483 expected.set_token2.Init(GetNextToken());
3484 expected.trace_call_begin.Init(kCategoryBucketId, kNameBucketId);
3485 expected.category_size2.Init(kCategoryBucketId, 0);
3486 expected.name_size2.Init(kNameBucketId, 0);
3487
3488 EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
3489 }
3490
3491 TEST_F(GLES2ImplementationTest, AllowNestedTracesCHROMIUM) {
3492 const std::string category1_name = "test category 1";
3493 const std::string trace1_name = "test trace 1";
3494 const std::string category2_name = "test category 2";
3495 const std::string trace2_name = "test trace 2";
3496
3497 gl_->TraceBeginCHROMIUM(category1_name.c_str(), trace1_name.c_str());
3498 EXPECT_EQ(GL_NO_ERROR, CheckError());
3499
3500 gl_->TraceBeginCHROMIUM(category2_name.c_str(), trace2_name.c_str());
3501 EXPECT_EQ(GL_NO_ERROR, CheckError());
3502
3503 gl_->TraceEndCHROMIUM();
3504 EXPECT_EQ(GL_NO_ERROR, CheckError());
3505
3506 gl_->TraceEndCHROMIUM();
3507 EXPECT_EQ(GL_NO_ERROR, CheckError());
3508
3509 // No more corresponding begin tracer marker should error.
3510 gl_->TraceEndCHROMIUM();
3511 EXPECT_EQ(GL_INVALID_OPERATION, CheckError());
3512 }
3513
3269 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) { 3514 TEST_F(GLES2ImplementationManualInitTest, LoseContextOnOOM) {
3270 ContextInitOptions init_options; 3515 ContextInitOptions init_options;
3271 init_options.lose_context_when_out_of_memory = true; 3516 init_options.lose_context_when_out_of_memory = true;
3272 ASSERT_TRUE(Initialize(init_options)); 3517 ASSERT_TRUE(Initialize(init_options));
3273 3518
3274 struct Cmds { 3519 struct Cmds {
3275 cmds::LoseContextCHROMIUM cmd; 3520 cmds::LoseContextCHROMIUM cmd;
3276 }; 3521 };
3277 3522
3278 GLsizei max = std::numeric_limits<GLsizei>::max(); 3523 GLsizei max = std::numeric_limits<GLsizei>::max();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) { 3563 TEST_F(GLES2ImplementationManualInitTest, FailInitOnTransferBufferFail) {
3319 ContextInitOptions init_options; 3564 ContextInitOptions init_options;
3320 init_options.transfer_buffer_initialize_fail = true; 3565 init_options.transfer_buffer_initialize_fail = true;
3321 EXPECT_FALSE(Initialize(init_options)); 3566 EXPECT_FALSE(Initialize(init_options));
3322 } 3567 }
3323 3568
3324 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" 3569 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
3325 3570
3326 } // namespace gles2 3571 } // namespace gles2
3327 } // namespace gpu 3572 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698