some portability fixes for gpu work

This commit is contained in:
zeromus 2015-09-14 03:45:53 +00:00
parent 5e8b836e83
commit 58732d31b4
3 changed files with 14 additions and 6 deletions

View File

@ -4142,8 +4142,7 @@ GPUSubsystem::GPUSubsystem()
_customVRAM = NULL;
_customVRAMBlank = NULL;
_customFramebuffer = (u16 *)malloc_alignedCacheLine(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16) * 2);
ClearWithColor(0x8000);
_nativeFramebuffer = (u16 *)malloc_alignedCacheLine(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16) * 2);
_displayInfo.isCustomSizeRequested = false;
_displayInfo.customWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
@ -4163,6 +4162,8 @@ GPUSubsystem::GPUSubsystem()
_displayInfo.renderedHeight[1] = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
_displayInfo.renderedBuffer[0] = _displayInfo.nativeBuffer[0];
_displayInfo.renderedBuffer[1] = _displayInfo.nativeBuffer[1];
ClearWithColor(0x8000);
}
GPUSubsystem::~GPUSubsystem()
@ -4170,6 +4171,7 @@ GPUSubsystem::~GPUSubsystem()
delete osd;
osd = NULL;
free_aligned(this->_nativeFramebuffer);
free_aligned(this->_customFramebuffer);
free_aligned(this->_customVRAM);

View File

@ -1324,7 +1324,9 @@ private:
u16 *_customVRAM;
u16 *_customVRAMBlank;
CACHE_ALIGN u16 _nativeFramebuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2];
//zero 13-sep-2015 - had to change this to a pointer instead of an array. as an array, we need the whole GPUSubsystem aligned, and that gets annoying.
//If having the array instead of the pointer is faster, we can change it back and just deal with this type being allocated specially
u16 *_nativeFramebuffer;
u16 *_customFramebuffer;
NDSDisplayInfo _displayInfo;

View File

@ -123,7 +123,9 @@
//------------alignment macros-------------
//dont apply these to types without further testing. it only works portably here on declarations of variables
//cant we find a pattern other people use more successfully?
#if defined(_MSC_VER) || defined(__INTEL_COMPILER)
#if _MSC_VER >= 1900
#define DS_ALIGN(X) alignas(X)
#elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
#define DS_ALIGN(X) __declspec(align(X))
#elif defined(__GNUC__)
#define DS_ALIGN(X) __attribute__ ((aligned (X)))
@ -132,11 +134,13 @@
#endif
#ifdef HOST_64
#define CACHE_ALIGN DS_ALIGN(64)
#define CACHE_ALIGN_SIZE 64
#else
#define CACHE_ALIGN DS_ALIGN(32)
#define CACHE_ALIGN_SIZE 32
#endif
//use this for example when you want a byte value to be better-aligned
#define CACHE_ALIGN DS_ALIGN(CACHE_ALIGN_SIZE)
#define FAST_ALIGN DS_ALIGN(4)
//---------------------------------------------