summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2022-12-02 20:07:30 +0100
committerAdmiral H. Curtiss <pikachu025@gmail.com>2022-12-03 13:27:02 +0100
commit839db591d9daa388c1b6eb944a9f34a9aa41c871 (patch)
tree38ea0e3d41b297c6adf6fba87c35d7a7a36a12e6 /Source/Core/VideoCommon
parent7cd9a78ebf6e49b21a5a5eee99858822a8946faa (diff)
HW/Memmap: Refactor Memory to class, move to Core::System.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp12
-rw-r--r--Source/Core/VideoCommon/Fifo.cpp8
-rw-r--r--Source/Core/VideoCommon/OpcodeDecoding.cpp14
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp17
-rw-r--r--Source/Core/VideoCommon/TextureInfo.cpp5
-rw-r--r--Source/Core/VideoCommon/VertexLoaderManager.cpp12
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp13
7 files changed, 60 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index a4c381d313..1bc9f69150 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -357,7 +357,9 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
if (!SConfig::GetInstance().bWii)
addr = addr & 0x01FFFFFF;
- Memory::CopyFromEmu(texMem + tlutTMemAddr, addr, tlutXferCount);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ memory.CopyFromEmu(texMem + tlutTMemAddr, addr, tlutXferCount);
if (OpcodeDecoder::g_record_fifo_data)
FifoRecorder::GetInstance().UseMemory(addr, tlutXferCount, MemoryUpdate::TMEM);
@@ -549,11 +551,15 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future)
if (tmem_addr_even + bytes_read > TMEM_SIZE)
bytes_read = TMEM_SIZE - tmem_addr_even;
- Memory::CopyFromEmu(texMem + tmem_addr_even, src_addr, bytes_read);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ memory.CopyFromEmu(texMem + tmem_addr_even, src_addr, bytes_read);
}
else // RGBA8 tiles (and CI14, but that might just be stupid libogc!)
{
- u8* src_ptr = Memory::GetPointer(src_addr);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ u8* src_ptr = memory.GetPointer(src_addr);
// AR and GB tiles are stored in separate TMEM banks => can't use a single memcpy for
// everything
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp
index 9e5b14b904..617a9d73f7 100644
--- a/Source/Core/VideoCommon/Fifo.cpp
+++ b/Source/Core/VideoCommon/Fifo.cpp
@@ -270,7 +270,9 @@ static void ReadDataFromFifo(u32 readPtr)
s_video_buffer_read_ptr = s_video_buffer;
}
// Copy new video instructions to s_video_buffer for future use in rendering the new picture
- Memory::CopyFromEmu(s_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ memory.CopyFromEmu(s_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE);
s_video_buffer_write_ptr += GPFifo::GATHER_PIPE_SIZE;
}
@@ -303,7 +305,9 @@ static void ReadDataFromFifoOnCPU(u32 readPtr)
return;
}
}
- Memory::CopyFromEmu(s_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ memory.CopyFromEmu(s_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE);
s_video_buffer_pp_read_ptr = OpcodeDecoder::RunFifo<true>(
DataReader(s_video_buffer_pp_read_ptr, write_ptr + GPFifo::GATHER_PIPE_SIZE), nullptr);
// This would have to be locked if the GPU thread didn't spin.
diff --git a/Source/Core/VideoCommon/OpcodeDecoding.cpp b/Source/Core/VideoCommon/OpcodeDecoding.cpp
index 36c9093365..d14bb46e6c 100644
--- a/Source/Core/VideoCommon/OpcodeDecoding.cpp
+++ b/Source/Core/VideoCommon/OpcodeDecoding.cpp
@@ -153,7 +153,9 @@ public:
if constexpr (is_preprocess)
{
- const u8* const start_address = Memory::GetPointer(address);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ const u8* const start_address = memory.GetPointer(address);
Fifo::PushFifoAuxBuffer(start_address, size);
@@ -167,11 +169,17 @@ public:
const u8* start_address;
if (Fifo::UseDeterministicGPUThread())
+ {
start_address = static_cast<u8*>(Fifo::PopFifoAuxBuffer(size));
+ }
else
- start_address = Memory::GetPointer(address);
+ {
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ start_address = memory.GetPointer(address);
+ }
- // Avoid the crash if Memory::GetPointer failed ..
+ // Avoid the crash if memory.GetPointer failed ..
if (start_address != nullptr)
{
// temporarily swap dl and non-dl (small "hack" for the stats)
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index f16bcc342a..f5dbb6b3fc 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -31,6 +31,7 @@
#include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/FifoPlayer/FifoRecorder.h"
#include "Core/HW/Memmap.h"
+#include "Core/System.h"
#include "VideoCommon/AbstractFramebuffer.h"
#include "VideoCommon/AbstractStagingTexture.h"
@@ -1732,7 +1733,9 @@ TextureCacheBase::TCacheEntry*
TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
MathUtil::Rectangle<int>* display_rect)
{
- const u8* src_data = Memory::GetPointer(address);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ const u8* src_data = memory.GetPointer(address);
if (!src_data)
{
ERROR_LOG_FMT(VIDEO, "Trying to load XFB texture from invalid address {:#010x}", address);
@@ -2107,7 +2110,9 @@ void TextureCacheBase::CopyRenderTargetToTexture(
!(is_xfb_copy ? g_ActiveConfig.bSkipXFBCopyToRam : g_ActiveConfig.bSkipEFBCopyToRam) ||
!copy_to_vram;
- u8* dst = Memory::GetPointer(dstAddr);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ u8* dst = memory.GetPointer(dstAddr);
if (dst == nullptr)
{
ERROR_LOG_FMT(VIDEO, "Trying to copy from EFB to invalid address {:#010x}", dstAddr);
@@ -2422,7 +2427,9 @@ void TextureCacheBase::WriteEFBCopyToRAM(u8* dst_ptr, u32 width, u32 height, u32
void TextureCacheBase::FlushEFBCopy(TCacheEntry* entry)
{
// Copy from texture -> guest memory.
- u8* const dst = Memory::GetPointer(entry->addr);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ u8* const dst = memory.GetPointer(entry->addr);
WriteEFBCopyToRAM(dst, entry->pending_efb_copy_width, entry->pending_efb_copy_height,
entry->memory_stride, std::move(entry->pending_efb_copy));
@@ -3024,7 +3031,9 @@ u64 TextureCacheBase::TCacheEntry::CalculateHash() const
const u32 hash_sample_size = HashSampleSize();
// FIXME: textures from tmem won't get the correct hash.
- u8* ptr = Memory::GetPointer(addr);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ u8* ptr = memory.GetPointer(addr);
if (memory_stride == bytes_per_row)
{
return Common::GetHash64(ptr, size_in_bytes, hash_sample_size);
diff --git a/Source/Core/VideoCommon/TextureInfo.cpp b/Source/Core/VideoCommon/TextureInfo.cpp
index 1d3371f7fc..35441d4d36 100644
--- a/Source/Core/VideoCommon/TextureInfo.cpp
+++ b/Source/Core/VideoCommon/TextureInfo.cpp
@@ -8,6 +8,7 @@
#include "Common/Align.h"
#include "Core/HW/Memmap.h"
+#include "Core/System.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/TextureDecoder.h"
@@ -44,7 +45,9 @@ TextureInfo TextureInfo::FromStage(u32 stage)
&texMem[tmem_address_even], mip_count);
}
- return TextureInfo(stage, Memory::GetPointer(address), tlut_ptr, address, texture_format,
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ return TextureInfo(stage, memory.GetPointer(address), tlut_ptr, address, texture_format,
tlut_format, width, height, false, nullptr, nullptr, mip_count);
}
diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp
index c37b4a4fa2..e788f8e3db 100644
--- a/Source/Core/VideoCommon/VertexLoaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp
@@ -18,6 +18,7 @@
#include "Core/DolphinAnalytics.h"
#include "Core/HW/Memmap.h"
+#include "Core/System.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/CPMemory.h"
@@ -81,6 +82,9 @@ void UpdateVertexArrayPointers()
if (!g_bases_dirty) [[likely]]
return;
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+
// Some games such as Burnout 2 can put invalid addresses into
// the array base registers. (see issue 8591)
// But the vertex arrays with invalid addresses aren't actually enabled.
@@ -89,24 +93,24 @@ void UpdateVertexArrayPointers()
// We also only update the array base if the vertex description states we are going to use it.
if (IsIndexed(g_main_cp_state.vtx_desc.low.Position))
cached_arraybases[CPArray::Position] =
- Memory::GetPointer(g_main_cp_state.array_bases[CPArray::Position]);
+ memory.GetPointer(g_main_cp_state.array_bases[CPArray::Position]);
if (IsIndexed(g_main_cp_state.vtx_desc.low.Normal))
cached_arraybases[CPArray::Normal] =
- Memory::GetPointer(g_main_cp_state.array_bases[CPArray::Normal]);
+ memory.GetPointer(g_main_cp_state.array_bases[CPArray::Normal]);
for (u8 i = 0; i < g_main_cp_state.vtx_desc.low.Color.Size(); i++)
{
if (IsIndexed(g_main_cp_state.vtx_desc.low.Color[i]))
cached_arraybases[CPArray::Color0 + i] =
- Memory::GetPointer(g_main_cp_state.array_bases[CPArray::Color0 + i]);
+ memory.GetPointer(g_main_cp_state.array_bases[CPArray::Color0 + i]);
}
for (u8 i = 0; i < g_main_cp_state.vtx_desc.high.TexCoord.Size(); i++)
{
if (IsIndexed(g_main_cp_state.vtx_desc.high.TexCoord[i]))
cached_arraybases[CPArray::TexCoord0 + i] =
- Memory::GetPointer(g_main_cp_state.array_bases[CPArray::TexCoord0 + i]);
+ memory.GetPointer(g_main_cp_state.array_bases[CPArray::TexCoord0 + i]);
}
g_bases_dirty = false;
diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp
index 168d310f81..716b29aef2 100644
--- a/Source/Core/VideoCommon/XFStructs.cpp
+++ b/Source/Core/VideoCommon/XFStructs.cpp
@@ -10,6 +10,7 @@
#include "Core/DolphinAnalytics.h"
#include "Core/HW/Memmap.h"
+#include "Core/System.h"
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/Fifo.h"
@@ -262,8 +263,10 @@ void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size)
}
else
{
- newData = (u32*)Memory::GetPointer(g_main_cp_state.array_bases[array] +
- g_main_cp_state.array_strides[array] * index);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ newData = (u32*)memory.GetPointer(g_main_cp_state.array_bases[array] +
+ g_main_cp_state.array_strides[array] * index);
}
bool changed = false;
for (u32 i = 0; i < size; ++i)
@@ -284,8 +287,10 @@ void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size)
void PreprocessIndexedXF(CPArray array, u32 index, u16 address, u8 size)
{
- const u8* new_data = Memory::GetPointer(g_preprocess_cp_state.array_bases[array] +
- g_preprocess_cp_state.array_strides[array] * index);
+ auto& system = Core::System::GetInstance();
+ auto& memory = system.GetMemory();
+ const u8* new_data = memory.GetPointer(g_preprocess_cp_state.array_bases[array] +
+ g_preprocess_cp_state.array_strides[array] * index);
const size_t buf_size = size * sizeof(u32);
Fifo::PushFifoAuxBuffer(new_data, buf_size);