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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 using namespace cmds; 55 using namespace cmds;
56 56
57 void GLES2DecoderRGBBackbufferTest::SetUp() { 57 void GLES2DecoderRGBBackbufferTest::SetUp() {
58 // Test codepath with workaround clear_alpha_in_readpixels because 58 // Test codepath with workaround clear_alpha_in_readpixels because
59 // ReadPixelsEmulator emulates the incorrect driver behavior. 59 // ReadPixelsEmulator emulates the incorrect driver behavior.
60 base::CommandLine command_line(0, NULL); 60 base::CommandLine command_line(0, NULL);
61 command_line.AppendSwitchASCII( 61 command_line.AppendSwitchASCII(
62 switches::kGpuDriverBugWorkarounds, 62 switches::kGpuDriverBugWorkarounds,
63 base::IntToString(gpu::CLEAR_ALPHA_IN_READPIXELS)); 63 base::IntToString(gpu::CLEAR_ALPHA_IN_READPIXELS));
64 InitState init; 64 InitState init;
65 init.gl_version = "3.0";
66 init.bind_generates_resource = true; 65 init.bind_generates_resource = true;
67 InitDecoderWithCommandLine(init, &command_line); 66 InitDecoderWithCommandLine(init, &command_line);
68 SetupDefaultProgram(); 67 SetupDefaultProgram();
69 } 68 }
70 69
71 // Override default setup so nothing gets setup. 70 // Override default setup so nothing gets setup.
72 void GLES2DecoderManualInitTest::SetUp() { 71 void GLES2DecoderManualInitTest::SetUp() {
73 } 72 }
74 73
75 void GLES2DecoderManualInitTest::EnableDisableTest(GLenum cap, 74 void GLES2DecoderManualInitTest::EnableDisableTest(GLenum cap,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 TEST_P(GLES2DecoderTest, IsTexture) { 260 TEST_P(GLES2DecoderTest, IsTexture) {
262 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 261 EXPECT_FALSE(DoIsTexture(client_texture_id_));
263 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 262 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
264 EXPECT_TRUE(DoIsTexture(client_texture_id_)); 263 EXPECT_TRUE(DoIsTexture(client_texture_id_));
265 DoDeleteTexture(client_texture_id_, kServiceTextureId); 264 DoDeleteTexture(client_texture_id_, kServiceTextureId);
266 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 265 EXPECT_FALSE(DoIsTexture(client_texture_id_));
267 } 266 }
268 267
269 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { 268 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) {
270 InitState init; 269 InitState init;
271 init.gl_version = "3.0";
272 InitDecoder(init); 270 InitDecoder(init);
273 271
274 BindTexture cmd1; 272 BindTexture cmd1;
275 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); 273 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId);
276 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 274 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
277 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 275 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
278 276
279 BindBuffer cmd2; 277 BindBuffer cmd2;
280 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); 278 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId);
281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 279 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 disable_cmd.Init(state); 695 disable_cmd.Init(state);
698 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); 696 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd));
699 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); 697 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd));
700 EXPECT_EQ(0u, *result); 698 EXPECT_EQ(0u, *result);
701 } 699 }
702 } 700 }
703 701
704 TEST_P(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { 702 TEST_P(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) {
705 InitState init; 703 InitState init;
706 init.extensions = "GL_ARB_texture_rectangle"; 704 init.extensions = "GL_ARB_texture_rectangle";
707 init.gl_version = "3.0";
708 init.bind_generates_resource = true; 705 init.bind_generates_resource = true;
709 InitDecoder(init); 706 InitDecoder(init);
710 707
711 Texture* texture = GetTexture(client_texture_id_)->texture(); 708 Texture* texture = GetTexture(client_texture_id_)->texture();
712 EXPECT_TRUE(texture != NULL); 709 EXPECT_TRUE(texture != NULL);
713 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); 710 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM);
714 711
715 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 712 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
716 713
717 TexParameteri cmd; 714 TexParameteri cmd;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 std::map<Pool, PoolInfo> pool_infos_; 770 std::map<Pool, PoolInfo> pool_infos_;
774 }; 771 };
775 772
776 } // anonymous namespace. 773 } // anonymous namespace.
777 774
778 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { 775 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) {
779 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 776 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
780 new SizeOnlyMemoryTracker(); 777 new SizeOnlyMemoryTracker();
781 set_memory_tracker(memory_tracker.get()); 778 set_memory_tracker(memory_tracker.get());
782 InitState init; 779 InitState init;
783 init.gl_version = "3.0";
784 init.bind_generates_resource = true; 780 init.bind_generates_resource = true;
785 InitDecoder(init); 781 InitDecoder(init);
786 // Expect that initial size - size is 0. 782 // Expect that initial size - size is 0.
787 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 783 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
788 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); 784 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
789 } 785 }
790 786
791 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { 787 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) {
792 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 788 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
793 new SizeOnlyMemoryTracker(); 789 new SizeOnlyMemoryTracker();
794 set_memory_tracker(memory_tracker.get()); 790 set_memory_tracker(memory_tracker.get());
795 InitState init; 791 InitState init;
796 init.gl_version = "3.0";
797 init.bind_generates_resource = true; 792 init.bind_generates_resource = true;
798 InitDecoder(init); 793 InitDecoder(init);
799 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 794 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
800 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 795 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
801 .WillOnce(Return(true)) 796 .WillOnce(Return(true))
802 .RetiresOnSaturation(); 797 .RetiresOnSaturation();
803 DoTexImage2D(GL_TEXTURE_2D, 798 DoTexImage2D(GL_TEXTURE_2D,
804 0, 799 0,
805 GL_RGBA, 800 GL_RGBA,
806 8, 801 8,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 838 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
844 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 839 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
845 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 840 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
846 } 841 }
847 842
848 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { 843 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) {
849 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 844 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
850 new SizeOnlyMemoryTracker(); 845 new SizeOnlyMemoryTracker();
851 set_memory_tracker(memory_tracker.get()); 846 set_memory_tracker(memory_tracker.get());
852 InitState init; 847 InitState init;
853 init.gl_version = "3.0";
854 init.bind_generates_resource = true; 848 init.bind_generates_resource = true;
855 InitDecoder(init); 849 InitDecoder(init);
856 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 850 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
857 // Check we get out of memory and no call to glTexStorage2DEXT 851 // Check we get out of memory and no call to glTexStorage2DEXT
858 // if Ensure fails. 852 // if Ensure fails.
859 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 853 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
860 .WillOnce(Return(false)) 854 .WillOnce(Return(false))
861 .RetiresOnSaturation(); 855 .RetiresOnSaturation();
862 TexStorage2DEXT cmd; 856 TexStorage2DEXT cmd;
863 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); 857 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4);
864 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 858 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
865 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 859 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
866 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 860 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
867 } 861 }
868 862
869 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { 863 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) {
870 GLenum target = GL_TEXTURE_2D; 864 GLenum target = GL_TEXTURE_2D;
871 GLint level = 0; 865 GLint level = 0;
872 GLenum internal_format = GL_RGBA; 866 GLenum internal_format = GL_RGBA;
873 GLsizei width = 4; 867 GLsizei width = 4;
874 GLsizei height = 8; 868 GLsizei height = 8;
875 GLint border = 0; 869 GLint border = 0;
876 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 870 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
877 new SizeOnlyMemoryTracker(); 871 new SizeOnlyMemoryTracker();
878 set_memory_tracker(memory_tracker.get()); 872 set_memory_tracker(memory_tracker.get());
879 InitState init; 873 InitState init;
880 init.gl_version = "3.0";
881 init.has_alpha = true; 874 init.has_alpha = true;
882 init.request_alpha = true; 875 init.request_alpha = true;
883 init.bind_generates_resource = true; 876 init.bind_generates_resource = true;
884 InitDecoder(init); 877 InitDecoder(init);
885 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 878 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
886 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 879 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
887 .WillOnce(Return(true)) 880 .WillOnce(Return(true))
888 .RetiresOnSaturation(); 881 .RetiresOnSaturation();
889 EXPECT_CALL(*gl_, GetError()) 882 EXPECT_CALL(*gl_, GetError())
890 .WillOnce(Return(GL_NO_ERROR)) 883 .WillOnce(Return(GL_NO_ERROR))
(...skipping 16 matching lines...) Expand all
907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 900 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
908 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 901 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
909 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 902 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
910 } 903 }
911 904
912 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { 905 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) {
913 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 906 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
914 new SizeOnlyMemoryTracker(); 907 new SizeOnlyMemoryTracker();
915 set_memory_tracker(memory_tracker.get()); 908 set_memory_tracker(memory_tracker.get());
916 InitState init; 909 InitState init;
917 init.gl_version = "3.0";
918 init.bind_generates_resource = true; 910 init.bind_generates_resource = true;
919 InitDecoder(init); 911 InitDecoder(init);
920 DoBindRenderbuffer( 912 DoBindRenderbuffer(
921 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId); 913 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId);
922 EnsureRenderbufferBound(false); 914 EnsureRenderbufferBound(false);
923 EXPECT_CALL(*gl_, GetError()) 915 EXPECT_CALL(*gl_, GetError())
924 .WillOnce(Return(GL_NO_ERROR)) 916 .WillOnce(Return(GL_NO_ERROR))
925 .WillOnce(Return(GL_NO_ERROR)) 917 .WillOnce(Return(GL_NO_ERROR))
926 .RetiresOnSaturation(); 918 .RetiresOnSaturation();
927 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 919 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
(...skipping 15 matching lines...) Expand all
943 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 935 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
944 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 936 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
945 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 937 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
946 } 938 }
947 939
948 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { 940 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) {
949 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 941 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
950 new SizeOnlyMemoryTracker(); 942 new SizeOnlyMemoryTracker();
951 set_memory_tracker(memory_tracker.get()); 943 set_memory_tracker(memory_tracker.get());
952 InitState init; 944 InitState init;
953 init.gl_version = "3.0";
954 init.bind_generates_resource = true; 945 init.bind_generates_resource = true;
955 InitDecoder(init); 946 InitDecoder(init);
956 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); 947 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
957 EXPECT_CALL(*gl_, GetError()) 948 EXPECT_CALL(*gl_, GetError())
958 .WillOnce(Return(GL_NO_ERROR)) 949 .WillOnce(Return(GL_NO_ERROR))
959 .WillOnce(Return(GL_NO_ERROR)) 950 .WillOnce(Return(GL_NO_ERROR))
960 .RetiresOnSaturation(); 951 .RetiresOnSaturation();
961 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 952 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
962 .WillOnce(Return(true)) 953 .WillOnce(Return(true))
963 .RetiresOnSaturation(); 954 .RetiresOnSaturation();
(...skipping 18 matching lines...) Expand all
982 TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) { 973 TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) {
983 const GLenum kTarget = GL_TEXTURE_2D; 974 const GLenum kTarget = GL_TEXTURE_2D;
984 const GLint kLevel = 0; 975 const GLint kLevel = 0;
985 const GLenum kInternalFormat = GL_RGBA; 976 const GLenum kInternalFormat = GL_RGBA;
986 const GLenum kSizedInternalFormat = GL_RGBA8; 977 const GLenum kSizedInternalFormat = GL_RGBA8;
987 const GLsizei kWidth = 4; 978 const GLsizei kWidth = 4;
988 const GLsizei kHeight = 8; 979 const GLsizei kHeight = 8;
989 const GLint kBorder = 0; 980 const GLint kBorder = 0;
990 InitState init; 981 InitState init;
991 init.extensions = "GL_EXT_texture_storage"; 982 init.extensions = "GL_EXT_texture_storage";
992 init.gl_version = "3.0";
993 init.has_alpha = true; 983 init.has_alpha = true;
994 init.request_alpha = true; 984 init.request_alpha = true;
995 init.bind_generates_resource = true; 985 init.bind_generates_resource = true;
996 InitDecoder(init); 986 InitDecoder(init);
997 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 987 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
998 988
999 // CopyTexImage2D will call arbitrary amount of GetErrors. 989 // CopyTexImage2D will call arbitrary amount of GetErrors.
1000 EXPECT_CALL(*gl_, GetError()) 990 EXPECT_CALL(*gl_, GetError())
1001 .Times(AtLeast(1)); 991 .Times(AtLeast(1));
1002 992
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); 1148 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool());
1159 1149
1160 INSTANTIATE_TEST_CASE_P(Service, 1150 INSTANTIATE_TEST_CASE_P(Service,
1161 GLES2DecoderRGBBackbufferTest, 1151 GLES2DecoderRGBBackbufferTest,
1162 ::testing::Bool()); 1152 ::testing::Bool());
1163 1153
1164 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool()); 1154 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderDoCommandsTest, ::testing::Bool());
1165 1155
1166 } // namespace gles2 1156 } // namespace gles2
1167 } // namespace gpu 1157 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698