Workaround CopyTex incremental ID leakage

This commit is contained in:
Luke Street
2026-06-16 01:51:05 -06:00
parent 153231b398
commit 3f1c26f2a6
3 changed files with 8 additions and 4 deletions
+4
View File
@@ -106,6 +106,10 @@ struct GXTexObj_ {
// Custom flag for texture caching
bool no_cache() const noexcept { return (flags & 0x80) != 0; }
void set_no_cache(bool value) noexcept { flags = value ? flags | 0x80 : flags & ~0x80; }
// Hacky workaround for an instances where incremental IDs are used for GXCopyTex, but the copy tex was invalidated
// and the texture reference is still present.
bool has_data() const noexcept { return reinterpret_cast<uintptr_t>(data) >= 0x10000; }
};
static_assert(sizeof(GXTexObj_) <= sizeof(GXTexObj), "GXTexObj too small!");
struct GXTlutObj_ {
+2 -2
View File
@@ -270,7 +270,7 @@ uint32_t texture_base_level_size(const GXTexObj_& obj) noexcept {
std::optional<uint64_t> compute_referenced_tlut_hash(const GXTexObj_& obj, std::span<const uint8_t> tlutData) noexcept {
const uint32_t textureSize = texture_base_level_size(obj);
const auto* textureData = static_cast<const uint8_t*>(obj.data);
if (!is_palette_format(obj.format()) || textureData == nullptr || textureSize == 0 || tlutData.empty()) {
if (!is_palette_format(obj.format()) || !obj.has_data() || textureSize == 0 || tlutData.empty()) {
return std::nullopt;
}
@@ -350,7 +350,7 @@ aurora::texture::TextureSourceKey build_source_key_base(const GXTexObj_& obj) no
};
const uint32_t textureSize = texture_base_level_size(obj);
if (obj.data != nullptr && textureSize != 0) {
if (obj.has_data() && textureSize != 0) {
key.textureHash = XXH64(obj.data, textureSize, 0);
}
return key;
+2 -2
View File
@@ -461,14 +461,14 @@ void resolve_sampled_textures(const ShaderInfo& info) noexcept {
if (tlut.data != nullptr) {
if (copyRef != nullptr) {
handle = resolve_dynamic_palette_texture(obj, *copyRef, tlut);
} else {
} else if (obj.has_data()) {
handle = resolve_static_palette_texture(obj, tlut);
}
}
}
} else if (copyRef != nullptr) {
handle = copyRef->handle;
} else if (obj.data != nullptr) {
} else if (obj.has_data()) {
handle = resolve_static_texture(obj);
}