OLD | NEW |
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> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 uint32_t ComputeOffset(const void* start, const void* position) { | 52 uint32_t ComputeOffset(const void* start, const void* position) { |
53 return static_cast<const uint8_t*>(position) - | 53 return static_cast<const uint8_t*>(position) - |
54 static_cast<const uint8_t*>(start); | 54 static_cast<const uint8_t*>(start); |
55 } | 55 } |
56 | 56 |
57 } // namespace anonymous | 57 } // namespace anonymous |
58 | 58 |
59 class ProgramManagerTestBase : public GpuServiceTest { | 59 class ProgramManagerTestBase : public GpuServiceTest { |
60 protected: | 60 protected: |
61 virtual void SetupProgramManager() { | 61 virtual void SetupProgramManager() { |
62 manager_.reset(new ProgramManager(nullptr, kMaxVaryingVectors, | 62 manager_.reset(new ProgramManager( |
63 kMaxDrawBuffers, | 63 nullptr, kMaxVaryingVectors, kMaxDrawBuffers, kMaxDualSourceDrawBuffers, |
64 kMaxDualSourceDrawBuffers, | 64 kMaxVertexAttribs, gpu_preferences_, feature_info_.get(), nullptr)); |
65 kMaxVertexAttribs, | |
66 gpu_preferences_, | |
67 feature_info_.get())); | |
68 } | 65 } |
69 void SetUpBase(const char* gl_version, | 66 void SetUpBase(const char* gl_version, |
70 const char* gl_extensions, | 67 const char* gl_extensions, |
71 FeatureInfo* feature_info = nullptr) { | 68 FeatureInfo* feature_info = nullptr) { |
72 GpuServiceTest::SetUpWithGLVersion(gl_version, gl_extensions); | 69 GpuServiceTest::SetUpWithGLVersion(gl_version, gl_extensions); |
73 if (!feature_info) | 70 if (!feature_info) |
74 feature_info = new FeatureInfo(); | 71 feature_info = new FeatureInfo(); |
75 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 72 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
76 gl_.get(), gl_extensions, "", gl_version, feature_info->context_type()); | 73 gl_.get(), gl_extensions, "", gl_version, feature_info->context_type()); |
77 feature_info->InitializeForTesting(); | 74 feature_info->InitializeForTesting(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 EXPECT_CALL(*gl_, DeleteProgram(kService1Id)) | 121 EXPECT_CALL(*gl_, DeleteProgram(kService1Id)) |
125 .Times(1) | 122 .Times(1) |
126 .RetiresOnSaturation(); | 123 .RetiresOnSaturation(); |
127 manager_->Destroy(true); | 124 manager_->Destroy(true); |
128 // Check the resources were released. | 125 // Check the resources were released. |
129 program1 = manager_->GetProgram(kClient1Id); | 126 program1 = manager_->GetProgram(kClient1Id); |
130 ASSERT_TRUE(program1 == NULL); | 127 ASSERT_TRUE(program1 == NULL); |
131 } | 128 } |
132 | 129 |
133 TEST_F(ProgramManagerTest, DeleteBug) { | 130 TEST_F(ProgramManagerTest, DeleteBug) { |
134 ShaderManager shader_manager; | 131 ShaderManager shader_manager(nullptr); |
135 const GLuint kClient1Id = 1; | 132 const GLuint kClient1Id = 1; |
136 const GLuint kClient2Id = 2; | 133 const GLuint kClient2Id = 2; |
137 const GLuint kService1Id = 11; | 134 const GLuint kService1Id = 11; |
138 const GLuint kService2Id = 12; | 135 const GLuint kService2Id = 12; |
139 // Check we can create program. | 136 // Check we can create program. |
140 scoped_refptr<Program> program1( | 137 scoped_refptr<Program> program1( |
141 manager_->CreateProgram(kClient1Id, kService1Id)); | 138 manager_->CreateProgram(kClient1Id, kService1Id)); |
142 scoped_refptr<Program> program2( | 139 scoped_refptr<Program> program2( |
143 manager_->CreateProgram(kClient2Id, kService2Id)); | 140 manager_->CreateProgram(kClient2Id, kService2Id)); |
144 // Check program got created. | 141 // Check program got created. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 static const char* kOutputVariable1Name; | 228 static const char* kOutputVariable1Name; |
232 static const GLint kOutputVariable1Size = 1; | 229 static const GLint kOutputVariable1Size = 1; |
233 static const GLenum kOutputVariable1Precision = GL_MEDIUM_FLOAT; | 230 static const GLenum kOutputVariable1Precision = GL_MEDIUM_FLOAT; |
234 static const bool kOutputVariable1StaticUse = true; | 231 static const bool kOutputVariable1StaticUse = true; |
235 static const GLint kOutputVariable1Location = -1; | 232 static const GLint kOutputVariable1Location = -1; |
236 static const GLenum kOutputVariable1Type = GL_FLOAT_VEC4; | 233 static const GLenum kOutputVariable1Type = GL_FLOAT_VEC4; |
237 | 234 |
238 static const size_t kNumAttribs; | 235 static const size_t kNumAttribs; |
239 static const size_t kNumUniforms; | 236 static const size_t kNumUniforms; |
240 | 237 |
| 238 ProgramManagerWithShaderTest() : shader_manager_(nullptr) {} |
| 239 |
241 protected: | 240 protected: |
242 typedef TestHelper::AttribInfo AttribInfo; | 241 typedef TestHelper::AttribInfo AttribInfo; |
243 typedef TestHelper::UniformInfo UniformInfo; | 242 typedef TestHelper::UniformInfo UniformInfo; |
244 | 243 |
245 typedef enum { | 244 typedef enum { |
246 kVarUniform, | 245 kVarUniform, |
247 kVarVarying, | 246 kVarVarying, |
248 kVarAttribute, | 247 kVarAttribute, |
249 kVarOutput, | 248 kVarOutput, |
250 } VarCategory; | 249 } VarCategory; |
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 public: | 2056 public: |
2058 static const GLuint kClientProgramId = 1; | 2057 static const GLuint kClientProgramId = 1; |
2059 static const GLuint kServiceProgramId = 10; | 2058 static const GLuint kServiceProgramId = 10; |
2060 static const GLuint kVertexShaderClientId = 2; | 2059 static const GLuint kVertexShaderClientId = 2; |
2061 static const GLuint kFragmentShaderClientId = 20; | 2060 static const GLuint kFragmentShaderClientId = 20; |
2062 static const GLuint kVertexShaderServiceId = 3; | 2061 static const GLuint kVertexShaderServiceId = 3; |
2063 static const GLuint kFragmentShaderServiceId = 30; | 2062 static const GLuint kFragmentShaderServiceId = 30; |
2064 | 2063 |
2065 ProgramManagerWithCacheTest() | 2064 ProgramManagerWithCacheTest() |
2066 : cache_(new MockProgramCache()), | 2065 : cache_(new MockProgramCache()), |
2067 vertex_shader_(NULL), | 2066 vertex_shader_(nullptr), |
2068 fragment_shader_(NULL), | 2067 fragment_shader_(nullptr), |
2069 program_(NULL) { | 2068 program_(nullptr), |
2070 } | 2069 shader_manager_(nullptr) {} |
2071 | 2070 |
2072 protected: | 2071 protected: |
2073 void SetupProgramManager() override { | 2072 void SetupProgramManager() override { |
2074 manager_.reset(new ProgramManager(cache_.get(), kMaxVaryingVectors, | 2073 manager_.reset( |
2075 kMaxDrawBuffers, | 2074 new ProgramManager(cache_.get(), kMaxVaryingVectors, kMaxDrawBuffers, |
2076 kMaxDualSourceDrawBuffers, | 2075 kMaxDualSourceDrawBuffers, kMaxVertexAttribs, |
2077 kMaxVertexAttribs, | 2076 gpu_preferences_, feature_info_.get(), nullptr)); |
2078 gpu_preferences_, | |
2079 feature_info_.get())); | |
2080 } | 2077 } |
2081 | 2078 |
2082 void SetUp() override { | 2079 void SetUp() override { |
2083 ProgramManagerTestBase::SetUp(); | 2080 ProgramManagerTestBase::SetUp(); |
2084 | 2081 |
2085 vertex_shader_ = shader_manager_.CreateShader( | 2082 vertex_shader_ = shader_manager_.CreateShader( |
2086 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); | 2083 kVertexShaderClientId, kVertexShaderServiceId, GL_VERTEX_SHADER); |
2087 fragment_shader_ = shader_manager_.CreateShader( | 2084 fragment_shader_ = shader_manager_.CreateShader( |
2088 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); | 2085 kFragmentShaderClientId, kFragmentShaderServiceId, GL_FRAGMENT_SHADER); |
2089 ASSERT_TRUE(vertex_shader_ != NULL); | 2086 ASSERT_TRUE(vertex_shader_ != NULL); |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 ProgramManagerDualSourceBlendingES2Test, | 2518 ProgramManagerDualSourceBlendingES2Test, |
2522 testing::Values( | 2519 testing::Values( |
2523 make_gl_ext_tuple("3.2", | 2520 make_gl_ext_tuple("3.2", |
2524 "GL_ARB_draw_buffers GL_ARB_blend_func_extended " | 2521 "GL_ARB_draw_buffers GL_ARB_blend_func_extended " |
2525 "GL_ARB_program_interface_query"), | 2522 "GL_ARB_program_interface_query"), |
2526 make_gl_ext_tuple("opengl es 3.1", | 2523 make_gl_ext_tuple("opengl es 3.1", |
2527 "GL_EXT_draw_buffers GL_EXT_blend_func_extended"))); | 2524 "GL_EXT_draw_buffers GL_EXT_blend_func_extended"))); |
2528 | 2525 |
2529 } // namespace gles2 | 2526 } // namespace gles2 |
2530 } // namespace gpu | 2527 } // namespace gpu |
OLD | NEW |