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

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: Fix 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 383 }
384 384
385 const std::vector<std::string>& transform_feedback_varyings() const { 385 const std::vector<std::string>& transform_feedback_varyings() const {
386 return transform_feedback_varyings_; 386 return transform_feedback_varyings_;
387 } 387 }
388 388
389 GLenum transform_feedback_buffer_mode() const { 389 GLenum transform_feedback_buffer_mode() const {
390 return transform_feedback_buffer_mode_; 390 return transform_feedback_buffer_mode_;
391 } 391 }
392 392
393 // See member declaration for details.
394 // The data are only valid after a successful link.
395 uint32_t fragment_output_type_mask() const {
396 return fragment_output_type_mask_;
397 }
398 uint32_t fragment_output_written_mask() const {
399 return fragment_output_written_mask_;
400 }
401
393 private: 402 private:
394 friend class base::RefCounted<Program>; 403 friend class base::RefCounted<Program>;
395 friend class ProgramManager; 404 friend class ProgramManager;
396 405
397 ~Program(); 406 ~Program();
398 407
399 void set_log_info(const char* str) { 408 void set_log_info(const char* str) {
400 log_info_.reset(str ? new std::string(str) : NULL); 409 log_info_.reset(str ? new std::string(str) : NULL);
401 } 410 }
402 411
(...skipping 16 matching lines...) Expand all
419 } 428 }
420 429
421 // Resets the program. 430 // Resets the program.
422 void Reset(); 431 void Reset();
423 432
424 // Updates the program info after a successful link. 433 // Updates the program info after a successful link.
425 void Update(); 434 void Update();
426 void UpdateUniforms(); 435 void UpdateUniforms();
427 void UpdateFragmentInputs(); 436 void UpdateFragmentInputs();
428 void UpdateProgramOutputs(); 437 void UpdateProgramOutputs();
438 void UpdateFragmentOutputBaseTypes();
429 439
430 // Process the program log, replacing the hashed names with original names. 440 // Process the program log, replacing the hashed names with original names.
431 std::string ProcessLogInfo(const std::string& log); 441 std::string ProcessLogInfo(const std::string& log);
432 442
433 // Updates the program log info from GL 443 // Updates the program log info from GL
434 void UpdateLogInfo(); 444 void UpdateLogInfo();
435 445
436 // Clears all the uniforms. 446 // Clears all the uniforms.
437 void ClearUniforms(std::vector<uint8_t>* zero_buffer); 447 void ClearUniforms(std::vector<uint8_t>* zero_buffer);
438 448
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 500
491 FragmentInputInfoVector fragment_input_infos_; 501 FragmentInputInfoVector fragment_input_infos_;
492 FragmentInputLocationVector fragment_input_locations_; 502 FragmentInputLocationVector fragment_input_locations_;
493 503
494 ProgramOutputInfoVector program_output_infos_; 504 ProgramOutputInfoVector program_output_infos_;
495 505
496 // The program this Program is tracking. 506 // The program this Program is tracking.
497 GLuint service_id_; 507 GLuint service_id_;
498 508
499 // Shaders by type of shader. 509 // Shaders by type of shader.
500 scoped_refptr<Shader> 510 scoped_refptr<Shader> attached_shaders_[kMaxAttachedShaders];
501 attached_shaders_[kMaxAttachedShaders];
502 511
503 // True if this program is marked as deleted. 512 // True if this program is marked as deleted.
504 bool deleted_; 513 bool deleted_;
505 514
506 // This is true if glLinkProgram was successful at least once. 515 // This is true if glLinkProgram was successful at least once.
507 bool valid_; 516 bool valid_;
508 517
509 // This is true if glLinkProgram was successful last time it was called. 518 // This is true if glLinkProgram was successful last time it was called.
510 bool link_status_; 519 bool link_status_;
511 520
(...skipping 13 matching lines...) Expand all
525 534
526 GLenum transform_feedback_buffer_mode_; 535 GLenum transform_feedback_buffer_mode_;
527 536
528 // Fragment input-location binding map from 537 // Fragment input-location binding map from
529 // glBindFragmentInputLocationCHROMIUM() calls. 538 // glBindFragmentInputLocationCHROMIUM() calls.
530 LocationMap bind_fragment_input_location_map_; 539 LocationMap bind_fragment_input_location_map_;
531 540
532 // output variable - (location,index) binding map from 541 // output variable - (location,index) binding map from
533 // glBindFragDataLocation() and ..IndexedEXT() calls. 542 // glBindFragDataLocation() and ..IndexedEXT() calls.
534 LocationIndexMap bind_program_output_location_index_map_; 543 LocationIndexMap bind_program_output_location_index_map_;
544
545 // Fragment output variable base types: FLOAT, INT, or UINT.
546 // We have up to 16 outputs, each is encoded into 2 bits, total 32 bits:
547 // the lowest 2 bits for location 0, the highest 2 bits for location 15.
548 uint32_t fragment_output_type_mask_;
549 // Same layout as above, 2 bits per location, 0x03 if a location is occupied
550 // by an output variable, 0x00 if not.
551 uint32_t fragment_output_written_mask_;
535 }; 552 };
536 553
537 // Tracks the Programs. 554 // Tracks the Programs.
538 // 555 //
539 // NOTE: To support shared resources an instance of this class will 556 // NOTE: To support shared resources an instance of this class will
540 // need to be shared by multiple GLES2Decoders. 557 // need to be shared by multiple GLES2Decoders.
541 class GPU_EXPORT ProgramManager { 558 class GPU_EXPORT ProgramManager {
542 public: 559 public:
543 ProgramManager(ProgramCache* program_cache, 560 ProgramManager(ProgramCache* program_cache,
544 uint32_t max_varying_vectors, 561 uint32_t max_varying_vectors,
562 uint32_t max_draw_buffers,
545 uint32_t max_dual_source_draw_buffers, 563 uint32_t max_dual_source_draw_buffers,
546 const GpuPreferences& gpu_preferences, 564 const GpuPreferences& gpu_preferences,
547 FeatureInfo* feature_info); 565 FeatureInfo* feature_info);
548 ~ProgramManager(); 566 ~ProgramManager();
549 567
550 // Must call before destruction. 568 // Must call before destruction.
551 void Destroy(bool have_context); 569 void Destroy(bool have_context);
552 570
553 // Creates a new program. 571 // Creates a new program.
554 Program* CreateProgram(GLuint client_id, GLuint service_id); 572 Program* CreateProgram(GLuint client_id, GLuint service_id);
(...skipping 23 matching lines...) Expand all
578 // variables. 596 // variables.
579 static bool HasBuiltInPrefix(const std::string& name); 597 static bool HasBuiltInPrefix(const std::string& name);
580 598
581 // Check if a Program is owned by this ProgramManager. 599 // Check if a Program is owned by this ProgramManager.
582 bool IsOwned(Program* program) const; 600 bool IsOwned(Program* program) const;
583 601
584 static int32_t MakeFakeLocation(int32_t index, int32_t element); 602 static int32_t MakeFakeLocation(int32_t index, int32_t element);
585 603
586 uint32_t max_varying_vectors() const { return max_varying_vectors_; } 604 uint32_t max_varying_vectors() const { return max_varying_vectors_; }
587 605
606 uint32_t max_draw_buffers() const { return max_draw_buffers_; }
607
588 uint32_t max_dual_source_draw_buffers() const { 608 uint32_t max_dual_source_draw_buffers() const {
589 return max_dual_source_draw_buffers_; 609 return max_dual_source_draw_buffers_;
590 } 610 }
591 611
592 private: 612 private:
593 friend class Program; 613 friend class Program;
594 614
595 void StartTracking(Program* program); 615 void StartTracking(Program* program);
596 void StopTracking(Program* program); 616 void StopTracking(Program* program);
597 617
(...skipping 10 matching lines...) Expand all
608 unsigned int program_count_; 628 unsigned int program_count_;
609 629
610 bool have_context_; 630 bool have_context_;
611 631
612 // Used to clear uniforms. 632 // Used to clear uniforms.
613 std::vector<uint8_t> zero_; 633 std::vector<uint8_t> zero_;
614 634
615 ProgramCache* program_cache_; 635 ProgramCache* program_cache_;
616 636
617 uint32_t max_varying_vectors_; 637 uint32_t max_varying_vectors_;
638 uint32_t max_draw_buffers_;
618 uint32_t max_dual_source_draw_buffers_; 639 uint32_t max_dual_source_draw_buffers_;
619 640
620 const GpuPreferences& gpu_preferences_; 641 const GpuPreferences& gpu_preferences_;
621 scoped_refptr<FeatureInfo> feature_info_; 642 scoped_refptr<FeatureInfo> feature_info_;
622 643
623 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 644 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
624 }; 645 };
625 646
626 inline const FeatureInfo& Program::feature_info() const { 647 inline const FeatureInfo& Program::feature_info() const {
627 return *manager_->feature_info_.get(); 648 return *manager_->feature_info_.get();
628 } 649 }
629 650
630 } // namespace gles2 651 } // namespace gles2
631 } // namespace gpu 652 } // namespace gpu
632 653
633 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 654 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698