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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 param = 0; | 2247 param = 0; |
2223 glGetActiveUniformBlockiv( | 2248 glGetActiveUniformBlockiv( |
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. | |
2233 size_t pos = names[ii].find_first_of('['); | 2257 size_t pos = names[ii].find_first_of('['); |
2234 const std::string* original_name; | 2258 const sh::InterfaceBlock* interface_block = nullptr; |
2235 std::string array_index_str = ""; | 2259 std::string array_index_str = ""; |
2236 if (pos != std::string::npos) { | 2260 if (pos != std::string::npos) { |
2237 original_name = GetOriginalNameFromHashedName(names[ii].substr(0, pos)); | 2261 interface_block = GetInterfaceBlockInfo(names[ii].substr(0, pos)); |
2238 array_index_str = names[ii].substr(pos); | 2262 array_index_str = names[ii].substr(pos); |
2239 } else { | 2263 } else { |
2240 original_name = GetOriginalNameFromHashedName(names[ii]); | 2264 interface_block = GetInterfaceBlockInfo(names[ii]); |
2241 } | 2265 } |
2242 if (original_name) | 2266 if (interface_block) |
2243 names[ii] = *original_name + array_index_str; | 2267 names[ii] = interface_block->name + array_index_str; |
2244 blocks[ii].name_length = names[ii].size() + 1; | 2268 blocks[ii].name_length = names[ii].size() + 1; |
2245 size += blocks[ii].name_length; | 2269 size += blocks[ii].name_length; |
2246 | 2270 |
2247 param = 0; | 2271 param = 0; |
2248 glGetActiveUniformBlockiv( | 2272 glGetActiveUniformBlockiv( |
2249 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); | 2273 program, ii, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, ¶m); |
2250 blocks[ii].active_uniforms = static_cast<uint32_t>(param); | 2274 blocks[ii].active_uniforms = static_cast<uint32_t>(param); |
2251 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); | 2275 blocks[ii].active_uniform_offset = size.ValueOrDefault(0); |
2252 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; | 2276 base::CheckedNumeric<uint32_t> indices_size = blocks[ii].active_uniforms; |
2253 indices_size *= sizeof(uint32_t); | 2277 indices_size *= sizeof(uint32_t); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2363 GLsizei var_name_length = 0; | 2387 GLsizei var_name_length = 0; |
2364 GLenum var_type = 0; | 2388 GLenum var_type = 0; |
2365 glGetTransformFeedbackVarying( | 2389 glGetTransformFeedbackVarying( |
2366 program, ii, max_name_length, | 2390 program, ii, max_name_length, |
2367 &var_name_length, &var_size, &var_type, &buffer[0]); | 2391 &var_name_length, &var_size, &var_type, &buffer[0]); |
2368 varyings[ii].size = static_cast<uint32_t>(var_size); | 2392 varyings[ii].size = static_cast<uint32_t>(var_size); |
2369 varyings[ii].type = static_cast<uint32_t>(var_type); | 2393 varyings[ii].type = static_cast<uint32_t>(var_type); |
2370 varyings[ii].name_offset = static_cast<uint32_t>(size.ValueOrDefault(0)); | 2394 varyings[ii].name_offset = static_cast<uint32_t>(size.ValueOrDefault(0)); |
2371 DCHECK_GT(max_name_length, var_name_length); | 2395 DCHECK_GT(max_name_length, var_name_length); |
2372 names[ii] = std::string(&buffer[0], var_name_length); | 2396 names[ii] = std::string(&buffer[0], var_name_length); |
2373 // TODO(zmo): optimize the name mapping lookup. | 2397 const sh::Varying* varying = GetVaryingInfo(names[ii]); |
2374 const std::string* original_name = GetOriginalNameFromHashedName(names[ii]); | 2398 if (varying) |
2375 if (original_name) | 2399 names[ii] = varying->name; |
2376 names[ii] = *original_name; | |
2377 varyings[ii].name_length = names[ii].size() + 1; | 2400 varyings[ii].name_length = names[ii].size() + 1; |
2378 size += names[ii].size(); | 2401 size += names[ii].size(); |
2379 size += 1; | 2402 size += 1; |
2380 } | 2403 } |
2381 if (!size.IsValid()) | 2404 if (!size.IsValid()) |
2382 return false; | 2405 return false; |
2383 uint32_t total_size = size.ValueOrDefault(0); | 2406 uint32_t total_size = size.ValueOrDefault(0); |
2384 DCHECK_LE(header_size + entry_size, total_size); | 2407 DCHECK_LE(header_size + entry_size, total_size); |
2385 uint32_t data_size = total_size - header_size - entry_size; | 2408 uint32_t data_size = total_size - header_size - entry_size; |
2386 | 2409 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 DCHECK(program); | 2683 DCHECK(program); |
2661 program->ClearUniforms(&zero_); | 2684 program->ClearUniforms(&zero_); |
2662 } | 2685 } |
2663 | 2686 |
2664 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2687 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
2665 return index + element * 0x10000; | 2688 return index + element * 0x10000; |
2666 } | 2689 } |
2667 | 2690 |
2668 } // namespace gles2 | 2691 } // namespace gles2 |
2669 } // namespace gpu | 2692 } // namespace gpu |
OLD | NEW |