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

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

Issue 2852923004: Remove NameMap from shader translator and shader/program managers (Closed)
Patch Set: split CL Created 3 years, 7 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/shader_manager.h" 5 #include "gpu/command_buffer/service/shader_manager.h"
6 6
7 #include "gpu/command_buffer/service/gpu_service_test.h" 7 #include "gpu/command_buffer/service/gpu_service_test.h"
8 #include "gpu/command_buffer/service/mocks.h" 8 #include "gpu/command_buffer/service/mocks.h"
9 #include "gpu/command_buffer/service/test_helper.h" 9 #include "gpu/command_buffer/service/test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 VaryingMap varying_map; 189 VaryingMap varying_map;
190 varying_map[kVarying1Name] = TestHelper::ConstructVarying( 190 varying_map[kVarying1Name] = TestHelper::ConstructVarying(
191 kVarying1Type, kVarying1Size, kVarying1Precision, 191 kVarying1Type, kVarying1Size, kVarying1Precision,
192 kVarying1StaticUse, kVarying1Name); 192 kVarying1StaticUse, kVarying1Name);
193 OutputVariableList output_variable_list; 193 OutputVariableList output_variable_list;
194 output_variable_list.push_back(TestHelper::ConstructOutputVariable( 194 output_variable_list.push_back(TestHelper::ConstructOutputVariable(
195 kOutputVariable1Type, kOutputVariable1Size, kOutputVariable1Precision, 195 kOutputVariable1Type, kOutputVariable1Size, kOutputVariable1Precision,
196 kOutputVariable1StaticUse, kOutputVariable1Name)); 196 kOutputVariable1StaticUse, kOutputVariable1Name));
197 TestHelper::SetShaderStates( 197 TestHelper::SetShaderStates(
198 gl_.get(), shader1, true, &kLog, &kTranslatedSource, nullptr, &attrib_map, 198 gl_.get(), shader1, true, &kLog, &kTranslatedSource, nullptr, &attrib_map,
199 &uniform_map, &varying_map, nullptr, &output_variable_list, nullptr); 199 &uniform_map, &varying_map, nullptr, &output_variable_list);
200 EXPECT_TRUE(shader1->valid()); 200 EXPECT_TRUE(shader1->valid());
201 // When compilation succeeds, no log is recorded. 201 // When compilation succeeds, no log is recorded.
202 EXPECT_STREQ("", shader1->log_info().c_str()); 202 EXPECT_STREQ("", shader1->log_info().c_str());
203 EXPECT_STREQ(kClient1Source, shader1->last_compiled_source().c_str()); 203 EXPECT_STREQ(kClient1Source, shader1->last_compiled_source().c_str());
204 EXPECT_STREQ(kTranslatedSource.c_str(), shader1->translated_source().c_str()); 204 EXPECT_STREQ(kTranslatedSource.c_str(), shader1->translated_source().c_str());
205 205
206 // Check varying infos got copied. 206 // Check varying infos got copied.
207 EXPECT_EQ(attrib_map.size(), shader1->attrib_map().size()); 207 EXPECT_EQ(attrib_map.size(), shader1->attrib_map().size());
208 for (AttributeMap::const_iterator it = attrib_map.begin(); 208 for (AttributeMap::const_iterator it = attrib_map.begin();
209 it != attrib_map.end(); ++it) { 209 it != attrib_map.end(); ++it) {
210 const sh::Attribute* variable_info = shader1->GetAttribInfo(it->first); 210 const sh::Attribute* variable_info = shader1->GetAttribInfo(it->first);
211 ASSERT_TRUE(variable_info != NULL); 211 ASSERT_TRUE(variable_info != NULL);
212 EXPECT_EQ(it->second.type, variable_info->type); 212 EXPECT_EQ(it->second.type, variable_info->type);
213 EXPECT_EQ(it->second.arraySize, variable_info->arraySize); 213 EXPECT_EQ(it->second.arraySize, variable_info->arraySize);
214 EXPECT_EQ(it->second.precision, variable_info->precision); 214 EXPECT_EQ(it->second.precision, variable_info->precision);
215 EXPECT_EQ(it->second.staticUse, variable_info->staticUse); 215 EXPECT_EQ(it->second.staticUse, variable_info->staticUse);
216 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str()); 216 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str());
217 EXPECT_STREQ(it->second.name.c_str(),
218 shader1->GetOriginalNameFromHashedName(it->first)->c_str());
217 } 219 }
218 // Check uniform infos got copied. 220 // Check uniform infos got copied.
219 EXPECT_EQ(uniform_map.size(), shader1->uniform_map().size()); 221 EXPECT_EQ(uniform_map.size(), shader1->uniform_map().size());
220 for (UniformMap::const_iterator it = uniform_map.begin(); 222 for (UniformMap::const_iterator it = uniform_map.begin();
221 it != uniform_map.end(); ++it) { 223 it != uniform_map.end(); ++it) {
222 const sh::Uniform* variable_info = shader1->GetUniformInfo(it->first); 224 const sh::Uniform* variable_info = shader1->GetUniformInfo(it->first);
223 ASSERT_TRUE(variable_info != NULL); 225 ASSERT_TRUE(variable_info != NULL);
224 EXPECT_EQ(it->second.type, variable_info->type); 226 EXPECT_EQ(it->second.type, variable_info->type);
225 EXPECT_EQ(it->second.arraySize, variable_info->arraySize); 227 EXPECT_EQ(it->second.arraySize, variable_info->arraySize);
226 EXPECT_EQ(it->second.precision, variable_info->precision); 228 EXPECT_EQ(it->second.precision, variable_info->precision);
227 EXPECT_EQ(it->second.staticUse, variable_info->staticUse); 229 EXPECT_EQ(it->second.staticUse, variable_info->staticUse);
228 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str()); 230 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str());
231 EXPECT_STREQ(it->second.name.c_str(),
232 shader1->GetOriginalNameFromHashedName(it->first)->c_str());
229 } 233 }
230 // Check varying infos got copied. 234 // Check varying infos got copied.
231 EXPECT_EQ(varying_map.size(), shader1->varying_map().size()); 235 EXPECT_EQ(varying_map.size(), shader1->varying_map().size());
232 for (VaryingMap::const_iterator it = varying_map.begin(); 236 for (VaryingMap::const_iterator it = varying_map.begin();
233 it != varying_map.end(); ++it) { 237 it != varying_map.end(); ++it) {
234 const sh::Varying* variable_info = shader1->GetVaryingInfo(it->first); 238 const sh::Varying* variable_info = shader1->GetVaryingInfo(it->first);
235 ASSERT_TRUE(variable_info != NULL); 239 ASSERT_TRUE(variable_info != NULL);
236 EXPECT_EQ(it->second.type, variable_info->type); 240 EXPECT_EQ(it->second.type, variable_info->type);
237 EXPECT_EQ(it->second.arraySize, variable_info->arraySize); 241 EXPECT_EQ(it->second.arraySize, variable_info->arraySize);
238 EXPECT_EQ(it->second.precision, variable_info->precision); 242 EXPECT_EQ(it->second.precision, variable_info->precision);
239 EXPECT_EQ(it->second.staticUse, variable_info->staticUse); 243 EXPECT_EQ(it->second.staticUse, variable_info->staticUse);
240 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str()); 244 EXPECT_STREQ(it->second.name.c_str(), variable_info->name.c_str());
245 EXPECT_STREQ(it->second.name.c_str(),
246 shader1->GetOriginalNameFromHashedName(it->first)->c_str());
241 } 247 }
248 // TODO(kainino): Check interface block infos got copied.
Ken Russell (switch to Gerrit) 2017/05/03 22:52:48 What's the plan to address this TODO?
Kai Ninomiya 2017/05/03 23:02:34 I didn't have much of a plan except "not now becau
Ken Russell (switch to Gerrit) 2017/05/03 23:10:02 Could you please do this in a follow-on CL? It wil
242 // Check output variable infos got copied. 249 // Check output variable infos got copied.
243 EXPECT_EQ(output_variable_list.size(), 250 EXPECT_EQ(output_variable_list.size(),
244 shader1->output_variable_list().size()); 251 shader1->output_variable_list().size());
245 for (auto it = output_variable_list.begin(); it != output_variable_list.end(); 252 for (auto it = output_variable_list.begin(); it != output_variable_list.end();
246 ++it) { 253 ++it) {
247 const sh::OutputVariable* variable_info = 254 const sh::OutputVariable* variable_info =
248 shader1->GetOutputVariableInfo(it->mappedName); 255 shader1->GetOutputVariableInfo(it->mappedName);
249 ASSERT_TRUE(variable_info != nullptr); 256 ASSERT_TRUE(variable_info != nullptr);
250 EXPECT_EQ(it->type, variable_info->type); 257 EXPECT_EQ(it->type, variable_info->type);
251 EXPECT_EQ(it->arraySize, variable_info->arraySize); 258 EXPECT_EQ(it->arraySize, variable_info->arraySize);
252 EXPECT_EQ(it->precision, variable_info->precision); 259 EXPECT_EQ(it->precision, variable_info->precision);
253 EXPECT_EQ(it->staticUse, variable_info->staticUse); 260 EXPECT_EQ(it->staticUse, variable_info->staticUse);
254 EXPECT_STREQ(it->name.c_str(), variable_info->name.c_str()); 261 EXPECT_STREQ(it->name.c_str(), variable_info->name.c_str());
262 EXPECT_STREQ(
263 it->name.c_str(),
264 shader1->GetOriginalNameFromHashedName(it->mappedName)->c_str());
255 } 265 }
256 266
257 // Compile failure case. 267 // Compile failure case.
258 TestHelper::SetShaderStates(gl_.get(), shader1, false, &kLog, 268 TestHelper::SetShaderStates(
259 &kTranslatedSource, nullptr, &attrib_map, 269 gl_.get(), shader1, false, &kLog, &kTranslatedSource, nullptr,
260 &uniform_map, &varying_map, nullptr, 270 &attrib_map, &uniform_map, &varying_map, nullptr, &output_variable_list);
261 &output_variable_list, nullptr);
262 EXPECT_FALSE(shader1->valid()); 271 EXPECT_FALSE(shader1->valid());
263 EXPECT_STREQ(kLog.c_str(), shader1->log_info().c_str()); 272 EXPECT_STREQ(kLog.c_str(), shader1->log_info().c_str());
264 EXPECT_STREQ("", shader1->translated_source().c_str()); 273 EXPECT_STREQ("", shader1->translated_source().c_str());
265 EXPECT_TRUE(shader1->attrib_map().empty()); 274 EXPECT_TRUE(shader1->attrib_map().empty());
266 EXPECT_TRUE(shader1->uniform_map().empty()); 275 EXPECT_TRUE(shader1->uniform_map().empty());
267 EXPECT_TRUE(shader1->varying_map().empty()); 276 EXPECT_TRUE(shader1->varying_map().empty());
268 EXPECT_TRUE(shader1->output_variable_list().empty()); 277 EXPECT_TRUE(shader1->output_variable_list().empty());
269 } 278 }
270 279
271 TEST_F(ShaderManagerTest, ShaderInfoUseCount) { 280 TEST_F(ShaderManagerTest, ShaderInfoUseCount) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 EXPECT_CALL(*gl_, DeleteShader(kService1Id)) 321 EXPECT_CALL(*gl_, DeleteShader(kService1Id))
313 .Times(1) 322 .Times(1)
314 .RetiresOnSaturation(); 323 .RetiresOnSaturation();
315 manager_.Delete(shader1); // this should delete the shader. 324 manager_.Delete(shader1); // this should delete the shader.
316 shader2 = manager_.GetShader(kClient1Id); 325 shader2 = manager_.GetShader(kClient1Id);
317 EXPECT_TRUE(shader2 == NULL); 326 EXPECT_TRUE(shader2 == NULL);
318 } 327 }
319 328
320 } // namespace gles2 329 } // namespace gles2
321 } // namespace gpu 330 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698