summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/texture_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/service/texture_manager.cc')
-rw-r--r--gpu/command_buffer/service/texture_manager.cc116
1 files changed, 35 insertions, 81 deletions
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index eb46353..4fb92c6 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -425,12 +425,11 @@ Texture::CanRenderCondition Texture::GetCanRenderCondition() const {
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 @@ bool Texture::MarkMipmapsGenerated(
}
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 @@ bool Texture::MarkMipmapsGenerated(
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 @@ bool Texture::TextureFaceComplete(const Texture::LevelInfo& first_face,
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 @@ bool Texture::TextureMipComplete(const Texture::LevelInfo& base_level_face,
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;
}
@@ -775,41 +772,6 @@ void Texture::IncAllFramebufferStateChangeCount() {
(*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,
GLenum target,
GLint level,
@@ -843,11 +805,10 @@ void Texture::SetLevelInfo(const FeatureInfo* feature_info,
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 @@ void Texture::SetLevelInfo(const FeatureInfo* feature_info,
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 @@ GLenum Texture::SetParameteri(
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 @@ void Texture::Update(const FeatureInfo* feature_info) {
// 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 @@ void Texture::Update(const FeatureInfo* feature_info) {
// 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 @@ void Texture::Update(const FeatureInfo* feature_info) {
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 @@ void Texture::Update(const FeatureInfo* feature_info) {
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 @@ bool Texture::ClearRenderableLevels(GLES2Decoder* decoder) {
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 @@ gfx::Rect Texture::GetLevelClearedRect(GLenum target, GLint level) const {
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 @@ bool Texture::ClearLevel(
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;
}