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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 // Create attrib location to index map. | 348 // Create attrib location to index map. |
349 attrib_location_to_index_map_.resize(max_location + 1); | 349 attrib_location_to_index_map_.resize(max_location + 1); |
350 for (GLint ii = 0; ii <= max_location; ++ii) { | 350 for (GLint ii = 0; ii <= max_location; ++ii) { |
351 attrib_location_to_index_map_[ii] = -1; | 351 attrib_location_to_index_map_[ii] = -1; |
352 } | 352 } |
353 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { | 353 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { |
354 const VertexAttrib& info = attrib_infos_[ii]; | 354 const VertexAttrib& info = attrib_infos_[ii]; |
355 attrib_location_to_index_map_[info.location] = ii; | 355 attrib_location_to_index_map_[info.location] = ii; |
356 } | 356 } |
357 | 357 |
358 #if !defined(NDEBUG) | |
359 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
360 switches::kEnableGPUServiceLoggingGPU)) { | |
361 DLOG(INFO) << "----: attribs for service_id: " << service_id(); | |
362 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { | |
363 const VertexAttrib& info = attrib_infos_[ii]; | |
364 DLOG(INFO) << ii << ": loc = " << info.location | |
365 << ", size = " << info.size | |
366 << ", type = " << GLES2Util::GetStringEnum(info.type) | |
367 << ", name = " << info.name; | |
368 } | |
369 } | |
370 #endif | |
371 | |
372 max_len = 0; | 358 max_len = 0; |
373 GLint num_uniforms = 0; | 359 GLint num_uniforms = 0; |
374 glGetProgramiv(service_id_, GL_ACTIVE_UNIFORMS, &num_uniforms); | 360 glGetProgramiv(service_id_, GL_ACTIVE_UNIFORMS, &num_uniforms); |
375 glGetProgramiv(service_id_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_len); | 361 glGetProgramiv(service_id_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_len); |
376 name_buffer.reset(new char[max_len]); | 362 name_buffer.reset(new char[max_len]); |
377 | 363 |
378 // Reads all the names. | 364 // Reads all the names. |
379 std::vector<UniformData> uniform_data; | 365 std::vector<UniformData> uniform_data; |
380 for (GLint ii = 0; ii < num_uniforms; ++ii) { | 366 for (GLint ii = 0; ii < num_uniforms; ++ii) { |
381 GLsizei length = 0; | 367 GLsizei length = 0; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Assigns the uniforms that were not bound. | 412 // Assigns the uniforms that were not bound. |
427 for (size_t ii = 0; ii < uniform_data.size(); ++ii) { | 413 for (size_t ii = 0; ii < uniform_data.size(); ++ii) { |
428 const UniformData& data = uniform_data[ii]; | 414 const UniformData& data = uniform_data[ii]; |
429 if (!data.added) { | 415 if (!data.added) { |
430 AddUniformInfo( | 416 AddUniformInfo( |
431 data.size, data.type, data.location, -1, data.corrected_name, | 417 data.size, data.type, data.location, -1, data.corrected_name, |
432 data.original_name, &next_available_index); | 418 data.original_name, &next_available_index); |
433 } | 419 } |
434 } | 420 } |
435 | 421 |
436 #if !defined(NDEBUG) | |
437 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
438 switches::kEnableGPUServiceLoggingGPU)) { | |
439 DLOG(INFO) << "----: uniforms for service_id: " << service_id(); | |
440 for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { | |
441 const UniformInfo& info = uniform_infos_[ii]; | |
442 if (info.IsValid()) { | |
443 DLOG(INFO) << ii << ": loc = " << info.element_locations[0] | |
444 << ", size = " << info.size | |
445 << ", type = " << GLES2Util::GetStringEnum(info.type) | |
446 << ", name = " << info.name; | |
447 } | |
448 } | |
449 } | |
450 #endif | |
451 | |
452 valid_ = true; | 422 valid_ = true; |
453 } | 423 } |
454 | 424 |
455 void Program::ExecuteBindAttribLocationCalls() { | 425 void Program::ExecuteBindAttribLocationCalls() { |
456 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); | 426 for (LocationMap::const_iterator it = bind_attrib_location_map_.begin(); |
457 it != bind_attrib_location_map_.end(); ++it) { | 427 it != bind_attrib_location_map_.end(); ++it) { |
458 const std::string* mapped_name = GetAttribMappedName(it->first); | 428 const std::string* mapped_name = GetAttribMappedName(it->first); |
459 if (mapped_name && *mapped_name != it->first) | 429 if (mapped_name && *mapped_name != it->first) |
460 glBindAttribLocation(service_id_, it->second, mapped_name->c_str()); | 430 glBindAttribLocation(service_id_, it->second, mapped_name->c_str()); |
461 } | 431 } |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 program->ClearUniforms(&zero_); | 1324 program->ClearUniforms(&zero_); |
1355 } | 1325 } |
1356 } | 1326 } |
1357 | 1327 |
1358 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { | 1328 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { |
1359 return index + element * 0x10000; | 1329 return index + element * 0x10000; |
1360 } | 1330 } |
1361 | 1331 |
1362 } // namespace gles2 | 1332 } // namespace gles2 |
1363 } // namespace gpu | 1333 } // namespace gpu |
OLD | NEW |