Commit 80b651df by Nicolas Capens

Implement GL_GENERATE_MIPMAP.

Bug 21278131 Change-Id: I6252b84f0fd810496475a6e19c9f131bb69d977f Reviewed-on: https://swiftshader-review.googlesource.com/3194Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent c0aa94dc
...@@ -35,6 +35,7 @@ Texture::Texture(GLuint name) : egl::Texture(name) ...@@ -35,6 +35,7 @@ Texture::Texture(GLuint name) : egl::Texture(name)
mWrapS = GL_REPEAT; mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT; mWrapT = GL_REPEAT;
mMaxAnisotropy = 1.0f; mMaxAnisotropy = 1.0f;
generateMipmap = GL_FALSE;
cropRectU = 0; cropRectU = 0;
cropRectV = 0; cropRectV = 0;
cropRectW = 0; cropRectW = 0;
...@@ -148,6 +149,11 @@ bool Texture::setMaxAnisotropy(float textureMaxAnisotropy) ...@@ -148,6 +149,11 @@ bool Texture::setMaxAnisotropy(float textureMaxAnisotropy)
return true; return true;
} }
void Texture::setGenerateMipmap(GLboolean enable)
{
generateMipmap = enable;
}
void Texture::setCropRect(GLint u, GLint v, GLint w, GLint h) void Texture::setCropRect(GLint u, GLint v, GLint w, GLint h)
{ {
cropRectU = u; cropRectU = u;
...@@ -181,6 +187,11 @@ GLfloat Texture::getMaxAnisotropy() const ...@@ -181,6 +187,11 @@ GLfloat Texture::getMaxAnisotropy() const
return mMaxAnisotropy; return mMaxAnisotropy;
} }
GLboolean Texture::getGenerateMipmap() const
{
return generateMipmap;
}
GLint Texture::getCropRectU() const GLint Texture::getCropRectU() const
{ {
return cropRectU; return cropRectU;
...@@ -694,6 +705,12 @@ void Texture2D::generateMipmaps() ...@@ -694,6 +705,12 @@ void Texture2D::generateMipmaps()
egl::Image *Texture2D::getImage(unsigned int level) egl::Image *Texture2D::getImage(unsigned int level)
{ {
if(generateMipmap && image[0]->hasDirtyMipmaps())
{
generateMipmaps();
image[0]->cleanMipmaps();
}
return image[level]; return image[level];
} }
......
...@@ -64,6 +64,7 @@ public: ...@@ -64,6 +64,7 @@ public:
bool setWrapS(GLenum wrap); bool setWrapS(GLenum wrap);
bool setWrapT(GLenum wrap); bool setWrapT(GLenum wrap);
bool setMaxAnisotropy(GLfloat textureMaxAnisotropy); bool setMaxAnisotropy(GLfloat textureMaxAnisotropy);
void setGenerateMipmap(GLboolean enable);
void setCropRect(GLint u, GLint v, GLint w, GLint h); void setCropRect(GLint u, GLint v, GLint w, GLint h);
GLenum getMinFilter() const; GLenum getMinFilter() const;
...@@ -71,6 +72,7 @@ public: ...@@ -71,6 +72,7 @@ public:
GLenum getWrapS() const; GLenum getWrapS() const;
GLenum getWrapT() const; GLenum getWrapT() const;
GLfloat getMaxAnisotropy() const; GLfloat getMaxAnisotropy() const;
GLboolean getGenerateMipmap() const;
GLint getCropRectU() const; GLint getCropRectU() const;
GLint getCropRectV() const; GLint getCropRectV() const;
GLint getCropRectW() const; GLint getCropRectW() const;
...@@ -110,6 +112,7 @@ protected: ...@@ -110,6 +112,7 @@ protected:
GLenum mWrapS; GLenum mWrapS;
GLenum mWrapT; GLenum mWrapT;
GLfloat mMaxAnisotropy; GLfloat mMaxAnisotropy;
GLboolean generateMipmap;
GLint cropRectU; GLint cropRectU;
GLint cropRectV; GLint cropRectV;
GLint cropRectW; GLint cropRectW;
......
...@@ -2263,6 +2263,9 @@ void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) ...@@ -2263,6 +2263,9 @@ void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params)
case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_MAX_ANISOTROPY_EXT:
*params = texture->getMaxAnisotropy(); *params = texture->getMaxAnisotropy();
break; break;
case GL_GENERATE_MIPMAP:
*params = (GLfloat)texture->getGenerateMipmap();
break;
case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
*params = (GLfloat)1; *params = (GLfloat)1;
break; break;
...@@ -2311,6 +2314,9 @@ void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) ...@@ -2311,6 +2314,9 @@ void GetTexParameteriv(GLenum target, GLenum pname, GLint* params)
case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_MAX_ANISOTROPY_EXT:
*params = (GLint)texture->getMaxAnisotropy(); *params = (GLint)texture->getMaxAnisotropy();
break; break;
case GL_GENERATE_MIPMAP:
*params = (GLint)texture->getGenerateMipmap();
break;
case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
*params = 1; *params = 1;
break; break;
...@@ -3376,6 +3382,9 @@ void TexParameterf(GLenum target, GLenum pname, GLfloat param) ...@@ -3376,6 +3382,9 @@ void TexParameterf(GLenum target, GLenum pname, GLfloat param)
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
break; break;
case GL_GENERATE_MIPMAP:
texture->setGenerateMipmap((GLboolean)param);
break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -3441,6 +3450,9 @@ void TexParameteri(GLenum target, GLenum pname, GLint param) ...@@ -3441,6 +3450,9 @@ void TexParameteri(GLenum target, GLenum pname, GLint param)
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
break; break;
case GL_GENERATE_MIPMAP:
texture->setGenerateMipmap((GLboolean)param);
break;
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
......
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