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

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

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 12 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/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <algorithm> 10 #include <algorithm>
8 11
9 #include "base/command_line.h" 12 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
13 #include "gpu/command_buffer/common/gles2_cmd_format.h" 16 #include "gpu/command_buffer/common/gles2_cmd_format.h"
14 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 17 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
15 #include "gpu/command_buffer/service/common_decoder.h" 18 #include "gpu/command_buffer/service/common_decoder.h"
16 #include "gpu/command_buffer/service/feature_info.h" 19 #include "gpu/command_buffer/service/feature_info.h"
(...skipping 14 matching lines...) Expand all
31 using ::testing::Return; 34 using ::testing::Return;
32 using ::testing::ReturnRef; 35 using ::testing::ReturnRef;
33 using ::testing::SetArrayArgument; 36 using ::testing::SetArrayArgument;
34 using ::testing::SetArgPointee; 37 using ::testing::SetArgPointee;
35 using ::testing::StrEq; 38 using ::testing::StrEq;
36 39
37 namespace gpu { 40 namespace gpu {
38 namespace gles2 { 41 namespace gles2 {
39 42
40 namespace { 43 namespace {
41 const uint32 kMaxVaryingVectors = 8; 44 const uint32_t kMaxVaryingVectors = 8;
42 const uint32 kMaxDrawBuffers = 8; 45 const uint32_t kMaxDrawBuffers = 8;
43 const uint32 kMaxDualSourceDrawBuffers = 8; 46 const uint32_t kMaxDualSourceDrawBuffers = 8;
44 47
45 void ShaderCacheCb(const std::string& key, const std::string& shader) {} 48 void ShaderCacheCb(const std::string& key, const std::string& shader) {}
46 49
47 uint32 ComputeOffset(const void* start, const void* position) { 50 uint32_t ComputeOffset(const void* start, const void* position) {
48 return static_cast<const uint8*>(position) - 51 return static_cast<const uint8_t*>(position) -
49 static_cast<const uint8*>(start); 52 static_cast<const uint8_t*>(start);
50 } 53 }
51 54
52 } // namespace anonymous 55 } // namespace anonymous
53 56
54 class ProgramManagerTestBase : public GpuServiceTest { 57 class ProgramManagerTestBase : public GpuServiceTest {
55 protected: 58 protected:
56 virtual void SetupProgramManager() { 59 virtual void SetupProgramManager() {
57 manager_.reset(new ProgramManager(nullptr, kMaxVaryingVectors, 60 manager_.reset(new ProgramManager(nullptr, kMaxVaryingVectors,
58 kMaxDualSourceDrawBuffers, 61 kMaxDualSourceDrawBuffers,
59 feature_info_.get())); 62 feature_info_.get()));
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 ASSERT_TRUE(header != NULL); 1058 ASSERT_TRUE(header != NULL);
1056 EXPECT_EQ(1u, header->link_status); 1059 EXPECT_EQ(1u, header->link_status);
1057 EXPECT_EQ(arraysize(kAttribs), header->num_attribs); 1060 EXPECT_EQ(arraysize(kAttribs), header->num_attribs);
1058 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms); 1061 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms);
1059 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>( 1062 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>(
1060 sizeof(*header), 1063 sizeof(*header),
1061 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); 1064 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms));
1062 ASSERT_TRUE(inputs != NULL); 1065 ASSERT_TRUE(inputs != NULL);
1063 const ProgramInput* input = inputs; 1066 const ProgramInput* input = inputs;
1064 // TODO(gman): Don't assume these are in order. 1067 // TODO(gman): Don't assume these are in order.
1065 for (uint32 ii = 0; ii < header->num_attribs; ++ii) { 1068 for (uint32_t ii = 0; ii < header->num_attribs; ++ii) {
1066 const AttribInfo& expected = kAttribs[ii]; 1069 const AttribInfo& expected = kAttribs[ii];
1067 EXPECT_EQ(expected.size, input->size); 1070 EXPECT_EQ(expected.size, input->size);
1068 EXPECT_EQ(expected.type, input->type); 1071 EXPECT_EQ(expected.type, input->type);
1069 const int32* location = bucket.GetDataAs<const int32*>( 1072 const int32_t* location = bucket.GetDataAs<const int32_t*>(
1070 input->location_offset, sizeof(int32)); 1073 input->location_offset, sizeof(int32_t));
1071 ASSERT_TRUE(location != NULL); 1074 ASSERT_TRUE(location != NULL);
1072 EXPECT_EQ(expected.location, *location); 1075 EXPECT_EQ(expected.location, *location);
1073 const char* name_buf = bucket.GetDataAs<const char*>( 1076 const char* name_buf = bucket.GetDataAs<const char*>(
1074 input->name_offset, input->name_length); 1077 input->name_offset, input->name_length);
1075 ASSERT_TRUE(name_buf != NULL); 1078 ASSERT_TRUE(name_buf != NULL);
1076 std::string name(name_buf, input->name_length); 1079 std::string name(name_buf, input->name_length);
1077 EXPECT_STREQ(expected.name, name.c_str()); 1080 EXPECT_STREQ(expected.name, name.c_str());
1078 ++input; 1081 ++input;
1079 } 1082 }
1080 // TODO(gman): Don't assume these are in order. 1083 // TODO(gman): Don't assume these are in order.
1081 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { 1084 for (uint32_t ii = 0; ii < header->num_uniforms; ++ii) {
1082 const UniformInfo& expected = kUniforms[ii]; 1085 const UniformInfo& expected = kUniforms[ii];
1083 EXPECT_EQ(expected.size, input->size); 1086 EXPECT_EQ(expected.size, input->size);
1084 EXPECT_EQ(expected.type, input->type); 1087 EXPECT_EQ(expected.type, input->type);
1085 const int32* locations = bucket.GetDataAs<const int32*>( 1088 const int32_t* locations = bucket.GetDataAs<const int32_t*>(
1086 input->location_offset, sizeof(int32) * input->size); 1089 input->location_offset, sizeof(int32_t) * input->size);
1087 ASSERT_TRUE(locations != NULL); 1090 ASSERT_TRUE(locations != NULL);
1088 for (int32 jj = 0; jj < input->size; ++jj) { 1091 for (int32_t jj = 0; jj < input->size; ++jj) {
1089 EXPECT_EQ( 1092 EXPECT_EQ(
1090 ProgramManager::MakeFakeLocation(expected.fake_location, jj), 1093 ProgramManager::MakeFakeLocation(expected.fake_location, jj),
1091 locations[jj]); 1094 locations[jj]);
1092 } 1095 }
1093 const char* name_buf = bucket.GetDataAs<const char*>( 1096 const char* name_buf = bucket.GetDataAs<const char*>(
1094 input->name_offset, input->name_length); 1097 input->name_offset, input->name_length);
1095 ASSERT_TRUE(name_buf != NULL); 1098 ASSERT_TRUE(name_buf != NULL);
1096 std::string name(name_buf, input->name_length); 1099 std::string name(name_buf, input->name_length);
1097 EXPECT_STREQ(expected.good_name, name.c_str()); 1100 EXPECT_STREQ(expected.good_name, name.c_str());
1098 ++input; 1101 ++input;
1099 } 1102 }
1100 EXPECT_EQ(header->num_attribs + header->num_uniforms, 1103 EXPECT_EQ(header->num_attribs + header->num_uniforms,
1101 static_cast<uint32>(input - inputs)); 1104 static_cast<uint32_t>(input - inputs));
1102 } 1105 }
1103 1106
1104 TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformBlocksNone) { 1107 TEST_F(ProgramManagerWithShaderTest, ProgramInfoGetUniformBlocksNone) {
1105 CommonDecoder::Bucket bucket; 1108 CommonDecoder::Bucket bucket;
1106 const Program* program = SetupDefaultProgram(); 1109 const Program* program = SetupDefaultProgram();
1107 ASSERT_TRUE(program != NULL); 1110 ASSERT_TRUE(program != NULL);
1108 // The program's previous link failed. 1111 // The program's previous link failed.
1109 EXPECT_CALL(*(gl_.get()), 1112 EXPECT_CALL(*(gl_.get()),
1110 GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _)) 1113 GetProgramiv(kServiceProgramId, GL_LINK_STATUS, _))
1111 .WillOnce(SetArgPointee<2>(GL_FALSE)) 1114 .WillOnce(SetArgPointee<2>(GL_FALSE))
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader)); 1490 bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader));
1488 ASSERT_TRUE(header != NULL); 1491 ASSERT_TRUE(header != NULL);
1489 EXPECT_EQ(1u, header->link_status); 1492 EXPECT_EQ(1u, header->link_status);
1490 EXPECT_EQ(arraysize(kAttribs), header->num_attribs); 1493 EXPECT_EQ(arraysize(kAttribs), header->num_attribs);
1491 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms); 1494 EXPECT_EQ(arraysize(kUniforms), header->num_uniforms);
1492 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>( 1495 const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>(
1493 sizeof(*header), 1496 sizeof(*header),
1494 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); 1497 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms));
1495 ASSERT_TRUE(inputs != NULL); 1498 ASSERT_TRUE(inputs != NULL);
1496 const ProgramInput* input = inputs + header->num_attribs; 1499 const ProgramInput* input = inputs + header->num_attribs;
1497 for (uint32 ii = 0; ii < header->num_uniforms; ++ii) { 1500 for (uint32_t ii = 0; ii < header->num_uniforms; ++ii) {
1498 const UniformInfo& expected = kUniforms[ii]; 1501 const UniformInfo& expected = kUniforms[ii];
1499 EXPECT_EQ(expected.size, input->size); 1502 EXPECT_EQ(expected.size, input->size);
1500 const int32* locations = bucket.GetDataAs<const int32*>( 1503 const int32_t* locations = bucket.GetDataAs<const int32_t*>(
1501 input->location_offset, sizeof(int32) * input->size); 1504 input->location_offset, sizeof(int32_t) * input->size);
1502 ASSERT_TRUE(locations != NULL); 1505 ASSERT_TRUE(locations != NULL);
1503 EXPECT_EQ( 1506 EXPECT_EQ(
1504 ProgramManager::MakeFakeLocation(expected.fake_location, 0), 1507 ProgramManager::MakeFakeLocation(expected.fake_location, 0),
1505 locations[0]); 1508 locations[0]);
1506 for (int32 jj = 1; jj < input->size; ++jj) 1509 for (int32_t jj = 1; jj < input->size; ++jj)
1507 EXPECT_EQ(-1, locations[jj]); 1510 EXPECT_EQ(-1, locations[jj]);
1508 ++input; 1511 ++input;
1509 } 1512 }
1510 } 1513 }
1511 1514
1512 TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) { 1515 TEST_F(ProgramManagerWithShaderTest, BindAttribLocationConflicts) {
1513 // Set up shader 1516 // Set up shader
1514 AttributeMap attrib_map; 1517 AttributeMap attrib_map;
1515 for (uint32 ii = 0; ii < kNumAttribs; ++ii) { 1518 for (uint32_t ii = 0; ii < kNumAttribs; ++ii) {
1516 attrib_map[kAttribs[ii].name] = TestHelper::ConstructAttribute( 1519 attrib_map[kAttribs[ii].name] = TestHelper::ConstructAttribute(
1517 kAttribs[ii].type, 1520 kAttribs[ii].type,
1518 kAttribs[ii].size, 1521 kAttribs[ii].size,
1519 GL_MEDIUM_FLOAT, 1522 GL_MEDIUM_FLOAT,
1520 kAttribStaticUse, 1523 kAttribStaticUse,
1521 kAttribs[ii].name); 1524 kAttribs[ii].name);
1522 } 1525 }
1523 const char kAttribMatName[] = "matAttrib"; 1526 const char kAttribMatName[] = "matAttrib";
1524 attrib_map[kAttribMatName] = TestHelper::ConstructAttribute( 1527 attrib_map[kAttribMatName] = TestHelper::ConstructAttribute(
1525 GL_FLOAT_MAT2, 1528 GL_FLOAT_MAT2,
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 ProgramManagerDualSourceBlendingES2Test, 2392 ProgramManagerDualSourceBlendingES2Test,
2390 testing::Values( 2393 testing::Values(
2391 make_gl_ext_tuple("3.2", 2394 make_gl_ext_tuple("3.2",
2392 "GL_ARB_draw_buffers GL_ARB_blend_func_extended " 2395 "GL_ARB_draw_buffers GL_ARB_blend_func_extended "
2393 "GL_ARB_program_interface_query"), 2396 "GL_ARB_program_interface_query"),
2394 make_gl_ext_tuple("opengl es 3.1", 2397 make_gl_ext_tuple("opengl es 3.1",
2395 "GL_EXT_draw_buffers GL_EXT_blend_func_extended"))); 2398 "GL_EXT_draw_buffers GL_EXT_blend_func_extended")));
2396 2399
2397 } // namespace gles2 2400 } // namespace gles2
2398 } // namespace gpu 2401 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.cc ('k') | gpu/command_buffer/service/query_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698