mirror of
https://github.com/encounter/aurora.git
synced 2026-07-09 18:19:33 -07:00
Workaround CopyTex incremental ID leakage
This commit is contained in:
@@ -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_ {
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user