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

Unified Diff: gpu/command_buffer/service/texture_manager.cc

Issue 1605323004: Check if internal_format is valid for GenerateMipmap(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/texture_manager.cc
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 9345bb871568fff1ca23c7e46211fa913537b325..6c395a697e710f47d47d0bb4d14280953f8b0ac2 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -529,11 +529,9 @@ void Texture::SetMailboxManager(MailboxManager* mailbox_manager) {
mailbox_manager_ = mailbox_manager;
}
-bool Texture::MarkMipmapsGenerated(
+void Texture::MarkMipmapsGenerated(
const FeatureInfo* feature_info) {
- if (!CanGenerateMipmaps(feature_info)) {
- return false;
- }
+ DCHECK(CanGenerateMipmaps(feature_info));
for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
const Texture::FaceInfo& face_info = face_infos_[ii];
const Texture::LevelInfo& level0_info = face_info.level_infos[base_level_];
@@ -554,8 +552,6 @@ bool Texture::MarkMipmapsGenerated(
level0_info.type, gfx::Rect(width, height));
}
}
-
- return true;
}
void Texture::SetTarget(
@@ -600,20 +596,33 @@ bool Texture::CanGenerateMipmaps(
return false;
}
- // TODO(gman): Check internal_format, format and type.
+ bool valid_internal_format = false;
+ if (feature_info->validators()->texture_unsized_internal_format.IsValid(
+ base.internal_format)) {
+ valid_internal_format = true;
+ } else if (feature_info->validators()->
+ texture_sized_color_renderable_internal_format.IsValid(
+ base.internal_format) && feature_info->validators()->
+ texture_sized_texture_filterable_internal_format.IsValid(
+ base.internal_format)) {
+ valid_internal_format = true;
+ }
+ if (!valid_internal_format) {
+ return false;
+ }
+
for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
const LevelInfo& info = face_infos_[ii].level_infos[base_level_];
- if ((info.target == 0) || (info.width != base.width) ||
- (info.height != base.height) || (info.depth != base.depth) ||
- (info.format != base.format) ||
- (info.internal_format != base.internal_format) ||
- (info.type != base.type) ||
+ if ((info.target == 0) ||
feature_info->validators()->compressed_texture_format.IsValid(
info.internal_format) ||
info.image.get()) {
return false;
}
}
+ if (face_infos_.size() == 6 && !cube_complete_) {
+ return false;
+ }
return true;
}
@@ -1112,7 +1121,8 @@ void Texture::Update(const FeatureInfo* feature_info) {
texture_complete_ =
max_level_set_ >= (levels_needed - 1) && max_level_set_ >= 0;
cube_complete_ = (face_infos_.size() == 6) &&
- (first_level.width == first_level.height);
+ (first_level.width == first_level.height) &&
+ (first_level.width > 0);
if (first_level.width == 0 || first_level.height == 0) {
texture_complete_ = false;
@@ -1695,13 +1705,12 @@ void TextureManager::SetParameterf(
}
}
-bool TextureManager::MarkMipmapsGenerated(TextureRef* ref) {
+void TextureManager::MarkMipmapsGenerated(TextureRef* ref) {
DCHECK(ref);
Texture* texture = ref->texture();
texture->GetMemTracker()->TrackMemFree(texture->estimated_size());
- bool result = texture->MarkMipmapsGenerated(feature_info_.get());
+ texture->MarkMipmapsGenerated(feature_info_.get());
texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size());
- return result;
}
TextureRef* TextureManager::CreateTexture(
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698