reset texture path cache on reload
This commit is contained in:
parent
1a34f6416b
commit
9a3d7a9db3
@ -502,6 +502,7 @@ static void load_game(void) {
|
||||
|
||||
static void reset_state(void) {
|
||||
input_reset_state(&ctx.input);
|
||||
textures_reset_state();
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,4 +87,6 @@ enum texture_mode textures_get_mode(const struct texture_cache *cache, t_texture
|
||||
/* returns the number of atlases in the cache */
|
||||
size_t textures_get_num_atlases(const struct texture_cache *cache);
|
||||
|
||||
void textures_reset_state(void);
|
||||
|
||||
#endif
|
||||
|
@ -385,20 +385,20 @@ void textures_update_atlas(struct texture_cache *cache) {
|
||||
/* EXPERIMANTAL: LIKELY TO BE REMOVED! */
|
||||
#ifdef __linux__ /* use rodata elf section for fast lookups of repeating textures */
|
||||
|
||||
#include "../system/linux/elf.h"
|
||||
#include "townengine/system/linux/elf.h"
|
||||
|
||||
static const char *rodata_start;
|
||||
static const char *rodata_stop;
|
||||
|
||||
/* TODO: separate and reuse */
|
||||
t_texture_key textures_get_key(struct texture_cache *cache, const char *path) {
|
||||
static const char *last_path = NULL;
|
||||
static t_texture_key last_texture;
|
||||
static struct ptr_to_texture {
|
||||
static const char *last_path = NULL;
|
||||
static t_texture_key last_texture;
|
||||
static struct ptr_to_texture {
|
||||
const void *key;
|
||||
t_texture_key value;
|
||||
} *ptr_to_texture;
|
||||
} *ptr_to_texture;
|
||||
|
||||
/* TODO: separate and reuse */
|
||||
t_texture_key textures_get_key(struct texture_cache *cache, const char *path) {
|
||||
if (rodata_stop == NULL)
|
||||
if (!infer_elf_section_bounds(".rodata", &rodata_start, &rodata_stop))
|
||||
CRY("Section inference", ".rodata section lookup failed");
|
||||
@ -548,3 +548,12 @@ enum texture_mode textures_get_mode(const struct texture_cache *cache, t_texture
|
||||
size_t textures_get_num_atlases(const struct texture_cache *cache) {
|
||||
return cache->atlas_index + 1;
|
||||
}
|
||||
|
||||
void textures_reset_state(void) {
|
||||
#ifdef __linux__
|
||||
last_path = NULL;
|
||||
last_texture = (t_texture_key){0};
|
||||
shfree(ptr_to_texture);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user