VideoCommon: Move TextureInfo getters to header

This improves my PC's performance on RS2 Hoth by... 0.1% or so, which I
think is within the margin of error. But this change also cuts down on
boilerplate.
This commit is contained in:
JosJuice
2026-01-19 19:41:30 +01:00
parent ff82ae3b5c
commit b07c78aabe
2 changed files with 28 additions and 163 deletions

View File

@@ -175,101 +175,6 @@ TextureInfo::NameDetails TextureInfo::CalculateTextureName() const
.format_name = fmt::to_string(static_cast<int>(m_texture_format))}; .format_name = fmt::to_string(static_cast<int>(m_texture_format))};
} }
bool TextureInfo::IsDataValid() const
{
return m_data_valid;
}
const u8* TextureInfo::GetData() const
{
return m_data.data();
}
const u8* TextureInfo::GetTlutAddress() const
{
return m_tlut_data.data();
}
u32 TextureInfo::GetRawAddress() const
{
return m_address;
}
bool TextureInfo::IsFromTmem() const
{
return m_from_tmem;
}
const u8* TextureInfo::GetTmemOddAddress() const
{
return m_tmem_odd.data();
}
TextureFormat TextureInfo::GetTextureFormat() const
{
return m_texture_format;
}
TLUTFormat TextureInfo::GetTlutFormat() const
{
return m_tlut_format;
}
std::optional<u32> TextureInfo::GetPaletteSize() const
{
return m_palette_size;
}
u32 TextureInfo::GetTextureSize() const
{
return m_texture_size;
}
u32 TextureInfo::GetBlockWidth() const
{
return m_block_width;
}
u32 TextureInfo::GetBlockHeight() const
{
return m_block_height;
}
u32 TextureInfo::GetExpandedWidth() const
{
return m_expanded_width;
}
u32 TextureInfo::GetExpandedHeight() const
{
return m_expanded_height;
}
u32 TextureInfo::GetRawWidth() const
{
return m_raw_width;
}
u32 TextureInfo::GetRawHeight() const
{
return m_raw_height;
}
u32 TextureInfo::GetStage() const
{
return m_stage;
}
bool TextureInfo::HasMipMaps() const
{
return m_limited_mip_count != 0;
}
u32 TextureInfo::GetLevelCount() const
{
return m_limited_mip_count + 1;
}
TextureInfo::MipLevels TextureInfo::GetMipMapLevels() const TextureInfo::MipLevels TextureInfo::GetMipMapLevels() const
{ {
MipLevelIterator begin; MipLevelIterator begin;
@@ -314,46 +219,6 @@ TextureInfo::MipLevel::MipLevel(u32 level, const TextureInfo& parent, std::span<
*data = Common::SafeSubspan(*data, m_texture_size); *data = Common::SafeSubspan(*data, m_texture_size);
} }
bool TextureInfo::MipLevel::IsDataValid() const
{
return m_data_valid;
}
const u8* TextureInfo::MipLevel::GetData() const
{
return m_ptr;
}
u32 TextureInfo::MipLevel::GetTextureSize() const
{
return m_texture_size;
}
u32 TextureInfo::MipLevel::GetExpandedWidth() const
{
return m_expanded_width;
}
u32 TextureInfo::MipLevel::GetExpandedHeight() const
{
return m_expanded_height;
}
u32 TextureInfo::MipLevel::GetRawWidth() const
{
return m_raw_width;
}
u32 TextureInfo::MipLevel::GetRawHeight() const
{
return m_raw_height;
}
u32 TextureInfo::MipLevel::GetLevel() const
{
return m_level;
}
TextureInfo::MipLevelIterator& TextureInfo::MipLevelIterator::operator++() TextureInfo::MipLevelIterator& TextureInfo::MipLevelIterator::operator++()
{ {
++m_level_index; ++m_level_index;

View File

@@ -13,7 +13,7 @@
enum class TextureFormat; enum class TextureFormat;
enum class TLUTFormat; enum class TLUTFormat;
class TextureInfo class TextureInfo final
{ {
public: public:
static TextureInfo FromStage(u32 stage); static TextureInfo FromStage(u32 stage);
@@ -33,32 +33,32 @@ public:
}; };
NameDetails CalculateTextureName() const; NameDetails CalculateTextureName() const;
bool IsDataValid() const; bool IsDataValid() const { return m_data_valid; }
const u8* GetData() const; const u8* GetData() const { return m_data.data(); }
const u8* GetTlutAddress() const; const u8* GetTlutAddress() const { return m_tlut_data.data(); }
u32 GetRawAddress() const; u32 GetRawAddress() const { return m_address; }
bool IsFromTmem() const; bool IsFromTmem() const { return m_from_tmem; }
const u8* GetTmemOddAddress() const; const u8* GetTmemOddAddress() const { return m_tmem_odd.data(); }
TextureFormat GetTextureFormat() const; TextureFormat GetTextureFormat() const { return m_texture_format; }
TLUTFormat GetTlutFormat() const; TLUTFormat GetTlutFormat() const { return m_tlut_format; }
std::optional<u32> GetPaletteSize() const; std::optional<u32> GetPaletteSize() const { return m_palette_size; }
u32 GetTextureSize() const; u32 GetTextureSize() const { return m_texture_size; }
u32 GetBlockWidth() const; u32 GetBlockWidth() const { return m_block_width; }
u32 GetBlockHeight() const; u32 GetBlockHeight() const { return m_block_height; }
u32 GetExpandedWidth() const; u32 GetExpandedWidth() const { return m_expanded_width; }
u32 GetExpandedHeight() const; u32 GetExpandedHeight() const { return m_expanded_height; }
u32 GetRawWidth() const; u32 GetRawWidth() const { return m_raw_width; }
u32 GetRawHeight() const; u32 GetRawHeight() const { return m_raw_height; }
u32 GetStage() const; u32 GetStage() const { return m_stage; }
class MipLevel final class MipLevel final
{ {
@@ -66,18 +66,18 @@ public:
MipLevel() = default; MipLevel() = default;
MipLevel(u32 level, const TextureInfo& parent, std::span<const u8>* data); MipLevel(u32 level, const TextureInfo& parent, std::span<const u8>* data);
bool IsDataValid() const; bool IsDataValid() const { return m_data_valid; }
const u8* GetData() const; const u8* GetData() const { return m_ptr; }
u32 GetTextureSize() const; u32 GetTextureSize() const { return m_texture_size; }
u32 GetExpandedWidth() const; u32 GetExpandedWidth() const { return m_expanded_width; }
u32 GetExpandedHeight() const; u32 GetExpandedHeight() const { return m_expanded_height; }
u32 GetRawWidth() const; u32 GetRawWidth() const { return m_raw_width; }
u32 GetRawHeight() const; u32 GetRawHeight() const { return m_raw_height; }
u32 GetLevel() const; u32 GetLevel() const { return m_level; }
private: private:
bool m_data_valid = false; bool m_data_valid = false;
@@ -147,8 +147,8 @@ public:
MipLevelIterator m_end; MipLevelIterator m_end;
}; };
bool HasMipMaps() const; bool HasMipMaps() const { return m_limited_mip_count != 0; }
u32 GetLevelCount() const; u32 GetLevelCount() const { return m_limited_mip_count + 1; }
MipLevels GetMipMapLevels() const; MipLevels GetMipMapLevels() const;
u32 GetFullLevelSize() const; u32 GetFullLevelSize() const;