From 62db55dee280b41d7a0484a98a1a1dbd3190595f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 26 Mar 2017 20:38:19 -0400 Subject: [PATCH 1/2] Fifo: const correctness PushFifoAuxBuffer only memcpys data using ptr as the source pointer, so it can be a pointer to const data because of that. --- Source/Core/VideoCommon/Fifo.cpp | 2 +- Source/Core/VideoCommon/Fifo.h | 2 +- Source/Core/VideoCommon/XFStructs.cpp | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 050eae6e57..d3ce2cf7fb 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -191,7 +191,7 @@ void SyncGPU(SyncGPUReason reason, bool may_move_read_ptr) } } -void PushFifoAuxBuffer(void* ptr, size_t size) +void PushFifoAuxBuffer(const void* ptr, size_t size) { if (size > (size_t)(s_fifo_aux_data + FIFO_SIZE - s_fifo_aux_write_ptr)) { diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h index 3b0114844e..dfdf43a157 100644 --- a/Source/Core/VideoCommon/Fifo.h +++ b/Source/Core/VideoCommon/Fifo.h @@ -33,7 +33,7 @@ enum class SyncGPUReason // In deterministic GPU thread mode this waits for the GPU to be done with pending work. void SyncGPU(SyncGPUReason reason, bool may_move_read_ptr = true); -void PushFifoAuxBuffer(void* ptr, size_t size); +void PushFifoAuxBuffer(const void* ptr, size_t size); void* PopFifoAuxBuffer(size_t size); void FlushGpu(); diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 9a2db74459..9581209419 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -288,12 +288,13 @@ void LoadIndexedXF(u32 val, int refarray) void PreprocessIndexedXF(u32 val, int refarray) { - int index = val >> 16; - int size = ((val >> 12) & 0xF) + 1; + const int index = val >> 16; + const int size = ((val >> 12) & 0xF) + 1; - u32* new_data = (u32*)Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + - g_preprocess_cp_state.array_strides[refarray] * index); + const u32* new_data = + (u32*)Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + + g_preprocess_cp_state.array_strides[refarray] * index); - size_t buf_size = size * sizeof(u32); + const size_t buf_size = size * sizeof(u32); Fifo::PushFifoAuxBuffer(new_data, buf_size); } From d44844ba29e9b2d2169c5acd82cb7001680b3c1e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 26 Mar 2017 23:09:28 -0400 Subject: [PATCH 2/2] XFStructs: Get rid of an unnecessary pointer cast Also gets rid of implicit sign conversions. --- Source/Core/VideoCommon/XFStructs.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index 9581209419..dbe3f21e02 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -288,12 +288,11 @@ void LoadIndexedXF(u32 val, int refarray) void PreprocessIndexedXF(u32 val, int refarray) { - const int index = val >> 16; - const int size = ((val >> 12) & 0xF) + 1; + const u32 index = val >> 16; + const u32 size = ((val >> 12) & 0xF) + 1; - const u32* new_data = - (u32*)Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + - g_preprocess_cp_state.array_strides[refarray] * index); + const u8* new_data = Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + + g_preprocess_cp_state.array_strides[refarray] * index); const size_t buf_size = size * sizeof(u32); Fifo::PushFifoAuxBuffer(new_data, buf_size);