mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
Merge pull request #719 from jonaeru/fix-menutexture
Fix menu character and weapon texture corruption
This commit is contained in:
5 files changed
+38
No files matched your search
@@ -48,6 +48,7 @@ void gfx_set_texture_filter(enum FilteringMode mode);
|
||||
void gfx_set_mipmap_filter(enum MipmapFilteringMode mode);
|
||||
void gfx_texture_cache_clear(void);
|
||||
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);
|
||||
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) ;
|
||||
|
||||
@@ -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) {
|
||||
const uint8_t* addr = loaded_texture.addr;
|
||||
const uint32_t size_bytes = loaded_texture.size_bytes;
|
||||
|
||||
@@ -74,6 +74,7 @@ s32 videoFramebuffersSupported(void);
|
||||
|
||||
void videoResetTextureCache(void);
|
||||
void videoFreeCachedTexture(const void *texptr);
|
||||
void videoFreeCachedTextures(const void *start, const void *end);
|
||||
|
||||
void videoShutdown(void);
|
||||
|
||||
|
||||
@@ -530,6 +530,11 @@ void videoFreeCachedTexture(const void *texptr)
|
||||
gfx_texture_cache_delete(texptr);
|
||||
}
|
||||
|
||||
void videoFreeCachedTextures(const void *start, const void *end)
|
||||
{
|
||||
gfx_texture_cache_delete_range(start, end);
|
||||
}
|
||||
|
||||
void videoShutdown(void)
|
||||
{
|
||||
free(vidModes);
|
||||
|
||||
@@ -1928,6 +1928,10 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype)
|
||||
totalfilelen += 0x4000;
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
videoFreeCachedTextures(menumodel->allocstart, menumodel->allocstart + menumodel->alloclen);
|
||||
#endif
|
||||
|
||||
texInitPool(&texpool, menumodel->allocstart + totalfilelen, menumodel->alloclen - totalfilelen);
|
||||
|
||||
menumodel->headnum = headnum;
|
||||
@@ -1960,6 +1964,10 @@ Gfx *menuRenderModel(Gfx *gdl, struct menumodel *menumodel, s32 modeltype)
|
||||
totalfilelen = ALIGN64(fileGetInflatedSize(menumodel->newparams, LOADTYPE_MODEL)) + 0x4000;
|
||||
if (1);
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
videoFreeCachedTextures(menumodel->allocstart, menumodel->allocstart + menumodel->alloclen);
|
||||
#endif
|
||||
|
||||
texInitPool(&texpool, &menumodel->allocstart[(u32)totalfilelen], menumodel->alloclen - totalfilelen);
|
||||
|
||||
menumodel->headnum = -1;
|
||||
|
||||
Reference in new issue
Block a user