- Fix bug where 3D rendering may not always finish on line 0, causing lingering 3D artifacts in certain games. Now it is always forced to finish. (Regression from r5255.)
- Bring back the backdrop clearing optimization from r5198 when rendering in the native resolution.
- Do some minor code cleanup.
This commit is contained in:
rogerman 2015-09-07 15:19:34 +00:00
parent 8038e559fe
commit 07e56b07c5
1 changed files with 119 additions and 57 deletions

View File

@ -318,9 +318,23 @@ void GPUEngineBase::_Reset_Base()
memset(this->_sprColor, 0, sizeof(this->_sprColor)); memset(this->_sprColor, 0, sizeof(this->_sprColor));
memset(this->_sprAlpha, 0, sizeof(this->_sprAlpha)); memset(this->_sprAlpha, 0, sizeof(this->_sprAlpha));
memset(this->_sprType, 0, sizeof(this->_sprType)); memset(this->_sprType, 0, sizeof(this->_sprType));
memset(this->_sprPrio, 0, sizeof(this->_sprPrio)); memset(this->_sprPrio, 0x7F, sizeof(this->_sprPrio));
memset(this->_sprNum, 0, sizeof(this->_sprNum));
memset(this->_h_win[0], 0, sizeof(this->_h_win[0]));
memset(this->_h_win[1], 0, sizeof(this->_h_win[1]));
memset(&this->_mosaicColors, 0, sizeof(MosaicColor));
memset(this->_itemsForPriority, 0, sizeof(this->_itemsForPriority)); memset(this->_itemsForPriority, 0, sizeof(this->_itemsForPriority));
if (this->workingScanline != NULL)
{
memset(this->workingScanline, 0, dispInfo.customWidth * _gpuLargestDstLineCount * sizeof(u16));
}
if (this->_bgPixels != NULL)
{
memset(this->_bgPixels, 0, dispInfo.customWidth * _gpuLargestDstLineCount * 4 * sizeof(u8));
}
this->_enableLayer[0] = false; this->_enableLayer[0] = false;
this->_enableLayer[1] = false; this->_enableLayer[1] = false;
this->_enableLayer[2] = false; this->_enableLayer[2] = false;
@ -340,11 +354,6 @@ void GPUEngineBase::_Reset_Base()
this->_BGTypes[2] = BGType_Invalid; this->_BGTypes[2] = BGType_Invalid;
this->_BGTypes[3] = BGType_Invalid; this->_BGTypes[3] = BGType_Invalid;
memset(&this->_mosaicColors, 0, sizeof(MosaicColor));
memset(this->_sprNum, 0, sizeof(this->_sprNum));
memset(this->_h_win[0], 0, sizeof(this->_h_win[0]));
memset(this->_h_win[1], 0, sizeof(this->_h_win[1]));
this->_curr_win[0] = GPUEngineBase::_winEmpty; this->_curr_win[0] = GPUEngineBase::_winEmpty;
this->_curr_win[1] = GPUEngineBase::_winEmpty; this->_curr_win[1] = GPUEngineBase::_winEmpty;
this->need_update_winh[0] = true; this->need_update_winh[0] = true;
@ -420,15 +429,6 @@ void GPUEngineBase::_Reset_Base()
this->MasterBrightMode = GPUMasterBrightMode_Disable; this->MasterBrightMode = GPUMasterBrightMode_Disable;
this->MasterBrightFactor = 0; this->MasterBrightFactor = 0;
if (this->workingScanline != NULL)
{
memset(this->workingScanline, 0, dispInfo.customWidth * _gpuLargestDstLineCount * sizeof(u16));
}
if (this->_bgPixels != NULL)
{
memset(this->_bgPixels, 0, dispInfo.customWidth * _gpuLargestDstLineCount * 4 * sizeof(u8));
}
this->currLine = 0; this->currLine = 0;
this->currDst = this->workingScanline; this->currDst = this->workingScanline;
this->_curr_mosaic_enabled = false; this->_curr_mosaic_enabled = false;
@ -2841,7 +2841,7 @@ void GPUEngineA::SetDISPCAPCNT(u32 val)
this->dispCapCnt.writeBlock = (val >> 16) & 0x03; this->dispCapCnt.writeBlock = (val >> 16) & 0x03;
this->dispCapCnt.writeOffset = (val >> 18) & 0x03; this->dispCapCnt.writeOffset = (val >> 18) & 0x03;
this->dispCapCnt.readBlock = dispCnt->VRAM_Block; this->dispCapCnt.readBlock = dispCnt->VRAM_Block;
this->dispCapCnt.readOffset = (dispCnt->DisplayMode == 2) ? 0 : (val >> 26) & 0x03; this->dispCapCnt.readOffset = (dispCnt->DisplayMode == GPUDisplayMode_VRAM) ? 0 : (val >> 26) & 0x03;
this->dispCapCnt.srcA = (val >> 24) & 0x01; this->dispCapCnt.srcA = (val >> 24) & 0x01;
this->dispCapCnt.srcB = (val >> 25) & 0x01; this->dispCapCnt.srcB = (val >> 25) & 0x01;
this->dispCapCnt.capSrc = (val >> 29) & 0x03; this->dispCapCnt.capSrc = (val >> 29) & 0x03;
@ -3070,24 +3070,60 @@ void GPUEngineA::_RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLi
//this is currently eating up 2fps or so. it is a reasonable candidate for optimization. //this is currently eating up 2fps or so. it is a reasonable candidate for optimization.
switch (this->_finalColorBckFuncID) switch (this->_finalColorBckFuncID)
{ {
//for backdrops, blend isnt applied (it's illogical, isnt it?) case 0: //for backdrops, blend isnt applied (it's illogical, isnt it?)
case 0:
case 1: case 1:
{
PLAIN_CLEAR: PLAIN_CLEAR:
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(backdrop_color), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(backdrop_color), pixCount);
}
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(backdrop_color));
}
break; break;
}
//for backdrops, fade in and fade out can be applied if it's a 1st target screen case 2: //for backdrops, fade in and fade out can be applied if it's a 1st target screen
case 2: {
if(this->_BLDCNT & 0x20) //backdrop is selected for color effect if (this->_BLDCNT & 0x20) //backdrop is selected for color effect
{
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]), pixCount);
else goto PLAIN_CLEAR; }
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]));
}
}
else
{
goto PLAIN_CLEAR;
}
break; break;
}
case 3: case 3:
{
if(this->_BLDCNT & 0x20) //backdrop is selected for color effect if(this->_BLDCNT & 0x20) //backdrop is selected for color effect
{
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]), pixCount);
else goto PLAIN_CLEAR; }
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]));
}
}
else
{
goto PLAIN_CLEAR;
}
break; break;
}
//windowed cases apparently need special treatment? why? can we not render the backdrop? how would that even work? //windowed cases apparently need special treatment? why? can we not render the backdrop? how would that even work?
case 4: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,4,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break; case 4: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,4,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break;
@ -3958,12 +3994,7 @@ void GPUEngineB::RenderLine(const u16 l, bool skip)
this->HandleDisplayModeNormal<ISCUSTOMRENDERINGNEEDED>(dstLine, l, dstLineWidth, dstLineCount); this->HandleDisplayModeNormal<ISCUSTOMRENDERINGNEEDED>(dstLine, l, dstLineWidth, dstLineCount);
break; break;
case GPUDisplayMode_VRAM: // Display vram framebuffer default:
this->HandleDisplayModeVRAM<ISCUSTOMRENDERINGNEEDED>(dstLine, l, dstLineWidth, dstLineCount);
break;
case GPUDisplayMode_MainMemory: // Display memory FIFO
this->HandleDisplayModeMainMemory<ISCUSTOMRENDERINGNEEDED>(dstLine, l, dstLineWidth, dstLineCount);
break; break;
} }
@ -3986,24 +4017,60 @@ void GPUEngineB::_RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLi
//this is currently eating up 2fps or so. it is a reasonable candidate for optimization. //this is currently eating up 2fps or so. it is a reasonable candidate for optimization.
switch (this->_finalColorBckFuncID) switch (this->_finalColorBckFuncID)
{ {
//for backdrops, blend isnt applied (it's illogical, isnt it?) case 0: //for backdrops, blend isnt applied (it's illogical, isnt it?)
case 0:
case 1: case 1:
{
PLAIN_CLEAR: PLAIN_CLEAR:
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(backdrop_color), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(backdrop_color), pixCount);
}
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(backdrop_color));
}
break; break;
}
//for backdrops, fade in and fade out can be applied if it's a 1st target screen case 2: //for backdrops, fade in and fade out can be applied if it's a 1st target screen
case 2: {
if(this->_BLDCNT & 0x20) //backdrop is selected for color effect if (this->_BLDCNT & 0x20) //backdrop is selected for color effect
{
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]), pixCount);
else goto PLAIN_CLEAR; }
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(this->_currentFadeInColors[backdrop_color]));
}
}
else
{
goto PLAIN_CLEAR;
}
break; break;
}
case 3: case 3:
{
if(this->_BLDCNT & 0x20) //backdrop is selected for color effect if(this->_BLDCNT & 0x20) //backdrop is selected for color effect
{
if (ISCUSTOMRENDERINGNEEDED)
{
memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]), pixCount); memset_u16(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]), pixCount);
else goto PLAIN_CLEAR; }
else
{
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(dstLine, LE_TO_LOCAL_16(this->_currentFadeOutColors[backdrop_color]));
}
}
else
{
goto PLAIN_CLEAR;
}
break; break;
}
//windowed cases apparently need special treatment? why? can we not render the backdrop? how would that even work? //windowed cases apparently need special treatment? why? can we not render the backdrop? how would that even work?
case 4: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,4,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break; case 4: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,4,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break;
@ -4012,7 +4079,7 @@ void GPUEngineB::_RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLi
case 7: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,7,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break; case 7: for(size_t x=0;x<GPU_FRAMEBUFFER_NATIVE_WIDTH;x++) this->___setFinalColorBck<GPULayerID_None,false,true,7,ISCUSTOMRENDERINGNEEDED,false>(backdrop_color,x,true); break;
} }
memset(this->_bgPixels, 5, pixCount); memset(this->_bgPixels, GPULayerID_None, pixCount);
// init background color & priorities // init background color & priorities
memset(this->_sprAlpha, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH); memset(this->_sprAlpha, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH);
@ -4285,11 +4352,6 @@ void GPUSubsystem::UpdateVRAM3DUsageProperties()
this->_displayInfo.renderedWidth[NDSDisplayID_Touch] = this->_displayTouch->GetEngine()->renderedWidth; this->_displayInfo.renderedWidth[NDSDisplayID_Touch] = this->_displayTouch->GetEngine()->renderedWidth;
this->_displayInfo.renderedHeight[NDSDisplayID_Touch] = this->_displayTouch->GetEngine()->renderedHeight; this->_displayInfo.renderedHeight[NDSDisplayID_Touch] = this->_displayTouch->GetEngine()->renderedHeight;
if (this->_engineMain->is3DEnabled)
{
CurrentRenderer->RenderFinish();
}
if (!this->_displayInfo.isCustomSizeRequested) if (!this->_displayInfo.isCustomSizeRequested)
{ {
return; return;
@ -4553,6 +4615,7 @@ void GPUSubsystem::RenderLine(const u16 l, bool skip)
{ {
if (l == 0) if (l == 0)
{ {
CurrentRenderer->RenderFinish();
GPU->UpdateVRAM3DUsageProperties(); GPU->UpdateVRAM3DUsageProperties();
} }
@ -4573,7 +4636,6 @@ void GPUSubsystem::RenderLine(const u16 l, bool skip)
{ {
this->_engineSub->RenderLine<false>(l, skip); this->_engineSub->RenderLine<false>(l, skip);
} }
} }
void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551) void GPUSubsystem::ClearWithColor(const u16 colorBGRA5551)