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/client/program_info_manager.h" | 5 #include "gpu/command_buffer/client/program_info_manager.h" |
6 | 6 |
7 namespace { | 7 namespace { |
8 | 8 |
9 template<typename T> static T LocalGetAs( | 9 template<typename T> static T LocalGetAs( |
10 const std::vector<int8>& data, uint32 offset, size_t size) { | 10 const std::vector<int8>& data, uint32 offset, size_t size) { |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // This should only happen on a lost context. | 325 // This should only happen on a lost context. |
326 return; | 326 return; |
327 } | 327 } |
328 DCHECK_GE(result.size(), sizeof(ProgramInfoHeader)); | 328 DCHECK_GE(result.size(), sizeof(ProgramInfoHeader)); |
329 const ProgramInfoHeader* header = LocalGetAs<const ProgramInfoHeader*>( | 329 const ProgramInfoHeader* header = LocalGetAs<const ProgramInfoHeader*>( |
330 result, 0, sizeof(header)); | 330 result, 0, sizeof(header)); |
331 link_status_ = header->link_status != 0; | 331 link_status_ = header->link_status != 0; |
332 if (!link_status_) { | 332 if (!link_status_) { |
333 return; | 333 return; |
334 } | 334 } |
335 attrib_infos_.clear(); | 335 DCHECK_EQ(0u, attrib_infos_.size()); |
336 uniform_infos_.clear(); | 336 DCHECK_EQ(0u, uniform_infos_.size()); |
337 frag_data_locations_.clear(); | 337 DCHECK_EQ(0, max_attrib_name_length_); |
338 max_attrib_name_length_ = 0; | 338 DCHECK_EQ(0, max_uniform_name_length_); |
339 max_uniform_name_length_ = 0; | |
340 const ProgramInput* inputs = LocalGetAs<const ProgramInput*>( | 339 const ProgramInput* inputs = LocalGetAs<const ProgramInput*>( |
341 result, sizeof(*header), | 340 result, sizeof(*header), |
342 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); | 341 sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms)); |
343 const ProgramInput* input = inputs; | 342 const ProgramInput* input = inputs; |
344 for (uint32 ii = 0; ii < header->num_attribs; ++ii) { | 343 for (uint32 ii = 0; ii < header->num_attribs; ++ii) { |
345 const int32* location = LocalGetAs<const int32*>( | 344 const int32* location = LocalGetAs<const int32*>( |
346 result, input->location_offset, sizeof(int32)); | 345 result, input->location_offset, sizeof(int32)); |
347 const char* name_buf = LocalGetAs<const char*>( | 346 const char* name_buf = LocalGetAs<const char*>( |
348 result, input->name_offset, input->name_length); | 347 result, input->name_offset, input->name_length); |
349 std::string name(name_buf, input->name_length); | 348 std::string name(name_buf, input->name_length); |
(...skipping 25 matching lines...) Expand all Loading... |
375 | 374 |
376 void ProgramInfoManager::Program::UpdateES3UniformBlocks( | 375 void ProgramInfoManager::Program::UpdateES3UniformBlocks( |
377 const std::vector<int8>& result) { | 376 const std::vector<int8>& result) { |
378 if (cached_es3_uniform_blocks_) { | 377 if (cached_es3_uniform_blocks_) { |
379 return; | 378 return; |
380 } | 379 } |
381 if (result.empty()) { | 380 if (result.empty()) { |
382 // This should only happen on a lost context. | 381 // This should only happen on a lost context. |
383 return; | 382 return; |
384 } | 383 } |
385 uniform_blocks_.clear(); | 384 DCHECK_EQ(0u, uniform_blocks_.size()); |
386 active_uniform_block_max_name_length_ = 0; | 385 DCHECK_EQ(0u, active_uniform_block_max_name_length_); |
387 | 386 |
388 // |result| comes from GPU process. We consider it trusted data. Therefore, | 387 // |result| comes from GPU process. We consider it trusted data. Therefore, |
389 // no need to check for overflows as the GPU side did the checks already. | 388 // no need to check for overflows as the GPU side did the checks already. |
390 uint32_t header_size = sizeof(UniformBlocksHeader); | 389 uint32_t header_size = sizeof(UniformBlocksHeader); |
391 DCHECK_GE(result.size(), header_size); | 390 DCHECK_GE(result.size(), header_size); |
392 const UniformBlocksHeader* header = LocalGetAs<const UniformBlocksHeader*>( | 391 const UniformBlocksHeader* header = LocalGetAs<const UniformBlocksHeader*>( |
393 result, 0, header_size); | 392 result, 0, header_size); |
394 DCHECK(header); | 393 DCHECK(header); |
395 if (header->num_uniform_blocks == 0) { | 394 if (header->num_uniform_blocks == 0) { |
396 DCHECK_EQ(result.size(), header_size); | 395 DCHECK_EQ(result.size(), header_size); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 445 |
447 void ProgramInfoManager::Program::UpdateES3Uniformsiv( | 446 void ProgramInfoManager::Program::UpdateES3Uniformsiv( |
448 const std::vector<int8>& result) { | 447 const std::vector<int8>& result) { |
449 if (cached_es3_uniformsiv_) { | 448 if (cached_es3_uniformsiv_) { |
450 return; | 449 return; |
451 } | 450 } |
452 if (result.empty()) { | 451 if (result.empty()) { |
453 // This should only happen on a lost context. | 452 // This should only happen on a lost context. |
454 return; | 453 return; |
455 } | 454 } |
456 uniforms_es3_.clear(); | 455 DCHECK_EQ(0u, uniforms_es3_.size()); |
457 | 456 |
458 // |result| comes from GPU process. We consider it trusted data. Therefore, | 457 // |result| comes from GPU process. We consider it trusted data. Therefore, |
459 // no need to check for overflows as the GPU side did the checks already. | 458 // no need to check for overflows as the GPU side did the checks already. |
460 uint32_t header_size = sizeof(UniformsES3Header); | 459 uint32_t header_size = sizeof(UniformsES3Header); |
461 DCHECK_GE(result.size(), header_size); | 460 DCHECK_GE(result.size(), header_size); |
462 const UniformsES3Header* header = LocalGetAs<const UniformsES3Header*>( | 461 const UniformsES3Header* header = LocalGetAs<const UniformsES3Header*>( |
463 result, 0, header_size); | 462 result, 0, header_size); |
464 DCHECK(header); | 463 DCHECK(header); |
465 if (header->num_uniforms == 0) { | 464 if (header->num_uniforms == 0) { |
466 DCHECK_EQ(result.size(), header_size); | 465 DCHECK_EQ(result.size(), header_size); |
(...skipping 21 matching lines...) Expand all Loading... |
488 | 487 |
489 void ProgramInfoManager::Program::UpdateES3TransformFeedbackVaryings( | 488 void ProgramInfoManager::Program::UpdateES3TransformFeedbackVaryings( |
490 const std::vector<int8>& result) { | 489 const std::vector<int8>& result) { |
491 if (cached_es3_transform_feedback_varyings_) { | 490 if (cached_es3_transform_feedback_varyings_) { |
492 return; | 491 return; |
493 } | 492 } |
494 if (result.empty()) { | 493 if (result.empty()) { |
495 // This should only happen on a lost context. | 494 // This should only happen on a lost context. |
496 return; | 495 return; |
497 } | 496 } |
498 transform_feedback_varyings_.clear(); | 497 DCHECK_EQ(0u, transform_feedback_varyings_.size()); |
499 transform_feedback_varying_max_length_ = 0; | 498 DCHECK_EQ(0u, transform_feedback_varying_max_length_); |
500 | 499 |
501 // |result| comes from GPU process. We consider it trusted data. Therefore, | 500 // |result| comes from GPU process. We consider it trusted data. Therefore, |
502 // no need to check for overflows as the GPU side did the checks already. | 501 // no need to check for overflows as the GPU side did the checks already. |
503 uint32_t header_size = sizeof(TransformFeedbackVaryingsHeader); | 502 uint32_t header_size = sizeof(TransformFeedbackVaryingsHeader); |
504 DCHECK_GE(result.size(), header_size); | 503 DCHECK_GE(result.size(), header_size); |
505 const TransformFeedbackVaryingsHeader* header = | 504 const TransformFeedbackVaryingsHeader* header = |
506 LocalGetAs<const TransformFeedbackVaryingsHeader*>( | 505 LocalGetAs<const TransformFeedbackVaryingsHeader*>( |
507 result, 0, header_size); | 506 result, 0, header_size); |
508 DCHECK(header); | 507 DCHECK(header); |
509 if (header->num_transform_feedback_varyings == 0) { | 508 if (header->num_transform_feedback_varyings == 0) { |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 } | 990 } |
992 return true; | 991 return true; |
993 } | 992 } |
994 } | 993 } |
995 return gl->GetUniformIndicesHelper(program, count, names, indices); | 994 return gl->GetUniformIndicesHelper(program, count, names, indices); |
996 } | 995 } |
997 | 996 |
998 } // namespace gles2 | 997 } // namespace gles2 |
999 } // namespace gpu | 998 } // namespace gpu |
1000 | 999 |
OLD | NEW |