Pass a SamplerState as a parameter to Texture::isSamplerComplete, instead of using the internal SamplerState.
TRAC #23453
Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Authored-by: Jamie Madill
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index b1e51e0..b6072f7 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2241,10 +2241,11 @@
TextureType textureType = programBinary->getSamplerTextureType(type, samplerIndex);
Texture *texture = getSamplerTexture(textureUnit, textureType);
- if (texture->isSamplerComplete())
+ SamplerState samplerState;
+ texture->getSamplerState(&samplerState);
+
+ if (texture->isSamplerComplete(samplerState))
{
- SamplerState samplerState;
- texture->getSamplerState(&samplerState);
mRenderer->setSamplerState(type, samplerIndex, samplerState);
mRenderer->setTexture(type, samplerIndex, texture);
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 55210ec..cb9b8f2 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -25,6 +25,23 @@
namespace gl
{
+bool IsMipmapFiltered(const SamplerState &samplerState)
+{
+ switch (samplerState.minFilter)
+ {
+ case GL_NEAREST:
+ case GL_LINEAR:
+ return false;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ return true;
+ default: UNREACHABLE();
+ return false;
+ }
+}
+
Texture::Texture(rx::Renderer *renderer, GLuint id) : RefCountObject(id)
{
mRenderer = renderer;
@@ -235,23 +252,6 @@
return mUsage;
}
-bool Texture::isMipmapFiltered() const
-{
- switch (mSamplerState.minFilter)
- {
- case GL_NEAREST:
- case GL_LINEAR:
- return false;
- case GL_NEAREST_MIPMAP_NEAREST:
- case GL_LINEAR_MIPMAP_NEAREST:
- case GL_NEAREST_MIPMAP_LINEAR:
- case GL_LINEAR_MIPMAP_LINEAR:
- return true;
- default: UNREACHABLE();
- return false;
- }
-}
-
void Texture::setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image)
{
if (pixels != NULL)
@@ -664,7 +664,7 @@
}
// Tests for 2D texture sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 85.
-bool Texture2D::isSamplerComplete() const
+bool Texture2D::isSamplerComplete(const SamplerState &samplerState) const
{
GLsizei width = mImageArray[0]->getWidth();
GLsizei height = mImageArray[0]->getHeight();
@@ -674,12 +674,10 @@
return false;
}
- bool mipmapping = isMipmapFiltered();
-
if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer))
{
- if (mSamplerState.magFilter != GL_NEAREST ||
- (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+ if (samplerState.magFilter != GL_NEAREST ||
+ (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
{
return false;
}
@@ -689,14 +687,14 @@
if (!npotSupport)
{
- if ((mSamplerState.wrapS != GL_CLAMP_TO_EDGE && !isPow2(width)) ||
- (mSamplerState.wrapT != GL_CLAMP_TO_EDGE && !isPow2(height)))
+ if ((samplerState.wrapS != GL_CLAMP_TO_EDGE && !isPow2(width)) ||
+ (samplerState.wrapT != GL_CLAMP_TO_EDGE && !isPow2(height)))
{
return false;
}
}
- if (mipmapping)
+ if (IsMipmapFiltered(samplerState))
{
if (!npotSupport)
{
@@ -1159,16 +1157,16 @@
}
// Tests for cube map sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 86.
-bool TextureCubeMap::isSamplerComplete() const
+bool TextureCubeMap::isSamplerComplete(const SamplerState &samplerState) const
{
int size = mImageArray[0][0]->getWidth();
- bool mipmapping = isMipmapFiltered();
+ bool mipmapping = IsMipmapFiltered(samplerState);
if (!IsTextureFilteringSupported(getInternalFormat(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0), mRenderer))
{
- if (mSamplerState.magFilter != GL_NEAREST ||
- (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+ if (samplerState.magFilter != GL_NEAREST ||
+ (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
{
return false;
}
@@ -1176,7 +1174,7 @@
if (!isPow2(size) && !mRenderer->getNonPower2TextureSupport())
{
- if (mSamplerState.wrapS != GL_CLAMP_TO_EDGE || mSamplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
+ if (samplerState.wrapS != GL_CLAMP_TO_EDGE || samplerState.wrapT != GL_CLAMP_TO_EDGE || mipmapping)
{
return false;
}
@@ -1871,7 +1869,7 @@
}
}
-bool Texture3D::isSamplerComplete() const
+bool Texture3D::isSamplerComplete(const SamplerState &samplerState) const
{
GLsizei width = mImageArray[0]->getWidth();
GLsizei height = mImageArray[0]->getHeight();
@@ -1882,18 +1880,16 @@
return false;
}
- bool mipmapping = isMipmapFiltered();
-
if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer))
{
- if (mSamplerState.magFilter != GL_NEAREST ||
- (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+ if (samplerState.magFilter != GL_NEAREST ||
+ (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
{
return false;
}
}
- if (mipmapping && !isMipmapComplete())
+ if (IsMipmapFiltered(samplerState) && !isMipmapComplete())
{
return false;
}
@@ -2400,7 +2396,7 @@
}
}
-bool Texture2DArray::isSamplerComplete() const
+bool Texture2DArray::isSamplerComplete(const SamplerState &samplerState) const
{
GLsizei width = getWidth(0);
GLsizei height = getHeight(0);
@@ -2411,18 +2407,16 @@
return false;
}
- bool mipmapping = isMipmapFiltered();
-
if (!IsTextureFilteringSupported(getInternalFormat(0), mRenderer))
{
- if (mSamplerState.magFilter != GL_NEAREST ||
- (mSamplerState.minFilter != GL_NEAREST && mSamplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
+ if (samplerState.magFilter != GL_NEAREST ||
+ (samplerState.minFilter != GL_NEAREST && samplerState.minFilter != GL_NEAREST_MIPMAP_NEAREST))
{
return false;
}
}
- if (mipmapping && !isMipmapComplete())
+ if (IsMipmapFiltered(samplerState) && !isMipmapComplete())
{
return false;
}
diff --git a/src/libGLESv2/Texture.h b/src/libGLESv2/Texture.h
index 2a17b78..4d96f7c 100644
--- a/src/libGLESv2/Texture.h
+++ b/src/libGLESv2/Texture.h
@@ -87,10 +87,9 @@
int getLodOffset();
void getSamplerState(SamplerState *sampler);
GLenum getUsage() const;
- bool isMipmapFiltered() const;
virtual int levelCount() = 0;
- virtual bool isSamplerComplete() const = 0;
+ virtual bool isSamplerComplete(const SamplerState &samplerState) const = 0;
rx::TextureStorageInterface *getNativeTexture();
virtual Renderbuffer *getRenderbuffer(GLenum target) = 0;
@@ -167,7 +166,7 @@
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
- virtual bool isSamplerComplete() const;
+ virtual bool isSamplerComplete(const SamplerState &samplerState) const;
virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
@@ -243,7 +242,7 @@
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei size);
- virtual bool isSamplerComplete() const;
+ virtual bool isSamplerComplete(const SamplerState &samplerState) const;
virtual void generateMipmaps();
@@ -315,7 +314,7 @@
virtual void generateMipmaps();
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
- virtual bool isSamplerComplete() const;
+ virtual bool isSamplerComplete(const SamplerState &samplerState) const;
virtual bool isMipmapComplete() const;
virtual Renderbuffer *getRenderbuffer(GLenum target);
@@ -381,7 +380,7 @@
virtual void generateMipmaps();
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
- virtual bool isSamplerComplete() const;
+ virtual bool isSamplerComplete(const SamplerState &samplerState) const;
virtual bool isMipmapComplete() const;
virtual Renderbuffer *getRenderbuffer(GLenum target);