From 54773bc5d2c847bc4e070a8a647b97a9fc76bcb0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 7 Apr 2024 11:13:25 +0200 Subject: 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. --- Source/Core/VideoCommon/XFStructs.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/XFStructs.cpp') 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(&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(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(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); } -- cgit v1.2.3