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

Side by Side Diff: gpu/command_buffer/client/program_info_manager.cc

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: address review comments Created 5 years, 2 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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // See "OpenGL ES 3.0.0, Section 2.11.3 Program Objects." 158 // See "OpenGL ES 3.0.0, Section 2.11.3 Program Objects."
159 if (info.name == name || 159 if (info.name == name ||
160 (info.is_array && 160 (info.is_array &&
161 info.name.compare(0, info.name.size() - 3, name) == 0)) { 161 info.name.compare(0, info.name.size() - 3, name) == 0)) {
162 return ii; 162 return ii;
163 } 163 }
164 } 164 }
165 return GL_INVALID_INDEX; 165 return GL_INVALID_INDEX;
166 } 166 }
167 167
168 GLint ProgramInfoManager::Program::GetFragDataIndex(
169 const std::string& name) const {
170 auto iter = frag_data_indices_.find(name);
171 if (iter == frag_data_indices_.end())
172 return -1;
173 return iter->second;
174 }
175
176 void ProgramInfoManager::Program::CacheFragDataIndex(const std::string& name,
177 GLint index) {
178 frag_data_indices_[name] = index;
179 }
180
168 GLint ProgramInfoManager::Program::GetFragDataLocation( 181 GLint ProgramInfoManager::Program::GetFragDataLocation(
169 const std::string& name) const { 182 const std::string& name) const {
170 base::hash_map<std::string, GLint>::const_iterator iter = 183 base::hash_map<std::string, GLint>::const_iterator iter =
171 frag_data_locations_.find(name); 184 frag_data_locations_.find(name);
172 if (iter == frag_data_locations_.end()) 185 if (iter == frag_data_locations_.end())
173 return -1; 186 return -1;
174 return iter->second; 187 return iter->second;
175 } 188 }
176 189
177 void ProgramInfoManager::Program::CacheFragDataLocation( 190 void ProgramInfoManager::Program::CacheFragDataLocation(
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 { 736 {
724 base::AutoLock auto_lock(lock_); 737 base::AutoLock auto_lock(lock_);
725 Program* info = GetProgramInfo(gl, program, kES2); 738 Program* info = GetProgramInfo(gl, program, kES2);
726 if (info) { 739 if (info) {
727 return info->GetUniformLocation(name); 740 return info->GetUniformLocation(name);
728 } 741 }
729 } 742 }
730 return gl->GetUniformLocationHelper(program, name); 743 return gl->GetUniformLocationHelper(program, name);
731 } 744 }
732 745
746 GLint ProgramInfoManager::GetFragDataIndex(GLES2Implementation* gl,
747 GLuint program,
748 const char* name) {
749 // TODO(zmo): make FragData indexes part of the ProgramInfo that are
750 // fetched from the service side. See crbug.com/452104.
751 {
752 base::AutoLock auto_lock(lock_);
753 Program* info = GetProgramInfo(gl, program, kNone);
754 if (info) {
755 GLint possible_index = info->GetFragDataIndex(name);
756 if (possible_index != -1)
757 return possible_index;
758 }
759 }
760 GLint index = gl->GetFragDataIndexEXTHelper(program, name);
761 if (index != -1) {
762 base::AutoLock auto_lock(lock_);
763 Program* info = GetProgramInfo(gl, program, kNone);
764 if (info) {
765 info->CacheFragDataIndex(name, index);
766 }
767 }
768 return index;
769 }
770
733 GLint ProgramInfoManager::GetFragDataLocation( 771 GLint ProgramInfoManager::GetFragDataLocation(
734 GLES2Implementation* gl, GLuint program, const char* name) { 772 GLES2Implementation* gl, GLuint program, const char* name) {
735 // TODO(zmo): make FragData locations part of the ProgramInfo that are 773 // TODO(zmo): make FragData locations part of the ProgramInfo that are
736 // fetched altogether from the service side. See crbug.com/452104. 774 // fetched altogether from the service side. See crbug.com/452104.
737 { 775 {
738 base::AutoLock auto_lock(lock_); 776 base::AutoLock auto_lock(lock_);
739 Program* info = GetProgramInfo(gl, program, kNone); 777 Program* info = GetProgramInfo(gl, program, kNone);
740 if (info) { 778 if (info) {
741 GLint possible_loc = info->GetFragDataLocation(name); 779 GLint possible_loc = info->GetFragDataLocation(name);
742 if (possible_loc != -1) 780 if (possible_loc != -1)
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 } 1037 }
1000 return true; 1038 return true;
1001 } 1039 }
1002 } 1040 }
1003 return gl->GetUniformIndicesHelper(program, count, names, indices); 1041 return gl->GetUniformIndicesHelper(program, count, names, indices);
1004 } 1042 }
1005 1043
1006 } // namespace gles2 1044 } // namespace gles2
1007 } // namespace gpu 1045 } // namespace gpu
1008 1046
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698