Commit 19d438d4 by Jamie Madill

Fix checks for base and max level in Texture.

The dEQP unpack buffer tests were failing because they use a max and base level of zero with mipmapping enabled. Update our sampler completeness checks to account for min and max level. We'll have to dig in to our code to find corner cases in D3D with base and max level. Change-Id: I74357c6dc2e1908d0463d2e5cbc8ee91b61a3b7f Reviewed-on: https://chromium-review.googlesource.com/240763Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 967ed7b4
...@@ -106,9 +106,9 @@ GLenum Texture::getInternalFormat(GLenum target, size_t level) const ...@@ -106,9 +106,9 @@ GLenum Texture::getInternalFormat(GLenum target, size_t level) const
bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &data) const bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &data) const
{ {
GLenum baseTarget = getBaseImageTarget(); GLenum baseTarget = getBaseImageTarget();
size_t width = getWidth(baseTarget, 0); size_t width = getWidth(baseTarget, samplerState.baseLevel);
size_t height = getHeight(baseTarget, 0); size_t height = getHeight(baseTarget, samplerState.baseLevel);
size_t depth = getDepth(baseTarget, 0); size_t depth = getDepth(baseTarget, samplerState.baseLevel);
if (width == 0 || height == 0 || depth == 0) if (width == 0 || height == 0 || depth == 0)
{ {
return false; return false;
...@@ -119,7 +119,7 @@ bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &da ...@@ -119,7 +119,7 @@ bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &da
return false; return false;
} }
GLenum internalFormat = getInternalFormat(baseTarget, 0); GLenum internalFormat = getInternalFormat(baseTarget, samplerState.baseLevel);
const TextureCaps &textureCaps = data.textureCaps->get(internalFormat); const TextureCaps &textureCaps = data.textureCaps->get(internalFormat);
if (!textureCaps.filterable && !IsPointSampled(samplerState)) if (!textureCaps.filterable && !IsPointSampled(samplerState))
{ {
...@@ -146,7 +146,7 @@ bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &da ...@@ -146,7 +146,7 @@ bool Texture::isSamplerComplete(const SamplerState &samplerState, const Data &da
} }
} }
if (!isMipmapComplete()) if (!isMipmapComplete(samplerState))
{ {
return false; return false;
} }
...@@ -432,16 +432,19 @@ size_t Texture::getExpectedMipLevels() const ...@@ -432,16 +432,19 @@ size_t Texture::getExpectedMipLevels() const
} }
} }
bool Texture::isMipmapComplete() const bool Texture::isMipmapComplete(const gl::SamplerState &samplerState) const
{ {
size_t expectedMipLevels = getExpectedMipLevels(); size_t expectedMipLevels = getExpectedMipLevels();
for (size_t level = 0; level < expectedMipLevels; level++)
size_t maxLevel = std::min<size_t>(expectedMipLevels, samplerState.maxLevel + 1);
for (size_t level = samplerState.baseLevel; level < maxLevel; level++)
{ {
if (mTarget == GL_TEXTURE_CUBE_MAP) if (mTarget == GL_TEXTURE_CUBE_MAP)
{ {
for (GLenum face = FirstCubeMapTextureTarget; face <= LastCubeMapTextureTarget; face++) for (GLenum face = FirstCubeMapTextureTarget; face <= LastCubeMapTextureTarget; face++)
{ {
if (!isLevelComplete(face, level)) if (!isLevelComplete(face, level, samplerState))
{ {
return false; return false;
} }
...@@ -449,7 +452,7 @@ bool Texture::isMipmapComplete() const ...@@ -449,7 +452,7 @@ bool Texture::isMipmapComplete() const
} }
else else
{ {
if (!isLevelComplete(mTarget, level)) if (!isLevelComplete(mTarget, level, samplerState))
{ {
return false; return false;
} }
...@@ -460,7 +463,8 @@ bool Texture::isMipmapComplete() const ...@@ -460,7 +463,8 @@ bool Texture::isMipmapComplete() const
} }
bool Texture::isLevelComplete(GLenum target, size_t level) const bool Texture::isLevelComplete(GLenum target, size_t level,
const gl::SamplerState &samplerState) const
{ {
ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS);
...@@ -469,9 +473,9 @@ bool Texture::isLevelComplete(GLenum target, size_t level) const ...@@ -469,9 +473,9 @@ bool Texture::isLevelComplete(GLenum target, size_t level) const
return true; return true;
} }
size_t width = getWidth(target, 0); size_t width = getWidth(target, samplerState.baseLevel);
size_t height = getHeight(target, 0); size_t height = getHeight(target, samplerState.baseLevel);
size_t depth = getHeight(target, 0); size_t depth = getHeight(target, samplerState.baseLevel);
if (width == 0 || height == 0 || depth == 0) if (width == 0 || height == 0 || depth == 0)
{ {
return false; return false;
...@@ -483,7 +487,7 @@ bool Texture::isLevelComplete(GLenum target, size_t level) const ...@@ -483,7 +487,7 @@ bool Texture::isLevelComplete(GLenum target, size_t level) const
return true; return true;
} }
if (getInternalFormat(target, level) != getInternalFormat(target, 0)) if (getInternalFormat(target, level) != getInternalFormat(target, samplerState.baseLevel))
{ {
return false; return false;
} }
......
...@@ -120,8 +120,9 @@ class Texture final : public RefCountObject ...@@ -120,8 +120,9 @@ class Texture final : public RefCountObject
GLenum getBaseImageTarget() const; GLenum getBaseImageTarget() const;
size_t getExpectedMipLevels() const; size_t getExpectedMipLevels() const;
bool isMipmapComplete() const; bool isMipmapComplete(const gl::SamplerState &samplerState) const;
bool isLevelComplete(GLenum target, size_t level) const; bool isLevelComplete(GLenum target, size_t level,
const gl::SamplerState &samplerState) const;
const ImageDesc &getImageDesc(const ImageIndex &index) const; const ImageDesc &getImageDesc(const ImageIndex &index) const;
void setImageDesc(const ImageIndex &index, const ImageDesc &desc); void setImageDesc(const ImageIndex &index, const ImageDesc &desc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment