From d4f22029065d1a88c4ecc5a30bc6875d5b48eb37 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 14 Feb 2024 12:50:40 +0100 Subject: [PATCH] Use po2 patches to fix mipmaps --- src/hardware/hw_cache.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c9b31932e..a4c1fc8e0 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -172,13 +172,18 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, palette = HWR_GetTexturePalette(); - ncols = (pwidth * pblockwidth) / pwidth; + //ncols = (pwidth * pblockwidth) / pwidth; + ncols = pwidth; // source advance xfrac = 0; - xfracstep = (pwidth << FRACBITS) / pblockwidth; - yfracstep = (pheight << FRACBITS) / pblockheight; - scale_y = (pblockheight << FRACBITS) / pheight; + //xfracstep = (pwidth << FRACBITS) / pblockwidth; + //yfracstep = (pheight << FRACBITS) / pblockheight; + //scale_y = (pblockheight << FRACBITS) / pheight; + + xfracstep = FRACUNIT; + yfracstep = FRACUNIT; + scale_y = FRACUNIT; bpp = format2bpp(mipmap->format); @@ -425,13 +430,20 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, bo grPatch->leftoffset = SHORT(patch->leftoffset); grPatch->topoffset = SHORT(patch->topoffset); - grMipmap->width = (UINT16)SHORT(patch->width); - grMipmap->height = (UINT16)SHORT(patch->height); + //grMipmap->width = (UINT16)SHORT(patch->width); + //grMipmap->height = (UINT16)SHORT(patch->height); + grMipmap->width = grMipmap->height = 1; + while (grMipmap->width < grPatch->width) grMipmap->width <<= 1; + while (grMipmap->height < grPatch->height) grMipmap->height <<= 1; // no wrap around, no chroma key grMipmap->flags = 0; // setup the texture info grMipmap->format = patchformat; + + //grPatch->max_s = grPatch->max_t = 1.0f; + grPatch->max_s = (float)grPatch->width / (float)grMipmap->width; + grPatch->max_t = (float)grPatch->height / (float)grMipmap->height; } Z_Free(grMipmap->data); @@ -441,12 +453,12 @@ void HWR_MakePatch (patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, bo { MakeBlock(grMipmap); HWR_DrawPatchInCache(grMipmap, - grPatch->width, grPatch->height, + grMipmap->width, grMipmap->height, grPatch->width, grPatch->height, patch); } - grPatch->max_s = grPatch->max_t = 1.0f; + //grPatch->max_s = grPatch->max_t = 1.0f; } // =================================================