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

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

Issue 1425943002: Revert of Fix WebGL 2 texture renderability check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 eb4635372cc8e93f03cb0459f6aceb3c4c4700e9..4fb92c6019812b26380e50e3bb4a66b51d9787b1 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -425,12 +425,11 @@
return CAN_RENDER_ALWAYS;
if (target_ != GL_TEXTURE_EXTERNAL_OES) {
- if (face_infos_.empty() ||
- static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) {
+ if (face_infos_.empty()) {
return CAN_RENDER_NEVER;
}
- const Texture::LevelInfo& first_face =
- face_infos_[0].level_infos[base_level_];
+
+ const Texture::LevelInfo& first_face = face_infos_[0].level_infos[0];
if (first_face.width == 0 ||
first_face.height == 0 ||
first_face.depth == 0) {
@@ -533,7 +532,7 @@
}
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_];
+ const Texture::LevelInfo& level0_info = face_info.level_infos[0];
GLsizei width = level0_info.width;
GLsizei height = level0_info.height;
GLsizei depth = level0_info.depth;
@@ -541,8 +540,7 @@
GLES2Util::IndexToGLFaceTarget(ii);
const GLsizei num_mips = face_info.num_mip_levels;
- for (GLsizei level = base_level_ + 1;
- level < base_level_ + num_mips; ++level) {
+ for (GLsizei level = 1; level < num_mips; ++level) {
width = std::max(1, width >> 1);
height = std::max(1, height >> 1);
depth = std::max(1, depth >> 1);
@@ -642,9 +640,9 @@
return complete;
}
-bool Texture::TextureMipComplete(const Texture::LevelInfo& base_level_face,
+bool Texture::TextureMipComplete(const Texture::LevelInfo& level0_face,
GLenum target,
- GLint level_diff,
+ GLint level,
GLenum internal_format,
GLsizei width,
GLsizei height,
@@ -652,18 +650,17 @@
GLenum format,
GLenum type) {
bool complete = (target != 0);
- if (level_diff > 0) {
- const GLsizei mip_width = std::max(1, base_level_face.width >> level_diff);
- const GLsizei mip_height =
- std::max(1, base_level_face.height >> level_diff);
- const GLsizei mip_depth = std::max(1, base_level_face.depth >> level_diff);
+ if (level != 0) {
+ const GLsizei mip_width = std::max(1, level0_face.width >> level);
+ const GLsizei mip_height = std::max(1, level0_face.height >> level);
+ const GLsizei mip_depth = std::max(1, level0_face.depth >> level);
complete &= (width == mip_width &&
height == mip_height &&
depth == mip_depth &&
- internal_format == base_level_face.internal_format &&
- format == base_level_face.format &&
- type == base_level_face.type);
+ internal_format == level0_face.internal_format &&
+ format == level0_face.format &&
+ type == level0_face.type);
}
return complete;
}
@@ -773,41 +770,6 @@
void Texture::IncAllFramebufferStateChangeCount() {
for (RefSet::iterator it = refs_.begin(); it != refs_.end(); ++it)
(*it)->manager()->IncFramebufferStateChangeCount();
-}
-
-void Texture::UpdateBaseLevel(GLint base_level) {
- if (base_level_ == base_level)
- return;
- base_level_ = base_level;
-
- UpdateNumMipLevels();
-}
-
-void Texture::UpdateMaxLevel(GLint max_level) {
- if (max_level_ == max_level)
- return;
- max_level_ = max_level;
-
- UpdateNumMipLevels();
-}
-
-void Texture::UpdateNumMipLevels() {
- if (face_infos_.empty())
- return;
-
- for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
- Texture::FaceInfo& face_info = face_infos_[ii];
- if (static_cast<size_t>(base_level_) >= face_info.level_infos.size())
- continue;
- const Texture::LevelInfo& info = face_info.level_infos[base_level_];
- face_info.num_mip_levels = std::min(
- std::max(0, max_level_ - base_level_ + 1),
- TextureManager::ComputeMipMapCount(
- target_, info.width, info.height, info.depth));
- }
-
- // mipmap-completeness needs to be re-evaluated.
- texture_mips_dirty_ = true;
}
void Texture::SetLevelInfo(const FeatureInfo* feature_info,
@@ -843,11 +805,10 @@
info.depth != depth ||
info.format != format ||
info.type != type) {
- if (level == base_level_) {
+ if (level == 0) {
// Calculate the mip level count.
- face_infos_[face_index].num_mip_levels = std::min(
- std::max(0, max_level_ - base_level_ + 1),
- TextureManager::ComputeMipMapCount(target_, width, height, depth));
+ face_infos_[face_index].num_mip_levels =
+ TextureManager::ComputeMipMapCount(target_, width, height, depth);
// Update NPOT face count for the first level.
bool prev_npot = TextureIsNPOT(info.width, info.height, info.depth);
@@ -877,7 +838,7 @@
estimated_size_ -= info.estimated_size;
GLES2Util::ComputeImageDataSizes(
- width, height, depth, format, type, 4, &info.estimated_size, NULL, NULL);
+ width, height, 1, format, type, 4, &info.estimated_size, NULL, NULL);
estimated_size_ += info.estimated_size;
max_level_set_ = std::max(max_level_set_, level);
@@ -1025,13 +986,13 @@
if (param < 0) {
return GL_INVALID_VALUE;
}
- UpdateBaseLevel(param);
+ base_level_ = param;
break;
case GL_TEXTURE_MAX_LEVEL:
if (param < 0) {
return GL_INVALID_VALUE;
}
- UpdateMaxLevel(param);
+ max_level_ = param;
break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (param < 1) {
@@ -1094,8 +1055,7 @@
// Assume GL_TEXTURE_EXTERNAL_OES textures are npot, all others
npot_ = (target_ == GL_TEXTURE_EXTERNAL_OES) || (num_npot_faces_ > 0);
- if (face_infos_.empty() ||
- static_cast<size_t>(base_level_) >= face_infos_[0].level_infos.size()) {
+ if (face_infos_.empty()) {
texture_complete_ = false;
cube_complete_ = false;
return;
@@ -1103,7 +1063,7 @@
// Update texture_complete and cube_complete status.
const Texture::FaceInfo& first_face = face_infos_[0];
- const Texture::LevelInfo& first_level = first_face.level_infos[base_level_];
+ const Texture::LevelInfo& first_level = first_face.level_infos[0];
const GLsizei levels_needed = first_face.num_mip_levels;
texture_complete_ =
@@ -1128,17 +1088,16 @@
if (cube_complete_ && texture_level0_dirty_) {
texture_level0_complete_ = true;
for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
- const Texture::LevelInfo& face_base_level =
- face_infos_[ii].level_infos[base_level_];
+ const Texture::LevelInfo& level0 = face_infos_[ii].level_infos[0];
if (!TextureFaceComplete(first_level,
ii,
- face_base_level.target,
- face_base_level.internal_format,
- face_base_level.width,
- face_base_level.height,
- face_base_level.depth,
- face_base_level.format,
- face_base_level.type)) {
+ level0.target,
+ level0.internal_format,
+ level0.width,
+ level0.height,
+ level0.depth,
+ level0.format,
+ level0.type)) {
texture_level0_complete_ = false;
break;
}
@@ -1153,14 +1112,12 @@
ii < face_infos_.size() && texture_mips_complete_;
++ii) {
const Texture::FaceInfo& face_info = face_infos_[ii];
- const Texture::LevelInfo& base_level_info =
- face_info.level_infos[base_level_];
+ const Texture::LevelInfo& level0 = face_info.level_infos[0];
for (GLsizei jj = 1; jj < levels_needed; ++jj) {
- const Texture::LevelInfo& level_info =
- face_infos_[ii].level_infos[base_level_ + jj];
- if (!TextureMipComplete(base_level_info,
+ const Texture::LevelInfo& level_info = face_infos_[ii].level_infos[jj];
+ if (!TextureMipComplete(level0,
level_info.target,
- jj, // level - base_level_
+ jj,
level_info.internal_format,
level_info.width,
level_info.height,
@@ -1185,8 +1142,7 @@
for (size_t ii = 0; ii < face_infos_.size(); ++ii) {
const Texture::FaceInfo& face_info = face_infos_[ii];
- for (GLint jj = base_level_;
- jj < base_level_ + face_info.num_mip_levels; ++jj) {
+ for (GLint jj = 0; jj < face_info.num_mip_levels; ++jj) {
const Texture::LevelInfo& info = face_info.level_infos[jj];
if (info.target != 0) {
if (!ClearLevel(decoder, info.target, jj)) {
@@ -1214,7 +1170,6 @@
bool Texture::IsLevelCleared(GLenum target, GLint level) const {
size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
if (face_index >= face_infos_.size() ||
- level < base_level_ ||
level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) {
return true;
}
@@ -1237,7 +1192,6 @@
DCHECK(decoder);
size_t face_index = GLES2Util::GLTargetToFaceIndex(target);
if (face_index >= face_infos_.size() ||
- level < base_level_ ||
level >= static_cast<GLint>(face_infos_[face_index].level_infos.size())) {
return true;
}
« 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