don't waste a full byte on mirror/flip setting

moved MIRROR bits into bits 2 and 3 of what used to be `uv_clamp` member of TextureObject
renamed `uv_clamp` member to `uv_wrap`
updated and commented code accessing `uv_wrap` for both clamp and mirror settings
This commit is contained in:
jnmartin84 2025-07-13 00:16:43 -04:00
parent 708566af72
commit 0cd447dbcf
3 changed files with 17 additions and 17 deletions

View File

@ -138,7 +138,7 @@ typedef struct {
GLubyte mipmap_bias; GLubyte mipmap_bias;
GLubyte env; GLubyte env;
GLubyte mipmapCount; /* The number of mipmap levels */ GLubyte mipmapCount; /* The number of mipmap levels */
GLubyte uv_clamp; GLubyte uv_wrap; /* clamp and flip settings for u and v */
//40 //40
/* Mipmap textures have a different /* Mipmap textures have a different
* offset for the base level when supplying the data, this * offset for the base level when supplying the data, this
@ -153,9 +153,7 @@ typedef struct {
//50 //50
GLenum internalFormat; GLenum internalFormat;
//54 //54
GLubyte uv_flip; GLubyte padding[10]; // Pad to 64-bytes
// 55
GLubyte padding[9]; // Pad to 64-bytes
} __attribute__((aligned(32))) TextureObject; } __attribute__((aligned(32))) TextureObject;
typedef struct { typedef struct {

View File

@ -390,8 +390,10 @@ void _glUpdatePVRTextureContext(PolyContext *context, GLshort textureUnit) {
} }
context->txr.env = tx1->env; context->txr.env = tx1->env;
context->txr.uv_flip = tx1->uv_flip; // extract mirror setting from bits 2 and 3 of uv_wrap by shifting out the clamp bits and masking
context->txr.uv_clamp = tx1->uv_clamp; context->txr.uv_flip = (tx1->uv_wrap >> 2) & 3;
// extract clamp setting from bits 0 and 1 of uv_wrap by masking
context->txr.uv_clamp = tx1->uv_wrap & 3;
} }
} }

View File

@ -14,12 +14,13 @@
* issues with the allocator */ * issues with the allocator */
#define PVR_MEM_BUFFER_SIZE (64 * 1024) #define PVR_MEM_BUFFER_SIZE (64 * 1024)
/* Clamp settings go in lower bits of uv_wrap
* Mirror settings go in upper bits */
#define MIRROR_U (1<<3)
#define MIRROR_V (1<<2)
#define CLAMP_U (1<<1) #define CLAMP_U (1<<1)
#define CLAMP_V (1<<0) #define CLAMP_V (1<<0)
#define MIRROR_U (1<<1)
#define MIRROR_V (1<<0)
static TextureObject* TEXTURE_UNITS[MAX_GLDC_TEXTURE_UNITS] = {NULL, NULL}; static TextureObject* TEXTURE_UNITS[MAX_GLDC_TEXTURE_UNITS] = {NULL, NULL};
static NamedArray TEXTURE_OBJECTS; static NamedArray TEXTURE_OBJECTS;
GLubyte ACTIVE_TEXTURE = 0; GLubyte ACTIVE_TEXTURE = 0;
@ -507,8 +508,7 @@ static void _glInitializeTextureObject(TextureObject* txr, unsigned int id) {
txr->index = id; txr->index = id;
txr->width = txr->height = 0; txr->width = txr->height = 0;
txr->mipmap = 0; txr->mipmap = 0;
txr->uv_clamp = 0; txr->uv_wrap = 0;
txr->uv_flip = 0;
txr->env = GPU_TXRENV_MODULATEALPHA; txr->env = GPU_TXRENV_MODULATEALPHA;
txr->data = NULL; txr->data = NULL;
txr->mipmapCount = 0; txr->mipmapCount = 0;
@ -1897,15 +1897,15 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) {
switch(param) { switch(param) {
case GL_CLAMP_TO_EDGE: case GL_CLAMP_TO_EDGE:
case GL_CLAMP: case GL_CLAMP:
active->uv_clamp |= CLAMP_U; active->uv_wrap |= CLAMP_U;
break; break;
case GL_REPEAT: case GL_REPEAT:
active->uv_clamp &= ~CLAMP_U; active->uv_wrap &= ~CLAMP_U;
break; break;
case GL_MIRRORED_REPEAT: case GL_MIRRORED_REPEAT:
active->uv_flip |= MIRROR_U; active->uv_wrap |= MIRROR_U;
break; break;
} }
@ -1915,15 +1915,15 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) {
switch(param) { switch(param) {
case GL_CLAMP_TO_EDGE: case GL_CLAMP_TO_EDGE:
case GL_CLAMP: case GL_CLAMP:
active->uv_clamp |= CLAMP_V; active->uv_wrap |= CLAMP_V;
break; break;
case GL_REPEAT: case GL_REPEAT:
active->uv_clamp &= ~CLAMP_V; active->uv_wrap &= ~CLAMP_V;
break; break;
case GL_MIRRORED_REPEAT: case GL_MIRRORED_REPEAT:
active->uv_flip |= MIRROR_V; active->uv_wrap |= MIRROR_V;
break; break;
} }