diff --git a/src/Drawer2D.c b/src/Drawer2D.c index 084860008..3dd40a3b9 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -152,10 +152,13 @@ void Context2D_Alloc(struct Context2D* ctx, int width, int height) { ctx->height = height; ctx->meta = NULL; - if (Gfx.NonPowTwoTexturesSupport != GFX_NONPOW2_FULL) { + if (Gfx.NonPowTwoTexturesSupport == GFX_NONPOW2_NONE) { /* Allocate power-of-2 sized bitmap equal to or greater than the given size */ width = Math_NextPowOf2(width); height = Math_NextPowOf2(height); + } else if (Gfx.NonPowTwoTexturesSupport == GFX_NONPOW2_UPLOAD) { + /* Can upload texture without needing to pad up to power of two height */ + width = Math_NextPowOf2(width); } if (Gfx.MinTexWidth) { width = max(width, Gfx.MinTexWidth); } @@ -324,8 +327,16 @@ void Context2D_MakeTexture(struct Texture* tex, struct Context2D* ctx) { tex->height = nouv ? ctx->bmp.height : ctx->height; tex->uv.u1 = 0.0f; tex->uv.v1 = 0.0f; - tex->uv.u2 = (float)ctx->width / (float)ctx->bmp.width; - tex->uv.v2 = (float)ctx->height / (float)ctx->bmp.height; + if (Gfx.NonPowTwoTexturesSupport == GFX_NONPOW2_FULL) { + tex->uv.u2 = 1.0f; + tex->uv.v2 = 1.0f; + } else if (Gfx.NonPowTwoTexturesSupport == GFX_NONPOW2_UPLOAD) { + tex->uv.u2 = (float)ctx->width / (float)ctx->bmp.width; + tex->uv.v2 = (float)ctx->height / (float)Math_NextPowOf2(ctx->bmp.height); + } else { + tex->uv.u2 = (float)ctx->width / (float)ctx->bmp.width; + tex->uv.v2 = (float)ctx->height / (float)ctx->bmp.height; + } } cc_bool Drawer2D_ValidColorCodeAt(const cc_string* text, int i) { diff --git a/src/Graphics_Dreamcast.c b/src/Graphics_Dreamcast.c index 7fad6d077..4d143d236 100644 --- a/src/Graphics_Dreamcast.c +++ b/src/Graphics_Dreamcast.c @@ -274,6 +274,7 @@ void Gfx_Create(void) { Gfx.MaxTexSize = 512 * 512; // reasonable cap as Dreamcast only has 8MB VRAM Gfx.Created = true; + Gfx.NonPowTwoTexturesSupport = GFX_NONPOW2_UPLOAD; Gfx_RestoreState(); } @@ -569,6 +570,9 @@ static CC_INLINE void TwiddleCalcFactors(unsigned w, unsigned h, *maskY = 0; int shift = 0; + w = Math_NextPowOf2(w); + h = Math_NextPowOf2(h); + for (; w > 1 || h > 1; w >>= 1, h >>= 1) { if (w > 1 && h > 1) { diff --git a/third_party/gldc/state.c b/third_party/gldc/state.c index 6b33e0867..25788ec7a 100644 --- a/third_party/gldc/state.c +++ b/third_party/gldc/state.c @@ -85,7 +85,7 @@ static GLDC_NO_INLINE void apply_poly_header(pvr_poly_hdr_t* dst, int list_type) dst->mode2 |= (PVR_MIPBIAS_NORMAL << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; dst->mode2 |= (PVR_TXRENV_MODULATEALPHA << PVR_TA_PM2_TXRENV_SHIFT) & PVR_TA_PM2_TXRENV_MASK; - dst->mode2 |= ((tx1->log2_width - 3) << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; + dst->mode2 |= ((tx1->log2_width - 3) << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; dst->mode2 |= ((tx1->log2_height - 3) << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; dst->mode3 = (0 << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK;