VideoCommon: add support for setting and getting the stage from the texture info

This commit is contained in:
iwubcode 2022-03-05 14:52:02 -06:00
parent a1892a9c68
commit 7854afe512
2 changed files with 22 additions and 12 deletions

View File

@ -39,20 +39,20 @@ TextureInfo TextureInfo::FromStage(u32 stage)
if (from_tmem) if (from_tmem)
{ {
return TextureInfo(&texMem[tmem_address_even], tlut_ptr, address, texture_format, tlut_format, return TextureInfo(stage, &texMem[tmem_address_even], tlut_ptr, address, texture_format,
width, height, true, &texMem[tmem_address_odd], &texMem[tmem_address_even], tlut_format, width, height, true, &texMem[tmem_address_odd],
mip_count); &texMem[tmem_address_even], mip_count);
} }
return TextureInfo(Memory::GetPointer(address), tlut_ptr, address, texture_format, tlut_format, return TextureInfo(stage, Memory::GetPointer(address), tlut_ptr, address, texture_format,
width, height, false, nullptr, nullptr, mip_count); tlut_format, width, height, false, nullptr, nullptr, mip_count);
} }
TextureInfo::TextureInfo(const u8* ptr, const u8* tlut_ptr, u32 address, TextureInfo::TextureInfo(u32 stage, const u8* ptr, const u8* tlut_ptr, u32 address,
TextureFormat texture_format, TLUTFormat tlut_format, u32 width, TextureFormat texture_format, TLUTFormat tlut_format, u32 width,
u32 height, bool from_tmem, const u8* tmem_odd, const u8* tmem_even, u32 height, bool from_tmem, const u8* tmem_odd, const u8* tmem_even,
std::optional<u32> mip_count) std::optional<u32> mip_count)
: m_ptr(ptr), m_tlut_ptr(tlut_ptr), m_address(address), m_from_tmem(from_tmem), : m_stage(stage), m_ptr(ptr), m_tlut_ptr(tlut_ptr), m_address(address), m_from_tmem(from_tmem),
m_tmem_odd(tmem_odd), m_texture_format(texture_format), m_tlut_format(tlut_format), m_tmem_odd(tmem_odd), m_texture_format(texture_format), m_tlut_format(tlut_format),
m_raw_width(width), m_raw_height(height) m_raw_width(width), m_raw_height(height)
{ {
@ -100,7 +100,7 @@ std::string TextureInfo::NameDetails::GetFullName() const
return fmt::format("{}_{}{}_{}", base_name, texture_name, tlut_name, format_name); return fmt::format("{}_{}{}_{}", base_name, texture_name, tlut_name, format_name);
} }
TextureInfo::NameDetails TextureInfo::CalculateTextureName() TextureInfo::NameDetails TextureInfo::CalculateTextureName() const
{ {
if (!m_ptr) if (!m_ptr)
return NameDetails{}; return NameDetails{};
@ -240,6 +240,11 @@ u32 TextureInfo::GetRawHeight() const
return m_raw_height; return m_raw_height;
} }
u32 TextureInfo::GetStage() const
{
return m_stage;
}
bool TextureInfo::HasMipMaps() const bool TextureInfo::HasMipMaps() const
{ {
return !m_mip_levels.empty(); return !m_mip_levels.empty();

View File

@ -17,9 +17,10 @@ class TextureInfo
{ {
public: public:
static TextureInfo FromStage(u32 stage); static TextureInfo FromStage(u32 stage);
TextureInfo(const u8* ptr, const u8* tlut_ptr, u32 address, TextureFormat texture_format, TextureInfo(u32 stage, const u8* ptr, const u8* tlut_ptr, u32 address,
TLUTFormat tlut_format, u32 width, u32 height, bool from_tmem, const u8* tmem_odd, TextureFormat texture_format, TLUTFormat tlut_format, u32 width, u32 height,
const u8* tmem_even, std::optional<u32> mip_count); bool from_tmem, const u8* tmem_odd, const u8* tmem_even,
std::optional<u32> mip_count);
struct NameDetails struct NameDetails
{ {
@ -30,7 +31,7 @@ public:
std::string GetFullName() const; std::string GetFullName() const;
}; };
NameDetails CalculateTextureName(); NameDetails CalculateTextureName() const;
const u8* GetData() const; const u8* GetData() const;
const u8* GetTlutAddress() const; const u8* GetTlutAddress() const;
@ -55,6 +56,8 @@ public:
u32 GetRawWidth() const; u32 GetRawWidth() const;
u32 GetRawHeight() const; u32 GetRawHeight() const;
u32 GetStage() const;
class MipLevel class MipLevel
{ {
public: public:
@ -115,4 +118,6 @@ private:
u32 m_block_height; u32 m_block_height;
u32 m_expanded_height; u32 m_expanded_height;
u32 m_raw_height; u32 m_raw_height;
u32 m_stage;
}; };