Skip to content

Commit b568e43

Browse files
committed
Render3D: Huge refactor that adds the new Render3DColorOut class, which now handles the framebuffers that integrate the 3D layer and the BG0 layer.
- Framebuffers are now double-buffered, which may help improve performance on games running at less than 60 FPS on host systems with weak GPUs. - For OpenGL, slightly improve framebuffer download performance on macOS.
1 parent 8238c35 commit b568e43

File tree

12 files changed

+2303
-1494
lines changed

12 files changed

+2303
-1494
lines changed

desmume/src/GPU.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,8 +3268,6 @@ GPUEngineA::GPUEngineA()
32683268
_isLineCaptureNative[3][l] = true;
32693269
}
32703270

3271-
_3DFramebufferMain = (Color4u8 *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(Color4u8));
3272-
_3DFramebuffer16 = (u16 *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16));
32733271
_captureWorkingDisplay16 = (u16 *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16));
32743272
_captureWorkingA16 = (u16 *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16));
32753273
_captureWorkingB16 = (u16 *)malloc_alignedPage(GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16));
@@ -3279,8 +3277,6 @@ GPUEngineA::GPUEngineA()
32793277

32803278
GPUEngineA::~GPUEngineA()
32813279
{
3282-
free_aligned(this->_3DFramebufferMain);
3283-
free_aligned(this->_3DFramebuffer16);
32843280
free_aligned(this->_captureWorkingDisplay16);
32853281
free_aligned(this->_captureWorkingA16);
32863282
free_aligned(this->_captureWorkingB16);
@@ -3305,10 +3301,6 @@ void GPUEngineA::Reset()
33053301
this->GPUEngineBase::Reset();
33063302

33073303
const size_t customWidth = this->_targetDisplay->GetWidth();
3308-
const size_t customHeight = this->_targetDisplay->GetHeight();
3309-
3310-
memset(this->_3DFramebufferMain, 0, customWidth * customHeight * sizeof(Color4u8));
3311-
memset(this->_3DFramebuffer16, 0, customWidth * customHeight * sizeof(u16));
33123304
memset(this->_captureWorkingDisplay16, 0, customWidth * _gpuLargestDstLineCount * sizeof(u16));
33133305
memset(this->_captureWorkingA16, 0, customWidth * _gpuLargestDstLineCount * sizeof(u16));
33143306
memset(this->_captureWorkingB16, 0, customWidth * _gpuLargestDstLineCount * sizeof(u16));
@@ -3399,16 +3391,6 @@ void GPUEngineA::ParseReg_DISPCAPCNT()
33993391
this->_dispCapCnt.srcA, this->_dispCapCnt.srcB);*/
34003392
}
34013393

3402-
Color4u8* GPUEngineA::Get3DFramebufferMain() const
3403-
{
3404-
return this->_3DFramebufferMain;
3405-
}
3406-
3407-
u16* GPUEngineA::Get3DFramebuffer16() const
3408-
{
3409-
return this->_3DFramebuffer16;
3410-
}
3411-
34123394
bool GPUEngineA::IsLineCaptureNative(const size_t blockID, const size_t blockLine)
34133395
{
34143396
return this->_isLineCaptureNative[blockID][blockLine];
@@ -3423,16 +3405,12 @@ void GPUEngineA::AllocateWorkingBuffers(NDSColorFormat requestedColorFormat, siz
34233405
{
34243406
this->GPUEngineBase::AllocateWorkingBuffers(requestedColorFormat, w, h);
34253407

3426-
Color4u8 *old3DFramebufferMain = this->_3DFramebufferMain;
3427-
u16 *old3DFramebuffer16 = this->_3DFramebuffer16;
34283408
u16 *oldCaptureWorkingDisplay16 = this->_captureWorkingDisplay16;
34293409
u16 *oldCaptureWorkingA16 = this->_captureWorkingA16;
34303410
u16 *oldCaptureWorkingB16 = this->_captureWorkingB16;
34313411
Color4u8 *oldCaptureWorkingA32 = this->_captureWorkingA32;
34323412
Color4u8 *oldCaptureWorkingB32 = this->_captureWorkingB32;
34333413

3434-
this->_3DFramebufferMain = (Color4u8 *)malloc_alignedPage(w * h * sizeof(Color4u8));
3435-
this->_3DFramebuffer16 = (u16 *)malloc_alignedPage(w * h * sizeof(u16));
34363414
this->_captureWorkingDisplay16 = (u16 *)malloc_alignedPage(w * _gpuLargestDstLineCount * sizeof(u16));
34373415
this->_captureWorkingA16 = (u16 *)malloc_alignedPage(w * _gpuLargestDstLineCount * sizeof(u16));
34383416
this->_captureWorkingB16 = (u16 *)malloc_alignedPage(w * _gpuLargestDstLineCount * sizeof(u16));
@@ -3456,8 +3434,6 @@ void GPUEngineA::AllocateWorkingBuffers(NDSColorFormat requestedColorFormat, siz
34563434
this->_VRAMCustomBlockPtr[3] = (u16 *)this->_VRAMCustomBlockPtr[0] + (3 * lineInfo.indexCustom * w);
34573435
}
34583436

3459-
free_aligned(old3DFramebufferMain);
3460-
free_aligned(old3DFramebuffer16);
34613437
free_aligned(oldCaptureWorkingDisplay16);
34623438
free_aligned(oldCaptureWorkingA16);
34633439
free_aligned(oldCaptureWorkingB16);
@@ -5274,7 +5250,6 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
52745250
this->_engineMain->AllocateWorkingBuffers(outputFormat, w, h);
52755251
this->_engineSub->AllocateWorkingBuffers(outputFormat, w, h);
52765252

5277-
BaseRenderer->SetFramebufferSize(w, h); // Since BaseRenderer is persistent, we need to update this manually.
52785253
if (CurrentRenderer != BaseRenderer)
52795254
{
52805255
CurrentRenderer->RequestColorFormat(outputFormat);

desmume/src/GPU.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,9 +1620,6 @@ class GPUEngineA : public GPUEngineBase
16201620
CACHE_ALIGN u16 _VRAMNativeBlockCaptureCopy[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_VRAM_BLOCK_LINES * 4];
16211621
u16 *_VRAMNativeBlockCaptureCopyPtr[4];
16221622

1623-
Color4u8 *_3DFramebufferMain;
1624-
u16 *_3DFramebuffer16;
1625-
16261623
u16 *_VRAMNativeBlockPtr[4];
16271624
void *_VRAMCustomBlockPtr[4];
16281625

@@ -1680,8 +1677,6 @@ class GPUEngineA : public GPUEngineBase
16801677
void ParseReg_DISPCAPCNT();
16811678
bool IsLineCaptureNative(const size_t blockID, const size_t blockLine);
16821679
void* GetCustomVRAMBlockPtr(const size_t blockID);
1683-
Color4u8* Get3DFramebufferMain() const;
1684-
u16* Get3DFramebuffer16() const;
16851680
virtual void AllocateWorkingBuffers(NDSColorFormat requestedColorFormat, size_t w, size_t h);
16861681

16871682
bool WillRender3DLayer();

0 commit comments

Comments
 (0)