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> |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1537 shader->GetUniformMappedName(original_name); | 1537 shader->GetUniformMappedName(original_name); |
1538 if (mapped_name) | 1538 if (mapped_name) |
1539 return mapped_name; | 1539 return mapped_name; |
1540 } | 1540 } |
1541 } | 1541 } |
1542 return nullptr; | 1542 return nullptr; |
1543 } | 1543 } |
1544 | 1544 |
1545 const std::string* Program::GetOriginalNameFromHashedName( | 1545 const std::string* Program::GetOriginalNameFromHashedName( |
1546 const std::string& hashed_name) const { | 1546 const std::string& hashed_name) const { |
1547 // TODO(kainino): Might not work on cache load, since name_map doesn't seem | |
1548 // to be loaded from cache. In GetUniformBlocks, GetInterfaceBlockInfo is | |
1549 // used instead. | |
Ken Russell (switch to Gerrit)
2017/05/01 23:02:30
Please refer to crbug.com/716018 at the end of thi
Kai Ninomiya
2017/05/02 00:06:13
Acknowledged.
| |
1547 for (auto shader : attached_shaders_) { | 1550 for (auto shader : attached_shaders_) { |
1548 if (shader) { | 1551 if (shader) { |
1549 const std::string* original_name = | 1552 const std::string* original_name = |
1550 shader->GetOriginalNameFromHashedName(hashed_name); | 1553 shader->GetOriginalNameFromHashedName(hashed_name); |
1551 if (original_name) | 1554 if (original_name) |
1552 return original_name; | 1555 return original_name; |
1553 } | 1556 } |
1554 } | 1557 } |
1555 return nullptr; | 1558 return nullptr; |
1556 } | 1559 } |
1557 | 1560 |
1561 const sh::InterfaceBlock* Program::GetInterfaceBlockInfo( | |
1562 const std::string& hashed_name) const { | |
1563 for (auto shader : attached_shaders_) { | |
1564 if (shader) { | |
1565 const sh::InterfaceBlock* info = | |
1566 shader->GetInterfaceBlockInfo(hashed_name); | |
1567 if (info) | |
1568 return info; | |
1569 } | |
1570 } | |
1571 return nullptr; | |
1572 } | |
1573 | |
1558 const Program::FragmentInputInfo* Program::GetFragmentInputInfoByFakeLocation( | 1574 const Program::FragmentInputInfo* Program::GetFragmentInputInfoByFakeLocation( |
1559 GLint fake_location) const { | 1575 GLint fake_location) const { |
1560 if (fake_location < 0) | 1576 if (fake_location < 0) |
1561 return nullptr; | 1577 return nullptr; |
1562 size_t location_index = static_cast<size_t>(fake_location); | 1578 size_t location_index = static_cast<size_t>(fake_location); |
1563 if (location_index >= fragment_input_locations_.size()) | 1579 if (location_index >= fragment_input_locations_.size()) |
1564 return nullptr; | 1580 return nullptr; |
1565 if (!fragment_input_locations_[location_index].IsActive()) | 1581 if (!fragment_input_locations_[location_index].IsActive()) |
1566 return nullptr; | 1582 return nullptr; |
1567 return fragment_input_locations_[location_index].shader_variable(); | 1583 return fragment_input_locations_[location_index].shader_variable(); |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 program, ii, GL_UNIFORM_BLOCK_NAME_LENGTH, ¶m); | 2240 program, ii, GL_UNIFORM_BLOCK_NAME_LENGTH, ¶m); |
2225 DCHECK_GE(max_name_length, param); | 2241 DCHECK_GE(max_name_length, param); |
2226 memset(&buffer[0], 0, param); | 2242 memset(&buffer[0], 0, param); |
2227 length = 0; | 2243 length = 0; |
2228 glGetActiveUniformBlockName( | 2244 glGetActiveUniformBlockName( |
2229 program, ii, static_cast<GLsizei>(param), &length, &buffer[0]); | 2245 program, ii, static_cast<GLsizei>(param), &length, &buffer[0]); |
2230 DCHECK_EQ(param, length + 1); | 2246 DCHECK_EQ(param, length + 1); |
2231 names[ii] = std::string(&buffer[0], length); | 2247 names[ii] = std::string(&buffer[0], length); |
2232 // TODO(zmo): optimize the name mapping lookup. | 2248 // TODO(zmo): optimize the name mapping lookup. |
2233 size_t pos = names[ii].find_first_of('['); | 2249 size_t pos = names[ii].find_first_of('['); |
2234 const std::string* original_name; | 2250 const sh::InterfaceBlock* interface_block = nullptr; |
2235 std::string array_index_str = ""; | 2251 std::string array_index_str = ""; |
2236 if (pos != std::string::npos) { | 2252 if (pos != std::string::npos) { |
2237 original_name = GetOriginalNameFromHashedName(names[ii].substr(0, pos)); | 2253 interface_block = GetInterfaceBlockInfo(names[ii].substr(0, pos)); |
2238 array_index_str = names[ii].substr(pos); | 2254 array_index_str = names[ii].substr(pos); |
2239 } else { | 2255 } else { |
2240 original_name = GetOriginalNameFromHashedName(names[ii]); | 2256 interface_block = GetInterfaceBlockInfo(names[ii]); |
2241 } | 2257 } |
2242 if (original_name) | 2258 if (interface_block) |
2243 names[ii] = *original_name + array_index_str; | 2259 names[ii] = interface_block->name + array_index_str; |
2244 blocks[ii].name_length = names[ii].size() + 1; | 2260 blocks[ii].name_length = names[ii].size() + 1; |
2245 size += blocks[ii].name_length; | 2261 size += blocks[ii].name_length; |
2246 | 2262 |
2247 param = 0; | 2263 param = 0; |
2248 glGetActiveUniformBlockiv( | 2264 glGetActiveUniformBlockiv( |
2249 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); | 2265 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); |
2250 blocks[ii].active_uniforms = static_cast<uint32_t>(param); | 2266 blocks[ii].active_uniforms = static_cast<uint32_t>(param); |
2251 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); | 2267 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); |
2252 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; | 2268 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; |
2253 indices_size *= sizeof(uint32_t); | 2269 indices_size *= sizeof(uint32_t); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2660 DCHECK(program); | 2676 DCHECK(program); |
2661 program->ClearUniforms(&zero_); | 2677 program->ClearUniforms(&zero_); |
2662 } | 2678 } |
2663 | 2679 |
2664 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2680 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
2665 return index + element * 0x10000; | 2681 return index + element * 0x10000; |
2666 } | 2682 } |
2667 | 2683 |
2668 } // namespace gles2 | 2684 } // namespace gles2 |
2669 } // namespace gpu | 2685 } // namespace gpu |
OLD | NEW |