Merge branch 'mirrored_repeat' into 'master'

Implement GL_MIRRORED_REPEAT support

See merge request simulant/GLdc!162
This commit is contained in:
Luke Benstead 2025-07-13 06:01:49 +00:00
commit 6619c3d397
4 changed files with 25 additions and 8 deletions

View File

@ -138,7 +138,7 @@ typedef struct {
GLubyte mipmap_bias;
GLubyte env;
GLubyte mipmapCount; /* The number of mipmap levels */
GLubyte uv_clamp;
GLubyte uv_wrap; /* clamp and flip settings for u and v */
//40
/* Mipmap textures have a different
* offset for the base level when supplying the data, this

View File

@ -390,8 +390,10 @@ void _glUpdatePVRTextureContext(PolyContext *context, GLshort textureUnit) {
}
context->txr.env = tx1->env;
context->txr.uv_flip = GPU_UVFLIP_NONE;
context->txr.uv_clamp = tx1->uv_clamp;
// extract mirror setting from bits 2 and 3 of uv_wrap by shifting out the clamp bits and masking
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,6 +14,10 @@
* issues with the allocator */
#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_V (1<<0)
@ -504,7 +508,7 @@ static void _glInitializeTextureObject(TextureObject* txr, unsigned int id) {
txr->index = id;
txr->width = txr->height = 0;
txr->mipmap = 0;
txr->uv_clamp = 0;
txr->uv_wrap = 0;
txr->env = GPU_TXRENV_MODULATEALPHA;
txr->data = NULL;
txr->mipmapCount = 0;
@ -1893,11 +1897,16 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) {
switch(param) {
case GL_CLAMP_TO_EDGE:
case GL_CLAMP:
active->uv_clamp |= CLAMP_U;
active->uv_wrap |= CLAMP_U;
break;
case GL_REPEAT:
active->uv_clamp &= ~CLAMP_U;
active->uv_wrap &= ~CLAMP_U;
break;
case GL_MIRRORED_REPEAT:
active->uv_wrap &= ~CLAMP_U;
active->uv_wrap |= MIRROR_U;
break;
}
@ -1907,11 +1916,16 @@ void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param) {
switch(param) {
case GL_CLAMP_TO_EDGE:
case GL_CLAMP:
active->uv_clamp |= CLAMP_V;
active->uv_wrap |= CLAMP_V;
break;
case GL_REPEAT:
active->uv_clamp &= ~CLAMP_V;
active->uv_wrap &= ~CLAMP_V;
break;
case GL_MIRRORED_REPEAT:
active->uv_wrap &= ~CLAMP_V;
active->uv_wrap |= MIRROR_V;
break;
}

View File

@ -116,6 +116,7 @@ __BEGIN_DECLS
#define GL_TEXTURE_WRAP_T 0x2803
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_MIRRORED_REPEAT 0x2902
#define GL_REPEAT 0x2901
#define GL_CLAMP 0x2900