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

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

Issue 1610613002: command_buffer: Fix setting samplers with bound uniforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc » ('j') | 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 GLSLArrayName parsed_service_name(service_name); 606 GLSLArrayName parsed_service_name(service_name);
607 if (parsed_service_name.IsArrayName()) { 607 if (parsed_service_name.IsArrayName()) {
608 service_base_name = parsed_service_name.base_name(); 608 service_base_name = parsed_service_name.base_name();
609 GLSLArrayName parsed_client_name(client_name); 609 GLSLArrayName parsed_client_name(client_name);
610 client_base_name = parsed_client_name.base_name(); 610 client_base_name = parsed_client_name.base_name();
611 } else { 611 } else {
612 service_name += "[0]"; 612 service_name += "[0]";
613 client_name += "[0]"; 613 client_name += "[0]";
614 } 614 }
615 } 615 }
616 616
Kimmo Kinnunen 2016/01/21 12:36:32 (1): This binds the automatically bound uniforms t
617 // Assign a location for the uniform: use either client-bound 617 // Assign a location for the uniform: use either client-bound
618 // location or automatically assigned to an unused location. 618 // location or automatically assigned to an unused location.
619 size_t client_location_base = 0; 619 size_t client_location_base = 0;
620 LocationMap::const_iterator it = 620 LocationMap::const_iterator it =
621 bind_uniform_location_map_.find(client_base_name); 621 bind_uniform_location_map_.find(client_base_name);
622 if (it != bind_uniform_location_map_.end()) { 622 if (it != bind_uniform_location_map_.end()) {
623 client_location_base = it->second; 623 client_location_base = it->second;
624 } else { 624 } else {
625 while (unused_client_location_cursor < uniform_locations_.size() && 625 while (unused_client_location_cursor < uniform_locations_.size() &&
626 !uniform_locations_[unused_client_location_cursor].IsUnused()) 626 !uniform_locations_[unused_client_location_cursor].IsUnused())
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 if (fake_location < 0) 1252 if (fake_location < 0)
1253 return nullptr; 1253 return nullptr;
1254 size_t location_index = static_cast<size_t>(fake_location); 1254 size_t location_index = static_cast<size_t>(fake_location);
1255 if (location_index >= fragment_input_locations_.size()) 1255 if (location_index >= fragment_input_locations_.size())
1256 return nullptr; 1256 return nullptr;
1257 if (!fragment_input_locations_[location_index].IsActive()) 1257 if (!fragment_input_locations_[location_index].IsActive())
1258 return nullptr; 1258 return nullptr;
1259 return fragment_input_locations_[location_index].shader_variable(); 1259 return fragment_input_locations_[location_index].shader_variable();
1260 } 1260 }
1261 1261
1262 bool Program::IsInactiveFragmentInputLocationByFakeLocation( 1262 bool Program::IsInactiveFragmentInputLocationByFakeLocation(
Kimmo Kinnunen 2016/01/21 12:36:32 (2): This is the place that is checking the possib
1263 GLint fake_location) const { 1263 GLint fake_location) const {
1264 if (fake_location < 0) 1264 if (fake_location < 0)
1265 return true; 1265 return true;
1266 size_t location_index = static_cast<size_t>(fake_location); 1266 size_t location_index = static_cast<size_t>(fake_location);
1267 if (location_index >= fragment_input_locations_.size()) 1267 if (location_index >= fragment_input_locations_.size())
1268 return false; 1268 return false;
1269 return fragment_input_locations_[location_index].IsInactive(); 1269 return fragment_input_locations_[location_index].IsInactive();
1270 } 1270 }
1271 1271
1272 bool Program::SetUniformLocationBinding( 1272 bool Program::SetUniformLocationBinding(
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (fake_location < 0) {
1409 return true; 1409 return true;
1410 } 1410 }
1411 size_t location_index = 1411 size_t location_index =
1412 GetUniformLocationIndexFromFakeLocation(fake_location); 1412 GetUniformLocationIndexFromFakeLocation(fake_location);
1413 if (location_index >= uniform_infos_.size()) 1413 if (location_index >= uniform_locations_.size())
Zhenyao Mo 2016/01/20 18:41:13 Correct me if I am wrong. uniform_locations_ size
Kimmo Kinnunen 2016/01/21 12:36:32 No, automatically bound uniforms get their client-
1414 return false; 1414 return false;
1415 1415
1416 if (!uniform_locations_[location_index].IsActive()) 1416 if (!uniform_locations_[location_index].IsActive())
Kimmo Kinnunen 2016/01/21 12:36:32 (2): This checks if the uniform has been optimized
1417 return false; 1417 return false;
1418 1418
1419 UniformInfo* info = uniform_locations_[location_index].shader_variable(); 1419 UniformInfo* info = uniform_locations_[location_index].shader_variable();
1420 1420
1421 size_t element_index = GetArrayElementIndexFromFakeLocation(fake_location); 1421 size_t element_index = GetArrayElementIndexFromFakeLocation(fake_location);
1422 if (static_cast<GLsizei>(element_index) >= info->size) 1422 if (static_cast<GLsizei>(element_index) >= info->size)
1423 return true; 1423 return true;
1424 count = std::min(info->size - static_cast<GLsizei>(element_index), count); 1424 count = std::min(info->size - static_cast<GLsizei>(element_index), count);
1425 if (info->IsSampler() && count > 0) { 1425 if (info->IsSampler() && count > 0) {
1426 for (GLsizei ii = 0; ii < count; ++ii) { 1426 for (GLsizei ii = 0; ii < count; ++ii) {
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 DCHECK(program); 2383 DCHECK(program);
2384 program->ClearUniforms(&zero_); 2384 program->ClearUniforms(&zero_);
2385 } 2385 }
2386 2386
2387 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { 2387 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) {
2388 return index + element * 0x10000; 2388 return index + element * 0x10000;
2389 } 2389 }
2390 2390
2391 } // namespace gles2 2391 } // namespace gles2
2392 } // namespace gpu 2392 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698