summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/XFStructs.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2024-04-07 11:13:25 +0200
committerJosJuice <josjuice@gmail.com>2024-04-09 21:08:57 +0200
commit54773bc5d2c847bc4e070a8a647b97a9fc76bcb0 (patch)
tree23974ba939d0a61c792e2fec2aca7e97758f59e0 /Source/Core/VideoCommon/XFStructs.cpp
parent69aca2fbfc88d08a17d36c03d51dd698eb9cce1b (diff)
VideoCommon: Remove calls to GetPointer
This fourth part of my series of patches to get rid of unsafe uses of GetPointer takes care of the "easy" cases in VideoCommon. Three uses of GetPointer now remain in Dolphin: VertexLoaderManager, TextureInfo, and the software renderer's TextureSampler.
Diffstat (limited to 'Source/Core/VideoCommon/XFStructs.cpp')
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp
index 906c37bb5a..33f47a01a5 100644
--- a/Source/Core/VideoCommon/XFStructs.cpp
+++ b/Source/Core/VideoCommon/XFStructs.cpp
@@ -259,19 +259,21 @@ void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size)
{
// load stuff from array to address in xf mem
- u32* currData = (u32*)(&xfmem) + address;
+ const u32 buf_size = size * sizeof(u32);
+ u32* currData = reinterpret_cast<u32*>(&xfmem) + address;
u32* newData;
auto& system = Core::System::GetInstance();
auto& fifo = system.GetFifo();
if (fifo.UseDeterministicGPUThread())
{
- newData = (u32*)fifo.PopFifoAuxBuffer(size * sizeof(u32));
+ newData = reinterpret_cast<u32*>(fifo.PopFifoAuxBuffer(buf_size));
}
else
{
auto& memory = system.GetMemory();
- newData = (u32*)memory.GetPointer(g_main_cp_state.array_bases[array] +
- g_main_cp_state.array_strides[array] * index);
+ newData = reinterpret_cast<u32*>(memory.GetPointerForRange(
+ g_main_cp_state.array_bases[array] + g_main_cp_state.array_strides[array] * index,
+ buf_size));
}
auto& xf_state_manager = system.GetXFStateManager();
@@ -294,12 +296,14 @@ void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size)
void PreprocessIndexedXF(CPArray array, u32 index, u16 address, u8 size)
{
+ const size_t buf_size = size * sizeof(u32);
+
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 u8* new_data = memory.GetPointerForRange(
+ g_preprocess_cp_state.array_bases[array] + g_preprocess_cp_state.array_strides[array] * index,
+ buf_size);
- const size_t buf_size = size * sizeof(u32);
system.GetFifo().PushFifoAuxBuffer(new_data, buf_size);
}