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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 service_id_(service_id), | 303 service_id_(service_id), |
| 304 deleted_(false), | 304 deleted_(false), |
| 305 valid_(false), | 305 valid_(false), |
| 306 link_status_(false), | 306 link_status_(false), |
| 307 uniforms_cleared_(false), | 307 uniforms_cleared_(false), |
| 308 transform_feedback_buffer_mode_(GL_NONE), | 308 transform_feedback_buffer_mode_(GL_NONE), |
| 309 fragment_output_type_mask_(0u), | 309 fragment_output_type_mask_(0u), |
| 310 fragment_output_written_mask_(0u) { | 310 fragment_output_written_mask_(0u) { |
| 311 DCHECK(manager_); | 311 DCHECK(manager_); |
| 312 manager_->StartTracking(this); | 312 manager_->StartTracking(this); |
| 313 uint32_t packed_size = manager_->max_vertex_attribs() / 16; | |
| 314 packed_size += (manager_->max_vertex_attribs() % 16 == 0) ? 0 : 1; | |
|
piman
2016/07/25 20:04:04
nit: uint32_t packed_size = (manager_->max_vertex_
| |
| 315 vertex_input_base_type_mask_.resize(packed_size); | |
| 316 vertex_input_active_mask_.resize(packed_size); | |
| 317 ClearVertexInputMasks(); | |
| 313 } | 318 } |
| 314 | 319 |
| 315 void Program::Reset() { | 320 void Program::Reset() { |
| 316 valid_ = false; | 321 valid_ = false; |
| 317 link_status_ = false; | 322 link_status_ = false; |
| 318 max_uniform_name_length_ = 0; | 323 max_uniform_name_length_ = 0; |
| 319 max_attrib_name_length_ = 0; | 324 max_attrib_name_length_ = 0; |
| 320 attrib_infos_.clear(); | 325 attrib_infos_.clear(); |
| 321 uniform_infos_.clear(); | 326 uniform_infos_.clear(); |
| 322 uniform_locations_.clear(); | 327 uniform_locations_.clear(); |
| 323 fragment_input_infos_.clear(); | 328 fragment_input_infos_.clear(); |
| 324 fragment_input_locations_.clear(); | 329 fragment_input_locations_.clear(); |
| 325 program_output_infos_.clear(); | 330 program_output_infos_.clear(); |
| 326 sampler_indices_.clear(); | 331 sampler_indices_.clear(); |
| 327 attrib_location_to_index_map_.clear(); | 332 attrib_location_to_index_map_.clear(); |
| 328 fragment_output_type_mask_ = 0u; | 333 fragment_output_type_mask_ = 0u; |
| 329 fragment_output_written_mask_ = 0u; | 334 fragment_output_written_mask_ = 0u; |
| 330 vertex_input_base_type_mask_.clear(); | 335 ClearVertexInputMasks(); |
| 331 vertex_input_type_written_mask_.clear(); | 336 } |
| 337 | |
| 338 void Program::ClearVertexInputMasks() { | |
| 339 for (uint32_t ii = 0; ii < vertex_input_base_type_mask_.size(); ++ii) { | |
| 340 vertex_input_base_type_mask_[ii] = 0u; | |
| 341 vertex_input_active_mask_[ii] = 0u; | |
| 342 } | |
| 332 } | 343 } |
| 333 | 344 |
| 334 void Program::UpdateFragmentOutputBaseTypes() { | 345 void Program::UpdateFragmentOutputBaseTypes() { |
| 335 fragment_output_type_mask_ = 0u; | 346 fragment_output_type_mask_ = 0u; |
| 336 fragment_output_written_mask_ = 0u; | 347 fragment_output_written_mask_ = 0u; |
| 337 Shader* fragment_shader = | 348 Shader* fragment_shader = |
| 338 attached_shaders_[ShaderTypeToIndex(GL_FRAGMENT_SHADER)].get(); | 349 attached_shaders_[ShaderTypeToIndex(GL_FRAGMENT_SHADER)].get(); |
| 339 DCHECK(fragment_shader); | 350 DCHECK(fragment_shader); |
| 340 for (auto const& output : fragment_shader->output_variable_list()) { | 351 for (auto const& output : fragment_shader->output_variable_list()) { |
| 341 int location = output.location; | 352 int location = output.location; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 363 // "FragData0" and "FragData1" returns 0. | 374 // "FragData0" and "FragData1" returns 0. |
| 364 int shift_bits = ii * 2; | 375 int shift_bits = ii * 2; |
| 365 fragment_output_written_mask_ |= 0x3 << shift_bits; | 376 fragment_output_written_mask_ |= 0x3 << shift_bits; |
| 366 fragment_output_type_mask_ |= | 377 fragment_output_type_mask_ |= |
| 367 InputOutputTypeToBaseType(false, output.type) << shift_bits; | 378 InputOutputTypeToBaseType(false, output.type) << shift_bits; |
| 368 } | 379 } |
| 369 } | 380 } |
| 370 } | 381 } |
| 371 | 382 |
| 372 void Program::UpdateVertexInputBaseTypes() { | 383 void Program::UpdateVertexInputBaseTypes() { |
| 373 max_vertex_attribs_ = manager_->max_vertex_attribs(); | 384 ClearVertexInputMasks(); |
| 374 uint32_t packed_size = max_vertex_attribs_ / 16; | 385 DCHECK_LE(attrib_infos_.size(), manager_->max_vertex_attribs()); |
| 375 packed_size += (max_vertex_attribs_ % 16 == 0) ? 0 : 1; | |
| 376 vertex_input_base_type_mask_.resize(packed_size); | |
| 377 vertex_input_type_written_mask_.resize(packed_size); | |
|
Zhenyao Mo
2016/07/23 16:10:40
We don't need to resize every link because they ne
yunchao
2016/07/24 04:52:13
Acknowledged.
| |
| 378 | |
| 379 for (uint32_t ii = 0; ii < packed_size; ++ii) { | |
| 380 vertex_input_type_written_mask_[ii] = 0u; | |
| 381 vertex_input_base_type_mask_[ii] = 0u; | |
| 382 } | |
| 383 | |
| 384 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { | 386 for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { |
| 385 DCHECK(ii < max_vertex_attribs_); | |
| 386 const VertexAttrib& input = attrib_infos_[ii]; | 387 const VertexAttrib& input = attrib_infos_[ii]; |
| 387 if (ProgramManager::HasBuiltInPrefix(input.name)) { | 388 if (ProgramManager::HasBuiltInPrefix(input.name)) { |
| 388 continue; | 389 continue; |
| 389 } | 390 } |
| 390 int shift_bits = (input.location % 16) * 2; | 391 int shift_bits = (input.location % 16) * 2; |
| 391 vertex_input_type_written_mask_[ii / 16] |= 0x3 << shift_bits; | 392 vertex_input_active_mask_[ii / 16] |= 0x3 << shift_bits; |
| 392 vertex_input_base_type_mask_[ii / 16] |= | 393 vertex_input_base_type_mask_[ii / 16] |= |
| 393 InputOutputTypeToBaseType(true, input.type) << shift_bits; | 394 InputOutputTypeToBaseType(true, input.type) << shift_bits; |
| 394 } | 395 } |
| 395 } | 396 } |
| 396 | 397 |
| 397 void Program::UpdateUniformBlockSizeInfo() { | 398 void Program::UpdateUniformBlockSizeInfo() { |
| 398 switch (feature_info().context_type()) { | 399 switch (feature_info().context_type()) { |
| 399 case CONTEXT_TYPE_OPENGLES2: | 400 case CONTEXT_TYPE_OPENGLES2: |
| 400 case CONTEXT_TYPE_WEBGL1: | 401 case CONTEXT_TYPE_WEBGL1: |
| 401 // Uniform blocks do not exist in ES2. | 402 // Uniform blocks do not exist in ES2. |
| 402 return; | 403 return; |
| 403 default: | 404 default: |
| (...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2533 DCHECK(program); | 2534 DCHECK(program); |
| 2534 program->ClearUniforms(&zero_); | 2535 program->ClearUniforms(&zero_); |
| 2535 } | 2536 } |
| 2536 | 2537 |
| 2537 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2538 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
| 2538 return index + element * 0x10000; | 2539 return index + element * 0x10000; |
| 2539 } | 2540 } |
| 2540 | 2541 |
| 2541 } // namespace gles2 | 2542 } // namespace gles2 |
| 2542 } // namespace gpu | 2543 } // namespace gpu |
| OLD | NEW |