Merge pull request #719 from jonaeru/fix-menutexture

Fix menu character and weapon texture corruption
This commit is contained in:
fgsfds authored and GitHub committed 2026-05-02 12:19:48 +02:00
commit 45139a9293
5 files changed
+38

No files matched your search

+1
View File
@@ -48,6 +48,7 @@ void gfx_set_texture_filter(enum FilteringMode mode);
void gfx_set_mipmap_filter(enum MipmapFilteringMode mode); void gfx_set_mipmap_filter(enum MipmapFilteringMode mode);
void gfx_texture_cache_clear(void); void gfx_texture_cache_clear(void);
void gfx_texture_cache_delete(const uint8_t *orig_addr); void gfx_texture_cache_delete(const uint8_t *orig_addr);
void gfx_texture_cache_delete_range(const uint8_t *start, const uint8_t *end);
int gfx_create_framebuffer(uint32_t width, uint32_t height, int upscale, int autoresize); int gfx_create_framebuffer(uint32_t width, uint32_t height, int upscale, int autoresize);
void gfx_resize_framebuffer(int fb, uint32_t width, uint32_t height, int upscale, int autoresize); void gfx_resize_framebuffer(int fb, uint32_t width, uint32_t height, int upscale, int autoresize);
void gfx_set_framebuffer(int fb, float noise_scale) ; void gfx_set_framebuffer(int fb, float noise_scale) ;
+23
View File
@@ -585,6 +585,29 @@ void gfx_texture_cache_delete(const uint8_t* orig_addr) {
} }
} }
void gfx_texture_cache_delete_range(const uint8_t* start, const uint8_t* end) {
gfx_flush();
for (int i = 0; i < 2; ++i) {
if (rendering_state.textures[i]
&& rendering_state.textures[i]->first.texture_addr >= start
&& rendering_state.textures[i]->first.texture_addr < end) {
rdp.textures_changed[i] = true;
rendering_state.textures[i] = nullptr;
}
}
for (auto it = gfx_texture_cache.map.begin(); it != gfx_texture_cache.map.end(); ) {
if (it->first.texture_addr >= start && it->first.texture_addr < end) {
gfx_texture_cache.lru.erase(it->second.lru_location);
gfx_texture_cache.free_texture_ids.push_back(it->second.texture_id);
it = gfx_texture_cache.map.erase(it);
} else {
++it;
}
}
}
static void import_texture_rgba16(int tile, const LoadedTexture& loaded_texture, bool gen_mipmaps) { static void import_texture_rgba16(int tile, const LoadedTexture& loaded_texture, bool gen_mipmaps) {
const uint8_t* addr = loaded_texture.addr; const uint8_t* addr = loaded_texture.addr;
const uint32_t size_bytes = loaded_texture.size_bytes; const uint32_t size_bytes = loaded_texture.size_bytes;
+1
View File
@@ -74,6 +74,7 @@ s32 videoFramebuffersSupported(void);
void videoResetTextureCache(void); void videoResetTextureCache(void);
void videoFreeCachedTexture(const void *texptr); void videoFreeCachedTexture(const void *texptr);
void videoFreeCachedTextures(const void *start, const void *end);
void videoShutdown(void); void videoShutdown(void);
+5
View File
@@ -530,6 +530,11 @@ void videoFreeCachedTexture(const void *texptr)
gfx_texture_cache_delete(texptr); gfx_texture_cache_delete(texptr);
} }
void videoFreeCachedTextures(const void *start, const void *end)
{
gfx_texture_cache_delete_range(start, end);
}
void videoShutdown(void) void videoShutdown(void)
{ {
free(vidModes); free(vidModes);
+8
View File
@@ -1928,6 +1928,10 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype)
totalfilelen += 0x4000; totalfilelen += 0x4000;
#endif #endif
#ifndef PLATFORM_N64
videoFreeCachedTextures(menumodel->allocstart, menumodel->allocstart + menumodel->alloclen);
#endif
texInitPool(&texpool, menumodel->allocstart + totalfilelen, menumodel->alloclen - totalfilelen); texInitPool(&texpool, menumodel->allocstart + totalfilelen, menumodel->alloclen - totalfilelen);
menumodel->headnum = headnum; menumodel->headnum = headnum;
@@ -1960,6 +1964,10 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype)
totalfilelen = ALIGN64(fileGetInflatedSize(menumodel->newparams, LOADTYPE_MODEL)) + 0x4000; totalfilelen = ALIGN64(fileGetInflatedSize(menumodel->newparams, LOADTYPE_MODEL)) + 0x4000;
if (1); if (1);
#ifndef PLATFORM_N64
videoFreeCachedTextures(menumodel->allocstart, menumodel->allocstart + menumodel->alloclen);
#endif
texInitPool(&texpool, &menumodel->allocstart[(u32)totalfilelen], menumodel->alloclen - totalfilelen); texInitPool(&texpool, &menumodel->allocstart[(u32)totalfilelen], menumodel->alloclen - totalfilelen);
menumodel->headnum = -1; menumodel->headnum = -1;