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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 418 } |
419 | 419 |
420 Texture::FaceInfo::~FaceInfo() { | 420 Texture::FaceInfo::~FaceInfo() { |
421 } | 421 } |
422 | 422 |
423 Texture::CanRenderCondition Texture::GetCanRenderCondition() const { | 423 Texture::CanRenderCondition Texture::GetCanRenderCondition() const { |
424 if (target_ == 0) | 424 if (target_ == 0) |
425 return CAN_RENDER_ALWAYS; | 425 return CAN_RENDER_ALWAYS; |
426 | 426 |
427 if (target_ != GL_TEXTURE_EXTERNAL_OES) { | 427 if (target_ != GL_TEXTURE_EXTERNAL_OES) { |
428 if (face_infos_.empty()) { | 428 if (face_infos_.empty() || |
| 429 static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) { |
429 return CAN_RENDER_NEVER; | 430 return CAN_RENDER_NEVER; |
430 } | 431 } |
431 | 432 const Texture::LevelInfo& first_face = |
432 const Texture::LevelInfo& first_face = face_infos_[0].level_infos[0]; | 433 face_infos_[0].level_infos[base_level_]; |
433 if (first_face.width == 0 || | 434 if (first_face.width == 0 || |
434 first_face.height == 0 || | 435 first_face.height == 0 || |
435 first_face.depth == 0) { | 436 first_face.depth == 0) { |
436 return CAN_RENDER_NEVER; | 437 return CAN_RENDER_NEVER; |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 bool needs_mips = NeedsMips(); | 441 bool needs_mips = NeedsMips(); |
441 if (needs_mips) { | 442 if (needs_mips) { |
442 if (!texture_complete()) | 443 if (!texture_complete()) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 mailbox_manager_ = mailbox_manager; | 526 mailbox_manager_ = mailbox_manager; |
526 } | 527 } |
527 | 528 |
528 bool Texture::MarkMipmapsGenerated( | 529 bool Texture::MarkMipmapsGenerated( |
529 const FeatureInfo* feature_info) { | 530 const FeatureInfo* feature_info) { |
530 if (!CanGenerateMipmaps(feature_info)) { | 531 if (!CanGenerateMipmaps(feature_info)) { |
531 return false; | 532 return false; |
532 } | 533 } |
533 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 534 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
534 const Texture::FaceInfo& face_info = face_infos_[ii]; | 535 const Texture::FaceInfo& face_info = face_infos_[ii]; |
535 const Texture::LevelInfo& level0_info = face_info.level_infos[0]; | 536 const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_]; |
536 GLsizei width = level0_info.width; | 537 GLsizei width = level0_info.width; |
537 GLsizei height = level0_info.height; | 538 GLsizei height = level0_info.height; |
538 GLsizei depth = level0_info.depth; | 539 GLsizei depth = level0_info.depth; |
539 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : | 540 GLenum target = target_ == GL_TEXTURE_2D ? GL_TEXTURE_2D : |
540 GLES2Util::IndexToGLFaceTarget(ii); | 541 GLES2Util::IndexToGLFaceTarget(ii); |
541 | 542 |
542 const GLsizei num_mips = face_info.num_mip_levels; | 543 const GLsizei num_mips = face_info.num_mip_levels; |
543 for (GLsizei level = 1; level < num_mips; ++level) { | 544 for (GLsizei level = base_level_ + 1; |
| 545 level < base_level_ + num_mips; ++level) { |
544 width = std::max(1, width >> 1); | 546 width = std::max(1, width >> 1); |
545 height = std::max(1, height >> 1); | 547 height = std::max(1, height >> 1); |
546 depth = std::max(1, depth >> 1); | 548 depth = std::max(1, depth >> 1); |
547 SetLevelInfo(feature_info, target, level, level0_info.internal_format, | 549 SetLevelInfo(feature_info, target, level, level0_info.internal_format, |
548 width, height, depth, level0_info.border, level0_info.format, | 550 width, height, depth, level0_info.border, level0_info.format, |
549 level0_info.type, gfx::Rect(width, height)); | 551 level0_info.type, gfx::Rect(width, height)); |
550 } | 552 } |
551 } | 553 } |
552 | 554 |
553 return true; | 555 return true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 if (face_index != 0) { | 635 if (face_index != 0) { |
634 complete &= (width == first_face.width && | 636 complete &= (width == first_face.width && |
635 height == first_face.height && | 637 height == first_face.height && |
636 internal_format == first_face.internal_format && | 638 internal_format == first_face.internal_format && |
637 format == first_face.format && | 639 format == first_face.format && |
638 type == first_face.type); | 640 type == first_face.type); |
639 } | 641 } |
640 return complete; | 642 return complete; |
641 } | 643 } |
642 | 644 |
643 bool Texture::TextureMipComplete(const Texture::LevelInfo& level0_face, | 645 bool Texture::TextureMipComplete(const Texture::LevelInfo& base_level_face, |
644 GLenum target, | 646 GLenum target, |
645 GLint level, | 647 GLint level_diff, |
646 GLenum internal_format, | 648 GLenum internal_format, |
647 GLsizei width, | 649 GLsizei width, |
648 GLsizei height, | 650 GLsizei height, |
649 GLsizei depth, | 651 GLsizei depth, |
650 GLenum format, | 652 GLenum format, |
651 GLenum type) { | 653 GLenum type) { |
652 bool complete = (target != 0); | 654 bool complete = (target != 0); |
653 if (level != 0) { | 655 if (level_diff > 0) { |
654 const GLsizei mip_width = std::max(1, level0_face.width >> level); | 656 const GLsizei mip_width = std::max(1, base_level_face.width >> level_diff); |
655 const GLsizei mip_height = std::max(1, level0_face.height >> level); | 657 const GLsizei mip_height = |
656 const GLsizei mip_depth = std::max(1, level0_face.depth >> level); | 658 std::max(1, base_level_face.height >> level_diff); |
| 659 const GLsizei mip_depth = std::max(1, base_level_face.depth >> level_diff); |
657 | 660 |
658 complete &= (width == mip_width && | 661 complete &= (width == mip_width && |
659 height == mip_height && | 662 height == mip_height && |
660 depth == mip_depth && | 663 depth == mip_depth && |
661 internal_format == level0_face.internal_format && | 664 internal_format == base_level_face.internal_format && |
662 format == level0_face.format && | 665 format == base_level_face.format && |
663 type == level0_face.type); | 666 type == base_level_face.type); |
664 } | 667 } |
665 return complete; | 668 return complete; |
666 } | 669 } |
667 | 670 |
668 void Texture::SetLevelClearedRect(GLenum target, | 671 void Texture::SetLevelClearedRect(GLenum target, |
669 GLint level, | 672 GLint level, |
670 const gfx::Rect& cleared_rect) { | 673 const gfx::Rect& cleared_rect) { |
671 DCHECK_GE(level, 0); | 674 DCHECK_GE(level, 0); |
672 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 675 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
673 DCHECK_LT(static_cast<size_t>(face_index), | 676 DCHECK_LT(static_cast<size_t>(face_index), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 int delta = has_images ? +1 : -1; | 768 int delta = has_images ? +1 : -1; |
766 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) | 769 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) |
767 (*it)->manager()->UpdateNumImages(delta); | 770 (*it)->manager()->UpdateNumImages(delta); |
768 } | 771 } |
769 | 772 |
770 void Texture::IncAllFramebufferStateChangeCount() { | 773 void Texture::IncAllFramebufferStateChangeCount() { |
771 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) | 774 for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it) |
772 (*it)->manager()->IncFramebufferStateChangeCount(); | 775 (*it)->manager()->IncFramebufferStateChangeCount(); |
773 } | 776 } |
774 | 777 |
| 778 void Texture::UpdateBaseLevel(GLint base_level) { |
| 779 if (base_level_ == base_level) |
| 780 return; |
| 781 base_level_ = base_level; |
| 782 |
| 783 UpdateNumMipLevels(); |
| 784 } |
| 785 |
| 786 void Texture::UpdateMaxLevel(GLint max_level) { |
| 787 if (max_level_ == max_level) |
| 788 return; |
| 789 max_level_ = max_level; |
| 790 |
| 791 UpdateNumMipLevels(); |
| 792 } |
| 793 |
| 794 void Texture::UpdateNumMipLevels() { |
| 795 if (face_infos_.empty()) |
| 796 return; |
| 797 |
| 798 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
| 799 Texture::FaceInfo& face_info = face_infos_[ii]; |
| 800 if (static_cast<size_t>(base_level_) >= face_info.level_infos.size()) |
| 801 continue; |
| 802 const Texture::LevelInfo& info = face_info.level_infos[base_level_]; |
| 803 face_info.num_mip_levels = std::min( |
| 804 std::max(0, max_level_ - base_level_ + 1), |
| 805 TextureManager::ComputeMipMapCount( |
| 806 target_, info.width, info.height, info.depth)); |
| 807 } |
| 808 |
| 809 // mipmap-completeness needs to be re-evaluated. |
| 810 texture_mips_dirty_ = true; |
| 811 } |
| 812 |
775 void Texture::SetLevelInfo(const FeatureInfo* feature_info, | 813 void Texture::SetLevelInfo(const FeatureInfo* feature_info, |
776 GLenum target, | 814 GLenum target, |
777 GLint level, | 815 GLint level, |
778 GLenum internal_format, | 816 GLenum internal_format, |
779 GLsizei width, | 817 GLsizei width, |
780 GLsizei height, | 818 GLsizei height, |
781 GLsizei depth, | 819 GLsizei depth, |
782 GLint border, | 820 GLint border, |
783 GLenum format, | 821 GLenum format, |
784 GLenum type, | 822 GLenum type, |
(...skipping 13 matching lines...) Expand all Loading... |
798 // Update counters only if any attributes have changed. Counters are | 836 // Update counters only if any attributes have changed. Counters are |
799 // comparisons between the old and new values so it must be done before any | 837 // comparisons between the old and new values so it must be done before any |
800 // assignment has been done to the LevelInfo. | 838 // assignment has been done to the LevelInfo. |
801 if (info.target != target || | 839 if (info.target != target || |
802 info.internal_format != internal_format || | 840 info.internal_format != internal_format || |
803 info.width != width || | 841 info.width != width || |
804 info.height != height || | 842 info.height != height || |
805 info.depth != depth || | 843 info.depth != depth || |
806 info.format != format || | 844 info.format != format || |
807 info.type != type) { | 845 info.type != type) { |
808 if (level == 0) { | 846 if (level == base_level_) { |
809 // Calculate the mip level count. | 847 // Calculate the mip level count. |
810 face_infos_[face_index].num_mip_levels = | 848 face_infos_[face_index].num_mip_levels = std::min( |
811 TextureManager::ComputeMipMapCount(target_, width, height, depth); | 849 std::max(0, max_level_ - base_level_ + 1), |
| 850 TextureManager::ComputeMipMapCount(target_, width, height, depth)); |
812 | 851 |
813 // Update NPOT face count for the first level. | 852 // Update NPOT face count for the first level. |
814 bool prev_npot = TextureIsNPOT(info.width, info.height, info.depth); | 853 bool prev_npot = TextureIsNPOT(info.width, info.height, info.depth); |
815 bool now_npot = TextureIsNPOT(width, height, depth); | 854 bool now_npot = TextureIsNPOT(width, height, depth); |
816 if (prev_npot != now_npot) | 855 if (prev_npot != now_npot) |
817 num_npot_faces_ += now_npot ? 1 : -1; | 856 num_npot_faces_ += now_npot ? 1 : -1; |
818 | 857 |
819 // Signify that level 0 has been changed, so they need to be reverified. | 858 // Signify that level 0 has been changed, so they need to be reverified. |
820 texture_level0_dirty_ = true; | 859 texture_level0_dirty_ = true; |
821 } | 860 } |
822 | 861 |
823 // Signify that at least one of the mips has changed. | 862 // Signify that at least one of the mips has changed. |
824 texture_mips_dirty_ = true; | 863 texture_mips_dirty_ = true; |
825 } | 864 } |
826 | 865 |
827 info.target = target; | 866 info.target = target; |
828 info.level = level; | 867 info.level = level; |
829 info.internal_format = internal_format; | 868 info.internal_format = internal_format; |
830 info.depth = depth; | 869 info.depth = depth; |
831 info.border = border; | 870 info.border = border; |
832 info.format = format; | 871 info.format = format; |
833 info.type = type; | 872 info.type = type; |
834 info.image = 0; | 873 info.image = 0; |
835 info.image_state = UNBOUND; | 874 info.image_state = UNBOUND; |
836 | 875 |
837 UpdateMipCleared(&info, width, height, cleared_rect); | 876 UpdateMipCleared(&info, width, height, cleared_rect); |
838 | 877 |
839 estimated_size_ -= info.estimated_size; | 878 estimated_size_ -= info.estimated_size; |
840 GLES2Util::ComputeImageDataSizes( | 879 GLES2Util::ComputeImageDataSizes( |
841 width, height, 1, format, type, 4, &info.estimated_size, NULL, NULL); | 880 width, height, depth, format, type, 4, &info.estimated_size, NULL, NULL); |
842 estimated_size_ += info.estimated_size; | 881 estimated_size_ += info.estimated_size; |
843 | 882 |
844 max_level_set_ = std::max(max_level_set_, level); | 883 max_level_set_ = std::max(max_level_set_, level); |
845 Update(feature_info); | 884 Update(feature_info); |
846 UpdateCleared(); | 885 UpdateCleared(); |
847 UpdateCanRenderCondition(); | 886 UpdateCanRenderCondition(); |
848 UpdateHasImages(); | 887 UpdateHasImages(); |
849 if (IsAttachedToFramebuffer()) { | 888 if (IsAttachedToFramebuffer()) { |
850 // TODO(gman): If textures tracked which framebuffers they were attached to | 889 // TODO(gman): If textures tracked which framebuffers they were attached to |
851 // we could just mark those framebuffers as not complete. | 890 // we could just mark those framebuffers as not complete. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 case GL_TEXTURE_COMPARE_MODE: | 1018 case GL_TEXTURE_COMPARE_MODE: |
980 if (!feature_info->validators()->texture_compare_mode.IsValid(param)) { | 1019 if (!feature_info->validators()->texture_compare_mode.IsValid(param)) { |
981 return GL_INVALID_ENUM; | 1020 return GL_INVALID_ENUM; |
982 } | 1021 } |
983 compare_mode_ = param; | 1022 compare_mode_ = param; |
984 break; | 1023 break; |
985 case GL_TEXTURE_BASE_LEVEL: | 1024 case GL_TEXTURE_BASE_LEVEL: |
986 if (param < 0) { | 1025 if (param < 0) { |
987 return GL_INVALID_VALUE; | 1026 return GL_INVALID_VALUE; |
988 } | 1027 } |
989 base_level_ = param; | 1028 UpdateBaseLevel(param); |
990 break; | 1029 break; |
991 case GL_TEXTURE_MAX_LEVEL: | 1030 case GL_TEXTURE_MAX_LEVEL: |
992 if (param < 0) { | 1031 if (param < 0) { |
993 return GL_INVALID_VALUE; | 1032 return GL_INVALID_VALUE; |
994 } | 1033 } |
995 max_level_ = param; | 1034 UpdateMaxLevel(param); |
996 break; | 1035 break; |
997 case GL_TEXTURE_MAX_ANISOTROPY_EXT: | 1036 case GL_TEXTURE_MAX_ANISOTROPY_EXT: |
998 if (param < 1) { | 1037 if (param < 1) { |
999 return GL_INVALID_VALUE; | 1038 return GL_INVALID_VALUE; |
1000 } | 1039 } |
1001 break; | 1040 break; |
1002 case GL_TEXTURE_USAGE_ANGLE: | 1041 case GL_TEXTURE_USAGE_ANGLE: |
1003 if (!feature_info->validators()->texture_usage.IsValid(param)) { | 1042 if (!feature_info->validators()->texture_usage.IsValid(param)) { |
1004 return GL_INVALID_ENUM; | 1043 return GL_INVALID_ENUM; |
1005 } | 1044 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 return GL_INVALID_ENUM; | 1087 return GL_INVALID_ENUM; |
1049 } | 1088 } |
1050 return GL_NO_ERROR; | 1089 return GL_NO_ERROR; |
1051 } | 1090 } |
1052 | 1091 |
1053 void Texture::Update(const FeatureInfo* feature_info) { | 1092 void Texture::Update(const FeatureInfo* feature_info) { |
1054 // Update npot status. | 1093 // Update npot status. |
1055 // Assume GL_TEXTURE_EXTERNAL_OES textures are npot, all others | 1094 // Assume GL_TEXTURE_EXTERNAL_OES textures are npot, all others |
1056 npot_ = (target_ == GL_TEXTURE_EXTERNAL_OES) || (num_npot_faces_ > 0); | 1095 npot_ = (target_ == GL_TEXTURE_EXTERNAL_OES) || (num_npot_faces_ > 0); |
1057 | 1096 |
1058 if (face_infos_.empty()) { | 1097 if (face_infos_.empty() || |
| 1098 static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) { |
1059 texture_complete_ = false; | 1099 texture_complete_ = false; |
1060 cube_complete_ = false; | 1100 cube_complete_ = false; |
1061 return; | 1101 return; |
1062 } | 1102 } |
1063 | 1103 |
1064 // Update texture_complete and cube_complete status. | 1104 // Update texture_complete and cube_complete status. |
1065 const Texture::FaceInfo& first_face = face_infos_[0]; | 1105 const Texture::FaceInfo& first_face = face_infos_[0]; |
1066 const Texture::LevelInfo& first_level = first_face.level_infos[0]; | 1106 const Texture::LevelInfo& first_level = first_face.level_infos[base_level_]; |
1067 const GLsizei levels_needed = first_face.num_mip_levels; | 1107 const GLsizei levels_needed = first_face.num_mip_levels; |
1068 | 1108 |
1069 texture_complete_ = | 1109 texture_complete_ = |
1070 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; | 1110 max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0; |
1071 cube_complete_ = (face_infos_.size() == 6) && | 1111 cube_complete_ = (face_infos_.size() == 6) && |
1072 (first_level.width == first_level.height); | 1112 (first_level.width == first_level.height); |
1073 | 1113 |
1074 if (first_level.width == 0 || first_level.height == 0) { | 1114 if (first_level.width == 0 || first_level.height == 0) { |
1075 texture_complete_ = false; | 1115 texture_complete_ = false; |
1076 } else if (first_level.type == GL_FLOAT && | 1116 } else if (first_level.type == GL_FLOAT && |
1077 !feature_info->feature_flags().enable_texture_float_linear && | 1117 !feature_info->feature_flags().enable_texture_float_linear && |
1078 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || | 1118 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || |
1079 mag_filter_ != GL_NEAREST)) { | 1119 mag_filter_ != GL_NEAREST)) { |
1080 texture_complete_ = false; | 1120 texture_complete_ = false; |
1081 } else if (first_level.type == GL_HALF_FLOAT_OES && | 1121 } else if (first_level.type == GL_HALF_FLOAT_OES && |
1082 !feature_info->feature_flags().enable_texture_half_float_linear && | 1122 !feature_info->feature_flags().enable_texture_half_float_linear && |
1083 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || | 1123 (min_filter_ != GL_NEAREST_MIPMAP_NEAREST || |
1084 mag_filter_ != GL_NEAREST)) { | 1124 mag_filter_ != GL_NEAREST)) { |
1085 texture_complete_ = false; | 1125 texture_complete_ = false; |
1086 } | 1126 } |
1087 | 1127 |
1088 if (cube_complete_ && texture_level0_dirty_) { | 1128 if (cube_complete_ && texture_level0_dirty_) { |
1089 texture_level0_complete_ = true; | 1129 texture_level0_complete_ = true; |
1090 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 1130 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
1091 const Texture::LevelInfo& level0 = face_infos_[ii].level_infos[0]; | 1131 const Texture::LevelInfo& face_base_level = |
| 1132 face_infos_[ii].level_infos[base_level_]; |
1092 if (!TextureFaceComplete(first_level, | 1133 if (!TextureFaceComplete(first_level, |
1093 ii, | 1134 ii, |
1094 level0.target, | 1135 face_base_level.target, |
1095 level0.internal_format, | 1136 face_base_level.internal_format, |
1096 level0.width, | 1137 face_base_level.width, |
1097 level0.height, | 1138 face_base_level.height, |
1098 level0.depth, | 1139 face_base_level.depth, |
1099 level0.format, | 1140 face_base_level.format, |
1100 level0.type)) { | 1141 face_base_level.type)) { |
1101 texture_level0_complete_ = false; | 1142 texture_level0_complete_ = false; |
1102 break; | 1143 break; |
1103 } | 1144 } |
1104 } | 1145 } |
1105 texture_level0_dirty_ = false; | 1146 texture_level0_dirty_ = false; |
1106 } | 1147 } |
1107 cube_complete_ &= texture_level0_complete_; | 1148 cube_complete_ &= texture_level0_complete_; |
1108 | 1149 |
1109 if (texture_complete_ && texture_mips_dirty_) { | 1150 if (texture_complete_ && texture_mips_dirty_) { |
1110 texture_mips_complete_ = true; | 1151 texture_mips_complete_ = true; |
1111 for (size_t ii = 0; | 1152 for (size_t ii = 0; |
1112 ii < face_infos_.size() && texture_mips_complete_; | 1153 ii < face_infos_.size() && texture_mips_complete_; |
1113 ++ii) { | 1154 ++ii) { |
1114 const Texture::FaceInfo& face_info = face_infos_[ii]; | 1155 const Texture::FaceInfo& face_info = face_infos_[ii]; |
1115 const Texture::LevelInfo& level0 = face_info.level_infos[0]; | 1156 const Texture::LevelInfo& base_level_info = |
| 1157 face_info.level_infos[base_level_]; |
1116 for (GLsizei jj = 1; jj < levels_needed; ++jj) { | 1158 for (GLsizei jj = 1; jj < levels_needed; ++jj) { |
1117 const Texture::LevelInfo& level_info = face_infos_[ii].level_infos[jj]; | 1159 const Texture::LevelInfo& level_info = |
1118 if (!TextureMipComplete(level0, | 1160 face_infos_[ii].level_infos[base_level_ + jj]; |
| 1161 if (!TextureMipComplete(base_level_info, |
1119 level_info.target, | 1162 level_info.target, |
1120 jj, | 1163 jj, // level - base_level_ |
1121 level_info.internal_format, | 1164 level_info.internal_format, |
1122 level_info.width, | 1165 level_info.width, |
1123 level_info.height, | 1166 level_info.height, |
1124 level_info.depth, | 1167 level_info.depth, |
1125 level_info.format, | 1168 level_info.format, |
1126 level_info.type)) { | 1169 level_info.type)) { |
1127 texture_mips_complete_ = false; | 1170 texture_mips_complete_ = false; |
1128 break; | 1171 break; |
1129 } | 1172 } |
1130 } | 1173 } |
1131 } | 1174 } |
1132 texture_mips_dirty_ = false; | 1175 texture_mips_dirty_ = false; |
1133 } | 1176 } |
1134 texture_complete_ &= texture_mips_complete_; | 1177 texture_complete_ &= texture_mips_complete_; |
1135 } | 1178 } |
1136 | 1179 |
1137 bool Texture::ClearRenderableLevels(GLES2Decoder* decoder) { | 1180 bool Texture::ClearRenderableLevels(GLES2Decoder* decoder) { |
1138 DCHECK(decoder); | 1181 DCHECK(decoder); |
1139 if (cleared_) { | 1182 if (cleared_) { |
1140 return true; | 1183 return true; |
1141 } | 1184 } |
1142 | 1185 |
1143 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { | 1186 for (size_t ii = 0; ii < face_infos_.size(); ++ii) { |
1144 const Texture::FaceInfo& face_info = face_infos_[ii]; | 1187 const Texture::FaceInfo& face_info = face_infos_[ii]; |
1145 for (GLint jj = 0; jj < face_info.num_mip_levels; ++jj) { | 1188 for (GLint jj = base_level_; |
| 1189 jj < base_level_ + face_info.num_mip_levels; ++jj) { |
1146 const Texture::LevelInfo& info = face_info.level_infos[jj]; | 1190 const Texture::LevelInfo& info = face_info.level_infos[jj]; |
1147 if (info.target != 0) { | 1191 if (info.target != 0) { |
1148 if (!ClearLevel(decoder, info.target, jj)) { | 1192 if (!ClearLevel(decoder, info.target, jj)) { |
1149 return false; | 1193 return false; |
1150 } | 1194 } |
1151 } | 1195 } |
1152 } | 1196 } |
1153 } | 1197 } |
1154 UpdateSafeToRenderFrom(true); | 1198 UpdateSafeToRenderFrom(true); |
1155 return true; | 1199 return true; |
1156 } | 1200 } |
1157 | 1201 |
1158 gfx::Rect Texture::GetLevelClearedRect(GLenum target, GLint level) const { | 1202 gfx::Rect Texture::GetLevelClearedRect(GLenum target, GLint level) const { |
1159 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1203 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1160 if (face_index >= face_infos_.size() || | 1204 if (face_index >= face_infos_.size() || |
1161 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { | 1205 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { |
1162 return gfx::Rect(); | 1206 return gfx::Rect(); |
1163 } | 1207 } |
1164 | 1208 |
1165 const Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; | 1209 const Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
1166 | 1210 |
1167 return info.cleared_rect; | 1211 return info.cleared_rect; |
1168 } | 1212 } |
1169 | 1213 |
1170 bool Texture::IsLevelCleared(GLenum target, GLint level) const { | 1214 bool Texture::IsLevelCleared(GLenum target, GLint level) const { |
1171 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1215 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1172 if (face_index >= face_infos_.size() || | 1216 if (face_index >= face_infos_.size() || |
| 1217 level < base_level_ || |
1173 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { | 1218 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { |
1174 return true; | 1219 return true; |
1175 } | 1220 } |
1176 | 1221 |
1177 const Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; | 1222 const Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
1178 | 1223 |
1179 return info.cleared_rect == gfx::Rect(info.width, info.height); | 1224 return info.cleared_rect == gfx::Rect(info.width, info.height); |
1180 } | 1225 } |
1181 | 1226 |
1182 void Texture::InitTextureMaxAnisotropyIfNeeded(GLenum target) { | 1227 void Texture::InitTextureMaxAnisotropyIfNeeded(GLenum target) { |
1183 if (texture_max_anisotropy_initialized_) | 1228 if (texture_max_anisotropy_initialized_) |
1184 return; | 1229 return; |
1185 texture_max_anisotropy_initialized_ = true; | 1230 texture_max_anisotropy_initialized_ = true; |
1186 GLfloat params[] = { 1.0f }; | 1231 GLfloat params[] = { 1.0f }; |
1187 glTexParameterfv(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, params); | 1232 glTexParameterfv(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, params); |
1188 } | 1233 } |
1189 | 1234 |
1190 bool Texture::ClearLevel( | 1235 bool Texture::ClearLevel( |
1191 GLES2Decoder* decoder, GLenum target, GLint level) { | 1236 GLES2Decoder* decoder, GLenum target, GLint level) { |
1192 DCHECK(decoder); | 1237 DCHECK(decoder); |
1193 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); | 1238 size_t face_index = GLES2Util::GLTargetToFaceIndex(target); |
1194 if (face_index >= face_infos_.size() || | 1239 if (face_index >= face_infos_.size() || |
| 1240 level < base_level_ || |
1195 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { | 1241 level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) { |
1196 return true; | 1242 return true; |
1197 } | 1243 } |
1198 | 1244 |
1199 Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; | 1245 Texture::LevelInfo& info = face_infos_[face_index].level_infos[level]; |
1200 | 1246 |
1201 DCHECK(target == info.target); | 1247 DCHECK(target == info.target); |
1202 | 1248 |
1203 if (info.target == 0 || | 1249 if (info.target == 0 || |
1204 info.cleared_rect == gfx::Rect(info.width, info.height) || | 1250 info.cleared_rect == gfx::Rect(info.width, info.height) || |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2209 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2164 | 2210 |
2165 // Dump all sub-levels held by the texture. They will appear below the main | 2211 // Dump all sub-levels held by the texture. They will appear below the main |
2166 // gl/textures/client_X/texture_Y dump. | 2212 // gl/textures/client_X/texture_Y dump. |
2167 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), | 2213 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), |
2168 dump_name); | 2214 dump_name); |
2169 } | 2215 } |
2170 | 2216 |
2171 } // namespace gles2 | 2217 } // namespace gles2 |
2172 } // namespace gpu | 2218 } // namespace gpu |
OLD | NEW |