ok, change the GPU buffer back to an embedded array, and change how it's allocated to ensure that it isnt allocated misaligned

This commit is contained in:
zeromus 2015-09-14 04:38:30 +00:00
parent 60f2d5d9cf
commit 386bbd6544
3 changed files with 21 additions and 11 deletions

View File

@ -4142,7 +4142,8 @@ GPUSubsystem::GPUSubsystem()
_customVRAM = NULL;
_customVRAMBlank = NULL;
_customFramebuffer = (u16 *)malloc_alignedCacheLine(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16) * 2);
_nativeFramebuffer = (u16 *)malloc_alignedCacheLine(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16) * 2);
ClearWithColor(0x8000);
_displayInfo.isCustomSizeRequested = false;
_displayInfo.customWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
@ -4162,8 +4163,6 @@ 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()
@ -4171,7 +4170,6 @@ GPUSubsystem::~GPUSubsystem()
delete osd;
osd = NULL;
free_aligned(this->_nativeFramebuffer);
free_aligned(this->_customFramebuffer);
free_aligned(this->_customVRAM);
@ -4186,6 +4184,17 @@ GPUSubsystem::~GPUSubsystem()
gfx3d_deinit();
}
GPUSubsystem* GPUSubsystem::Allocate()
{
return new(malloc_aligned64(sizeof(GPUSubsystem))) GPUSubsystem();
}
void GPUSubsystem::FinalizeAndDeallocate()
{
this->~GPUSubsystem();
free_aligned(this);
}
void GPUSubsystem::Reset()
{
if (this->_customVRAM == NULL || this->_customVRAM == NULL || this->_customFramebuffer == NULL)

View File

@ -1324,16 +1324,17 @@ private:
u16 *_customVRAM;
u16 *_customVRAMBlank;
//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;
CACHE_ALIGN u16 _nativeFramebuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2];
u16 *_customFramebuffer;
NDSDisplayInfo _displayInfo;
public:
GPUSubsystem();
~GPUSubsystem();
public:
static GPUSubsystem* Allocate();
void FinalizeAndDeallocate();
void Reset();
VRAM3DUsageProperties& GetVRAM3DUsageProperties();

View File

@ -170,10 +170,10 @@ int NDS_Init()
if (GPU != NULL)
{
delete GPU;
GPU->FinalizeAndDeallocate();
}
GPU = new GPUSubsystem;
GPU = GPUSubsystem::Allocate();
if (SPU_Init(SNDCORE_DUMMY, 740) != 0)
return -1;
@ -191,7 +191,7 @@ void NDS_DeInit(void)
gameInfo.closeROM();
SPU_DeInit();
delete GPU;
GPU->FinalizeAndDeallocate();
GPU = NULL;
MMU_DeInit();