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

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

Issue 660229: "/b/slave/chromium-rel-linux/build/src/gpu/command_buffer/client/gles2_demo_c... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 #include "gpu/command_buffer/common/gles2_cmd_format.h" 6 #include "gpu/command_buffer/common/gles2_cmd_format.h"
7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
8 #include "gpu/command_buffer/service/gl_mock.h" 8 #include "gpu/command_buffer/service/gl_mock.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
10 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 10 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 CompileShader cmd; 846 CompileShader cmd;
847 cmd.Init(kInvalidClientId); 847 cmd.Init(kInvalidClientId);
848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
849 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 849 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
850 cmd.Init(client_texture_id_); 850 cmd.Init(client_texture_id_);
851 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 851 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
852 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 852 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
853 } 853 }
854 854
855 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { 855 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) {
856 const uint32 kBucketId = 123;
857 const char kSource[] = "hello"; 856 const char kSource[] = "hello";
858 const uint32 kSourceSize = sizeof(kSource) - 1; 857 const uint32 kSourceSize = sizeof(kSource) - 1;
859 memcpy(shared_memory_address_, kSource, kSourceSize); 858 memcpy(shared_memory_address_, kSource, kSourceSize);
860 ShaderSource cmd; 859 ShaderSource cmd;
861 cmd.Init(client_shader_id_, 860 cmd.Init(client_shader_id_,
862 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 861 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
863 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 862 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
864 memset(shared_memory_address_, 0, kSourceSize); 863 memset(shared_memory_address_, 0, kSourceSize);
864 // TODO(gman): GetShaderSource has to change format so result is always set.
865 GetShaderSource get_cmd; 865 GetShaderSource get_cmd;
866 get_cmd.Init(client_shader_id_, kBucketId); 866 get_cmd.Init(client_shader_id_, kSourceSize + 1,
867 kSharedMemoryId, kSharedMemoryOffset,
868 kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize));
867 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); 869 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
868 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 870 EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>());
869 ASSERT_TRUE(bucket != NULL); 871 EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)),
870 EXPECT_EQ(kSourceSize + 1, bucket->size()); 872 kSource, kSourceSize));
871 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource,
872 bucket->size()));
873 } 873 }
874 874
875 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { 875 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) {
876 const char kSource[] = "hello"; 876 const char kSource[] = "hello";
877 const uint32 kSourceSize = sizeof(kSource) - 1; 877 const uint32 kSourceSize = sizeof(kSource) - 1;
878 memcpy(shared_memory_address_, kSource, kSourceSize); 878 memcpy(shared_memory_address_, kSource, kSourceSize);
879 ShaderSource cmd; 879 ShaderSource cmd;
880 cmd.Init(kInvalidClientId, 880 cmd.Init(kInvalidClientId,
881 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 881 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
882 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 882 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
883 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 883 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
884 cmd.Init(client_texture_id_, 884 cmd.Init(client_texture_id_,
885 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 885 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
887 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 887 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
888 cmd.Init(client_shader_id_, 888 cmd.Init(client_shader_id_,
889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize); 889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize);
890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
891 cmd.Init(client_shader_id_, 891 cmd.Init(client_shader_id_,
892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize); 892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize);
893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
894 cmd.Init(client_shader_id_, 894 cmd.Init(client_shader_id_,
895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); 895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
897 } 897 }
898 898
899 TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) { 899 TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) {
900 const uint32 kBucketId = 123;
901 const char kSource[] = "hello"; 900 const char kSource[] = "hello";
902 const uint32 kSourceSize = sizeof(kSource) - 1; 901 const uint32 kSourceSize = sizeof(kSource) - 1;
903 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); 902 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>();
904 cmd.Init(client_shader_id_, kSourceSize); 903 cmd.Init(client_shader_id_, kSourceSize);
905 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); 904 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize);
906 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); 905 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize));
907 memset(shared_memory_address_, 0, kSourceSize); 906 memset(shared_memory_address_, 0, kSourceSize);
908 // TODO(gman): GetShaderSource has to change format so result is always set. 907 // TODO(gman): GetShaderSource has to change format so result is always set.
909 GetShaderSource get_cmd; 908 GetShaderSource get_cmd;
910 get_cmd.Init(client_shader_id_, kBucketId); 909 get_cmd.Init(client_shader_id_, kSourceSize + 1,
910 kSharedMemoryId, kSharedMemoryOffset,
911 kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize));
911 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); 912 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
912 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 913 EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>());
913 ASSERT_TRUE(bucket != NULL); 914 EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)),
914 EXPECT_EQ(kSourceSize + 1, bucket->size()); 915 kSource, kSourceSize));
915 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource,
916 bucket->size()));
917 } 916 }
918 917
919 TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) { 918 TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) {
920 const char kSource[] = "hello"; 919 const char kSource[] = "hello";
921 const uint32 kSourceSize = sizeof(kSource) - 1; 920 const uint32 kSourceSize = sizeof(kSource) - 1;
922 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); 921 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>();
923 cmd.Init(kInvalidClientId, kSourceSize); 922 cmd.Init(kInvalidClientId, kSourceSize);
924 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); 923 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize);
925 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); 924 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize));
926 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 925 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 // TODO(gman): UseProgram 1037 // TODO(gman): UseProgram
1039 1038
1040 // TODO(gman): SwapBuffers 1039 // TODO(gman): SwapBuffers
1041 1040
1042 // TODO(gman): VertexAttribPointer 1041 // TODO(gman): VertexAttribPointer
1043 1042
1044 } // namespace gles2 1043 } // namespace gles2
1045 } // namespace gpu 1044 } // namespace gpu
1046 1045
1047 1046
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698