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

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

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Program::Program(ProgramManager* manager, GLuint service_id) 204 Program::Program(ProgramManager* manager, GLuint service_id)
205 : manager_(manager), 205 : manager_(manager),
206 use_count_(0), 206 use_count_(0),
207 max_attrib_name_length_(0), 207 max_attrib_name_length_(0),
208 max_uniform_name_length_(0), 208 max_uniform_name_length_(0),
209 service_id_(service_id), 209 service_id_(service_id),
210 deleted_(false), 210 deleted_(false),
211 valid_(false), 211 valid_(false),
212 link_status_(false), 212 link_status_(false),
213 uniforms_cleared_(false), 213 uniforms_cleared_(false),
214 num_uniforms_(0) { 214 num_uniforms_(0),
215 transform_feedback_buffer_mode_(GL_NONE) {
215 manager_->StartTracking(this); 216 manager_->StartTracking(this);
216 } 217 }
217 218
218 void Program::Reset() { 219 void Program::Reset() {
219 valid_ = false; 220 valid_ = false;
220 link_status_ = false; 221 link_status_ = false;
221 num_uniforms_ = 0; 222 num_uniforms_ = 0;
222 max_uniform_name_length_ = 0; 223 max_uniform_name_length_ = 0;
223 max_attrib_name_length_ = 0; 224 max_attrib_name_length_ = 0;
224 attrib_infos_.clear(); 225 attrib_infos_.clear();
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 526
526 TimeTicks before_time = TimeTicks::Now(); 527 TimeTicks before_time = TimeTicks::Now();
527 bool link = true; 528 bool link = true;
528 ProgramCache* cache = manager_->program_cache_; 529 ProgramCache* cache = manager_->program_cache_;
529 if (cache) { 530 if (cache) {
530 DCHECK(!attached_shaders_[0]->last_compiled_source().empty() && 531 DCHECK(!attached_shaders_[0]->last_compiled_source().empty() &&
531 !attached_shaders_[1]->last_compiled_source().empty()); 532 !attached_shaders_[1]->last_compiled_source().empty());
532 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus( 533 ProgramCache::LinkedProgramStatus status = cache->GetLinkedProgramStatus(
533 attached_shaders_[0]->last_compiled_signature(), 534 attached_shaders_[0]->last_compiled_signature(),
534 attached_shaders_[1]->last_compiled_signature(), 535 attached_shaders_[1]->last_compiled_signature(),
535 &bind_attrib_location_map_); 536 &bind_attrib_location_map_,
537 transform_feedback_varyings_,
538 transform_feedback_buffer_mode_);
536 539
537 if (status == ProgramCache::LINK_SUCCEEDED) { 540 if (status == ProgramCache::LINK_SUCCEEDED) {
538 ProgramCache::ProgramLoadResult success = 541 ProgramCache::ProgramLoadResult success =
539 cache->LoadLinkedProgram(service_id(), 542 cache->LoadLinkedProgram(service_id(),
540 attached_shaders_[0].get(), 543 attached_shaders_[0].get(),
541 attached_shaders_[1].get(), 544 attached_shaders_[1].get(),
542 &bind_attrib_location_map_, 545 &bind_attrib_location_map_,
546 transform_feedback_varyings_,
547 transform_feedback_buffer_mode_,
543 shader_callback); 548 shader_callback);
544 link = success != ProgramCache::PROGRAM_LOAD_SUCCESS; 549 link = success != ProgramCache::PROGRAM_LOAD_SUCCESS;
545 UMA_HISTOGRAM_BOOLEAN("GPU.ProgramCache.LoadBinarySuccess", !link); 550 UMA_HISTOGRAM_BOOLEAN("GPU.ProgramCache.LoadBinarySuccess", !link);
546 } 551 }
547 } 552 }
548 553
549 if (link) { 554 if (link) {
550 CompileAttachedShaders(); 555 CompileAttachedShaders();
551 556
552 if (!CanLink()) { 557 if (!CanLink()) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 GLint success = 0; 606 GLint success = 0;
602 glGetProgramiv(service_id(), GL_LINK_STATUS, &success); 607 glGetProgramiv(service_id(), GL_LINK_STATUS, &success);
603 if (success == GL_TRUE) { 608 if (success == GL_TRUE) {
604 Update(); 609 Update();
605 if (link) { 610 if (link) {
606 if (cache) { 611 if (cache) {
607 cache->SaveLinkedProgram(service_id(), 612 cache->SaveLinkedProgram(service_id(),
608 attached_shaders_[0].get(), 613 attached_shaders_[0].get(),
609 attached_shaders_[1].get(), 614 attached_shaders_[1].get(),
610 &bind_attrib_location_map_, 615 &bind_attrib_location_map_,
616 transform_feedback_varyings_,
617 transform_feedback_buffer_mode_,
611 shader_callback); 618 shader_callback);
612 } 619 }
613 UMA_HISTOGRAM_CUSTOM_COUNTS( 620 UMA_HISTOGRAM_CUSTOM_COUNTS(
614 "GPU.ProgramCache.BinaryCacheMissTime", 621 "GPU.ProgramCache.BinaryCacheMissTime",
615 static_cast<base::HistogramBase::Sample>( 622 static_cast<base::HistogramBase::Sample>(
616 (TimeTicks::Now() - before_time).InMicroseconds()), 623 (TimeTicks::Now() - before_time).InMicroseconds()),
617 0, 624 0,
618 static_cast<base::HistogramBase::Sample>( 625 static_cast<base::HistogramBase::Sample>(
619 TimeDelta::FromSeconds(10).InMicroseconds()), 626 TimeDelta::FromSeconds(10).InMicroseconds()),
620 50); 627 50);
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 } 1603 }
1597 glGetActiveUniformsiv( 1604 glGetActiveUniformsiv(
1598 program, count, &indices[0], kPname[pname_index], &params[0]); 1605 program, count, &indices[0], kPname[pname_index], &params[0]);
1599 for (GLsizei ii = 0; ii < count; ++ii) { 1606 for (GLsizei ii = 0; ii < count; ++ii) {
1600 entries[kStride * ii + pname_index] = params[ii]; 1607 entries[kStride * ii + pname_index] = params[ii];
1601 } 1608 }
1602 } 1609 }
1603 return true; 1610 return true;
1604 } 1611 }
1605 1612
1613 void Program::TransformFeedbackVaryings(GLsizei count,
1614 const char* const* varyings,
1615 GLenum buffer_mode) {
1616 transform_feedback_varyings_.clear();
1617 for (GLsizei i = 0; i < count; ++i) {
1618 transform_feedback_varyings_.push_back(std::string(varyings[i]));
1619 }
1620 transform_feedback_buffer_mode_ = buffer_mode;
1621 }
1622
1606 Program::~Program() { 1623 Program::~Program() {
1607 if (manager_) { 1624 if (manager_) {
1608 if (manager_->have_context_) { 1625 if (manager_->have_context_) {
1609 glDeleteProgram(service_id()); 1626 glDeleteProgram(service_id());
1610 } 1627 }
1611 manager_->StopTracking(this); 1628 manager_->StopTracking(this);
1612 manager_ = NULL; 1629 manager_ = NULL;
1613 } 1630 }
1614 } 1631 }
1615 1632
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 DCHECK(program); 1745 DCHECK(program);
1729 program->ClearUniforms(&zero_); 1746 program->ClearUniforms(&zero_);
1730 } 1747 }
1731 1748
1732 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) { 1749 int32 ProgramManager::MakeFakeLocation(int32 index, int32 element) {
1733 return index + element * 0x10000; 1750 return index + element * 0x10000;
1734 } 1751 }
1735 1752
1736 } // namespace gles2 1753 } // namespace gles2
1737 } // namespace gpu 1754 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | gpu/command_buffer/service/program_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698