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