GPU: Partially revert commit a948838. It still bothered me that native line tracking wasn't individually handled for rendered lines and displayed lines, and so this paradigm has been restored. However, native line tracking continues to be handled purely with GPUEngineBase.

- GPUSubsystem::ClearWithColor() also now handles clearing the master framebuffer with better specificity.
This commit is contained in:
rogerman 2021-09-16 15:24:23 -07:00
parent c6d35f9894
commit 07aadb462e
2 changed files with 120 additions and 124 deletions

View File

@ -354,8 +354,9 @@ void GPUEngineBase::_Reset_Base()
for (size_t l = 0; l < GPU_FRAMEBUFFER_NATIVE_HEIGHT; l++) for (size_t l = 0; l < GPU_FRAMEBUFFER_NATIVE_HEIGHT; l++)
{ {
this->_isLineRenderNative[l] = true; this->_isLineRenderNative[l] = true;
this->_isLineDisplayNative[l] = true;
} }
this->_nativeLineRenderCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_nativeLineDisplayCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
GPUEngineRenderState &renderState = this->_currentRenderState; GPUEngineRenderState &renderState = this->_currentRenderState;
@ -822,8 +823,9 @@ void GPUEngineBase::SetupRenderStates()
for (size_t l = 0; l < GPU_FRAMEBUFFER_NATIVE_HEIGHT; l++) for (size_t l = 0; l < GPU_FRAMEBUFFER_NATIVE_HEIGHT; l++)
{ {
this->_isLineRenderNative[l] = true; this->_isLineRenderNative[l] = true;
this->_isLineDisplayNative[l] = true;
} }
this->_nativeLineRenderCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_nativeLineDisplayCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
if (this->_targetDisplayID == NDSDisplayID_Main) if (this->_targetDisplayID == NDSDisplayID_Main)
{ {
@ -1067,7 +1069,6 @@ void GPUEngineBase::_TransitionLineNativeToCustom(GPUEngineCompositorInfo &compI
compInfo.target.lineColorHead = compInfo.target.lineColorHeadCustom; compInfo.target.lineColorHead = compInfo.target.lineColorHeadCustom;
compInfo.target.lineLayerIDHead = compInfo.target.lineLayerIDHeadCustom; compInfo.target.lineLayerIDHead = compInfo.target.lineLayerIDHeadCustom;
this->_isLineRenderNative[compInfo.line.indexNative] = false; this->_isLineRenderNative[compInfo.line.indexNative] = false;
this->_nativeLineRenderCount--;
} }
//this is fantastically inaccurate. //this is fantastically inaccurate.
@ -3118,18 +3119,19 @@ void GPUEngineBase::_HandleDisplayModeOff(const size_t l)
memset_u32_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>((u32 *)this->_nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH), 0xFFFFFFFF); memset_u32_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>((u32 *)this->_nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH), 0xFFFFFFFF);
break; break;
} }
if (!this->_isLineRenderNative[l])
{
this->_isLineRenderNative[l] = true;
this->_nativeLineRenderCount++;
}
} }
template <NDSColorFormat OUTPUTFORMAT> template <NDSColorFormat OUTPUTFORMAT>
void GPUEngineBase::_HandleDisplayModeNormal(const size_t l) void GPUEngineBase::_HandleDisplayModeNormal(const size_t l)
{ {
// Do nothing. if (!this->_isLineRenderNative[l])
{
if (this->_isLineDisplayNative[l])
{
this->_isLineDisplayNative[l] = false;
this->_nativeLineDisplayCount--;
}
}
} }
template <size_t WINNUM> template <size_t WINNUM>
@ -3291,7 +3293,7 @@ GPUEngineID GPUEngineBase::GetEngineID() const
return this->_engineID; return this->_engineID;
} }
void GPUEngineBase::SetCustomFramebufferSize(size_t w, size_t h) void GPUEngineBase::SetupWorkingBuffers(NDSColorFormat requestedColorFormat, size_t w, size_t h)
{ {
void *oldWorkingLineColor = this->_internalRenderLineTargetCustom; void *oldWorkingLineColor = this->_internalRenderLineTargetCustom;
u8 *oldWorkingLineLayerID = this->_renderLineLayerIDCustom; u8 *oldWorkingLineLayerID = this->_renderLineLayerIDCustom;
@ -3346,18 +3348,27 @@ void GPUEngineBase::SetCustomFramebufferSize(size_t w, size_t h)
free_aligned(oldDidPassWindowTestCustomMasterPtr); free_aligned(oldDidPassWindowTestCustomMasterPtr);
} }
void GPUEngineBase::ResolveToCustomFramebuffer(NDSDisplayInfo &mutableInfo) void GPUEngineBase::ResolveFramebufferToCustom(NDSDisplayInfo &mutableInfo)
{ {
if (mutableInfo.didPerformCustomRender[this->_targetDisplayID]) if (mutableInfo.didPerformCustomRender[this->_targetDisplayID])
{ {
return; return;
} }
if (mutableInfo.isCustomSizeRequested) if (!mutableInfo.isCustomSizeRequested)
{ {
memcpy(mutableInfo.customBuffer[this->_targetDisplayID], mutableInfo.nativeBuffer[this->_targetDisplayID], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * mutableInfo.pixelBytes);
return;
}
// All lines should be 15-bit native-sized lines.
//
// This method is called to transfer these lines into the customBuffer portion of the current
// framebuffer page so that clients can access a single continuous buffer.
if (mutableInfo.pixelBytes == 2) if (mutableInfo.pixelBytes == 2)
{ {
const u16 *__restrict src = (u16 *__restrict)mutableInfo.nativeBuffer[this->_targetDisplayID]; const u16 *__restrict src = (u16 *)mutableInfo.nativeBuffer[this->_targetDisplayID];
u16 *__restrict dst = (u16 *__restrict)mutableInfo.customBuffer[this->_targetDisplayID]; u16 *__restrict dst = (u16 *__restrict)mutableInfo.customBuffer[this->_targetDisplayID];
for (size_t y = 0; y < GPU_FRAMEBUFFER_NATIVE_HEIGHT; y++) for (size_t y = 0; y < GPU_FRAMEBUFFER_NATIVE_HEIGHT; y++)
@ -3370,7 +3381,7 @@ void GPUEngineBase::ResolveToCustomFramebuffer(NDSDisplayInfo &mutableInfo)
} }
else if (mutableInfo.pixelBytes == 4) else if (mutableInfo.pixelBytes == 4)
{ {
const u32 *__restrict src = (u32 *__restrict)mutableInfo.nativeBuffer[this->_targetDisplayID]; const u32 *__restrict src = (u32 *)mutableInfo.nativeBuffer[this->_targetDisplayID];
u32 *__restrict dst = (u32 *__restrict)mutableInfo.customBuffer[this->_targetDisplayID]; u32 *__restrict dst = (u32 *__restrict)mutableInfo.customBuffer[this->_targetDisplayID];
for (size_t y = 0; y < GPU_FRAMEBUFFER_NATIVE_HEIGHT; y++) for (size_t y = 0; y < GPU_FRAMEBUFFER_NATIVE_HEIGHT; y++)
@ -3381,19 +3392,14 @@ void GPUEngineBase::ResolveToCustomFramebuffer(NDSDisplayInfo &mutableInfo)
dst += lineInfo.pixelCount; dst += lineInfo.pixelCount;
} }
} }
}
else
{
memcpy(mutableInfo.customBuffer[this->_targetDisplayID], mutableInfo.nativeBuffer[this->_targetDisplayID], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * mutableInfo.pixelBytes);
}
mutableInfo.didPerformCustomRender[this->_targetDisplayID] = true; mutableInfo.didPerformCustomRender[this->_targetDisplayID] = true;
} }
template <NDSColorFormat OUTPUTFORMAT> template <NDSColorFormat OUTPUTFORMAT>
void GPUEngineBase::ResolveNativeLines() void GPUEngineBase::ResolveLinesDisplayedNative()
{ {
if ( (this->_nativeLineRenderCount == 0) || (this->_nativeLineRenderCount == GPU_FRAMEBUFFER_NATIVE_HEIGHT) ) if ( !GPU->GetDisplayInfo().isCustomSizeRequested || (this->_nativeLineDisplayCount == 0) || (this->_nativeLineDisplayCount == GPU_FRAMEBUFFER_NATIVE_HEIGHT) )
{ {
return; return;
} }
@ -3410,10 +3416,10 @@ void GPUEngineBase::ResolveNativeLines()
{ {
const GPUEngineLineInfo &lineInfo = this->_currentCompositorInfo[y].line; const GPUEngineLineInfo &lineInfo = this->_currentCompositorInfo[y].line;
if (this->_isLineRenderNative[y]) if (this->_isLineDisplayNative[y])
{ {
CopyLineExpandHinted<0x3FFF, true, false, false, 2>(lineInfo, src, dst); CopyLineExpandHinted<0x3FFF, true, false, false, 2>(lineInfo, src, dst);
this->_isLineRenderNative[y] = false; this->_isLineDisplayNative[y] = false;
} }
src += GPU_FRAMEBUFFER_NATIVE_WIDTH; src += GPU_FRAMEBUFFER_NATIVE_WIDTH;
@ -3429,10 +3435,10 @@ void GPUEngineBase::ResolveNativeLines()
{ {
const GPUEngineLineInfo &lineInfo = this->_currentCompositorInfo[y].line; const GPUEngineLineInfo &lineInfo = this->_currentCompositorInfo[y].line;
if (this->_isLineRenderNative[y]) if (this->_isLineDisplayNative[y])
{ {
CopyLineExpandHinted<0x3FFF, true, false, false, 4>(lineInfo, src, dst); CopyLineExpandHinted<0x3FFF, true, false, false, 4>(lineInfo, src, dst);
this->_isLineRenderNative[y] = false; this->_isLineDisplayNative[y] = false;
} }
src += GPU_FRAMEBUFFER_NATIVE_WIDTH; src += GPU_FRAMEBUFFER_NATIVE_WIDTH;
@ -3440,17 +3446,12 @@ void GPUEngineBase::ResolveNativeLines()
} }
} }
this->_nativeLineRenderCount = 0; this->_nativeLineDisplayCount = 0;
} }
size_t GPUEngineBase::GetNativeLineCount() size_t GPUEngineBase::GetLinesDisplayedNativeCount()
{ {
return this->_nativeLineRenderCount; return this->_nativeLineDisplayCount;
}
bool GPUEngineBase::GetIsLineNative(const size_t l)
{
return this->_isLineRenderNative[l];
} }
void GPUEngineBase::RefreshAffineStartRegs() void GPUEngineBase::RefreshAffineStartRegs()
@ -3704,9 +3705,9 @@ void* GPUEngineA::GetCustomVRAMBlockPtr(const size_t blockID)
return this->_VRAMCustomBlockPtr[blockID]; return this->_VRAMCustomBlockPtr[blockID];
} }
void GPUEngineA::SetCustomFramebufferSize(size_t w, size_t h) void GPUEngineA::SetupWorkingBuffers(NDSColorFormat requestedColorFormat, size_t w, size_t h)
{ {
this->GPUEngineBase::SetCustomFramebufferSize(w, h); this->GPUEngineBase::SetupWorkingBuffers(requestedColorFormat, w, h);
FragmentColor *old3DFramebufferMain = this->_3DFramebufferMain; FragmentColor *old3DFramebufferMain = this->_3DFramebufferMain;
u16 *old3DFramebuffer16 = this->_3DFramebuffer16; u16 *old3DFramebuffer16 = this->_3DFramebuffer16;
@ -4740,12 +4741,6 @@ void GPUEngineA::_HandleDisplayModeVRAM(const GPUEngineLineInfo &lineInfo)
break; break;
} }
} }
if (!this->_isLineRenderNative[lineInfo.indexNative])
{
this->_isLineRenderNative[lineInfo.indexNative] = true;
this->_nativeLineRenderCount++;
}
} }
else else
{ {
@ -4779,10 +4774,10 @@ void GPUEngineA::_HandleDisplayModeVRAM(const GPUEngineLineInfo &lineInfo)
if ((OUTPUTFORMAT != NDSColorFormat_BGR888_Rev) || GPU->GetDisplayInfo().isCustomSizeRequested) if ((OUTPUTFORMAT != NDSColorFormat_BGR888_Rev) || GPU->GetDisplayInfo().isCustomSizeRequested)
{ {
if (this->_isLineRenderNative[lineInfo.indexNative]) if (this->_isLineDisplayNative[lineInfo.indexNative])
{ {
this->_isLineRenderNative[lineInfo.indexNative] = false; this->_isLineDisplayNative[lineInfo.indexNative] = false;
this->_nativeLineRenderCount--; this->_nativeLineDisplayCount--;
} }
} }
} }
@ -4811,12 +4806,6 @@ void GPUEngineA::_HandleDisplayModeMainMemory(const GPUEngineLineInfo &lineInfo)
break; break;
} }
} }
if (!this->_isLineRenderNative[lineInfo.indexNative])
{
this->_isLineRenderNative[lineInfo.indexNative] = true;
this->_nativeLineRenderCount++;
}
} }
template<GPUCompositorMode COMPOSITORMODE, NDSColorFormat OUTPUTFORMAT, bool MOSAIC, bool WILLPERFORMWINDOWTEST, bool WILLDEFERCOMPOSITING> template<GPUCompositorMode COMPOSITORMODE, NDSColorFormat OUTPUTFORMAT, bool MOSAIC, bool WILLPERFORMWINDOWTEST, bool WILLDEFERCOMPOSITING>
@ -5511,13 +5500,15 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
this->_displayInfo.masterFramebufferHead = this->_masterFramebuffer; this->_displayInfo.masterFramebufferHead = this->_masterFramebuffer;
this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize); this->_displayInfo.masterNativeBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize);
this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (nativeFramebufferSize * 2) + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize); this->_displayInfo.masterCustomBuffer = (u8 *)this->_masterFramebuffer + (this->_displayInfo.bufferIndex * this->_displayInfo.framebufferPageSize) + (nativeFramebufferSize * 2);
this->_displayInfo.nativeBuffer[NDSDisplayID_Main] = this->_displayInfo.masterNativeBuffer; this->_displayInfo.nativeBuffer[NDSDisplayID_Main] = this->_displayInfo.masterNativeBuffer;
this->_displayInfo.customBuffer[NDSDisplayID_Main] = this->_displayInfo.masterCustomBuffer; this->_displayInfo.customBuffer[NDSDisplayID_Main] = this->_displayInfo.masterCustomBuffer;
this->_displayInfo.nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_displayInfo.masterNativeBuffer + nativeFramebufferSize; this->_displayInfo.nativeBuffer[NDSDisplayID_Touch] = (u8 *)this->_displayInfo.masterNativeBuffer + nativeFramebufferSize;
this->_displayInfo.customBuffer[NDSDisplayID_Touch] = (u8 *)this->_displayInfo.masterCustomBuffer + customFramebufferSize; this->_displayInfo.customBuffer[NDSDisplayID_Touch] = (u8 *)this->_displayInfo.masterCustomBuffer + customFramebufferSize;
this->ClearWithColor(0x8000);
if (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) if (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main])
{ {
this->_displayInfo.renderedBuffer[NDSDisplayID_Main] = this->_displayInfo.customBuffer[NDSDisplayID_Main]; this->_displayInfo.renderedBuffer[NDSDisplayID_Main] = this->_displayInfo.customBuffer[NDSDisplayID_Main];
@ -5549,7 +5540,6 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR555_Rev: case NDSColorFormat_BGR555_Rev:
newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16)); newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16)); memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset_u16(this->_masterFramebuffer, 0x8000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(u16));
this->_customVRAM = newCustomVRAM; this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4); this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break; break;
@ -5557,7 +5547,6 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR666_Rev: case NDSColorFormat_BGR666_Rev:
newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16)); newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16)); memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(u16));
memset_u32(this->_masterFramebuffer, 0x1F000000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(FragmentColor));
this->_customVRAM = newCustomVRAM; this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4); this->_customVRAMBlank = (u16 *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break; break;
@ -5565,7 +5554,6 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
case NDSColorFormat_BGR888_Rev: case NDSColorFormat_BGR888_Rev:
newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor)); newCustomVRAM = (void *)malloc_alignedPage(((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor));
memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor)); memset(newCustomVRAM, 0, ((newCustomVRAMBlockSize * 4) + newCustomVRAMBlankSize) * sizeof(FragmentColor));
memset_u32(this->_masterFramebuffer, 0xFF000000, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / sizeof(FragmentColor));
this->_customVRAM = newCustomVRAM; this->_customVRAM = newCustomVRAM;
this->_customVRAMBlank = (FragmentColor *)newCustomVRAM + (newCustomVRAMBlockSize * 4); this->_customVRAMBlank = (FragmentColor *)newCustomVRAM + (newCustomVRAMBlockSize * 4);
break; break;
@ -5577,8 +5565,8 @@ void GPUSubsystem::_AllocateFramebuffers(NDSColorFormat outputFormat, size_t w,
this->_display[NDSDisplayID_Main]->SetDrawBuffers(this->_displayInfo.nativeBuffer[NDSDisplayID_Main], this->_displayInfo.customBuffer[NDSDisplayID_Main]); this->_display[NDSDisplayID_Main]->SetDrawBuffers(this->_displayInfo.nativeBuffer[NDSDisplayID_Main], this->_displayInfo.customBuffer[NDSDisplayID_Main]);
this->_display[NDSDisplayID_Touch]->SetDrawBuffers(this->_displayInfo.nativeBuffer[NDSDisplayID_Touch], this->_displayInfo.customBuffer[NDSDisplayID_Touch]); this->_display[NDSDisplayID_Touch]->SetDrawBuffers(this->_displayInfo.nativeBuffer[NDSDisplayID_Touch], this->_displayInfo.customBuffer[NDSDisplayID_Touch]);
this->_engineMain->SetCustomFramebufferSize(w, h); this->_engineMain->SetupWorkingBuffers(outputFormat, w, h);
this->_engineSub->SetCustomFramebufferSize(w, h); this->_engineSub->SetupWorkingBuffers(outputFormat, w, h);
BaseRenderer->SetFramebufferSize(w, h); // Since BaseRenderer is persistent, we need to update this manually. BaseRenderer->SetFramebufferSize(w, h); // Since BaseRenderer is persistent, we need to update this manually.
if (CurrentRenderer != BaseRenderer) if (CurrentRenderer != BaseRenderer)
@ -5736,7 +5724,7 @@ void GPUSubsystem::PostprocessDisplay(const NDSDisplayID displayID, NDSDisplayIn
void GPUSubsystem::ResolveDisplayToCustomFramebuffer(const NDSDisplayID displayID, NDSDisplayInfo &mutableInfo) void GPUSubsystem::ResolveDisplayToCustomFramebuffer(const NDSDisplayID displayID, NDSDisplayInfo &mutableInfo)
{ {
this->_display[displayID]->GetEngine()->ResolveToCustomFramebuffer(mutableInfo); this->_display[displayID]->GetEngine()->ResolveFramebufferToCustom(mutableInfo);
} }
bool GPUSubsystem::GetWillAutoResolveToCustomBuffer() const bool GPUSubsystem::GetWillAutoResolveToCustomBuffer() const
@ -5879,18 +5867,15 @@ void GPUSubsystem::RenderLine(const size_t l)
if (!this->_willFrameSkip) if (!this->_willFrameSkip)
{ {
if (this->_displayInfo.isCustomSizeRequested) this->_display[NDSDisplayID_Main]->GetEngine()->ResolveLinesDisplayedNative<OUTPUTFORMAT>();
{ this->_display[NDSDisplayID_Touch]->GetEngine()->ResolveLinesDisplayedNative<OUTPUTFORMAT>();
this->_display[NDSDisplayID_Main]->GetEngine()->ResolveNativeLines<OUTPUTFORMAT>();
this->_display[NDSDisplayID_Touch]->GetEngine()->ResolveNativeLines<OUTPUTFORMAT>();
}
this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main] = (this->_display[NDSDisplayID_Main]->GetEngine()->GetNativeLineCount() < GPU_FRAMEBUFFER_NATIVE_HEIGHT); this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main] = (this->_display[NDSDisplayID_Main]->GetEngine()->GetLinesDisplayedNativeCount() < GPU_FRAMEBUFFER_NATIVE_HEIGHT);
this->_displayInfo.renderedBuffer[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customBuffer[NDSDisplayID_Main] : this->_displayInfo.nativeBuffer[NDSDisplayID_Main]; this->_displayInfo.renderedBuffer[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customBuffer[NDSDisplayID_Main] : this->_displayInfo.nativeBuffer[NDSDisplayID_Main];
this->_displayInfo.renderedWidth[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customWidth : GPU_FRAMEBUFFER_NATIVE_WIDTH; this->_displayInfo.renderedWidth[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customWidth : GPU_FRAMEBUFFER_NATIVE_WIDTH;
this->_displayInfo.renderedHeight[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customHeight : GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_displayInfo.renderedHeight[NDSDisplayID_Main] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) ? this->_displayInfo.customHeight : GPU_FRAMEBUFFER_NATIVE_HEIGHT;
this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch] = (this->_display[NDSDisplayID_Touch]->GetEngine()->GetNativeLineCount() < GPU_FRAMEBUFFER_NATIVE_HEIGHT); this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch] = (this->_display[NDSDisplayID_Touch]->GetEngine()->GetLinesDisplayedNativeCount() < GPU_FRAMEBUFFER_NATIVE_HEIGHT);
this->_displayInfo.renderedBuffer[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customBuffer[NDSDisplayID_Touch] : this->_displayInfo.nativeBuffer[NDSDisplayID_Touch]; this->_displayInfo.renderedBuffer[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customBuffer[NDSDisplayID_Touch] : this->_displayInfo.nativeBuffer[NDSDisplayID_Touch];
this->_displayInfo.renderedWidth[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customWidth : GPU_FRAMEBUFFER_NATIVE_WIDTH; this->_displayInfo.renderedWidth[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customWidth : GPU_FRAMEBUFFER_NATIVE_WIDTH;
this->_displayInfo.renderedHeight[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customHeight : GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_displayInfo.renderedHeight[NDSDisplayID_Touch] = (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Touch]) ? this->_displayInfo.customHeight : GPU_FRAMEBUFFER_NATIVE_HEIGHT;
@ -5967,15 +5952,34 @@ void GPUSubsystem::UpdateAverageBacklightIntensityTotal()
void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551) void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551)
{ {
u16 color16 = colorBGRA5551; const u16 color16 = colorBGRA5551 | 0x8000;
const size_t nativeFramebufferPixCount = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2;
const size_t customFramebufferPixCount = this->_displayInfo.customWidth * this->_displayInfo.customHeight * 2;
if (this->_displayInfo.colorFormat == NDSColorFormat_BGR555_Rev)
{
if (this->_displayInfo.isCustomSizeRequested)
{
for (size_t i = 0; i < this->_displayInfo.framebufferPageCount; i++)
{
memset_u16((u8 *)this->_masterFramebuffer + (this->_displayInfo.framebufferPageSize * i), color16, nativeFramebufferPixCount);
memset_u16((u8 *)this->_masterFramebuffer + (this->_displayInfo.framebufferPageSize * i) + (nativeFramebufferPixCount * sizeof(u16)), color16, customFramebufferPixCount);
}
}
else
{
for (size_t i = 0; i < this->_displayInfo.framebufferPageCount; i++)
{
memset_u16((u8 *)this->_masterFramebuffer + (this->_displayInfo.framebufferPageSize * i), color16, nativeFramebufferPixCount);
}
}
}
else
{
FragmentColor color32; FragmentColor color32;
switch (this->_displayInfo.colorFormat) switch (this->_displayInfo.colorFormat)
{ {
case NDSColorFormat_BGR555_Rev:
color16 = colorBGRA5551 | 0x8000;
break;
case NDSColorFormat_BGR666_Rev: case NDSColorFormat_BGR666_Rev:
color32.color = LE_TO_LOCAL_32( ColorspaceConvert555To6665Opaque<false>(colorBGRA5551 & 0x7FFF) ); color32.color = LE_TO_LOCAL_32( ColorspaceConvert555To6665Opaque<false>(colorBGRA5551 & 0x7FFF) );
break; break;
@ -5988,18 +5992,11 @@ void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551)
break; break;
} }
switch (this->_displayInfo.pixelBytes) for (size_t i = 0; i < this->_displayInfo.framebufferPageCount; i++)
{ {
case 2: memset_u32((u8 *)this->_masterFramebuffer + (this->_displayInfo.framebufferPageSize * i), color32.color, nativeFramebufferPixCount);
memset_u16(this->_masterFramebuffer, color16, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / this->_displayInfo.pixelBytes); memset_u32((u8 *)this->_masterFramebuffer + (this->_displayInfo.framebufferPageSize * i) + (nativeFramebufferPixCount * sizeof(FragmentColor)), color32.color, customFramebufferPixCount);
break; }
case 4:
memset_u32(this->_masterFramebuffer, color32.color, (this->_displayInfo.framebufferPageSize * this->_displayInfo.framebufferPageCount) / this->_displayInfo.pixelBytes);
break;
default:
break;
} }
} }

View File

@ -1391,8 +1391,9 @@ protected:
void *_customBuffer; void *_customBuffer;
void *_nativeBuffer; void *_nativeBuffer;
size_t _nativeLineRenderCount;
bool _isLineRenderNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT]; bool _isLineRenderNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT];
bool _isLineDisplayNative[GPU_FRAMEBUFFER_NATIVE_HEIGHT];
size_t _nativeLineDisplayCount;
bool _enableEngine; bool _enableEngine;
bool _enableBGLayer[5]; bool _enableBGLayer[5];
@ -1584,12 +1585,10 @@ public:
GPUEngineID GetEngineID() const; GPUEngineID GetEngineID() const;
virtual void SetCustomFramebufferSize(size_t w, size_t h); virtual void SetupWorkingBuffers(NDSColorFormat requestedColorFormat, size_t w, size_t h);
void ResolveToCustomFramebuffer(NDSDisplayInfo &mutableInfo); void ResolveFramebufferToCustom(NDSDisplayInfo &mutableInfo);
template<NDSColorFormat OUTPUTFORMAT> void ResolveNativeLines(); template<NDSColorFormat OUTPUTFORMAT> void ResolveLinesDisplayedNative();
size_t GetLinesDisplayedNativeCount();
size_t GetNativeLineCount();
bool GetIsLineNative(const size_t l);
void REG_DISPx_pack_test(); void REG_DISPx_pack_test();
}; };
@ -1669,7 +1668,7 @@ public:
void* GetCustomVRAMBlockPtr(const size_t blockID); void* GetCustomVRAMBlockPtr(const size_t blockID);
FragmentColor* Get3DFramebufferMain() const; FragmentColor* Get3DFramebufferMain() const;
u16* Get3DFramebuffer16() const; u16* Get3DFramebuffer16() const;
virtual void SetCustomFramebufferSize(size_t w, size_t h); virtual void SetupWorkingBuffers(NDSColorFormat requestedColorFormat, size_t w, size_t h);
bool WillRender3DLayer(); bool WillRender3DLayer();
bool WillCapture3DLayerDirect(const size_t l); bool WillCapture3DLayerDirect(const size_t l);