diff options
| author | Scott Mansell <phiren@gmail.com> | 2021-10-10 08:16:15 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2021-10-10 09:09:43 +1300 |
| commit | 9fa26624b02562fb8626c93c45acf2015fc06f40 (patch) | |
| tree | 870bffe166ba60ef71dc8c19b89de59ca438d337 /Source/Core/VideoCommon/TextureInfo.cpp | |
| parent | ef0e401708dc534e8bfac52e5e43086b4255c22d (diff) | |
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.
Diffstat (limited to 'Source/Core/VideoCommon/TextureInfo.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureInfo.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
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<u32> 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) { |
