mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Move TCacheEntry out of TextureCacheBase
Allows for fowards declaration
This commit is contained in:
@ -62,13 +62,13 @@ static int xfb_count = 0;
|
|||||||
|
|
||||||
std::unique_ptr<TextureCacheBase> g_texture_cache;
|
std::unique_ptr<TextureCacheBase> g_texture_cache;
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry::TCacheEntry(std::unique_ptr<AbstractTexture> tex,
|
TCacheEntry::TCacheEntry(std::unique_ptr<AbstractTexture> tex,
|
||||||
std::unique_ptr<AbstractFramebuffer> fb)
|
std::unique_ptr<AbstractFramebuffer> fb)
|
||||||
: texture(std::move(tex)), framebuffer(std::move(fb))
|
: texture(std::move(tex)), framebuffer(std::move(fb))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry::~TCacheEntry()
|
TCacheEntry::~TCacheEntry()
|
||||||
{
|
{
|
||||||
for (auto& reference : references)
|
for (auto& reference : references)
|
||||||
reference->references.erase(this);
|
reference->references.erase(this);
|
||||||
@ -240,7 +240,7 @@ void TextureCacheBase::Cleanup(int _frameCount)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureCacheBase::TCacheEntry::OverlapsMemoryRange(u32 range_address, u32 range_size) const
|
bool TCacheEntry::OverlapsMemoryRange(u32 range_address, u32 range_size) const
|
||||||
{
|
{
|
||||||
if (addr + size_in_bytes <= range_address)
|
if (addr + size_in_bytes <= range_address)
|
||||||
return false;
|
return false;
|
||||||
@ -268,7 +268,7 @@ void TextureCacheBase::SetBackupConfig(const VideoConfig& config)
|
|||||||
config.graphics_mod_config ? config.graphics_mod_config->GetChangeCount() : 0;
|
config.graphics_mod_config ? config.graphics_mod_config->GetChangeCount() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry*
|
TCacheEntry*
|
||||||
TextureCacheBase::ApplyPaletteToEntry(TCacheEntry* entry, const u8* palette, TLUTFormat tlutfmt)
|
TextureCacheBase::ApplyPaletteToEntry(TCacheEntry* entry, const u8* palette, TLUTFormat tlutfmt)
|
||||||
{
|
{
|
||||||
DEBUG_ASSERT(g_ActiveConfig.backend_info.bSupportsPaletteConversion);
|
DEBUG_ASSERT(g_ActiveConfig.backend_info.bSupportsPaletteConversion);
|
||||||
@ -337,7 +337,7 @@ TextureCacheBase::ApplyPaletteToEntry(TCacheEntry* entry, const u8* palette, TLU
|
|||||||
return decoded_entry;
|
return decoded_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry* TextureCacheBase::ReinterpretEntry(const TCacheEntry* existing_entry,
|
TCacheEntry* TextureCacheBase::ReinterpretEntry(const TCacheEntry* existing_entry,
|
||||||
TextureFormat new_format)
|
TextureFormat new_format)
|
||||||
{
|
{
|
||||||
const AbstractPipeline* pipeline =
|
const AbstractPipeline* pipeline =
|
||||||
@ -383,7 +383,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::ReinterpretEntry(const TCacheEn
|
|||||||
return reinterpreted_entry;
|
return reinterpreted_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::ScaleTextureCacheEntryTo(TextureCacheBase::TCacheEntry* entry, u32 new_width,
|
void TextureCacheBase::ScaleTextureCacheEntryTo(TCacheEntry* entry, u32 new_width,
|
||||||
u32 new_height)
|
u32 new_height)
|
||||||
{
|
{
|
||||||
if (entry->GetWidth() == new_width && entry->GetHeight() == new_height)
|
if (entry->GetWidth() == new_width && entry->GetHeight() == new_height)
|
||||||
@ -746,7 +746,7 @@ void TextureCacheBase::DoLoadState(PointerWrap& p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::TCacheEntry::DoState(PointerWrap& p)
|
void TCacheEntry::DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
p.Do(addr);
|
p.Do(addr);
|
||||||
p.Do(size_in_bytes);
|
p.Do(size_in_bytes);
|
||||||
@ -770,7 +770,7 @@ void TextureCacheBase::TCacheEntry::DoState(PointerWrap& p)
|
|||||||
p.Do(frameCount);
|
p.Do(frameCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry*
|
TCacheEntry*
|
||||||
TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, const u8* palette,
|
TextureCacheBase::DoPartialTextureUpdates(TCacheEntry* entry_to_update, const u8* palette,
|
||||||
TLUTFormat tlutfmt)
|
TLUTFormat tlutfmt)
|
||||||
{
|
{
|
||||||
@ -1224,7 +1224,7 @@ private:
|
|||||||
std::vector<Level> levels;
|
std::vector<Level> levels;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture_info)
|
TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture_info)
|
||||||
{
|
{
|
||||||
// if this stage was not invalidated by changes to texture registers, keep the current texture
|
// if this stage was not invalidated by changes to texture registers, keep the current texture
|
||||||
if (TMEM::IsValid(texture_info.GetStage()) && bound_textures[texture_info.GetStage()])
|
if (TMEM::IsValid(texture_info.GetStage()) && bound_textures[texture_info.GetStage()])
|
||||||
@ -1272,7 +1272,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const TextureInfo& texture
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry*
|
TCacheEntry*
|
||||||
TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize,
|
TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize,
|
||||||
const TextureInfo& texture_info)
|
const TextureInfo& texture_info)
|
||||||
{
|
{
|
||||||
@ -1729,7 +1729,7 @@ TextureCacheBase::GetTexture(const int textureCacheSafetyColorSampleSize,
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetDisplayRectForXFBEntry(TextureCacheBase::TCacheEntry* entry, u32 width, u32 height,
|
static void GetDisplayRectForXFBEntry(TCacheEntry* entry, u32 width, u32 height,
|
||||||
MathUtil::Rectangle<int>* display_rect)
|
MathUtil::Rectangle<int>* display_rect)
|
||||||
{
|
{
|
||||||
// Scale the sub-rectangle to the full resolution of the texture.
|
// Scale the sub-rectangle to the full resolution of the texture.
|
||||||
@ -1739,7 +1739,7 @@ static void GetDisplayRectForXFBEntry(TextureCacheBase::TCacheEntry* entry, u32
|
|||||||
display_rect->bottom = static_cast<int>(height * entry->GetHeight() / entry->native_height);
|
display_rect->bottom = static_cast<int>(height * entry->GetHeight() / entry->native_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry*
|
TCacheEntry*
|
||||||
TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
|
TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
|
||||||
MathUtil::Rectangle<int>* display_rect)
|
MathUtil::Rectangle<int>* display_rect)
|
||||||
{
|
{
|
||||||
@ -1822,7 +1822,7 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry* TextureCacheBase::GetXFBFromCache(u32 address, u32 width, u32 height,
|
TCacheEntry* TextureCacheBase::GetXFBFromCache(u32 address, u32 width, u32 height,
|
||||||
u32 stride)
|
u32 stride)
|
||||||
{
|
{
|
||||||
auto iter_range = textures_by_address.equal_range(address);
|
auto iter_range = textures_by_address.equal_range(address);
|
||||||
@ -2555,7 +2555,7 @@ void TextureCacheBase::UninitializeXFBMemory(u8* dst, u32 stride, u32 bytes_per_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TCacheEntry* TextureCacheBase::AllocateCacheEntry(const TextureConfig& config)
|
TCacheEntry* TextureCacheBase::AllocateCacheEntry(const TextureConfig& config)
|
||||||
{
|
{
|
||||||
std::optional<TexPoolEntry> alloc = AllocateTexture(config);
|
std::optional<TexPoolEntry> alloc = AllocateTexture(config);
|
||||||
if (!alloc)
|
if (!alloc)
|
||||||
@ -2619,7 +2619,7 @@ TextureCacheBase::FindMatchingTextureFromPool(const TextureConfig& config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureCacheBase::TexAddrCache::iterator
|
TextureCacheBase::TexAddrCache::iterator
|
||||||
TextureCacheBase::GetTexCacheIter(TextureCacheBase::TCacheEntry* entry)
|
TextureCacheBase::GetTexCacheIter(TCacheEntry* entry)
|
||||||
{
|
{
|
||||||
auto iter_range = textures_by_address.equal_range(entry->addr);
|
auto iter_range = textures_by_address.equal_range(entry->addr);
|
||||||
TexAddrCache::iterator iter = iter_range.first;
|
TexAddrCache::iterator iter = iter_range.first;
|
||||||
@ -2967,7 +2967,7 @@ bool TextureCacheBase::DecodeTextureOnGPU(TCacheEntry* entry, u32 dst_level, con
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TextureCacheBase::TCacheEntry::BytesPerRow() const
|
u32 TCacheEntry::BytesPerRow() const
|
||||||
{
|
{
|
||||||
// RGBA takes two cache lines per block; all others take one
|
// RGBA takes two cache lines per block; all others take one
|
||||||
const u32 bytes_per_block = format == TextureFormat::RGBA8 ? 64 : 32;
|
const u32 bytes_per_block = format == TextureFormat::RGBA8 ? 64 : 32;
|
||||||
@ -2975,7 +2975,7 @@ u32 TextureCacheBase::TCacheEntry::BytesPerRow() const
|
|||||||
return NumBlocksX() * bytes_per_block;
|
return NumBlocksX() * bytes_per_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TextureCacheBase::TCacheEntry::NumBlocksX() const
|
u32 TCacheEntry::NumBlocksX() const
|
||||||
{
|
{
|
||||||
const u32 blockW = TexDecoder_GetBlockWidthInTexels(format.texfmt);
|
const u32 blockW = TexDecoder_GetBlockWidthInTexels(format.texfmt);
|
||||||
|
|
||||||
@ -2985,7 +2985,7 @@ u32 TextureCacheBase::TCacheEntry::NumBlocksX() const
|
|||||||
return actualWidth / blockW;
|
return actualWidth / blockW;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 TextureCacheBase::TCacheEntry::NumBlocksY() const
|
u32 TCacheEntry::NumBlocksY() const
|
||||||
{
|
{
|
||||||
u32 blockH = TexDecoder_GetBlockHeightInTexels(format.texfmt);
|
u32 blockH = TexDecoder_GetBlockHeightInTexels(format.texfmt);
|
||||||
// Round up source height to multiple of block size
|
// Round up source height to multiple of block size
|
||||||
@ -2994,7 +2994,7 @@ u32 TextureCacheBase::TCacheEntry::NumBlocksY() const
|
|||||||
return actualHeight / blockH;
|
return actualHeight / blockH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::TCacheEntry::SetXfbCopy(u32 stride)
|
void TCacheEntry::SetXfbCopy(u32 stride)
|
||||||
{
|
{
|
||||||
is_efb_copy = false;
|
is_efb_copy = false;
|
||||||
is_xfb_copy = true;
|
is_xfb_copy = true;
|
||||||
@ -3006,7 +3006,7 @@ void TextureCacheBase::TCacheEntry::SetXfbCopy(u32 stride)
|
|||||||
size_in_bytes = memory_stride * NumBlocksY();
|
size_in_bytes = memory_stride * NumBlocksY();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::TCacheEntry::SetEfbCopy(u32 stride)
|
void TCacheEntry::SetEfbCopy(u32 stride)
|
||||||
{
|
{
|
||||||
is_efb_copy = true;
|
is_efb_copy = true;
|
||||||
is_xfb_copy = false;
|
is_xfb_copy = false;
|
||||||
@ -3018,14 +3018,14 @@ void TextureCacheBase::TCacheEntry::SetEfbCopy(u32 stride)
|
|||||||
size_in_bytes = memory_stride * NumBlocksY();
|
size_in_bytes = memory_stride * NumBlocksY();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheBase::TCacheEntry::SetNotCopy()
|
void TCacheEntry::SetNotCopy()
|
||||||
{
|
{
|
||||||
is_efb_copy = false;
|
is_efb_copy = false;
|
||||||
is_xfb_copy = false;
|
is_xfb_copy = false;
|
||||||
is_xfb_container = false;
|
is_xfb_container = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextureCacheBase::TCacheEntry::HashSampleSize() const
|
int TCacheEntry::HashSampleSize() const
|
||||||
{
|
{
|
||||||
if (should_force_safe_hashing)
|
if (should_force_safe_hashing)
|
||||||
{
|
{
|
||||||
@ -3035,7 +3035,7 @@ int TextureCacheBase::TCacheEntry::HashSampleSize() const
|
|||||||
return g_ActiveConfig.iSafeTextureCache_ColorSamples;
|
return g_ActiveConfig.iSafeTextureCache_ColorSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 TextureCacheBase::TCacheEntry::CalculateHash() const
|
u64 TCacheEntry::CalculateHash() const
|
||||||
{
|
{
|
||||||
const u32 bytes_per_row = BytesPerRow();
|
const u32 bytes_per_row = BytesPerRow();
|
||||||
const u32 hash_sample_size = HashSampleSize();
|
const u32 hash_sample_size = HashSampleSize();
|
||||||
|
@ -33,6 +33,8 @@ struct VideoConfig;
|
|||||||
constexpr std::string_view EFB_DUMP_PREFIX = "efb1";
|
constexpr std::string_view EFB_DUMP_PREFIX = "efb1";
|
||||||
constexpr std::string_view XFB_DUMP_PREFIX = "xfb1";
|
constexpr std::string_view XFB_DUMP_PREFIX = "xfb1";
|
||||||
|
|
||||||
|
static constexpr int FRAMECOUNT_INVALID = 0;
|
||||||
|
|
||||||
struct TextureAndTLUTFormat
|
struct TextureAndTLUTFormat
|
||||||
{
|
{
|
||||||
TextureAndTLUTFormat(TextureFormat texfmt_ = TextureFormat::I4,
|
TextureAndTLUTFormat(TextureFormat texfmt_ = TextureFormat::I4,
|
||||||
@ -103,14 +105,8 @@ struct fmt::formatter<EFBCopyParams>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureCacheBase
|
struct TCacheEntry
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
static const int FRAMECOUNT_INVALID = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
struct TCacheEntry
|
|
||||||
{
|
|
||||||
// common members
|
// common members
|
||||||
std::unique_ptr<AbstractTexture> texture;
|
std::unique_ptr<AbstractTexture> texture;
|
||||||
std::unique_ptr<AbstractFramebuffer> framebuffer;
|
std::unique_ptr<AbstractFramebuffer> framebuffer;
|
||||||
@ -216,8 +212,11 @@ public:
|
|||||||
u32 GetNumLayers() const { return texture->GetConfig().layers; }
|
u32 GetNumLayers() const { return texture->GetConfig().layers; }
|
||||||
AbstractTextureFormat GetFormat() const { return texture->GetConfig().format; }
|
AbstractTextureFormat GetFormat() const { return texture->GetConfig().format; }
|
||||||
void DoState(PointerWrap& p);
|
void DoState(PointerWrap& p);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TextureCacheBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
// Minimal version of TCacheEntry just for TexPool
|
// Minimal version of TCacheEntry just for TexPool
|
||||||
struct TexPoolEntry
|
struct TexPoolEntry
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user