| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/numerics/safe_math.h" | 20 #include "base/numerics/safe_math.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 25 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 26 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 27 #include "gpu/command_buffer/service/feature_info.h" | 27 #include "gpu/command_buffer/service/feature_info.h" |
| 28 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 28 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 29 #include "gpu/command_buffer/service/gpu_switches.h" | 29 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 30 #include "gpu/command_buffer/service/program_cache.h" | 30 #include "gpu/command_buffer/service/program_cache.h" |
| 31 #include "gpu/command_buffer/service/shader_manager.h" | 31 #include "gpu/command_buffer/service/shader_manager.h" |
| 32 #include "third_party/re2/src/re2/re2.h" | 32 #include "third_party/re2/src/re2/re2.h" |
| 33 #include "ui/gl/gl_version_info.h" | 33 #include "ui/gl/gl_version_info.h" |
| 34 | 34 |
| 35 using base::TimeDelta; | 35 using base::TimeDelta; |
| 36 using base::TimeTicks; | 36 using base::TimeTicks; |
| 37 | 37 |
| 38 namespace gpu { | 38 namespace gpu { |
| 39 namespace gles2 { | 39 namespace gles2 { |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 attrib_location_to_index_map_.resize(max_location + 1); | 486 attrib_location_to_index_map_.resize(max_location + 1); |
| 487 for (GLint ii = 0; ii <= max_location; ++ii) { | 487 for (GLint ii = 0; ii <= max_location; ++ii) { |
| 488 attrib_location_to_index_map_[ii] = -1; | 488 attrib_location_to_index_map_[ii] = -1; |
| 489 } | 489 } |
| 490 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { | 490 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { |
| 491 const VertexAttrib& info = attrib_infos_[ii]; | 491 const VertexAttrib& info = attrib_infos_[ii]; |
| 492 attrib_location_to_index_map_[info.location] = ii; | 492 attrib_location_to_index_map_[info.location] = ii; |
| 493 } | 493 } |
| 494 | 494 |
| 495 #if !defined(NDEBUG) | 495 #if !defined(NDEBUG) |
| 496 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 496 if (manager_->gpu_preferences_.enable_gpu_service_logging_gpu) { |
| 497 switches::kEnableGPUServiceLoggingGPU)) { | |
| 498 DVLOG(1) << "----: attribs for service_id: " << service_id(); | 497 DVLOG(1) << "----: attribs for service_id: " << service_id(); |
| 499 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { | 498 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { |
| 500 const VertexAttrib& info = attrib_infos_[ii]; | 499 const VertexAttrib& info = attrib_infos_[ii]; |
| 501 DVLOG(1) << ii << ": loc = " << info.location | 500 DVLOG(1) << ii << ": loc = " << info.location |
| 502 << ", size = " << info.size | 501 << ", size = " << info.size |
| 503 << ", type = " << GLES2Util::GetStringEnum(info.type) | 502 << ", type = " << GLES2Util::GetStringEnum(info.type) |
| 504 << ", name = " << info.name; | 503 << ", name = " << info.name; |
| 505 } | 504 } |
| 506 } | 505 } |
| 507 #endif | 506 #endif |
| 508 UpdateUniforms(); | 507 UpdateUniforms(); |
| 509 | 508 |
| 510 #if !defined(NDEBUG) | 509 #if !defined(NDEBUG) |
| 511 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 510 if (manager_->gpu_preferences_.enable_gpu_service_logging_gpu) { |
| 512 switches::kEnableGPUServiceLoggingGPU)) { | |
| 513 DVLOG(1) << "----: uniforms for service_id: " << service_id(); | 511 DVLOG(1) << "----: uniforms for service_id: " << service_id(); |
| 514 size_t ii = 0; | 512 size_t ii = 0; |
| 515 for (const UniformInfo& info : uniform_infos_) { | 513 for (const UniformInfo& info : uniform_infos_) { |
| 516 DVLOG(1) << ii++ << ": loc = " << info.element_locations[0] | 514 DVLOG(1) << ii++ << ": loc = " << info.element_locations[0] |
| 517 << ", size = " << info.size | 515 << ", size = " << info.size |
| 518 << ", type = " << GLES2Util::GetStringEnum(info.type) | 516 << ", type = " << GLES2Util::GetStringEnum(info.type) |
| 519 << ", name = " << info.name; | 517 << ", name = " << info.name; |
| 520 } | 518 } |
| 521 } | 519 } |
| 522 #endif | 520 #endif |
| (...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2257 Program::~Program() { | 2255 Program::~Program() { |
| 2258 if (manager_) { | 2256 if (manager_) { |
| 2259 if (manager_->have_context_) { | 2257 if (manager_->have_context_) { |
| 2260 glDeleteProgram(service_id()); | 2258 glDeleteProgram(service_id()); |
| 2261 } | 2259 } |
| 2262 manager_->StopTracking(this); | 2260 manager_->StopTracking(this); |
| 2263 manager_ = NULL; | 2261 manager_ = NULL; |
| 2264 } | 2262 } |
| 2265 } | 2263 } |
| 2266 | 2264 |
| 2267 ProgramManager::ProgramManager(ProgramCache* program_cache, | 2265 ProgramManager::ProgramManager( |
| 2268 uint32_t max_varying_vectors, | 2266 ProgramCache* program_cache, |
| 2269 uint32_t max_dual_source_draw_buffers, | 2267 uint32_t max_varying_vectors, |
| 2270 FeatureInfo* feature_info) | 2268 uint32_t max_dual_source_draw_buffers, |
| 2269 const GpuPreferences& gpu_preferences, |
| 2270 FeatureInfo* feature_info) |
| 2271 : program_count_(0), | 2271 : program_count_(0), |
| 2272 have_context_(true), | 2272 have_context_(true), |
| 2273 program_cache_(program_cache), | 2273 program_cache_(program_cache), |
| 2274 max_varying_vectors_(max_varying_vectors), | 2274 max_varying_vectors_(max_varying_vectors), |
| 2275 max_dual_source_draw_buffers_(max_dual_source_draw_buffers), | 2275 max_dual_source_draw_buffers_(max_dual_source_draw_buffers), |
| 2276 gpu_preferences_(gpu_preferences), |
| 2276 feature_info_(feature_info) {} | 2277 feature_info_(feature_info) {} |
| 2277 | 2278 |
| 2278 ProgramManager::~ProgramManager() { | 2279 ProgramManager::~ProgramManager() { |
| 2279 DCHECK(programs_.empty()); | 2280 DCHECK(programs_.empty()); |
| 2280 } | 2281 } |
| 2281 | 2282 |
| 2282 void ProgramManager::Destroy(bool have_context) { | 2283 void ProgramManager::Destroy(bool have_context) { |
| 2283 have_context_ = have_context; | 2284 have_context_ = have_context; |
| 2284 programs_.clear(); | 2285 programs_.clear(); |
| 2285 } | 2286 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2380 DCHECK(program); | 2381 DCHECK(program); |
| 2381 program->ClearUniforms(&zero_); | 2382 program->ClearUniforms(&zero_); |
| 2382 } | 2383 } |
| 2383 | 2384 |
| 2384 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2385 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
| 2385 return index + element * 0x10000; | 2386 return index + element * 0x10000; |
| 2386 } | 2387 } |
| 2387 | 2388 |
| 2388 } // namespace gles2 | 2389 } // namespace gles2 |
| 2389 } // namespace gpu | 2390 } // namespace gpu |
| OLD | NEW |