- Do some refactoring and code cleanup.
This commit is contained in:
rogerman 2016-07-14 05:49:47 +00:00
parent 6530d35c3e
commit 7ae811e5cf
2 changed files with 415 additions and 695 deletions

View File

@ -475,9 +475,6 @@ void GPUEngineBase::_Reset_Base()
this->_needUpdateWINH[0] = true; this->_needUpdateWINH[0] = true;
this->_needUpdateWINH[1] = true; this->_needUpdateWINH[1] = true;
this->isCustomRenderingNeeded = false;
this->vramBGLayer = VRAM_NO_3D_USAGE;
this->vramBlockBGIndex = VRAM_NO_3D_USAGE;
this->vramBlockOBJIndex = VRAM_NO_3D_USAGE; this->vramBlockOBJIndex = VRAM_NO_3D_USAGE;
this->nativeLineRenderCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->nativeLineRenderCount = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
@ -4179,9 +4176,220 @@ void GPUEngineBase::_SpriteRenderPerform(const u16 lineIndex, u16 *__restrict ds
} }
} }
template <NDSColorFormat OUTPUTFORMAT>
void* GPUEngineBase::_RenderLine_Layers(const u16 l) void* GPUEngineBase::_RenderLine_Layers(const u16 l)
{ {
return ((u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU->GetDisplayInfo().pixelBytes)); const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
itemsForPriority_t *item;
// Optimization: For normal display mode, render straight to the output buffer when that is what we are going to end
// up displaying anyway. Otherwise, we need to use the working buffer.
void *currentRenderLineTarget = (this->_displayOutputMode == GPUDisplayMode_Normal) ? (u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetNative;
const u16 backdropColor = LE_TO_LOCAL_16(this->_paletteBG[0]) & 0x7FFF;
this->_RenderLine_Clear(backdropColor, l, currentRenderLineTarget);
// for all the pixels in the line
if (this->_enableLayer[GPULayerID_OBJ])
{
this->_RenderLine_SetupSprites(backdropColor, l);
}
// paint lower priorities first
// then higher priorities on top
for (size_t prio = NB_PRIORITIES; prio > 0; )
{
prio--;
item = &(this->_itemsForPriority[prio]);
// render BGs
if (this->_isAnyBGLayerEnabled)
{
for (size_t i = 0; i < item->nbBGs; i++)
{
const GPULayerID layerID = (GPULayerID)item->BGs[i];
if (this->_enableLayer[layerID])
{
if (this->_engineID == GPUEngineID_Main)
{
if ( (layerID == GPULayerID_BG0) && GPU->GetEngineMain()->WillRender3DLayer() )
{
currentRenderLineTarget = GPU->GetEngineMain()->RenderLine_Layer3D<OUTPUTFORMAT>(currentRenderLineTarget, l);
continue;
}
}
if (this->isLineRenderNative[l])
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, false>(currentRenderLineTarget, l); break;
default:
break;
}
}
else
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, true>(currentRenderLineTarget, l); break;
default:
break;
}
}
} //layer enabled
}
}
// render sprite Pixels
if ( this->_enableLayer[GPULayerID_OBJ] && (item->nbPixelsX > 0) )
{
currentRenderLineTarget = this->_RenderLine_LayerOBJ<OUTPUTFORMAT>(item, currentRenderLineTarget, l);
}
}
return currentRenderLineTarget;
}
void GPUEngineBase::_RenderLine_SetupSprites(const u16 backdropColor, const u16 lineIndex)
{
itemsForPriority_t *item;
//n.b. - this is clearing the sprite line buffer to the background color,
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(this->_sprColor, backdropColor);
memset(this->_sprAlpha, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprType, OBJMode_Normal, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprPrio, 0x7F, GPU_FRAMEBUFFER_NATIVE_WIDTH);
//zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure
//how it interacts with this. I wish we knew why we needed this
this->_SpriteRender<false>(lineIndex, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
this->_MosaicSpriteLine(lineIndex, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i++)
{
// assign them to the good priority item
const size_t prio = this->_sprPrio[i];
if (prio >= 4) continue;
item = &(this->_itemsForPriority[prio]);
item->PixelsX[item->nbPixelsX] = i;
item->nbPixelsX++;
}
}
template <NDSColorFormat OUTPUTFORMAT>
void* GPUEngineBase::_RenderLine_LayerOBJ(itemsForPriority_t *__restrict item, void *__restrict dstColorLine, const u16 lineIndex)
{
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
const size_t customLineWidth = dispInfo.customWidth;
const size_t customLineCount = _gpuDstLineCount[lineIndex];
const size_t customLineIndex = _gpuDstLineIndex[lineIndex];
if (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE)
{
if (GPU->GetEngineMain()->VerifyVRAMLineDidChange(this->vramBlockOBJIndex, lineIndex))
{
void *newRenderLineTarget = (this->_displayOutputMode == GPUDisplayMode_Normal) ? (u8 *)this->nativeBuffer + (lineIndex * GPU_FRAMEBUFFER_NATIVE_WIDTH * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetNative;
switch (OUTPUTFORMAT)
{
case NDSColorFormat_BGR555_Rev:
this->_LineColorCopy<true, false, false, false, 2>(newRenderLineTarget, dstColorLine, lineIndex);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
this->_LineColorCopy<true, false, false, false, 4>(newRenderLineTarget, dstColorLine, lineIndex);
break;
}
this->_LineLayerIDCopy<true, false>(this->_renderLineLayerIDNative, this->_renderLineLayerIDCustom, lineIndex);
dstColorLine = newRenderLineTarget;
}
}
const bool useCustomVRAM = (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE) && !GPU->GetEngineMain()->isLineCaptureNative[this->vramBlockOBJIndex][lineIndex];
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetEngineMain()->GetCustomVRAMBlockPtr(this->vramBlockOBJIndex) + (customLineIndex * customLineWidth) : NULL;
if (this->isLineRenderNative[lineIndex] && useCustomVRAM)
{
void *newRenderLineTarget = (this->_displayOutputMode == GPUDisplayMode_Normal) ? (u8 *)this->customBuffer + (customLineIndex * customLineWidth * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetCustom;
switch (OUTPUTFORMAT)
{
case NDSColorFormat_BGR555_Rev:
this->_LineColorCopy<false, true, false, false, 2>(newRenderLineTarget, dstColorLine, lineIndex);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
this->_LineColorCopy<false, true, false, false, 4>(newRenderLineTarget, dstColorLine, lineIndex);
break;
}
this->_LineLayerIDCopy<false, true>(this->_renderLineLayerIDCustom, this->_renderLineLayerIDNative, lineIndex);
dstColorLine = newRenderLineTarget;
this->isLineRenderNative[lineIndex] = false;
this->nativeLineRenderCount--;
}
u16 *__restrict dstColorLine16 = (u16 *)dstColorLine;
FragmentColor *__restrict dstColorLine32 = (FragmentColor *)dstColorLine;
if (this->isLineRenderNative[lineIndex])
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDNative;
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
this->_RenderPixel<OUTPUTFORMAT, GPULayerID_OBJ, false, false, false>(srcX,
this->_sprColor[srcX],
this->_sprAlpha[srcX],
(OUTPUTFORMAT == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + srcX) : (void *)(dstColorLine32 + srcX),
dstLayerIDPtr + srcX);
}
}
else
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDCustom;
for (size_t line = 0; line < customLineCount; line++)
{
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
for (size_t p = 0; p < _gpuDstPitchCount[srcX]; p++)
{
const size_t dstX = _gpuDstPitchIndex[srcX] + p;
this->_RenderPixel<OUTPUTFORMAT, GPULayerID_OBJ, false, false, false>(srcX,
(useCustomVRAM) ? srcLine[dstX] : this->_sprColor[srcX],
this->_sprAlpha[srcX],
(OUTPUTFORMAT == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + dstX) : (void *)(dstColorLine32 + dstX),
dstLayerIDPtr + dstX);
}
}
srcLine += customLineWidth;
dstColorLine16 += customLineWidth;
dstColorLine32 += customLineWidth;
dstLayerIDPtr += customLineWidth;
}
}
return dstColorLine;
} }
template <bool ISFULLINTENSITYHINT> template <bool ISFULLINTENSITYHINT>
@ -4507,50 +4715,6 @@ void GPUEngineBase::_UpdateWINH()
} }
} }
void GPUEngineBase::UpdateVRAM3DUsageProperties_BGLayer(const size_t bankIndex)
{
const bool isBG2UsingVRAM = this->_enableLayer[GPULayerID_BG2] && (this->_BGLayer[GPULayerID_BG2].type == BGType_AffineExt_Direct) && (this->_BGLayer[GPULayerID_BG2].size.width == 256) && (this->_BGLayer[GPULayerID_BG2].size.height == 256);
const bool isBG3UsingVRAM = this->_enableLayer[GPULayerID_BG3] && (this->_BGLayer[GPULayerID_BG3].type == BGType_AffineExt_Direct) && (this->_BGLayer[GPULayerID_BG3].size.width == 256) && (this->_BGLayer[GPULayerID_BG3].size.height == 256);
u8 selectedBGLayer = VRAM_NO_3D_USAGE;
if (!isBG2UsingVRAM && !isBG3UsingVRAM)
{
return;
}
else if (!isBG2UsingVRAM && isBG3UsingVRAM)
{
selectedBGLayer = GPULayerID_BG3;
}
else if (isBG2UsingVRAM && !isBG3UsingVRAM)
{
selectedBGLayer = GPULayerID_BG2;
}
else if (isBG2UsingVRAM && isBG3UsingVRAM)
{
selectedBGLayer = (this->_BGLayer[GPULayerID_BG3].priority <= this->_BGLayer[GPULayerID_BG2].priority) ? GPULayerID_BG3 : GPULayerID_BG2;
}
if (selectedBGLayer != VRAM_NO_3D_USAGE)
{
const IOREG_BGnParameter *bgParams = (selectedBGLayer == GPULayerID_BG2) ? (IOREG_BGnParameter *)&this->_IORegisterMap->BG2Param : (IOREG_BGnParameter *)&this->_IORegisterMap->BG3Param;
const IOREG_BGnX &savedBGnX = (selectedBGLayer == GPULayerID_BG2) ? this->savedBG2X : this->savedBG3X;
const IOREG_BGnY &savedBGnY = (selectedBGLayer == GPULayerID_BG2) ? this->savedBG2Y : this->savedBG3Y;
if ( (bgParams->BGnPA.value != 0x100) ||
(bgParams->BGnPB.value != 0) ||
(bgParams->BGnPC.value != 0) ||
(bgParams->BGnPD.value != 0x100) ||
(savedBGnX.value != 0) ||
(savedBGnY.value != 0) )
{
selectedBGLayer = VRAM_NO_3D_USAGE;
}
}
this->vramBGLayer = selectedBGLayer;
this->vramBlockBGIndex = (selectedBGLayer != VRAM_NO_3D_USAGE) ? bankIndex : VRAM_NO_3D_USAGE;
}
void GPUEngineBase::UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex) void GPUEngineBase::UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex)
{ {
const IOREG_DISPCNT &DISPCNT = this->_IORegisterMap->DISPCNT; const IOREG_DISPCNT &DISPCNT = this->_IORegisterMap->DISPCNT;
@ -5221,7 +5385,7 @@ void GPUEngineA::RenderLine(const u16 l)
this->_SetupWindows<1>(l); this->_SetupWindows<1>(l);
// Render the line // Render the line
void *renderLineTarget = this->_RenderLine_Layers(l); void *renderLineTarget = this->_RenderLine_Layers<NDSColorFormat_BGR555_Rev>(l);
// Fill the display output // Fill the display output
switch (this->_displayOutputMode) switch (this->_displayOutputMode)
@ -5261,102 +5425,47 @@ void GPUEngineA::RenderLine(const u16 l)
} }
} }
void* GPUEngineA::_RenderLine_Layers(const u16 l) template <NDSColorFormat OUTPUTFORMAT>
{ void* GPUEngineA::RenderLine_Layer3D(void *dstColorLine, const u16 lineIndex)
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
const size_t customLineWidth = dispInfo.customWidth;
const size_t customLineCount = _gpuDstLineCount[l];
const size_t customLineIndex = _gpuDstLineIndex[l];
// Optimization: For normal display mode, render straight to the output buffer when that is what we are going to end
// up displaying anyway. Otherwise, we need to use the working buffer.
const bool isDisplayModeNormal = (this->_displayOutputMode == GPUDisplayMode_Normal);
void *renderLineTargetNative = (isDisplayModeNormal) ? (u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetNative;
void *renderLineTargetCustom = (isDisplayModeNormal) ? (u8 *)this->customBuffer + (customLineIndex * customLineWidth * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetCustom;
void *currentRenderLineTarget = renderLineTargetNative;
const u16 backdropColor = LE_TO_LOCAL_16(this->_paletteBG[0]) & 0x7FFF;
this->_RenderLine_Clear(backdropColor, l, renderLineTargetNative);
itemsForPriority_t *__restrict item;
// for all the pixels in the line
if (this->_enableLayer[GPULayerID_OBJ])
{
//n.b. - this is clearing the sprite line buffer to the background color,
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(this->_sprColor, backdropColor);
memset(this->_sprAlpha, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprType, OBJMode_Normal, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprPrio, 0x7F, GPU_FRAMEBUFFER_NATIVE_WIDTH);
//zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure
//how it interacts with this. I wish we knew why we needed this
this->_SpriteRender<false>(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
this->_MosaicSpriteLine(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i++)
{
// assign them to the good priority item
const size_t prio = this->_sprPrio[i];
if (prio >= 4) continue;
item = &(this->_itemsForPriority[prio]);
item->PixelsX[item->nbPixelsX] = i;
item->nbPixelsX++;
}
}
// paint lower priorities first
// then higher priorities on top
for (size_t prio = NB_PRIORITIES; prio > 0; )
{
prio--;
item = &(this->_itemsForPriority[prio]);
// render BGs
if (this->_isAnyBGLayerEnabled)
{
for (size_t i = 0; i < item->nbBGs; i++)
{
const GPULayerID layerID = (GPULayerID)item->BGs[i];
if (this->_enableLayer[layerID])
{
if ( (layerID == GPULayerID_BG0) && this->WillRender3DLayer() )
{ {
const FragmentColor *__restrict framebuffer3D = CurrentRenderer->GetFramebuffer(); const FragmentColor *__restrict framebuffer3D = CurrentRenderer->GetFramebuffer();
if (framebuffer3D == NULL) if (framebuffer3D == NULL)
{ {
continue; return dstColorLine;
} }
if (this->isLineRenderNative[l] && !CurrentRenderer->IsFramebufferNativeSize()) const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
{ const size_t customLineWidth = dispInfo.customWidth;
void *newRenderLineTarget = renderLineTargetCustom; const size_t customLineCount = _gpuDstLineCount[lineIndex];
const size_t customLineIndex = _gpuDstLineIndex[lineIndex];
switch (dispInfo.colorFormat) if (this->isLineRenderNative[lineIndex] && !CurrentRenderer->IsFramebufferNativeSize())
{
void *newRenderLineTarget = (this->_displayOutputMode == GPUDisplayMode_Normal) ? (u8 *)this->customBuffer + (customLineIndex * customLineWidth * dispInfo.pixelBytes) : (u8 *)this->_internalRenderLineTargetCustom;
switch (OUTPUTFORMAT)
{ {
case NDSColorFormat_BGR555_Rev: case NDSColorFormat_BGR555_Rev:
this->_LineColorCopy<false, true, false, false, 2>(newRenderLineTarget, currentRenderLineTarget, l); this->_LineColorCopy<false, true, false, false, 2>(newRenderLineTarget, dstColorLine, lineIndex);
break; break;
case NDSColorFormat_BGR666_Rev: case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev: case NDSColorFormat_BGR888_Rev:
this->_LineColorCopy<false, true, false, false, 4>(newRenderLineTarget, currentRenderLineTarget, l); this->_LineColorCopy<false, true, false, false, 4>(newRenderLineTarget, dstColorLine, lineIndex);
break; break;
} }
this->_LineLayerIDCopy<false, true>(this->_renderLineLayerIDCustom, this->_renderLineLayerIDNative, l); this->_LineLayerIDCopy<false, true>(this->_renderLineLayerIDCustom, this->_renderLineLayerIDNative, lineIndex);
currentRenderLineTarget = newRenderLineTarget; dstColorLine = newRenderLineTarget;
this->isLineRenderNative[l] = false; this->isLineRenderNative[lineIndex] = false;
this->nativeLineRenderCount--; this->nativeLineRenderCount--;
} }
const float customWidthScale = (float)customLineWidth / (float)GPU_FRAMEBUFFER_NATIVE_WIDTH; const float customWidthScale = (float)customLineWidth / (float)GPU_FRAMEBUFFER_NATIVE_WIDTH;
const FragmentColor *__restrict srcLinePtr = framebuffer3D + (customLineIndex * customLineWidth); const FragmentColor *__restrict srcLinePtr = framebuffer3D + (customLineIndex * customLineWidth);
void *__restrict dstColorLinePtr = currentRenderLineTarget; void *__restrict dstColorLinePtr = dstColorLine;
u8 *__restrict dstLayerIDPtr = (this->isLineRenderNative[l]) ? this->_renderLineLayerIDNative : this->_renderLineLayerIDCustom; u8 *__restrict dstLayerIDPtr = (this->isLineRenderNative[lineIndex]) ? this->_renderLineLayerIDNative : this->_renderLineLayerIDCustom;
// Horizontally offset the 3D layer by this amount. // Horizontally offset the 3D layer by this amount.
// Test case: Blowing up large objects in Nanostray 2 will cause the main screen to shake horizontally. // Test case: Blowing up large objects in Nanostray 2 will cause the main screen to shake horizontally.
@ -5370,7 +5479,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
#ifdef ENABLE_SSE2 #ifdef ENABLE_SSE2
const size_t ssePixCount = customLineWidth - (customLineWidth % 16); const size_t ssePixCount = customLineWidth - (customLineWidth % 16);
for (; dstX < ssePixCount; dstX+=16, srcLinePtr+=16, dstLayerIDPtr+=16, dstColorLinePtr = (dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 16) : (void *)((FragmentColor *)dstColorLinePtr + 16)) for (; dstX < ssePixCount; dstX+=16, srcLinePtr+=16, dstLayerIDPtr+=16, dstColorLinePtr = (OUTPUTFORMAT == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 16) : (void *)((FragmentColor *)dstColorLinePtr + 16))
{ {
const __m128i src[4] = { _mm_load_si128((__m128i *)srcLinePtr + 0), const __m128i src[4] = { _mm_load_si128((__m128i *)srcLinePtr + 0),
_mm_load_si128((__m128i *)srcLinePtr + 1), _mm_load_si128((__m128i *)srcLinePtr + 1),
@ -5402,7 +5511,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
dst[0] = _mm_load_si128((__m128i *)dstColorLinePtr + 0); dst[0] = _mm_load_si128((__m128i *)dstColorLinePtr + 0);
dst[1] = _mm_load_si128((__m128i *)dstColorLinePtr + 1); dst[1] = _mm_load_si128((__m128i *)dstColorLinePtr + 1);
if (dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) if (OUTPUTFORMAT == NDSColorFormat_BGR555_Rev)
{ {
// Instead of letting these vectors go to waste, let's convert the src colors to 16-bit now and // Instead of letting these vectors go to waste, let's convert the src colors to 16-bit now and
// then pack the converted 16-bit colors into these vectors. // then pack the converted 16-bit colors into these vectors.
@ -5417,43 +5526,16 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
dst[3] = _mm_load_si128((__m128i *)dstColorLinePtr + 3); dst[3] = _mm_load_si128((__m128i *)dstColorLinePtr + 3);
} }
switch (dispInfo.colorFormat) this->_RenderPixel3D_SSE2<OUTPUTFORMAT>(passMask8,
{
case NDSColorFormat_BGR555_Rev:
{
this->_RenderPixel3D_SSE2<NDSColorFormat_BGR555_Rev>(passMask8,
enableColorEffectMask, enableColorEffectMask,
src[3], src[2], src[1], src[0], src[3], src[2], src[1], src[0],
dst[3], dst[2], dst[1], dst[0], dst[3], dst[2], dst[1], dst[0],
dstLayerID_vec128); dstLayerID_vec128);
break;
}
case NDSColorFormat_BGR666_Rev:
{
this->_RenderPixel3D_SSE2<NDSColorFormat_BGR666_Rev>(passMask8,
enableColorEffectMask,
src[3], src[2], src[1], src[0],
dst[3], dst[2], dst[1], dst[0],
dstLayerID_vec128);
break;
}
case NDSColorFormat_BGR888_Rev:
{
this->_RenderPixel3D_SSE2<NDSColorFormat_BGR888_Rev>(passMask8,
enableColorEffectMask,
src[3], src[2], src[1], src[0],
dst[3], dst[2], dst[1], dst[0],
dstLayerID_vec128);
break;
}
}
_mm_store_si128((__m128i *)dstColorLinePtr + 0, dst[0]); _mm_store_si128((__m128i *)dstColorLinePtr + 0, dst[0]);
_mm_store_si128((__m128i *)dstColorLinePtr + 1, dst[1]); _mm_store_si128((__m128i *)dstColorLinePtr + 1, dst[1]);
if (dispInfo.colorFormat != NDSColorFormat_BGR555_Rev) if (OUTPUTFORMAT != NDSColorFormat_BGR555_Rev)
{ {
_mm_store_si128((__m128i *)dstColorLinePtr + 2, dst[2]); _mm_store_si128((__m128i *)dstColorLinePtr + 2, dst[2]);
_mm_store_si128((__m128i *)dstColorLinePtr + 3, dst[3]); _mm_store_si128((__m128i *)dstColorLinePtr + 3, dst[3]);
@ -5467,7 +5549,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
#pragma LOOPVECTORIZE_DISABLE #pragma LOOPVECTORIZE_DISABLE
#endif #endif
for (; dstX < customLineWidth; dstX++, srcLinePtr++, dstLayerIDPtr++, dstColorLinePtr = (dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 1) : (void *)((FragmentColor *)dstColorLinePtr + 1)) for (; dstX < customLineWidth; dstX++, srcLinePtr++, dstLayerIDPtr++, dstColorLinePtr = (OUTPUTFORMAT == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 1) : (void *)((FragmentColor *)dstColorLinePtr + 1))
{ {
if (srcLinePtr->a == 0) if (srcLinePtr->a == 0)
{ {
@ -5484,7 +5566,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
continue; continue;
} }
switch (dispInfo.colorFormat) switch (OUTPUTFORMAT)
{ {
case NDSColorFormat_BGR555_Rev: case NDSColorFormat_BGR555_Rev:
{ {
@ -5496,17 +5578,9 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
} }
case NDSColorFormat_BGR666_Rev: case NDSColorFormat_BGR666_Rev:
{
this->_RenderPixel3D<NDSColorFormat_BGR666_Rev>(*srcLinePtr,
*(FragmentColor *)dstColorLinePtr,
*dstLayerIDPtr,
enableColorEffect);
break;
}
case NDSColorFormat_BGR888_Rev: case NDSColorFormat_BGR888_Rev:
{ {
this->_RenderPixel3D<NDSColorFormat_BGR888_Rev>(*srcLinePtr, this->_RenderPixel3D<OUTPUTFORMAT>(*srcLinePtr,
*(FragmentColor *)dstColorLinePtr, *(FragmentColor *)dstColorLinePtr,
*dstLayerIDPtr, *dstLayerIDPtr,
enableColorEffect); enableColorEffect);
@ -5520,7 +5594,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
{ {
for (size_t line = 0; line < customLineCount; line++) for (size_t line = 0; line < customLineCount; line++)
{ {
for (size_t dstX = 0; dstX < customLineWidth; dstX++, dstLayerIDPtr++, dstColorLinePtr = (dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 1) : (void *)((FragmentColor *)dstColorLinePtr + 1)) for (size_t dstX = 0; dstX < customLineWidth; dstX++, dstLayerIDPtr++, dstColorLinePtr = (OUTPUTFORMAT == NDSColorFormat_BGR555_Rev) ? (void *)((u16 *)dstColorLinePtr + 1) : (void *)((FragmentColor *)dstColorLinePtr + 1))
{ {
size_t srcX = dstX + hofs; size_t srcX = dstX + hofs;
if (srcX >= customLineWidth * 2) if (srcX >= customLineWidth * 2)
@ -5543,7 +5617,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
continue; continue;
} }
switch (dispInfo.colorFormat) switch (OUTPUTFORMAT)
{ {
case NDSColorFormat_BGR555_Rev: case NDSColorFormat_BGR555_Rev:
{ {
@ -5555,17 +5629,9 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
} }
case NDSColorFormat_BGR666_Rev: case NDSColorFormat_BGR666_Rev:
{
this->_RenderPixel3D<NDSColorFormat_BGR666_Rev>(srcLinePtr[srcX],
*(FragmentColor *)dstColorLinePtr,
*dstLayerIDPtr,
enableColorEffect);
break;
}
case NDSColorFormat_BGR888_Rev: case NDSColorFormat_BGR888_Rev:
{ {
this->_RenderPixel3D<NDSColorFormat_BGR888_Rev>(srcLinePtr[srcX], this->_RenderPixel3D<OUTPUTFORMAT>(srcLinePtr[srcX],
*(FragmentColor *)dstColorLinePtr, *(FragmentColor *)dstColorLinePtr,
*dstLayerIDPtr, *dstLayerIDPtr,
enableColorEffect); enableColorEffect);
@ -5578,140 +5644,7 @@ void* GPUEngineA::_RenderLine_Layers(const u16 l)
} }
} }
continue; return dstColorLine;
}
if (this->isLineRenderNative[l])
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, false>(currentRenderLineTarget, l); break;
default:
break;
}
}
else
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, true>(currentRenderLineTarget, l); break;
default:
break;
}
}
} //layer enabled
}
}
// render sprite Pixels
if ( this->_enableLayer[GPULayerID_OBJ] && (item->nbPixelsX > 0) )
{
if (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE)
{
if (GPU->GetEngineMain()->VerifyVRAMLineDidChange(this->vramBlockOBJIndex, l))
{
void *newRenderLineTarget = (void *)renderLineTargetNative;
switch (dispInfo.colorFormat)
{
case NDSColorFormat_BGR555_Rev:
this->_LineColorCopy<true, false, false, false, 2>(newRenderLineTarget, currentRenderLineTarget, l);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
this->_LineColorCopy<true, false, false, false, 4>(newRenderLineTarget, currentRenderLineTarget, l);
break;
}
this->_LineLayerIDCopy<true, false>(this->_renderLineLayerIDNative, this->_renderLineLayerIDCustom, l);
currentRenderLineTarget = newRenderLineTarget;
}
}
const bool useCustomVRAM = (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE) && !GPU->GetEngineMain()->isLineCaptureNative[this->vramBlockOBJIndex][l];
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetEngineMain()->GetCustomVRAMBlockPtr(this->vramBlockOBJIndex) + (customLineIndex * customLineWidth) : NULL;
if (this->isLineRenderNative[l] && useCustomVRAM)
{
void *newRenderLineTarget = renderLineTargetCustom;
switch (dispInfo.colorFormat)
{
case NDSColorFormat_BGR555_Rev:
this->_LineColorCopy<false, true, false, false, 2>(newRenderLineTarget, currentRenderLineTarget, l);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
this->_LineColorCopy<false, true, false, false, 4>(newRenderLineTarget, currentRenderLineTarget, l);
break;
}
this->_LineLayerIDCopy<false, true>(this->_renderLineLayerIDCustom, this->_renderLineLayerIDNative, l);
currentRenderLineTarget = newRenderLineTarget;
this->isLineRenderNative[l] = false;
this->nativeLineRenderCount--;
}
u16 *__restrict dstColorLine16 = (u16 *)currentRenderLineTarget;
FragmentColor *__restrict dstColorLine32 = (FragmentColor *)currentRenderLineTarget;
if (this->isLineRenderNative[l])
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDNative;
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
this->_RenderPixel<NDSColorFormat_BGR555_Rev, GPULayerID_OBJ, false, false, false>(srcX,
this->_sprColor[srcX],
this->_sprAlpha[srcX],
(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + srcX) : (void *)(dstColorLine32 + srcX),
dstLayerIDPtr + srcX);
}
}
else
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDCustom;
for (size_t line = 0; line < customLineCount; line++)
{
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
for (size_t p = 0; p < _gpuDstPitchCount[srcX]; p++)
{
const size_t dstX = _gpuDstPitchIndex[srcX] + p;
this->_RenderPixel<NDSColorFormat_BGR555_Rev, GPULayerID_OBJ, false, false, false>(srcX,
(useCustomVRAM) ? srcLine[dstX] : this->_sprColor[srcX],
this->_sprAlpha[srcX],
(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + dstX) : (void *)(dstColorLine32 + dstX),
dstLayerIDPtr + dstX);
}
}
srcLine += customLineWidth;
dstColorLine16 += customLineWidth;
dstColorLine32 += customLineWidth;
dstLayerIDPtr += customLineWidth;
}
}
}
}
return currentRenderLineTarget;
} }
template<size_t CAPTURELENGTH> template<size_t CAPTURELENGTH>
@ -6902,7 +6835,7 @@ void GPUEngineB::RenderLine(const u16 l)
break; break;
case GPUDisplayMode_Normal: // Display BG and OBJ layers case GPUDisplayMode_Normal: // Display BG and OBJ layers
this->_RenderLine_Layers(l); this->_RenderLine_Layers<NDSColorFormat_BGR555_Rev>(l);
this->_HandleDisplayModeNormal(l); this->_HandleDisplayModeNormal(l);
break; break;
@ -6911,197 +6844,6 @@ void GPUEngineB::RenderLine(const u16 l)
} }
} }
void* GPUEngineB::_RenderLine_Layers(const u16 l)
{
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
const size_t customLineWidth = dispInfo.customWidth;
const size_t customLineCount = _gpuDstLineCount[l];
const size_t customLineIndex = _gpuDstLineIndex[l];
void *currentRenderLineTarget = (u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * dispInfo.pixelBytes);
itemsForPriority_t *__restrict item;
const u16 backdropColor = LE_TO_LOCAL_16(this->_paletteBG[0]) & 0x7FFF;
this->_RenderLine_Clear(backdropColor, l, currentRenderLineTarget);
// for all the pixels in the line
if (this->_enableLayer[GPULayerID_OBJ])
{
//n.b. - this is clearing the sprite line buffer to the background color,
memset_u16_fast<GPU_FRAMEBUFFER_NATIVE_WIDTH>(this->_sprColor, backdropColor);
memset(this->_sprAlpha, 0, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprType, OBJMode_Normal, GPU_FRAMEBUFFER_NATIVE_WIDTH);
memset(this->_sprPrio, 0x7F, GPU_FRAMEBUFFER_NATIVE_WIDTH);
//zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure
//how it interacts with this. I wish we knew why we needed this
this->_SpriteRender<false>(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
this->_MosaicSpriteLine(l, this->_sprColor, this->_sprAlpha, this->_sprType, this->_sprPrio);
for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i++)
{
// assign them to the good priority item
const size_t prio = this->_sprPrio[i];
if (prio >= 4) continue;
item = &(this->_itemsForPriority[prio]);
item->PixelsX[item->nbPixelsX] = i;
item->nbPixelsX++;
}
}
// paint lower priorities first
// then higher priorities on top
for (size_t prio = NB_PRIORITIES; prio > 0; )
{
prio--;
item = &(this->_itemsForPriority[prio]);
// render BGs
if (this->_isAnyBGLayerEnabled)
{
for (size_t i = 0; i < item->nbBGs; i++)
{
const GPULayerID layerID = (GPULayerID)item->BGs[i];
if (this->_enableLayer[layerID])
{
if (this->isLineRenderNative[l])
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, false>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, false>(currentRenderLineTarget, l); break;
default:
break;
}
}
else
{
switch (layerID)
{
case GPULayerID_BG0: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG0, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG1: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG1, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG2: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG2, false, true>(currentRenderLineTarget, l); break;
case GPULayerID_BG3: currentRenderLineTarget = this->_RenderLine_LayerBG<GPULayerID_BG3, false, true>(currentRenderLineTarget, l); break;
default:
break;
}
}
} //layer enabled
}
}
// render sprite Pixels
if ( this->_enableLayer[GPULayerID_OBJ] && (item->nbPixelsX > 0) )
{
if (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE)
{
if (GPU->GetEngineMain()->VerifyVRAMLineDidChange(this->vramBlockOBJIndex, l))
{
void *newRenderLineTarget;
switch (dispInfo.colorFormat)
{
case NDSColorFormat_BGR555_Rev:
newRenderLineTarget = (u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16));
this->_LineColorCopy<true, false, false, false, 2>(newRenderLineTarget, currentRenderLineTarget, l);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
newRenderLineTarget = (u8 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(FragmentColor));
this->_LineColorCopy<true, false, false, false, 4>(newRenderLineTarget, currentRenderLineTarget, l);
break;
}
this->_LineLayerIDCopy<true, false>(this->_renderLineLayerIDNative, this->_renderLineLayerIDCustom, l);
currentRenderLineTarget = newRenderLineTarget;
}
}
const bool useCustomVRAM = (this->vramBlockOBJIndex != VRAM_NO_3D_USAGE) && !GPU->GetEngineMain()->isLineCaptureNative[this->vramBlockOBJIndex][l];
const u16 *__restrict srcLine = (useCustomVRAM) ? GPU->GetEngineMain()->GetCustomVRAMBlockPtr(this->vramBlockOBJIndex) + (customLineIndex * customLineWidth) : NULL;
if (this->isLineRenderNative[l] && useCustomVRAM)
{
void *newRenderLineTarget;
switch (dispInfo.colorFormat)
{
case NDSColorFormat_BGR555_Rev:
newRenderLineTarget = (u8 *)this->customBuffer + (customLineIndex * customLineWidth * sizeof(u16));
this->_LineColorCopy<false, true, false, false, 2>(newRenderLineTarget, currentRenderLineTarget, l);
break;
case NDSColorFormat_BGR666_Rev:
case NDSColorFormat_BGR888_Rev:
newRenderLineTarget = (u8 *)this->customBuffer + (customLineIndex * customLineWidth * sizeof(FragmentColor));
this->_LineColorCopy<false, true, false, false, 4>(newRenderLineTarget, currentRenderLineTarget, l);
break;
}
this->_LineLayerIDCopy<false, true>(this->_renderLineLayerIDCustom, this->_renderLineLayerIDNative, l);
currentRenderLineTarget = newRenderLineTarget;
this->isLineRenderNative[l] = false;
this->nativeLineRenderCount--;
}
u16 *__restrict dstColorLine16 = (u16 *)currentRenderLineTarget;
FragmentColor *__restrict dstColorLine32 = (FragmentColor *)currentRenderLineTarget;
if (this->isLineRenderNative[l])
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDNative;
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
this->_RenderPixel<NDSColorFormat_BGR555_Rev, GPULayerID_OBJ, false, false, false>(srcX,
this->_sprColor[srcX],
this->_sprAlpha[srcX],
(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + srcX) : (void *)(dstColorLine32 + srcX),
dstLayerIDPtr + srcX);
}
}
else
{
u8 *__restrict dstLayerIDPtr = this->_renderLineLayerIDCustom;
for (size_t line = 0; line < customLineCount; line++)
{
for (size_t i = 0; i < item->nbPixelsX; i++)
{
const size_t srcX = item->PixelsX[i];
for (size_t p = 0; p < _gpuDstPitchCount[srcX]; p++)
{
const size_t dstX = _gpuDstPitchIndex[srcX] + p;
this->_RenderPixel<NDSColorFormat_BGR555_Rev, GPULayerID_OBJ, false, false, false>(srcX,
(useCustomVRAM) ? srcLine[dstX] : this->_sprColor[srcX],
this->_sprAlpha[srcX],
(dispInfo.colorFormat == NDSColorFormat_BGR555_Rev) ? (void *)(dstColorLine16 + dstX) : (void *)(dstColorLine32 + dstX),
dstLayerIDPtr + dstX);
}
}
srcLine += customLineWidth;
dstColorLine16 += customLineWidth;
dstColorLine32 += customLineWidth;
dstLayerIDPtr += customLineWidth;
}
}
}
}
return currentRenderLineTarget;
}
GPUSubsystem::GPUSubsystem() GPUSubsystem::GPUSubsystem()
{ {
static bool needInitTables = true; static bool needInitTables = true;
@ -7259,18 +7001,12 @@ void GPUSubsystem::Reset()
void GPUSubsystem::UpdateRenderProperties() void GPUSubsystem::UpdateRenderProperties()
{ {
this->_engineMain->isCustomRenderingNeeded = false;
this->_engineMain->vramBlockBGIndex = VRAM_NO_3D_USAGE;
this->_engineMain->vramBlockOBJIndex = VRAM_NO_3D_USAGE; this->_engineMain->vramBlockOBJIndex = VRAM_NO_3D_USAGE;
this->_engineMain->vramBGLayer = VRAM_NO_3D_USAGE;
this->_engineMain->renderedWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH; this->_engineMain->renderedWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
this->_engineMain->renderedHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_engineMain->renderedHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
this->_engineMain->renderedBuffer = this->_engineMain->nativeBuffer; this->_engineMain->renderedBuffer = this->_engineMain->nativeBuffer;
this->_engineSub->isCustomRenderingNeeded = false;
this->_engineSub->vramBlockBGIndex = VRAM_NO_3D_USAGE;
this->_engineSub->vramBlockOBJIndex = VRAM_NO_3D_USAGE; this->_engineSub->vramBlockOBJIndex = VRAM_NO_3D_USAGE;
this->_engineSub->vramBGLayer = VRAM_NO_3D_USAGE;
this->_engineSub->renderedWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH; this->_engineSub->renderedWidth = GPU_FRAMEBUFFER_NATIVE_WIDTH;
this->_engineSub->renderedHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT; this->_engineSub->renderedHeight = GPU_FRAMEBUFFER_NATIVE_HEIGHT;
this->_engineSub->renderedBuffer = this->_engineSub->nativeBuffer; this->_engineSub->renderedBuffer = this->_engineSub->nativeBuffer;
@ -7316,11 +7052,8 @@ void GPUSubsystem::UpdateRenderProperties()
switch (vramConfiguration.banks[i].purpose) switch (vramConfiguration.banks[i].purpose)
{ {
case VramConfiguration::ABG: case VramConfiguration::ABG:
this->_engineMain->UpdateVRAM3DUsageProperties_BGLayer(i);
break;
case VramConfiguration::BBG: case VramConfiguration::BBG:
this->_engineSub->UpdateVRAM3DUsageProperties_BGLayer(i); case VramConfiguration::LCDC:
break; break;
case VramConfiguration::AOBJ: case VramConfiguration::AOBJ:
@ -7331,9 +7064,6 @@ void GPUSubsystem::UpdateRenderProperties()
this->_engineSub->UpdateVRAM3DUsageProperties_OBJLayer(i); this->_engineSub->UpdateVRAM3DUsageProperties_OBJLayer(i);
break; break;
case VramConfiguration::LCDC:
break;
default: default:
{ {
this->_engineMain->nativeLineCaptureCount[i] = GPU_VRAM_BLOCK_LINES; this->_engineMain->nativeLineCaptureCount[i] = GPU_VRAM_BLOCK_LINES;
@ -7345,13 +7075,6 @@ void GPUSubsystem::UpdateRenderProperties()
} }
} }
} }
this->_engineMain->isCustomRenderingNeeded = (this->_engineMain->WillRender3DLayer() && !CurrentRenderer->IsFramebufferNativeSize()) ||
(this->_engineMain->vramBlockBGIndex != VRAM_NO_3D_USAGE) ||
(this->_engineMain->vramBlockOBJIndex != VRAM_NO_3D_USAGE);
this->_engineSub->isCustomRenderingNeeded = (this->_engineSub->vramBlockBGIndex != VRAM_NO_3D_USAGE) ||
(this->_engineSub->vramBlockOBJIndex != VRAM_NO_3D_USAGE);
} }
const NDSDisplayInfo& GPUSubsystem::GetDisplayInfo() const NDSDisplayInfo& GPUSubsystem::GetDisplayInfo()

View File

@ -1327,7 +1327,8 @@ protected:
template<GPULayerID LAYERID> void _RenderPixel_CheckWindows(const size_t srcX, bool &didPassWindowTest, bool &enableColorEffect) const; template<GPULayerID LAYERID> void _RenderPixel_CheckWindows(const size_t srcX, bool &didPassWindowTest, bool &enableColorEffect) const;
void _RenderLine_Clear(const u16 clearColor, const u16 l, void *renderLineTarget); void _RenderLine_Clear(const u16 clearColor, const u16 l, void *renderLineTarget);
void* _RenderLine_Layers(const u16 l); void _RenderLine_SetupSprites(const u16 backdropColor, const u16 lineIndex);
template<NDSColorFormat OUTPUTFORMAT> void* _RenderLine_Layers(const u16 l);
void _HandleDisplayModeOff(const size_t l); void _HandleDisplayModeOff(const size_t l);
void _HandleDisplayModeNormal(const size_t l); void _HandleDisplayModeNormal(const size_t l);
@ -1341,6 +1342,8 @@ protected:
template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void* _RenderLine_LayerBG_ApplyMosaic(void *dstColorLine, const u16 lineIndex); template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void* _RenderLine_LayerBG_ApplyMosaic(void *dstColorLine, const u16 lineIndex);
template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool ISCUSTOMRENDERINGNEEDED> void* _RenderLine_LayerBG(void *dstColorLine, const u16 lineIndex); template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool ISCUSTOMRENDERINGNEEDED> void* _RenderLine_LayerBG(void *dstColorLine, const u16 lineIndex);
template<NDSColorFormat OUTPUTFORMAT> void* _RenderLine_LayerOBJ(itemsForPriority_t *__restrict item, void *__restrict dstColorLine, const u16 lineIndex);
template<NDSColorFormat OUTPUTFORMAT, GPULayerID LAYERID, bool ISDEBUGRENDER, bool NOWINDOWSENABLEDHINT, bool COLOREFFECTDISABLEDHINT> FORCEINLINE void _RenderPixel(const size_t srcX, const u16 src, const u8 srcAlpha, void *__restrict dstColorLine, u8 *__restrict dstLayerIDLine); template<NDSColorFormat OUTPUTFORMAT, GPULayerID LAYERID, bool ISDEBUGRENDER, bool NOWINDOWSENABLEDHINT, bool COLOREFFECTDISABLEDHINT> FORCEINLINE void _RenderPixel(const size_t srcX, const u16 src, const u8 srcAlpha, void *__restrict dstColorLine, u8 *__restrict dstLayerIDLine);
FORCEINLINE void _RenderPixel3D(const FragmentColor src, u16 &dstColor, u8 &dstLayerID, bool enableColorEffect); FORCEINLINE void _RenderPixel3D(const FragmentColor src, u16 &dstColor, u8 &dstLayerID, bool enableColorEffect);
template<NDSColorFormat OUTPUTFORMAT> FORCEINLINE void _RenderPixel3D(const FragmentColor src, FragmentColor &dstColor, u8 &dstLayerID, bool enableColorEffect); template<NDSColorFormat OUTPUTFORMAT> FORCEINLINE void _RenderPixel3D(const FragmentColor src, FragmentColor &dstColor, u8 &dstLayerID, bool enableColorEffect);
@ -1408,9 +1411,6 @@ public:
void UpdatePropertiesWithoutRender(const u16 l); void UpdatePropertiesWithoutRender(const u16 l);
void FramebufferPostprocess(); void FramebufferPostprocess();
bool isCustomRenderingNeeded;
u8 vramBGLayer;
u8 vramBlockBGIndex;
u8 vramBlockOBJIndex; u8 vramBlockOBJIndex;
size_t nativeLineRenderCount; size_t nativeLineRenderCount;
@ -1443,7 +1443,6 @@ public:
const BGLayerInfo& GetBGLayerInfoByID(const GPULayerID layerID); const BGLayerInfo& GetBGLayerInfoByID(const GPULayerID layerID);
void UpdateVRAM3DUsageProperties_BGLayer(const size_t bankIndex);
void UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex); void UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex);
void SpriteRenderDebug(const u16 lineIndex, u16 *dst); void SpriteRenderDebug(const u16 lineIndex, u16 *dst);
@ -1482,7 +1481,6 @@ protected:
template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool MOSAIC, bool NOWINDOWSENABLEDHINT, bool COLOREFFECTDISABLEDHINT, bool ISCUSTOMRENDERINGNEEDED> void _LineLarge8bpp(u16 *__restrict dstColorLine, const u16 lineIndex); template<GPULayerID LAYERID, bool ISDEBUGRENDER, bool MOSAIC, bool NOWINDOWSENABLEDHINT, bool COLOREFFECTDISABLEDHINT, bool ISCUSTOMRENDERINGNEEDED> void _LineLarge8bpp(u16 *__restrict dstColorLine, const u16 lineIndex);
void* _RenderLine_Layers(const u16 l);
template<size_t CAPTURELENGTH> void _RenderLine_DisplayCapture(const void *renderedLineSrcA, const u16 l); template<size_t CAPTURELENGTH> void _RenderLine_DisplayCapture(const void *renderedLineSrcA, const u16 l);
void _RenderLine_DispCapture_FIFOToBuffer(u16 *fifoLineBuffer); void _RenderLine_DispCapture_FIFOToBuffer(u16 *fifoLineBuffer);
@ -1526,6 +1524,8 @@ public:
virtual void Reset(); virtual void Reset();
virtual void RenderLine(const u16 l); virtual void RenderLine(const u16 l);
template<NDSColorFormat OUTPUTFORMAT> void* RenderLine_Layer3D(void *dstColorLine, const u16 lineIndex);
}; };
class GPUEngineB : public GPUEngineBase class GPUEngineB : public GPUEngineBase
@ -1534,9 +1534,6 @@ private:
GPUEngineB(); GPUEngineB();
~GPUEngineB(); ~GPUEngineB();
protected:
void* _RenderLine_Layers(const u16 l);
public: public:
static GPUEngineB* Allocate(); static GPUEngineB* Allocate();
void FinalizeAndDeallocate(); void FinalizeAndDeallocate();