From 9fa26624b02562fb8626c93c45acf2015fc06f40 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sun, 10 Oct 2021 08:16:15 +1300 Subject: BPMemory: Refactor/consolidate TexUnit Addressing Currently the logic for addressing the individual TexUnits is splattered all across dolphin's codebase, this commit attempts to consolidate it all into a single place and formalise it using our new TexUnitAddress struct. --- Source/Core/VideoCommon/TextureInfo.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'Source/Core/VideoCommon/TextureInfo.cpp') diff --git a/Source/Core/VideoCommon/TextureInfo.cpp b/Source/Core/VideoCommon/TextureInfo.cpp index 631e91c6ee..6959b95534 100644 --- a/Source/Core/VideoCommon/TextureInfo.cpp +++ b/Source/Core/VideoCommon/TextureInfo.cpp @@ -14,30 +14,29 @@ TextureInfo TextureInfo::FromStage(u32 stage) { - const FourTexUnits& tex = bpmem.tex[stage >> 2]; - const u32 id = stage & 3; + const auto tex = bpmem.tex.GetUnit(stage); - const auto texture_format = tex.texImage0[id].format; - const auto tlut_format = tex.texTlut[id].tlut_format; + const auto texture_format = tex.texImage0.format; + const auto tlut_format = tex.texTlut.tlut_format; - const auto width = tex.texImage0[id].width + 1; - const auto height = tex.texImage0[id].height + 1; + const auto width = tex.texImage0.width + 1; + const auto height = tex.texImage0.height + 1; - const u32 address = (tex.texImage3[id].image_base /* & 0x1FFFFF*/) << 5; + const u32 address = (tex.texImage3.image_base /* & 0x1FFFFF*/) << 5; - const u32 tlutaddr = tex.texTlut[id].tmem_offset << 9; + const u32 tlutaddr = tex.texTlut.tmem_offset << 9; const u8* tlut_ptr = &texMem[tlutaddr]; std::optional mip_count; - const bool has_mipmaps = SamplerCommon::AreBpTexMode0MipmapsEnabled(tex.texMode0[id]); + const bool has_mipmaps = SamplerCommon::AreBpTexMode0MipmapsEnabled(tex.texMode0); if (has_mipmaps) { - mip_count = (tex.texMode1[id].max_lod + 0xf) / 0x10; + mip_count = (tex.texMode1.max_lod + 0xf) / 0x10; } - const bool from_tmem = tex.texImage1[id].cache_manually_managed != 0; - const u32 tmem_address_even = from_tmem ? tex.texImage1[id].tmem_even * TMEM_LINE_SIZE : 0; - const u32 tmem_address_odd = from_tmem ? tex.texImage2[id].tmem_odd * TMEM_LINE_SIZE : 0; + const bool from_tmem = tex.texImage1.cache_manually_managed != 0; + const u32 tmem_address_even = from_tmem ? tex.texImage1.tmem_even * TMEM_LINE_SIZE : 0; + const u32 tmem_address_odd = from_tmem ? tex.texImage2.tmem_odd * TMEM_LINE_SIZE : 0; if (from_tmem) { -- cgit v1.2.3