Skip to content

Commit

Permalink
include texture size for cache key (Kenix3#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored Mar 7, 2024
1 parent f79b19a commit df22bbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/graphic/Fast3D/gfx_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ static std::string gfx_get_base_texture_path(const std::string& path) {

void gfx_texture_cache_delete(const uint8_t* orig_addr) {
while (gfx_texture_cache.map.bucket_count() > 0) {
TextureCacheKey key = { orig_addr, { 0 }, 0, 0 }; // bucket index only depends on the address
TextureCacheKey key = { orig_addr, { 0 }, 0, 0, 0 }; // bucket index only depends on the address
size_t bucket = gfx_texture_cache.map.bucket(key);
bool again = false;
for (auto it = gfx_texture_cache.map.begin(bucket); it != gfx_texture_cache.map.end(bucket); ++it) {
Expand Down Expand Up @@ -968,6 +968,7 @@ static void import_texture(int i, int tile, bool importReplacement) {
uint32_t texFlags = rdp.loaded_texture[rdp.texture_tile[tile].tmem_index].tex_flags;
uint32_t tmem_index = rdp.texture_tile[tile].tmem_index;
uint8_t palette_index = rdp.texture_tile[tile].palette;
uint32_t orig_size_bytes = rdp.loaded_texture[rdp.texture_tile[tile].tmem_index].orig_size_bytes;

const RawTexMetadata* metadata = &rdp.loaded_texture[rdp.texture_tile[tile].tmem_index].raw_tex_metadata;
const uint8_t* orig_addr =
Expand All @@ -978,9 +979,9 @@ static void import_texture(int i, int tile, bool importReplacement) {

TextureCacheKey key;
if (fmt == G_IM_FMT_CI) {
key = { orig_addr, { rdp.palettes[0], rdp.palettes[1] }, fmt, siz, palette_index };
key = { orig_addr, { rdp.palettes[0], rdp.palettes[1] }, fmt, siz, palette_index, orig_size_bytes };
} else {
key = { orig_addr, {}, fmt, siz, palette_index };
key = { orig_addr, {}, fmt, siz, palette_index, orig_size_bytes };
}

if (gfx_texture_cache_lookup(i, key)) {
Expand Down Expand Up @@ -1052,7 +1053,7 @@ static void import_texture_mask(int i, int tile) {
return;
}

TextureCacheKey key = { orig_addr, {}, 0, 0, 0 };
TextureCacheKey key = { orig_addr, {}, 0, 0, 0, 0 };

if (gfx_texture_cache_lookup(i, key)) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/graphic/Fast3D/gfx_pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct TextureCacheKey {
const uint8_t* palette_addrs[2];
uint8_t fmt, siz;
uint8_t palette_index;
uint32_t size_bytes;

bool operator==(const TextureCacheKey&) const noexcept = default;

Expand Down

0 comments on commit df22bbd

Please sign in to comment.