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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // The program links OK, but both calling glGetFragDataLocation on both | 349 // The program links OK, but both calling glGetFragDataLocation on both |
350 // "FragData0" and "FragData1" returns 0. | 350 // "FragData0" and "FragData1" returns 0. |
351 int shift_bits = ii * 2; | 351 int shift_bits = ii * 2; |
352 fragment_output_written_mask_ |= 0x3 << shift_bits; | 352 fragment_output_written_mask_ |= 0x3 << shift_bits; |
353 fragment_output_type_mask_ |= | 353 fragment_output_type_mask_ |= |
354 FragmentOutputTypeToBaseType(output.type) << shift_bits; | 354 FragmentOutputTypeToBaseType(output.type) << shift_bits; |
355 } | 355 } |
356 } | 356 } |
357 } | 357 } |
358 | 358 |
| 359 void Program::UpdateUniformBlockSizeInfo() { |
| 360 switch (feature_info().context_type()) { |
| 361 case CONTEXT_TYPE_OPENGLES2: |
| 362 case CONTEXT_TYPE_WEBGL1: |
| 363 // Uniform blocks do not exist in ES2. |
| 364 return; |
| 365 default: |
| 366 break; |
| 367 } |
| 368 |
| 369 uniform_block_size_info_.clear(); |
| 370 |
| 371 GLint num_uniform_blocks = 0; |
| 372 glGetProgramiv(service_id_, GL_ACTIVE_UNIFORM_BLOCKS, &num_uniform_blocks); |
| 373 uniform_block_size_info_.resize(num_uniform_blocks); |
| 374 for (GLint ii = 0; ii < num_uniform_blocks; ++ii) { |
| 375 GLint binding = 0; |
| 376 glGetActiveUniformBlockiv( |
| 377 service_id_, ii, GL_UNIFORM_BLOCK_BINDING, &binding); |
| 378 uniform_block_size_info_[ii].binding = static_cast<GLuint>(binding); |
| 379 |
| 380 GLint size = 0; |
| 381 glGetActiveUniformBlockiv( |
| 382 service_id_, ii, GL_UNIFORM_BLOCK_DATA_SIZE, &size); |
| 383 uniform_block_size_info_[ii].data_size = static_cast<GLuint>(size); |
| 384 } |
| 385 } |
| 386 |
| 387 void Program::SetUniformBlockBinding(GLuint index, GLuint binding) { |
| 388 DCHECK_GT(uniform_block_size_info_.size(), index); |
| 389 uniform_block_size_info_[index].binding = binding; |
| 390 } |
| 391 |
359 std::string Program::ProcessLogInfo( | 392 std::string Program::ProcessLogInfo( |
360 const std::string& log) { | 393 const std::string& log) { |
361 std::string output; | 394 std::string output; |
362 re2::StringPiece input(log); | 395 re2::StringPiece input(log); |
363 std::string prior_log; | 396 std::string prior_log; |
364 std::string hashed_name; | 397 std::string hashed_name; |
365 while (RE2::Consume(&input, | 398 while (RE2::Consume(&input, |
366 "(.*?)(webgl_[0123456789abcdefABCDEF]+)", | 399 "(.*?)(webgl_[0123456789abcdefABCDEF]+)", |
367 &prior_log, | 400 &prior_log, |
368 &hashed_name)) { | 401 &hashed_name)) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 DVLOG(1) << ii++ << ": loc = " << info.element_locations[0] | 616 DVLOG(1) << ii++ << ": loc = " << info.element_locations[0] |
584 << ", size = " << info.size | 617 << ", size = " << info.size |
585 << ", type = " << GLES2Util::GetStringEnum(info.type) | 618 << ", type = " << GLES2Util::GetStringEnum(info.type) |
586 << ", name = " << info.name; | 619 << ", name = " << info.name; |
587 } | 620 } |
588 } | 621 } |
589 | 622 |
590 UpdateFragmentInputs(); | 623 UpdateFragmentInputs(); |
591 UpdateProgramOutputs(); | 624 UpdateProgramOutputs(); |
592 UpdateFragmentOutputBaseTypes(); | 625 UpdateFragmentOutputBaseTypes(); |
| 626 UpdateUniformBlockSizeInfo(); |
593 | 627 |
594 valid_ = true; | 628 valid_ = true; |
595 } | 629 } |
596 | 630 |
597 void Program::UpdateUniforms() { | 631 void Program::UpdateUniforms() { |
598 // Reserve each client-bound uniform location. This way unbound uniforms will | 632 // Reserve each client-bound uniform location. This way unbound uniforms will |
599 // not be allocated to locations that user expects bound uniforms to be, even | 633 // not be allocated to locations that user expects bound uniforms to be, even |
600 // if the expected uniforms are optimized away by the driver. | 634 // if the expected uniforms are optimized away by the driver. |
601 for (const auto& binding : bind_uniform_location_map_) { | 635 for (const auto& binding : bind_uniform_location_map_) { |
602 if (binding.second < 0) | 636 if (binding.second < 0) |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 DCHECK(program); | 2500 DCHECK(program); |
2467 program->ClearUniforms(&zero_); | 2501 program->ClearUniforms(&zero_); |
2468 } | 2502 } |
2469 | 2503 |
2470 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2504 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
2471 return index + element * 0x10000; | 2505 return index + element * 0x10000; |
2472 } | 2506 } |
2473 | 2507 |
2474 } // namespace gles2 | 2508 } // namespace gles2 |
2475 } // namespace gpu | 2509 } // namespace gpu |
OLD | NEW |