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