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

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

Issue 9309047: Swizzle Uniform Locations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unsigned math Created 8 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 | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 kClient1Id, kService1Id); 118 kClient1Id, kService1Id);
119 ASSERT_TRUE(info1); 119 ASSERT_TRUE(info1);
120 EXPECT_EQ(kService1Id, info1->service_id()); 120 EXPECT_EQ(kService1Id, info1->service_id());
121 EXPECT_FALSE(info1->InUse()); 121 EXPECT_FALSE(info1->InUse());
122 EXPECT_FALSE(info1->IsValid()); 122 EXPECT_FALSE(info1->IsValid());
123 EXPECT_FALSE(info1->IsDeleted()); 123 EXPECT_FALSE(info1->IsDeleted());
124 EXPECT_FALSE(info1->CanLink()); 124 EXPECT_FALSE(info1->CanLink());
125 EXPECT_TRUE(info1->log_info() == NULL); 125 EXPECT_TRUE(info1->log_info() == NULL);
126 } 126 }
127 127
128 TEST_F(ProgramManagerTest, SwizzleLocation) {
129 GLint power = 1;
130 for (GLint p = 0; p < 5; ++p, power *= 10) {
131 GLint limit = power * 20 + 1;
132 for (GLint ii = -limit; ii < limit; ii += power) {
133 GLint s = manager_.SwizzleLocation(ii);
134 EXPECT_EQ(ii, manager_.UnswizzleLocation(s));
135 }
136 }
137 }
138
128 class ProgramManagerWithShaderTest : public testing::Test { 139 class ProgramManagerWithShaderTest : public testing::Test {
129 public: 140 public:
130 ProgramManagerWithShaderTest() 141 ProgramManagerWithShaderTest()
131 : program_info_(NULL) { 142 : program_info_(NULL) {
132 } 143 }
133 144
134 ~ProgramManagerWithShaderTest() { 145 ~ProgramManagerWithShaderTest() {
135 manager_.Destroy(false); 146 manager_.Destroy(false);
136 shader_manager_.Destroy(false); 147 shader_manager_.Destroy(false);
137 } 148 }
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 EXPECT_TRUE(info2 == NULL); 852 EXPECT_TRUE(info2 == NULL);
842 EXPECT_FALSE(vshader->InUse()); 853 EXPECT_FALSE(vshader->InUse());
843 EXPECT_FALSE(fshader->InUse()); 854 EXPECT_FALSE(fshader->InUse());
844 } 855 }
845 856
846 TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetProgramInfo) { 857 TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetProgramInfo) {
847 CommonDecoder::Bucket bucket; 858 CommonDecoder::Bucket bucket;
848 const ProgramManager::ProgramInfo* program_info = 859 const ProgramManager::ProgramInfo* program_info =
849 manager_.GetProgramInfo(kClientProgramId); 860 manager_.GetProgramInfo(kClientProgramId);
850 ASSERT_TRUE(program_info != NULL); 861 ASSERT_TRUE(program_info != NULL);
851 program_info->GetProgramInfo(&bucket); 862 program_info->GetProgramInfo(&manager_, &bucket);
852 ProgramInfoHeader* header = 863 ProgramInfoHeader* header =
853 bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader)); 864 bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader));
854 ASSERT_TRUE(header != NULL); 865 ASSERT_TRUE(header != NULL);
855 EXPECT_EQ(1u, header->link_status); 866 EXPECT_EQ(1u, header->link_status);
856 EXPECT_EQ(arraysize(kAttribs), header->num_attribs); 867 EXPECT_EQ(arraysize(kAttribs), header->num_attribs);
857 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms); 868 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms);
858 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>( 869 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>(
859 sizeof(*header), 870 sizeof(*header),
860 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); 871 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms));
861 ASSERT_TRUE(inputs != NULL); 872 ASSERT_TRUE(inputs != NULL);
(...skipping 16 matching lines...) Expand all
878 } 889 }
879 // TODO(gman): Don't assume these are in order. 890 // TODO(gman): Don't assume these are in order.
880 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { 891 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) {
881 const UniformInfo& expected = kUniforms[ii]; 892 const UniformInfo& expected = kUniforms[ii];
882 EXPECT_EQ(expected.size, input->size); 893 EXPECT_EQ(expected.size, input->size);
883 EXPECT_EQ(expected.type, input->type); 894 EXPECT_EQ(expected.type, input->type);
884 const int32* locations = bucket.GetDataAs<const int32*>( 895 const int32* locations = bucket.GetDataAs<const int32*>(
885 input->location_offset, sizeof(int32) * input->size); 896 input->location_offset, sizeof(int32) * input->size);
886 ASSERT_TRUE(locations != NULL); 897 ASSERT_TRUE(locations != NULL);
887 for (int32 jj = 0; jj < input->size; ++jj) { 898 for (int32 jj = 0; jj < input->size; ++jj) {
888 EXPECT_EQ(expected.location + jj * 2, locations[jj]); 899 EXPECT_EQ(manager_.SwizzleLocation(expected.location + jj * 2),
900 locations[jj]);
889 } 901 }
890 const char* name_buf = bucket.GetDataAs<const char*>( 902 const char* name_buf = bucket.GetDataAs<const char*>(
891 input->name_offset, input->name_length); 903 input->name_offset, input->name_length);
892 ASSERT_TRUE(name_buf != NULL); 904 ASSERT_TRUE(name_buf != NULL);
893 std::string name(name_buf, input->name_length); 905 std::string name(name_buf, input->name_length);
894 EXPECT_STREQ(expected.good_name, name.c_str()); 906 EXPECT_STREQ(expected.good_name, name.c_str());
895 ++input; 907 ++input;
896 } 908 }
897 EXPECT_EQ(header->num_attribs + header->num_uniforms, 909 EXPECT_EQ(header->num_attribs + header->num_uniforms,
898 static_cast<uint32>(input - inputs)); 910 static_cast<uint32>(input - inputs));
899 } 911 }
900 912
901 } // namespace gles2 913 } // namespace gles2
902 } // namespace gpu 914 } // namespace gpu
903 915
904 916
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698