Commit 71e1e750 by Alexis Hetu Committed by Alexis Hétu

Adjusting texture completeness checks

Mipmap levels used in texture sampling must be limited by the texture's base level (default: 0) and max level (default: 1000). This has an effect on texture completeness, since only the required levels are required to be present in the texture to be considered complete. Change-Id: I31dd87d5a4306622e469c2546107b59f6e51c7dd Reviewed-on: https://swiftshader-review.googlesource.com/4039Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 46140099
...@@ -822,12 +822,12 @@ bool Texture2D::isSamplerComplete() const ...@@ -822,12 +822,12 @@ bool Texture2D::isSamplerComplete() const
// Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for 2D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool Texture2D::isMipmapComplete() const bool Texture2D::isMipmapComplete() const
{ {
GLsizei width = image[0]->getWidth(); GLsizei width = image[mBaseLevel]->getWidth();
GLsizei height = image[0]->getHeight(); GLsizei height = image[mBaseLevel]->getHeight();
int q = log2(std::max(width, height)); int q = std::min(log2(std::max(width, height)), mMaxLevel);
for(int level = 1; level <= q; level++) for(int level = mBaseLevel + 1; level <= q; level++)
{ {
if(!image[level]) if(!image[level])
{ {
...@@ -1138,17 +1138,17 @@ bool TextureCubeMap::isSamplerComplete() const ...@@ -1138,17 +1138,17 @@ bool TextureCubeMap::isSamplerComplete() const
// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool TextureCubeMap::isCubeComplete() const bool TextureCubeMap::isCubeComplete() const
{ {
if(image[0][0]->getWidth() <= 0 || image[0][0]->getHeight() != image[0][0]->getWidth()) if(image[0][mBaseLevel]->getWidth() <= 0 || image[0][mBaseLevel]->getHeight() != image[0][mBaseLevel]->getWidth())
{ {
return false; return false;
} }
for(unsigned int face = 1; face < 6; face++) for(unsigned int face = 1; face < 6; face++)
{ {
if(image[face][0]->getWidth() != image[0][0]->getWidth() || if(image[face][mBaseLevel]->getWidth() != image[0][mBaseLevel]->getWidth() ||
image[face][0]->getWidth() != image[0][0]->getHeight() || image[face][mBaseLevel]->getWidth() != image[0][mBaseLevel]->getHeight() ||
image[face][0]->getFormat() != image[0][0]->getFormat() || image[face][mBaseLevel]->getFormat() != image[0][mBaseLevel]->getFormat() ||
image[face][0]->getType() != image[0][0]->getType()) image[face][mBaseLevel]->getType() != image[0][mBaseLevel]->getType())
{ {
return false; return false;
} }
...@@ -1164,24 +1164,24 @@ bool TextureCubeMap::isMipmapCubeComplete() const ...@@ -1164,24 +1164,24 @@ bool TextureCubeMap::isMipmapCubeComplete() const
return false; return false;
} }
GLsizei size = image[0][0]->getWidth(); GLsizei size = image[0][mBaseLevel]->getWidth();
int q = log2(size); int q = std::min(log2(size), mMaxLevel);
for(int face = 0; face < 6; face++) for(int face = 0; face < 6; face++)
{ {
for(int level = 1; level <= q; level++) for(int level = mBaseLevel + 1; level <= q; level++)
{ {
if(!image[face][level]) if(!image[face][level])
{ {
return false; return false;
} }
if(image[face][level]->getFormat() != image[0][0]->getFormat()) if(image[face][level]->getFormat() != image[0][mBaseLevel]->getFormat())
{ {
return false; return false;
} }
if(image[face][level]->getType() != image[0][0]->getType()) if(image[face][level]->getType() != image[0][mBaseLevel]->getType())
{ {
return false; return false;
} }
...@@ -1722,13 +1722,13 @@ bool Texture3D::isSamplerComplete() const ...@@ -1722,13 +1722,13 @@ bool Texture3D::isSamplerComplete() const
// Tests for 3D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81. // Tests for 3D texture (mipmap) completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
bool Texture3D::isMipmapComplete() const bool Texture3D::isMipmapComplete() const
{ {
GLsizei width = image[0]->getWidth(); GLsizei width = image[mBaseLevel]->getWidth();
GLsizei height = image[0]->getHeight(); GLsizei height = image[mBaseLevel]->getHeight();
GLsizei depth = image[0]->getDepth(); GLsizei depth = image[mBaseLevel]->getDepth();
int q = log2(std::max(std::max(width, height), depth)); int q = std::min(log2(std::max(std::max(width, height), depth)), mMaxLevel);
for(int level = 1; level <= q; level++) for(int level = mBaseLevel + 1; level <= q; level++)
{ {
if(!image[level]) if(!image[level])
{ {
......
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