mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
Dreamcast: Only allocate necessary VRAM rows for UI textures
Doesn't usually save that much, but does make UI textures a bit quicker to upload and also makes virtual keyboard texture ~24 kb less
This commit is contained in:
parent
8dd99cb11c
commit
863906766f
@ -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) {
|
||||
|
@ -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) {
|
||||
|
2
third_party/gldc/state.c
vendored
2
third_party/gldc/state.c
vendored
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user