Chromium Code Reviews| 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/client/program_info_manager.h" | 5 #include "gpu/command_buffer/client/program_info_manager.h" |
| 6 | 6 |
| 7 namespace { | 7 namespace { |
| 8 | 8 |
| 9 template<typename T> static T LocalGetAs( | 9 template<typename T> static T LocalGetAs( |
| 10 const std::vector<int8>& data, uint32 offset, size_t size) { | 10 const std::vector<int8>& data, uint32 offset, size_t size) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 GLuint ProgramInfoManager::Program::GetUniformBlockIndex( | 172 GLuint ProgramInfoManager::Program::GetUniformBlockIndex( |
| 173 const std::string& name) const { | 173 const std::string& name) const { |
| 174 for (size_t ii = 0; ii < uniform_blocks_.size(); ++ii) { | 174 for (size_t ii = 0; ii < uniform_blocks_.size(); ++ii) { |
| 175 if (uniform_blocks_[ii].name == name) { | 175 if (uniform_blocks_[ii].name == name) { |
| 176 return static_cast<GLuint>(ii); | 176 return static_cast<GLuint>(ii); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 return GL_INVALID_INDEX; | 179 return GL_INVALID_INDEX; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void ProgramInfoManager::Program::UniformBlockBinding( | |
| 183 GLuint index , GLuint binding) { | |
| 184 if (index < uniform_blocks_.size()) { | |
| 185 uniform_blocks_[index].binding = binding; | |
| 186 } | |
| 187 } | |
| 188 | |
| 182 void ProgramInfoManager::Program::UpdateES2(const std::vector<int8>& result) { | 189 void ProgramInfoManager::Program::UpdateES2(const std::vector<int8>& result) { |
| 183 if (cached_es2_) { | 190 if (cached_es2_) { |
| 184 return; | 191 return; |
| 185 } | 192 } |
| 186 if (result.empty()) { | 193 if (result.empty()) { |
| 187 // This should only happen on a lost context. | 194 // This should only happen on a lost context. |
| 188 return; | 195 return; |
| 189 } | 196 } |
| 190 DCHECK_GE(result.size(), sizeof(ProgramInfoHeader)); | 197 DCHECK_GE(result.size(), sizeof(ProgramInfoHeader)); |
| 191 const ProgramInfoHeader* header = LocalGetAs<const ProgramInfoHeader*>( | 198 const ProgramInfoHeader* header = LocalGetAs<const ProgramInfoHeader*>( |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 default: | 638 default: |
| 632 NOTREACHED(); | 639 NOTREACHED(); |
| 633 } | 640 } |
| 634 return true; | 641 return true; |
| 635 } | 642 } |
| 636 } | 643 } |
| 637 } | 644 } |
| 638 return gl->GetActiveUniformBlockivHelper(program, index, pname, params); | 645 return gl->GetActiveUniformBlockivHelper(program, index, pname, params); |
| 639 } | 646 } |
| 640 | 647 |
| 648 void ProgramInfoManager::UniformBlockBinding( | |
| 649 GLES2Implementation* gl, GLuint program, GLuint index, GLuint binding) { | |
| 650 GLuint max_bindings = | |
| 651 static_cast<GLuint>(gl->capabilities().max_uniform_buffer_bindings); | |
| 652 if (binding < max_bindings) { | |
|
piman
2015/02/07 01:16:32
nit: do we care about this check? The check in Pro
Zhenyao Mo
2015/02/07 01:48:43
I think we do. The checking in Program::UniformBlo
piman
2015/02/07 01:50:58
Oh, you're right.
| |
| 653 base::AutoLock auto_lock(lock_); | |
| 654 // If UniformBlock info haven't been cached yet, skip updating the binding. | |
| 655 Program* info = GetProgramInfo(gl, program, kNone); | |
| 656 if (info) { | |
| 657 info->UniformBlockBinding(index, binding); | |
| 658 } | |
| 659 } | |
| 660 } | |
| 661 | |
| 641 } // namespace gles2 | 662 } // namespace gles2 |
| 642 } // namespace gpu | 663 } // namespace gpu |
| 643 | 664 |
| OLD | NEW |