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

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

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

Powered by Google App Engine
This is Rietveld 408576698