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/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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1548 if (shader) { | 1548 if (shader) { |
| 1549 const std::string* original_name = | 1549 const std::string* original_name = |
| 1550 shader->GetOriginalNameFromHashedName(hashed_name); | 1550 shader->GetOriginalNameFromHashedName(hashed_name); |
| 1551 if (original_name) | 1551 if (original_name) |
| 1552 return original_name; | 1552 return original_name; |
| 1553 } | 1553 } |
| 1554 } | 1554 } |
| 1555 return nullptr; | 1555 return nullptr; |
| 1556 } | 1556 } |
| 1557 | 1557 |
| 1558 const sh::Varying* Program::GetVaryingInfo( | |
| 1559 const std::string& hashed_name) const { | |
| 1560 for (auto shader : attached_shaders_) { | |
| 1561 if (shader) { | |
| 1562 const sh::Varying* info = shader->GetVaryingInfo(hashed_name); | |
| 1563 if (info) | |
| 1564 return info; | |
| 1565 } | |
| 1566 } | |
| 1567 return nullptr; | |
| 1568 } | |
| 1569 | |
| 1570 const sh::InterfaceBlock* Program::GetInterfaceBlockInfo( | |
| 1571 const std::string& hashed_name) const { | |
| 1572 for (auto shader : attached_shaders_) { | |
| 1573 if (shader) { | |
| 1574 const sh::InterfaceBlock* info = | |
| 1575 shader->GetInterfaceBlockInfo(hashed_name); | |
| 1576 if (info) | |
| 1577 return info; | |
| 1578 } | |
| 1579 } | |
| 1580 return nullptr; | |
| 1581 } | |
| 1582 | |
| 1558 const Program::FragmentInputInfo* Program::GetFragmentInputInfoByFakeLocation( | 1583 const Program::FragmentInputInfo* Program::GetFragmentInputInfoByFakeLocation( |
| 1559 GLint fake_location) const { | 1584 GLint fake_location) const { |
| 1560 if (fake_location < 0) | 1585 if (fake_location < 0) |
| 1561 return nullptr; | 1586 return nullptr; |
| 1562 size_t location_index = static_cast<size_t>(fake_location); | 1587 size_t location_index = static_cast<size_t>(fake_location); |
| 1563 if (location_index >= fragment_input_locations_.size()) | 1588 if (location_index >= fragment_input_locations_.size()) |
| 1564 return nullptr; | 1589 return nullptr; |
| 1565 if (!fragment_input_locations_[location_index].IsActive()) | 1590 if (!fragment_input_locations_[location_index].IsActive()) |
| 1566 return nullptr; | 1591 return nullptr; |
| 1567 return fragment_input_locations_[location_index].shader_variable(); | 1592 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); | 2249 program, ii, GL_UNIFORM_BLOCK_NAME_LENGTH, ¶m); |
| 2225 DCHECK_GE(max_name_length, param); | 2250 DCHECK_GE(max_name_length, param); |
| 2226 memset(&buffer[0], 0, param); | 2251 memset(&buffer[0], 0, param); |
| 2227 length = 0; | 2252 length = 0; |
| 2228 glGetActiveUniformBlockName( | 2253 glGetActiveUniformBlockName( |
| 2229 program, ii, static_cast<GLsizei>(param), &length, &buffer[0]); | 2254 program, ii, static_cast<GLsizei>(param), &length, &buffer[0]); |
| 2230 DCHECK_EQ(param, length + 1); | 2255 DCHECK_EQ(param, length + 1); |
| 2231 names[ii] = std::string(&buffer[0], length); | 2256 names[ii] = std::string(&buffer[0], length); |
| 2232 // TODO(zmo): optimize the name mapping lookup. | 2257 // TODO(zmo): optimize the name mapping lookup. |
| 2233 size_t pos = names[ii].find_first_of('['); | 2258 size_t pos = names[ii].find_first_of('['); |
| 2234 const std::string* original_name; | 2259 const sh::InterfaceBlock* interface_block = nullptr; |
| 2235 std::string array_index_str = ""; | 2260 std::string array_index_str = ""; |
| 2236 if (pos != std::string::npos) { | 2261 if (pos != std::string::npos) { |
| 2237 original_name = GetOriginalNameFromHashedName(names[ii].substr(0, pos)); | 2262 interface_block = GetInterfaceBlockInfo(names[ii].substr(0, pos)); |
| 2238 array_index_str = names[ii].substr(pos); | 2263 array_index_str = names[ii].substr(pos); |
| 2239 } else { | 2264 } else { |
| 2240 original_name = GetOriginalNameFromHashedName(names[ii]); | 2265 interface_block = GetInterfaceBlockInfo(names[ii]); |
| 2241 } | 2266 } |
| 2242 if (original_name) | 2267 if (interface_block) |
| 2243 names[ii] = *original_name + array_index_str; | 2268 names[ii] = interface_block->name + array_index_str; |
|
Ken Russell (switch to Gerrit)
2017/05/03 22:52:48
This change is well tested with the existing confo
Kai Ninomiya
2017/05/03 23:02:34
That the interface block name returned will be the
| |
| 2244 blocks[ii].name_length = names[ii].size() + 1; | 2269 blocks[ii].name_length = names[ii].size() + 1; |
| 2245 size += blocks[ii].name_length; | 2270 size += blocks[ii].name_length; |
| 2246 | 2271 |
| 2247 param = 0; | 2272 param = 0; |
| 2248 glGetActiveUniformBlockiv( | 2273 glGetActiveUniformBlockiv( |
| 2249 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); | 2274 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); |
| 2250 blocks[ii].active_uniforms = static_cast<uint32_t>(param); | 2275 blocks[ii].active_uniforms = static_cast<uint32_t>(param); |
| 2251 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); | 2276 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); |
| 2252 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; | 2277 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; |
| 2253 indices_size *= sizeof(uint32_t); | 2278 indices_size *= sizeof(uint32_t); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2363 GLsizei var_name_length = 0; | 2388 GLsizei var_name_length = 0; |
| 2364 GLenum var_type = 0; | 2389 GLenum var_type = 0; |
| 2365 glGetTransformFeedbackVarying( | 2390 glGetTransformFeedbackVarying( |
| 2366 program, ii, max_name_length, | 2391 program, ii, max_name_length, |
| 2367 &var_name_length, &var_size, &var_type, &buffer[0]); | 2392 &var_name_length, &var_size, &var_type, &buffer[0]); |
| 2368 varyings[ii].size = static_cast<uint32_t>(var_size); | 2393 varyings[ii].size = static_cast<uint32_t>(var_size); |
| 2369 varyings[ii].type = static_cast<uint32_t>(var_type); | 2394 varyings[ii].type = static_cast<uint32_t>(var_type); |
| 2370 varyings[ii].name_offset = static_cast<uint32_t>(size.ValueOrDefault(0)); | 2395 varyings[ii].name_offset = static_cast<uint32_t>(size.ValueOrDefault(0)); |
| 2371 DCHECK_GT(max_name_length, var_name_length); | 2396 DCHECK_GT(max_name_length, var_name_length); |
| 2372 names[ii] = std::string(&buffer[0], var_name_length); | 2397 names[ii] = std::string(&buffer[0], var_name_length); |
| 2373 // TODO(zmo): optimize the name mapping lookup. | 2398 // TODO(zmo): optimize the name mapping lookup. |
|
Zhenyao Mo
2017/05/03 23:24:12
You can probably remove this comment because I don
| |
| 2374 const std::string* original_name = GetOriginalNameFromHashedName(names[ii]); | 2399 const sh::Varying* varying = GetVaryingInfo(names[ii]); |
| 2375 if (original_name) | 2400 if (varying) |
| 2376 names[ii] = *original_name; | 2401 names[ii] = varying->name; |
|
Ken Russell (switch to Gerrit)
2017/05/03 22:52:48
Same question here.
Kai Ninomiya
2017/05/03 23:02:34
Ditto.
| |
| 2377 varyings[ii].name_length = names[ii].size() + 1; | 2402 varyings[ii].name_length = names[ii].size() + 1; |
| 2378 size += names[ii].size(); | 2403 size += names[ii].size(); |
| 2379 size += 1; | 2404 size += 1; |
| 2380 } | 2405 } |
| 2381 if (!size.IsValid()) | 2406 if (!size.IsValid()) |
| 2382 return false; | 2407 return false; |
| 2383 uint32_t total_size = size.ValueOrDefault(0); | 2408 uint32_t total_size = size.ValueOrDefault(0); |
| 2384 DCHECK_LE(header_size + entry_size, total_size); | 2409 DCHECK_LE(header_size + entry_size, total_size); |
| 2385 uint32_t data_size = total_size - header_size - entry_size; | 2410 uint32_t data_size = total_size - header_size - entry_size; |
| 2386 | 2411 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2660 DCHECK(program); | 2685 DCHECK(program); |
| 2661 program->ClearUniforms(&zero_); | 2686 program->ClearUniforms(&zero_); |
| 2662 } | 2687 } |
| 2663 | 2688 |
| 2664 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2689 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
| 2665 return index + element * 0x10000; | 2690 return index + element * 0x10000; |
| 2666 } | 2691 } |
| 2667 | 2692 |
| 2668 } // namespace gles2 | 2693 } // namespace gles2 |
| 2669 } // namespace gpu | 2694 } // namespace gpu |
| OLD | NEW |