mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
small optimization: avoid calling InterleaveSprites() if no sprites were drawn.
This commit is contained in:
@ -1047,7 +1047,7 @@ void GPU2D::CalculateWindowMask(u32 line, u8* mask)
|
|||||||
|
|
||||||
|
|
||||||
template<u32 bgmode>
|
template<u32 bgmode>
|
||||||
void GPU2D::DrawScanlineBGMode(u32 line, u32* spritebuf, u32* dst)
|
void GPU2D::DrawScanlineBGMode(u32 line, u32 nsprites, u32* spritebuf, u32* dst)
|
||||||
{
|
{
|
||||||
for (int i = 3; i >= 0; i--)
|
for (int i = 3; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -1092,12 +1092,12 @@ void GPU2D::DrawScanlineBGMode(u32 line, u32* spritebuf, u32* dst)
|
|||||||
DrawBG_Text(line, dst, 0);
|
DrawBG_Text(line, dst, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DispCnt & 0x1000)
|
if ((DispCnt & 0x1000) && nsprites)
|
||||||
InterleaveSprites(spritebuf, 0x8000 | (i<<16), dst);
|
InterleaveSprites(spritebuf, 0x8000 | (i<<16), dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU2D::DrawScanlineBGMode6(u32 line, u32* spritebuf, u32* dst)
|
void GPU2D::DrawScanlineBGMode6(u32 line, u32 nsprites, u32* spritebuf, u32* dst)
|
||||||
{
|
{
|
||||||
if (Num)
|
if (Num)
|
||||||
{
|
{
|
||||||
@ -1122,7 +1122,7 @@ void GPU2D::DrawScanlineBGMode6(u32 line, u32* spritebuf, u32* dst)
|
|||||||
DrawBG_3D(line, dst);
|
DrawBG_3D(line, dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DispCnt & 0x1000)
|
if ((DispCnt & 0x1000) && nsprites)
|
||||||
InterleaveSprites(spritebuf, 0x8000 | (i<<16), dst);
|
InterleaveSprites(spritebuf, 0x8000 | (i<<16), dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1153,20 +1153,20 @@ void GPU2D::DrawScanline_Mode1(u32 line, u32* dst)
|
|||||||
memset(windowmask, 0xFF, 256);
|
memset(windowmask, 0xFF, 256);
|
||||||
|
|
||||||
// prerender sprites
|
// prerender sprites
|
||||||
u32 spritebuf[256];
|
u32 spritebuf[256]; u32 nsprites = 0;
|
||||||
memset(spritebuf, 0, 256*4);
|
memset(spritebuf, 0, 256*4);
|
||||||
if (DispCnt & 0x1000) DrawSprites(line, spritebuf);
|
if (DispCnt & 0x1000) nsprites = DrawSprites(line, spritebuf);
|
||||||
|
|
||||||
// TODO: what happens in mode 7? mode 6 on the sub engine?
|
// TODO: what happens in mode 7? mode 6 on the sub engine?
|
||||||
switch (DispCnt & 0x7)
|
switch (DispCnt & 0x7)
|
||||||
{
|
{
|
||||||
case 0: DrawScanlineBGMode<0>(line, spritebuf, linebuf); break;
|
case 0: DrawScanlineBGMode<0>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 1: DrawScanlineBGMode<1>(line, spritebuf, linebuf); break;
|
case 1: DrawScanlineBGMode<1>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 2: DrawScanlineBGMode<2>(line, spritebuf, linebuf); break;
|
case 2: DrawScanlineBGMode<2>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 3: DrawScanlineBGMode<3>(line, spritebuf, linebuf); break;
|
case 3: DrawScanlineBGMode<3>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 4: DrawScanlineBGMode<4>(line, spritebuf, linebuf); break;
|
case 4: DrawScanlineBGMode<4>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 5: DrawScanlineBGMode<5>(line, spritebuf, linebuf); break;
|
case 5: DrawScanlineBGMode<5>(line, nsprites, spritebuf, linebuf); break;
|
||||||
case 6: DrawScanlineBGMode6(line, spritebuf, linebuf); break;
|
case 6: DrawScanlineBGMode6(line, nsprites, spritebuf, linebuf); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// color special effects
|
// color special effects
|
||||||
@ -1930,7 +1930,7 @@ void GPU2D::InterleaveSprites(u32* buf, u32 prio, u32* dst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU2D::DrawSprites(u32 line, u32* dst)
|
u32 GPU2D::DrawSprites(u32 line, u32* dst)
|
||||||
{
|
{
|
||||||
u16* oam = (u16*)&GPU::OAM[Num ? 0x400 : 0];
|
u16* oam = (u16*)&GPU::OAM[Num ? 0x400 : 0];
|
||||||
|
|
||||||
@ -1949,6 +1949,8 @@ void GPU2D::DrawSprites(u32 line, u32* dst)
|
|||||||
64, 32, 64, 0
|
64, 32, 64, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
u32 nsprites = 0;
|
||||||
|
|
||||||
for (int bgnum = 0x0C00; bgnum >= 0x0000; bgnum -= 0x0400)
|
for (int bgnum = 0x0C00; bgnum >= 0x0000; bgnum -= 0x0400)
|
||||||
{
|
{
|
||||||
for (int sprnum = 127; sprnum >= 0; sprnum--)
|
for (int sprnum = 127; sprnum >= 0; sprnum--)
|
||||||
@ -1987,6 +1989,7 @@ void GPU2D::DrawSprites(u32 line, u32* dst)
|
|||||||
u32 rotparamgroup = (attrib[1] >> 9) & 0x1F;
|
u32 rotparamgroup = (attrib[1] >> 9) & 0x1F;
|
||||||
|
|
||||||
DrawSprite_Rotscale<false>(attrib, &oam[(rotparamgroup*16) + 3], boundwidth, boundheight, width, height, xpos, ypos, dst);
|
DrawSprite_Rotscale<false>(attrib, &oam[(rotparamgroup*16) + 3], boundwidth, boundheight, width, height, xpos, ypos, dst);
|
||||||
|
nsprites++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2011,9 +2014,12 @@ void GPU2D::DrawSprites(u32 line, u32* dst)
|
|||||||
ypos = height-1 - ypos;
|
ypos = height-1 - ypos;
|
||||||
|
|
||||||
DrawSprite_Normal<false>(attrib, width, xpos, ypos, dst);
|
DrawSprite_Normal<false>(attrib, width, xpos, ypos, dst);
|
||||||
|
nsprites++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nsprites;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU2D::DrawSpritesWindow(u32 line, u8* dst)
|
void GPU2D::DrawSpritesWindow(u32 line, u8* dst)
|
||||||
|
@ -114,8 +114,8 @@ private:
|
|||||||
u32 BGExtPalStatus[4];
|
u32 BGExtPalStatus[4];
|
||||||
u32 OBJExtPalStatus;
|
u32 OBJExtPalStatus;
|
||||||
|
|
||||||
template<u32 bgmode> void DrawScanlineBGMode(u32 line, u32* spritebuf, u32* dst);
|
template<u32 bgmode> void DrawScanlineBGMode(u32 line, u32 nsprites, u32* spritebuf, u32* dst);
|
||||||
void DrawScanlineBGMode6(u32 line, u32* spritebuf, u32* dst);
|
void DrawScanlineBGMode6(u32 line, u32 nsprites, u32* spritebuf, u32* dst);
|
||||||
void DrawScanline_Mode1(u32 line, u32* dst);
|
void DrawScanline_Mode1(u32 line, u32* dst);
|
||||||
|
|
||||||
void DrawPixel(u32* dst, u16 color, u32 flag);
|
void DrawPixel(u32* dst, u16 color, u32 flag);
|
||||||
@ -127,7 +127,7 @@ private:
|
|||||||
void DrawBG_Large(u32 line, u32* dst);
|
void DrawBG_Large(u32 line, u32* dst);
|
||||||
|
|
||||||
void InterleaveSprites(u32* buf, u32 prio, u32* dst);
|
void InterleaveSprites(u32* buf, u32 prio, u32* dst);
|
||||||
void DrawSprites(u32 line, u32* dst);
|
u32 DrawSprites(u32 line, u32* dst);
|
||||||
void DrawSpritesWindow(u32 line, u8* dst);
|
void DrawSpritesWindow(u32 line, u8* dst);
|
||||||
template<bool window> void DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos, u32* dst);
|
template<bool window> void DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos, u32* dst);
|
||||||
template<bool window> void DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* dst);
|
template<bool window> void DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* dst);
|
||||||
|
Reference in New Issue
Block a user