summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/test/gpu/gpu_tests/webgl2_conformance_expectations.py1
-rw-r--r--gpu/command_buffer/service/texture_manager.cc116
-rw-r--r--gpu/command_buffer/service/texture_manager.h13
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc63
4 files changed, 46 insertions, 147 deletions
diff --git a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
index 1ee338f2..325fb45 100644
--- a/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
+++ b/content/test/gpu/gpu_tests/webgl2_conformance_expectations.py
@@ -91,6 +91,7 @@ class WebGL2ConformanceExpectations(WebGLConformanceExpectations):
bug=483282)
self.Fail('conformance2/samplers/sampler-drawing-test.html', bug=483282)
self.Skip('conformance2/textures/webgl_canvas/*', bug=483282)
+ self.Fail('conformance2/textures/misc/tex-mipmap-levels.html', bug=483282)
self.Fail('conformance2/textures/misc/tex-storage-2d.html', bug=483282)
# Windows only.
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;
}
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index 7a3065e..33cd54a 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -272,9 +272,7 @@ class GPU_EXPORT Texture {
FaceInfo();
~FaceInfo();
- // This is relative to base_level and max_level of a texture.
GLsizei num_mip_levels;
- // This contains slots for all levels starting at 0.
std::vector<LevelInfo> level_infos;
};
@@ -364,11 +362,10 @@ class GPU_EXPORT Texture {
GLenum format,
GLenum type);
- // Returns true if texture mip level is complete relative to base level.
- // Note that level_diff = level - base_level.
- static bool TextureMipComplete(const Texture::LevelInfo& base_level_face,
+ // Returns true if texture mip level is complete relative to first level.
+ static bool TextureMipComplete(const Texture::LevelInfo& level0_face,
GLenum target,
- GLint level_diff,
+ GLint level,
GLenum internal_format,
GLsizei width,
GLsizei height,
@@ -421,10 +418,6 @@ class GPU_EXPORT Texture {
// referencing this texture.
void IncAllFramebufferStateChangeCount();
- void UpdateBaseLevel(GLint base_level);
- void UpdateMaxLevel(GLint max_level);
- void UpdateNumMipLevels();
-
MailboxManager* mailbox_manager_;
// Info about each face and level of texture.
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index af18f79..516f478 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -47,12 +47,12 @@ class TextureTestHelper {
class TextureManagerTest : public GpuServiceTest {
public:
- static const GLint kMaxTextureSize = 32;
+ static const GLint kMaxTextureSize = 16;
static const GLint kMaxCubeMapTextureSize = 8;
- static const GLint kMaxRectangleTextureSize = 32;
- static const GLint kMaxExternalTextureSize = 32;
+ static const GLint kMaxRectangleTextureSize = 16;
+ static const GLint kMaxExternalTextureSize = 16;
static const GLint kMax3DTextureSize = 256;
- static const GLint kMax2dLevels = 6;
+ static const GLint kMax2dLevels = 5;
static const GLint kMaxCubeMapLevels = 4;
static const GLint kMaxExternalLevels = 1;
static const bool kUseDefaultTextures = false;
@@ -465,11 +465,11 @@ TEST_F(TextureManagerTest, ValidForTargetNPOT) {
class TextureTestBase : public GpuServiceTest {
public:
- static const GLint kMaxTextureSize = 32;
+ static const GLint kMaxTextureSize = 16;
static const GLint kMaxCubeMapTextureSize = 8;
- static const GLint kMaxRectangleTextureSize = 32;
+ static const GLint kMaxRectangleTextureSize = 16;
static const GLint kMax3DTextureSize = 256;
- static const GLint kMax2dLevels = 6;
+ static const GLint kMax2dLevels = 5;
static const GLint kMaxCubeMapLevels = 4;
static const GLuint kClient1Id = 1;
static const GLuint kService1Id = 11;
@@ -684,55 +684,6 @@ TEST_F(TextureTest, POT2D) {
EXPECT_FALSE(manager_->HaveUnrenderableTextures());
}
-TEST_F(TextureTest, BaseLevel) {
- manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
- Texture* texture = texture_ref_->texture();
- EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
- // Check Setting level 1 to POT
- manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4));
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
- EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 1, GL_NO_ERROR);
- EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
- EXPECT_FALSE(manager_->HaveUnrenderableTextures());
-}
-
-TEST_F(TextureTest, BaseLevelMaxLevel) {
- manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
- Texture* texture = texture_ref_->texture();
- EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_2D), texture->target());
- // Set up level 2, 3, 4.
- manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 2, GL_RGBA, 8, 8, 1,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(8, 8));
- manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(4, 4));
- manager_->SetLevelInfo(texture_ref_.get(), GL_TEXTURE_2D, 4, GL_RGBA, 2, 2, 1,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, gfx::Rect(2, 2));
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR,
- GL_NO_ERROR);
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_MAG_FILTER, GL_LINEAR, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
- EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 2, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
- EXPECT_TRUE(manager_->HaveUnrenderableTextures());
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_MAX_LEVEL, 4, GL_NO_ERROR);
- EXPECT_TRUE(manager_->CanRender(texture_ref_.get()));
- EXPECT_FALSE(manager_->HaveUnrenderableTextures());
- SetParameter(
- texture_ref_.get(), GL_TEXTURE_BASE_LEVEL, 0, GL_NO_ERROR);
- EXPECT_FALSE(manager_->CanRender(texture_ref_.get()));
- EXPECT_TRUE(manager_->HaveUnrenderableTextures());
-}
-
TEST_F(TextureMemoryTrackerTest, MarkMipmapsGenerated) {
manager_->SetTarget(texture_ref_.get(), GL_TEXTURE_2D);
EXPECT_MEMORY_ALLOCATION_CHANGE(0, 64);