From 894e9f1414fb2a18ec728ee1cdcbe9912079cde5 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Mon, 9 Apr 2018 21:11:06 +0200 Subject: [PATCH] Cleanup changes for merge with master --- core/hw/pvr/ta_ctx.cpp | 25 +++++++++++++++++++++++++ core/hw/pvr/ta_ctx.h | 29 +++-------------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/core/hw/pvr/ta_ctx.cpp b/core/hw/pvr/ta_ctx.cpp index 89a04823c..2a0dd0e2d 100644 --- a/core/hw/pvr/ta_ctx.cpp +++ b/core/hw/pvr/ta_ctx.cpp @@ -1,3 +1,5 @@ +#include + #include "ta.h" #include "ta_ctx.h" @@ -15,6 +17,29 @@ tad_context ta_tad; TA_context* vd_ctx; rend_context vd_rc; +// helper for 32 byte aligned memory allocation +void* OS_aligned_malloc(size_t align, size_t size) +{ + void *result; + #if HOST_OS == OS_WINDOWS + result = _aligned_malloc(size, align); + #else + if(posix_memalign(&result, align, size)) result = 0; + #endif + return result; +} + +// helper for 32 byte aligned memory de-allocation +void OS_aligned_free(void *ptr) +{ + #if HOST_OS == OS_WINDOWS + _aligned_free(ptr); + #else + free(ptr); + #endif +} + + void SetCurrentTARC(u32 addr) { if (addr != TACTX_NONE) diff --git a/core/hw/pvr/ta_ctx.h b/core/hw/pvr/ta_ctx.h index c527dbbf3..a5224af88 100644 --- a/core/hw/pvr/ta_ctx.h +++ b/core/hw/pvr/ta_ctx.h @@ -1,30 +1,7 @@ #pragma once -#include -#include #include "ta.h" #include "pvr_regs.h" -// helper for 32 byte aligned memory allocation -inline void* aligned_malloc(size_t align, size_t size) -{ - void *result; - #if HOST_OS == OS_WINDOWS - result = _aligned_malloc(size, align); - #else - if(posix_memalign(&result, align, size)) result = 0; - #endif - return result; -} -// helper for 32 byte aligned memory de-allocation -inline void aligned_free(void *ptr) -{ - #ifdef WIN32 - _aligned_free(ptr); - #else - free(ptr); - #endif -} - //Vertex storage types struct Vertex { @@ -174,8 +151,8 @@ struct TA_context } void Alloc() { - tad.Reset((u8*)aligned_malloc(32, 2*1024*1024)); - + tad.Reset((u8*)malloc(2*1024*1024)); + rend.verts.InitBytes(1024*1024,&rend.Overrun); //up to 1 mb of vtx data/frame = ~ 38k vtx/frame rend.idx.Init(60*1024,&rend.Overrun); //up to 60K indexes ( idx have stripification overhead ) rend.global_param_op.Init(4096,&rend.Overrun); @@ -199,7 +176,7 @@ struct TA_context void Free() { - aligned_free(tad.thd_root); + free(tad.thd_root); rend.verts.Free(); rend.idx.Free(); rend.global_param_op.Free();