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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 GLint index) const { | 1398 GLint index) const { |
1399 if (static_cast<size_t>(index) >= uniform_infos_.size()) { | 1399 if (static_cast<size_t>(index) >= uniform_infos_.size()) { |
1400 return NULL; | 1400 return NULL; |
1401 } | 1401 } |
1402 return &uniform_infos_[index]; | 1402 return &uniform_infos_[index]; |
1403 } | 1403 } |
1404 | 1404 |
1405 bool Program::SetSamplers( | 1405 bool Program::SetSamplers( |
1406 GLint num_texture_units, GLint fake_location, | 1406 GLint num_texture_units, GLint fake_location, |
1407 GLsizei count, const GLint* value) { | 1407 GLsizei count, const GLint* value) { |
1408 if (fake_location < 0) { | 1408 // The caller has checked that the location is active and valid. |
1409 return true; | 1409 DCHECK(fake_location >= 0); |
1410 } | |
1411 size_t location_index = | 1410 size_t location_index = |
1412 GetUniformLocationIndexFromFakeLocation(fake_location); | 1411 GetUniformLocationIndexFromFakeLocation(fake_location); |
1413 if (location_index >= uniform_infos_.size()) | 1412 DCHECK(location_index < uniform_locations_.size()); |
1414 return false; | 1413 DCHECK(uniform_locations_[location_index].IsActive()); |
1415 | |
1416 if (!uniform_locations_[location_index].IsActive()) | |
1417 return false; | |
1418 | 1414 |
1419 UniformInfo* info = uniform_locations_[location_index].shader_variable(); | 1415 UniformInfo* info = uniform_locations_[location_index].shader_variable(); |
1420 | 1416 |
1421 size_t element_index = GetArrayElementIndexFromFakeLocation(fake_location); | 1417 size_t element_index = GetArrayElementIndexFromFakeLocation(fake_location); |
1422 if (static_cast<GLsizei>(element_index) >= info->size) | 1418 if (static_cast<GLsizei>(element_index) >= info->size) |
1423 return true; | 1419 return true; |
1424 count = std::min(info->size - static_cast<GLsizei>(element_index), count); | 1420 count = std::min(info->size - static_cast<GLsizei>(element_index), count); |
1425 if (info->IsSampler() && count > 0) { | 1421 if (info->IsSampler() && count > 0) { |
1426 for (GLsizei ii = 0; ii < count; ++ii) { | 1422 for (GLsizei ii = 0; ii < count; ++ii) { |
1427 if (value[ii] < 0 || value[ii] >= num_texture_units) { | 1423 if (value[ii] < 0 || value[ii] >= num_texture_units) { |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 DCHECK(program); | 2379 DCHECK(program); |
2384 program->ClearUniforms(&zero_); | 2380 program->ClearUniforms(&zero_); |
2385 } | 2381 } |
2386 | 2382 |
2387 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2383 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
2388 return index + element * 0x10000; | 2384 return index + element * 0x10000; |
2389 } | 2385 } |
2390 | 2386 |
2391 } // namespace gles2 | 2387 } // namespace gles2 |
2392 } // namespace gpu | 2388 } // namespace gpu |
OLD | NEW |