Merge pull request #3059 from lioncash/vtx
VertexLoaderUtils: Get rid of pointer casts
This commit is contained in:
commit
8bd1be643c
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
|
||||||
|
@ -24,10 +25,11 @@ __forceinline void DataSkip()
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
__forceinline T DataPeek(int _uOffset, u8** bufp = &g_video_buffer_read_ptr)
|
__forceinline T DataPeek(int _uOffset, u8* bufp = g_video_buffer_read_ptr)
|
||||||
{
|
{
|
||||||
auto const result = Common::FromBigEndian(*reinterpret_cast<T*>(*bufp + _uOffset));
|
T result;
|
||||||
return result;
|
std::memcpy(&result, &bufp[_uOffset], sizeof(T));
|
||||||
|
return Common::FromBigEndian(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: kill these
|
// TODO: kill these
|
||||||
|
@ -49,7 +51,7 @@ __forceinline u32 DataPeek32(int _uOffset)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
__forceinline T DataRead(u8** bufp = &g_video_buffer_read_ptr)
|
__forceinline T DataRead(u8** bufp = &g_video_buffer_read_ptr)
|
||||||
{
|
{
|
||||||
auto const result = DataPeek<T>(0, bufp);
|
auto const result = DataPeek<T>(0, *bufp);
|
||||||
*bufp += sizeof(T);
|
*bufp += sizeof(T);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -77,9 +79,10 @@ __forceinline u32 DataReadU32()
|
||||||
|
|
||||||
__forceinline u32 DataReadU32Unswapped()
|
__forceinline u32 DataReadU32Unswapped()
|
||||||
{
|
{
|
||||||
u32 tmp = *(u32*)g_video_buffer_read_ptr;
|
u32 result;
|
||||||
g_video_buffer_read_ptr += 4;
|
std::memcpy(&result, g_video_buffer_read_ptr, sizeof(u32));
|
||||||
return tmp;
|
g_video_buffer_read_ptr += sizeof(u32);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline u8* DataGetPosition()
|
__forceinline u8* DataGetPosition()
|
||||||
|
@ -90,6 +93,6 @@ __forceinline u8* DataGetPosition()
|
||||||
template <typename T>
|
template <typename T>
|
||||||
__forceinline void DataWrite(T data)
|
__forceinline void DataWrite(T data)
|
||||||
{
|
{
|
||||||
*(T*)g_vertex_manager_write_ptr = data;
|
std::memcpy(g_vertex_manager_write_ptr, &data, sizeof(T));
|
||||||
g_vertex_manager_write_ptr += sizeof(T);
|
g_vertex_manager_write_ptr += sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue