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

Side by Side Diff: gpu/command_buffer/service/program_manager.cc

Issue 2158793006: program_manager::CheckPacking, sends full sh::ShaderVariable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 1855
1856 bool Program::CheckVaryingsPacking( 1856 bool Program::CheckVaryingsPacking(
1857 Program::VaryingsPackingOption option) const { 1857 Program::VaryingsPackingOption option) const {
1858 DCHECK(attached_shaders_[0].get() && 1858 DCHECK(attached_shaders_[0].get() &&
1859 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && 1859 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
1860 attached_shaders_[1].get() && 1860 attached_shaders_[1].get() &&
1861 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); 1861 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER);
1862 const VaryingMap* vertex_varyings = &(attached_shaders_[0]->varying_map()); 1862 const VaryingMap* vertex_varyings = &(attached_shaders_[0]->varying_map());
1863 const VaryingMap* fragment_varyings = &(attached_shaders_[1]->varying_map()); 1863 const VaryingMap* fragment_varyings = &(attached_shaders_[1]->varying_map());
1864 1864
1865 std::map<std::string, ShVariableInfo> combined_map; 1865 std::map<std::string, const sh::ShaderVariable*> combined_map;
1866 1866
1867 for (const auto& key_value : *fragment_varyings) { 1867 for (const auto& key_value : *fragment_varyings) {
1868 if (!key_value.second.staticUse && option == kCountOnlyStaticallyUsed) 1868 if (!key_value.second.staticUse && option == kCountOnlyStaticallyUsed)
1869 continue; 1869 continue;
1870 if (!IsBuiltInFragmentVarying(key_value.first)) { 1870 if (!IsBuiltInFragmentVarying(key_value.first)) {
1871 VaryingMap::const_iterator vertex_iter = 1871 VaryingMap::const_iterator vertex_iter =
1872 vertex_varyings->find(key_value.first); 1872 vertex_varyings->find(key_value.first);
1873 if (vertex_iter == vertex_varyings->end() || 1873 if (vertex_iter == vertex_varyings->end() ||
1874 (!vertex_iter->second.staticUse && 1874 (!vertex_iter->second.staticUse &&
1875 option == kCountOnlyStaticallyUsed)) 1875 option == kCountOnlyStaticallyUsed))
1876 continue; 1876 continue;
1877 } 1877 }
1878 1878
1879 ShVariableInfo var; 1879 combined_map[key_value.first] = &key_value.second;
1880 var.type = static_cast<sh::GLenum>(key_value.second.type);
1881 var.size = std::max(1u, key_value.second.arraySize);
1882 combined_map[key_value.first] = var;
1883 } 1880 }
1884 1881
1885 if (combined_map.size() == 0) 1882 if (combined_map.size() == 0)
1886 return true; 1883 return true;
1887 std::unique_ptr<ShVariableInfo[]> variables( 1884 std::vector<sh::ShaderVariable> variables;
1888 new ShVariableInfo[combined_map.size()]);
1889 size_t index = 0;
1890 for (const auto& key_value : combined_map) { 1885 for (const auto& key_value : combined_map) {
1891 variables[index].type = key_value.second.type; 1886 variables.push_back(*key_value.second);
1892 variables[index].size = key_value.second.size;
1893 ++index;
1894 } 1887 }
1895 return ShCheckVariablesWithinPackingLimits( 1888 return ShCheckVariablesWithinPackingLimits(
1896 static_cast<int>(manager_->max_varying_vectors()), 1889 static_cast<int>(manager_->max_varying_vectors()),
1897 variables.get(), 1890 variables);
1898 combined_map.size());
1899 } 1891 }
1900 1892
1901 void Program::GetProgramInfo( 1893 void Program::GetProgramInfo(
1902 ProgramManager* manager, CommonDecoder::Bucket* bucket) const { 1894 ProgramManager* manager, CommonDecoder::Bucket* bucket) const {
1903 // NOTE: It seems to me the math in here does not need check for overflow 1895 // NOTE: It seems to me the math in here does not need check for overflow
1904 // because the data being calucated from has various small limits. The max 1896 // because the data being calucated from has various small limits. The max
1905 // number of attribs + uniforms is somewhere well under 1024. The maximum size 1897 // number of attribs + uniforms is somewhere well under 1024. The maximum size
1906 // of an identifier is 256 characters. 1898 // of an identifier is 256 characters.
1907 uint32_t num_locations = 0; 1899 uint32_t num_locations = 0;
1908 uint32_t total_string_size = 0; 1900 uint32_t total_string_size = 0;
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 DCHECK(program); 2458 DCHECK(program);
2467 program->ClearUniforms(&zero_); 2459 program->ClearUniforms(&zero_);
2468 } 2460 }
2469 2461
2470 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { 2462 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) {
2471 return index + element * 0x10000; 2463 return index + element * 0x10000;
2472 } 2464 }
2473 2465
2474 } // namespace gles2 2466 } // namespace gles2
2475 } // namespace gpu 2467 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698