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

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

Issue 2142353002: Validate fbo color image format and fragment shader output variable type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 379 }
380 380
381 const std::vector<std::string>& transform_feedback_varyings() const { 381 const std::vector<std::string>& transform_feedback_varyings() const {
382 return transform_feedback_varyings_; 382 return transform_feedback_varyings_;
383 } 383 }
384 384
385 GLenum transform_feedback_buffer_mode() const { 385 GLenum transform_feedback_buffer_mode() const {
386 return transform_feedback_buffer_mode_; 386 return transform_feedback_buffer_mode_;
387 } 387 }
388 388
389 // Return each draw buffer's corresponding fragment shader output variable's
390 // base type: FLOAT, INT, or UINT.
391 // If the draw buffer has no corresponding output variable, its base type
392 // is UNDEFINED_TYPE.
393 // The data are only valid after a successful link.
394 const std::vector<ShaderVariableBaseType>& GetFragmentOutputBaseTypes(
395 ) const {
396 return fragment_output_base_types_;
397 }
398
389 private: 399 private:
390 friend class base::RefCounted<Program>; 400 friend class base::RefCounted<Program>;
391 friend class ProgramManager; 401 friend class ProgramManager;
392 402
393 ~Program(); 403 ~Program();
394 404
395 void set_log_info(const char* str) { 405 void set_log_info(const char* str) {
396 log_info_.reset(str ? new std::string(str) : NULL); 406 log_info_.reset(str ? new std::string(str) : NULL);
397 } 407 }
398 408
(...skipping 16 matching lines...) Expand all
415 } 425 }
416 426
417 // Resets the program. 427 // Resets the program.
418 void Reset(); 428 void Reset();
419 429
420 // Updates the program info after a successful link. 430 // Updates the program info after a successful link.
421 void Update(); 431 void Update();
422 void UpdateUniforms(); 432 void UpdateUniforms();
423 void UpdateFragmentInputs(); 433 void UpdateFragmentInputs();
424 void UpdateProgramOutputs(); 434 void UpdateProgramOutputs();
435 void UpdateFragmentOutputBaseTypes();
425 436
426 // Process the program log, replacing the hashed names with original names. 437 // Process the program log, replacing the hashed names with original names.
427 std::string ProcessLogInfo(const std::string& log); 438 std::string ProcessLogInfo(const std::string& log);
428 439
429 // Updates the program log info from GL 440 // Updates the program log info from GL
430 void UpdateLogInfo(); 441 void UpdateLogInfo();
431 442
432 // Clears all the uniforms. 443 // Clears all the uniforms.
433 void ClearUniforms(std::vector<uint8_t>* zero_buffer); 444 void ClearUniforms(std::vector<uint8_t>* zero_buffer);
434 445
435 // If long attribate names are mapped during shader translation, call 446 // If long attribate names are mapped during shader translation, call
436 // glBindAttribLocation() again with the mapped names. 447 // glBindAttribLocation() again with the mapped names.
437 // This is called right before the glLink() call, but after shaders are 448 // This is called right before the glLink() call, but after shaders are
438 // translated. 449 // translated.
439 void ExecuteBindAttribLocationCalls(); 450 void ExecuteBindAttribLocationCalls();
440 451
441 // The names of transform feedback varyings need to be hashed just 452 // The names of transform feedback varyings need to be hashed just
442 // like bound attributes' locations, just before the link call. 453 // like bound attributes' locations, just before the link call.
443 // Returns false upon failure. 454 // Returns false upon failure.
444 bool ExecuteTransformFeedbackVaryingsCall(); 455 bool ExecuteTransformFeedbackVaryingsCall();
445 456
446 void ExecuteProgramOutputBindCalls(); 457 void ExecuteProgramOutputBindCalls();
447 458
448 // Query VertexAttrib data returned by ANGLE translator by the mapped name. 459 // Query VertexAttrib data returned by ANGLE translator by the mapped name.
449 void GetVertexAttribData( 460 void GetVertexAttribData(
450 const std::string& name, std::string* original_name, GLenum* type) const; 461 const std::string& name, std::string* original_name, GLenum* type) const;
451 462
452 void DetachShaders(ShaderManager* manager); 463 void DetachShaders(ShaderManager* manager);
453 464
465 void ResetFragmentOutputBaseTypes();
466
454 static inline size_t GetUniformLocationIndexFromFakeLocation( 467 static inline size_t GetUniformLocationIndexFromFakeLocation(
455 GLint fake_location) { 468 GLint fake_location) {
456 return static_cast<size_t>(fake_location & 0xFFFF); 469 return static_cast<size_t>(fake_location & 0xFFFF);
457 } 470 }
458 471
459 static inline size_t GetArrayElementIndexFromFakeLocation( 472 static inline size_t GetArrayElementIndexFromFakeLocation(
460 GLint fake_location) { 473 GLint fake_location) {
461 return static_cast<size_t>((fake_location >> 16) & 0xFFFF); 474 return static_cast<size_t>((fake_location >> 16) & 0xFFFF);
462 } 475 }
463 476
(...skipping 22 matching lines...) Expand all
486 499
487 FragmentInputInfoVector fragment_input_infos_; 500 FragmentInputInfoVector fragment_input_infos_;
488 FragmentInputLocationVector fragment_input_locations_; 501 FragmentInputLocationVector fragment_input_locations_;
489 502
490 ProgramOutputInfoVector program_output_infos_; 503 ProgramOutputInfoVector program_output_infos_;
491 504
492 // The program this Program is tracking. 505 // The program this Program is tracking.
493 GLuint service_id_; 506 GLuint service_id_;
494 507
495 // Shaders by type of shader. 508 // Shaders by type of shader.
496 scoped_refptr<Shader> 509 scoped_refptr<Shader> attached_shaders_[kMaxAttachedShaders];
497 attached_shaders_[kMaxAttachedShaders];
498 510
499 // True if this program is marked as deleted. 511 // True if this program is marked as deleted.
500 bool deleted_; 512 bool deleted_;
501 513
502 // This is true if glLinkProgram was successful at least once. 514 // This is true if glLinkProgram was successful at least once.
503 bool valid_; 515 bool valid_;
504 516
505 // This is true if glLinkProgram was successful last time it was called. 517 // This is true if glLinkProgram was successful last time it was called.
506 bool link_status_; 518 bool link_status_;
507 519
(...skipping 13 matching lines...) Expand all
521 533
522 GLenum transform_feedback_buffer_mode_; 534 GLenum transform_feedback_buffer_mode_;
523 535
524 // Fragment input-location binding map from 536 // Fragment input-location binding map from
525 // glBindFragmentInputLocationCHROMIUM() calls. 537 // glBindFragmentInputLocationCHROMIUM() calls.
526 LocationMap bind_fragment_input_location_map_; 538 LocationMap bind_fragment_input_location_map_;
527 539
528 // output variable - (location,index) binding map from 540 // output variable - (location,index) binding map from
529 // glBindFragDataLocation() and ..IndexedEXT() calls. 541 // glBindFragDataLocation() and ..IndexedEXT() calls.
530 LocationIndexMap bind_program_output_location_index_map_; 542 LocationIndexMap bind_program_output_location_index_map_;
543
544 // Fragment output variable base types: FLOAT, INT, or UINT.
545 std::vector<ShaderVariableBaseType> fragment_output_base_types_;
531 }; 546 };
532 547
533 // Tracks the Programs. 548 // Tracks the Programs.
534 // 549 //
535 // NOTE: To support shared resources an instance of this class will 550 // NOTE: To support shared resources an instance of this class will
536 // need to be shared by multiple GLES2Decoders. 551 // need to be shared by multiple GLES2Decoders.
537 class GPU_EXPORT ProgramManager { 552 class GPU_EXPORT ProgramManager {
538 public: 553 public:
539 ProgramManager(ProgramCache* program_cache, 554 ProgramManager(ProgramCache* program_cache,
540 uint32_t max_varying_vectors, 555 uint32_t max_varying_vectors,
556 uint32_t max_draw_buffers,
541 uint32_t max_dual_source_draw_buffers, 557 uint32_t max_dual_source_draw_buffers,
542 const GpuPreferences& gpu_preferences, 558 const GpuPreferences& gpu_preferences,
543 FeatureInfo* feature_info); 559 FeatureInfo* feature_info);
544 ~ProgramManager(); 560 ~ProgramManager();
545 561
546 // Must call before destruction. 562 // Must call before destruction.
547 void Destroy(bool have_context); 563 void Destroy(bool have_context);
548 564
549 // Creates a new program. 565 // Creates a new program.
550 Program* CreateProgram(GLuint client_id, GLuint service_id); 566 Program* CreateProgram(GLuint client_id, GLuint service_id);
(...skipping 23 matching lines...) Expand all
574 // variables. 590 // variables.
575 static bool HasBuiltInPrefix(const std::string& name); 591 static bool HasBuiltInPrefix(const std::string& name);
576 592
577 // Check if a Program is owned by this ProgramManager. 593 // Check if a Program is owned by this ProgramManager.
578 bool IsOwned(Program* program) const; 594 bool IsOwned(Program* program) const;
579 595
580 static int32_t MakeFakeLocation(int32_t index, int32_t element); 596 static int32_t MakeFakeLocation(int32_t index, int32_t element);
581 597
582 uint32_t max_varying_vectors() const { return max_varying_vectors_; } 598 uint32_t max_varying_vectors() const { return max_varying_vectors_; }
583 599
600 uint32_t max_draw_buffers() const { return max_draw_buffers_; }
601
584 uint32_t max_dual_source_draw_buffers() const { 602 uint32_t max_dual_source_draw_buffers() const {
585 return max_dual_source_draw_buffers_; 603 return max_dual_source_draw_buffers_;
586 } 604 }
587 605
588 private: 606 private:
589 friend class Program; 607 friend class Program;
590 608
591 void StartTracking(Program* program); 609 void StartTracking(Program* program);
592 void StopTracking(Program* program); 610 void StopTracking(Program* program);
593 611
(...skipping 10 matching lines...) Expand all
604 unsigned int program_count_; 622 unsigned int program_count_;
605 623
606 bool have_context_; 624 bool have_context_;
607 625
608 // Used to clear uniforms. 626 // Used to clear uniforms.
609 std::vector<uint8_t> zero_; 627 std::vector<uint8_t> zero_;
610 628
611 ProgramCache* program_cache_; 629 ProgramCache* program_cache_;
612 630
613 uint32_t max_varying_vectors_; 631 uint32_t max_varying_vectors_;
632 uint32_t max_draw_buffers_;
614 uint32_t max_dual_source_draw_buffers_; 633 uint32_t max_dual_source_draw_buffers_;
615 634
616 const GpuPreferences& gpu_preferences_; 635 const GpuPreferences& gpu_preferences_;
617 scoped_refptr<FeatureInfo> feature_info_; 636 scoped_refptr<FeatureInfo> feature_info_;
618 637
619 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 638 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
620 }; 639 };
621 640
622 inline const FeatureInfo& Program::feature_info() const { 641 inline const FeatureInfo& Program::feature_info() const {
623 return *manager_->feature_info_.get(); 642 return *manager_->feature_info_.get();
624 } 643 }
625 644
626 } // namespace gles2 645 } // namespace gles2
627 } // namespace gpu 646 } // namespace gpu
628 647
629 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 648 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698