From 7854afe512870b83baae0e11c42d62721e20a083 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Sat, 5 Mar 2022 14:52:02 -0600 Subject: [PATCH] VideoCommon: add support for setting and getting the stage from the texture info --- Source/Core/VideoCommon/TextureInfo.cpp | 21 +++++++++++++-------- Source/Core/VideoCommon/TextureInfo.h | 13 +++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Source/Core/VideoCommon/TextureInfo.cpp b/Source/Core/VideoCommon/TextureInfo.cpp index 696f5b904c..ff117c6926 100644 --- a/Source/Core/VideoCommon/TextureInfo.cpp +++ b/Source/Core/VideoCommon/TextureInfo.cpp @@ -39,20 +39,20 @@ TextureInfo TextureInfo::FromStage(u32 stage) if (from_tmem) { - return TextureInfo(&texMem[tmem_address_even], tlut_ptr, address, texture_format, tlut_format, - width, height, true, &texMem[tmem_address_odd], &texMem[tmem_address_even], - mip_count); + return TextureInfo(stage, &texMem[tmem_address_even], tlut_ptr, address, texture_format, + tlut_format, width, height, true, &texMem[tmem_address_odd], + &texMem[tmem_address_even], mip_count); } - return TextureInfo(Memory::GetPointer(address), tlut_ptr, address, texture_format, tlut_format, - width, height, false, nullptr, nullptr, mip_count); + return TextureInfo(stage, Memory::GetPointer(address), tlut_ptr, address, texture_format, + 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, u32 height, bool from_tmem, const u8* tmem_odd, const u8* tmem_even, std::optional 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_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); } -TextureInfo::NameDetails TextureInfo::CalculateTextureName() +TextureInfo::NameDetails TextureInfo::CalculateTextureName() const { if (!m_ptr) return NameDetails{}; @@ -240,6 +240,11 @@ u32 TextureInfo::GetRawHeight() const return m_raw_height; } +u32 TextureInfo::GetStage() const +{ + return m_stage; +} + bool TextureInfo::HasMipMaps() const { return !m_mip_levels.empty(); diff --git a/Source/Core/VideoCommon/TextureInfo.h b/Source/Core/VideoCommon/TextureInfo.h index 109715ba45..940b09b3cb 100644 --- a/Source/Core/VideoCommon/TextureInfo.h +++ b/Source/Core/VideoCommon/TextureInfo.h @@ -17,9 +17,10 @@ class TextureInfo { public: static TextureInfo FromStage(u32 stage); - TextureInfo(const u8* ptr, const u8* tlut_ptr, u32 address, TextureFormat texture_format, - TLUTFormat tlut_format, u32 width, u32 height, bool from_tmem, const u8* tmem_odd, - const u8* tmem_even, std::optional mip_count); + TextureInfo(u32 stage, const u8* ptr, const u8* tlut_ptr, u32 address, + TextureFormat texture_format, TLUTFormat tlut_format, u32 width, u32 height, + bool from_tmem, const u8* tmem_odd, const u8* tmem_even, + std::optional mip_count); struct NameDetails { @@ -30,7 +31,7 @@ public: std::string GetFullName() const; }; - NameDetails CalculateTextureName(); + NameDetails CalculateTextureName() const; const u8* GetData() const; const u8* GetTlutAddress() const; @@ -55,6 +56,8 @@ public: u32 GetRawWidth() const; u32 GetRawHeight() const; + u32 GetStage() const; + class MipLevel { public: @@ -115,4 +118,6 @@ private: u32 m_block_height; u32 m_expanded_height; u32 m_raw_height; + + u32 m_stage; };