Fix some bugs with mipmaps + compressed textures

This commit is contained in:
Luke Benstead 2018-08-20 08:34:54 +01:00
parent 25e4518501
commit 26bd8df37c
3 changed files with 12 additions and 2 deletions

View File

@ -43,6 +43,8 @@ typedef struct {
GLenum minFilter;
GLenum magFilter;
GLboolean isCompressed;
} TextureObject;
typedef struct {

View File

@ -146,6 +146,12 @@ void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit) {
break;
}
/* FIXME: If you disable mipmaps on a compressed mipmapped texture
* you get corruption and I don't know why, so we force mipmapping for now */
if(tx1->isCompressed && _glIsMipmapComplete(tx1)) {
enableMipmaps = GL_TRUE;
}
if(enableMipmaps) {
if(tx1->minFilter == GL_LINEAR_MIPMAP_NEAREST) {
filter = PVR_FILTER_TRILINEAR1;

View File

@ -330,14 +330,15 @@ void APIENTRY glCompressedTexImage2DARB(GLenum target,
TextureObject* active = TEXTURE_UNITS[ACTIVE_TEXTURE];
/* Set the required mipmap count */
active->mipmapCount = _glGetMipmapLevelCount(active);
active->mipmap = (mipmapped) ? ~0 : (1 << level); /* Set only a single bit if this wasn't mipmapped otherwise set all */
active->width = width;
active->height = height;
active->color = _determinePVRFormat(
internalFormat,
internalFormat /* Doesn't matter (see determinePVRFormat) */
);
active->mipmapCount = _glGetMipmapLevelCount(active);
active->mipmap = (mipmapped) ? ~0 : (1 << level); /* Set only a single bit if this wasn't mipmapped otherwise set all */
active->isCompressed = GL_TRUE;
/* Odds are slim new data is same size as old, so free always */
if(active->data)
@ -644,6 +645,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
GLuint size = _glGetMipmapDataSize(active);
active->data = pvr_mem_malloc(size);
active->isCompressed = GL_FALSE;
}
/* Mark this level as set in the mipmap bitmask */