Cleanup changes for merge with master

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2018-04-09 21:11:06 +02:00
parent d1bac19a0a
commit 894e9f1414
2 changed files with 28 additions and 26 deletions

View File

@ -1,3 +1,5 @@
#include <malloc.h>
#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)

View File

@ -1,30 +1,7 @@
#pragma once
#include <malloc.h>
#include <stdlib.h>
#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();