mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 05:17:40 -07:00
small optimization
This commit is contained in:
parent
39a569bd35
commit
520f7a0f3a
@ -174,7 +174,7 @@ u32 SoftRenderer::DoTimingsPixels(s32 pixels, s32* timingcounter)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
void SoftRenderer::FindFirstPolyDoTimings(int npolys, s32 y, s32* timingcountereven, s32*timingcounterodd)
|
||||
void SoftRenderer::FindFirstPolyDoTimings(int npolys, s32 y, int* firstpolyeven, int* firstpolyodd, s32* timingcountereven, s32*timingcounterodd)
|
||||
{
|
||||
// TODO: actually figure this out
|
||||
|
||||
@ -184,9 +184,9 @@ void SoftRenderer::FindFirstPolyDoTimings(int npolys, s32 y, s32* timingcountere
|
||||
bool perslope = false;
|
||||
bool etc = false;
|
||||
|
||||
for (int i = 0; i < npolys; i++)
|
||||
for (*firstpolyeven = 0; *firstpolyeven < npolys; (*firstpolyeven)++)
|
||||
{
|
||||
RendererPolygon* rp = &PolygonList[i];
|
||||
RendererPolygon* rp = &PolygonList[*firstpolyeven];
|
||||
Polygon* polygon = rp->PolyData;
|
||||
|
||||
if (y >= polygon->YTop && y <= polygon->YBottom)
|
||||
@ -206,9 +206,9 @@ void SoftRenderer::FindFirstPolyDoTimings(int npolys, s32 y, s32* timingcountere
|
||||
}
|
||||
|
||||
y++;
|
||||
for (int i = 0; i < npolys; i++)
|
||||
for (*firstpolyodd = 0; *firstpolyodd < npolys; (*firstpolyodd)++)
|
||||
{
|
||||
RendererPolygon* rp = &PolygonList[i];
|
||||
RendererPolygon* rp = &PolygonList[*firstpolyodd];
|
||||
Polygon* polygon = rp->PolyData;
|
||||
|
||||
if (y >= polygon->YTop && y <= polygon->YBottom)
|
||||
@ -1518,12 +1518,12 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
||||
}
|
||||
|
||||
template <bool accuracy>
|
||||
void SoftRenderer::RenderScanline(const GPU& gpu, s32 y, int npolys, s32* timingcounter)
|
||||
void SoftRenderer::RenderScanline(const GPU& gpu, s32 y, int firstpoly, int npolys, s32* timingcounter)
|
||||
{
|
||||
bool abort = false;
|
||||
for (int i = 0; i < npolys; i++)
|
||||
for (; firstpoly < npolys; firstpoly++)
|
||||
{
|
||||
RendererPolygon* rp = &PolygonList[i];
|
||||
RendererPolygon* rp = &PolygonList[firstpoly];
|
||||
Polygon* polygon = rp->PolyData;
|
||||
|
||||
if (accuracy && y == polygon->YBottom && y != polygon->YTop)
|
||||
@ -1950,9 +1950,9 @@ void SoftRenderer::FinishPushScanline(s32 y, s32 pixelsremain)
|
||||
/* update sl timeout */\
|
||||
ScanlineTimeout = SLRead[y-1] - FinalPassLen;\
|
||||
\
|
||||
FindFirstPolyDoTimings(j, y, &rastertimingeven, &rastertimingodd);\
|
||||
RenderScanline<true>(gpu, y, j, &rastertimingeven);\
|
||||
RenderScanline<true>(gpu, y+1, j, &rastertimingodd);\
|
||||
FindFirstPolyDoTimings(j, y, &firstpolyeven, &firstpolyodd, &rastertimingeven, &rastertimingodd);\
|
||||
RenderScanline<true>(gpu, y, firstpolyeven, j, &rastertimingeven);\
|
||||
RenderScanline<true>(gpu, y+1, firstpolyodd, j, &rastertimingodd);\
|
||||
\
|
||||
prevtimespent = timespent;\
|
||||
RasterTiming += timespent = std::max(std::initializer_list<s32> {rastertimingeven, rastertimingodd, FinalPassLen});\
|
||||
@ -1969,12 +1969,13 @@ void SoftRenderer::RenderPolygonsFast(GPU& gpu, Polygon** polygons, int npolys)
|
||||
if (polygons[i]->Degenerate) continue;
|
||||
SetupPolygon(&PolygonList[j++], polygons[i]);
|
||||
}
|
||||
|
||||
int dummy;
|
||||
RenderScanline<false>(gpu, 0, j, &dummy);
|
||||
RenderScanline<false>(gpu, 0, 0, j, &dummy);
|
||||
|
||||
for (s32 y = 1; y < 192; y++)
|
||||
{
|
||||
RenderScanline<false>(gpu, y, j, &dummy);
|
||||
RenderScanline<false>(gpu, y, 0, j, &dummy);
|
||||
ScanlineFinalPass<true>(gpu.GPU3D, y-1, true, true);
|
||||
}
|
||||
|
||||
@ -1998,11 +1999,12 @@ void SoftRenderer::RenderPolygonsTiming(GPU& gpu, Polygon** polygons, int npolys
|
||||
s32 scanlineswaiting = 0, slwaitingrd = 0;
|
||||
s32 nextread = 0, nextreadrd = 0;
|
||||
u32 timespent, prevtimespent;
|
||||
int firstpolyeven, firstpolyodd;
|
||||
|
||||
FindFirstPolyDoTimings(j, 0, &rastertimingeven, &rastertimingodd);
|
||||
FindFirstPolyDoTimings(j, 0, &firstpolyeven, &firstpolyodd, &rastertimingeven, &rastertimingodd);
|
||||
// scanlines are rendered in pairs of two
|
||||
RenderScanline<true>(gpu, 0, j, &rastertimingeven);
|
||||
RenderScanline<true>(gpu, 1, j, &rastertimingodd);
|
||||
RenderScanline<true>(gpu, 0, firstpolyeven, j, &rastertimingeven);
|
||||
RenderScanline<true>(gpu, 1, firstpolyodd, j, &rastertimingodd);
|
||||
|
||||
// it can't proceed to the next scanline unless all others steps are done (both scanlines in the pair, and final pass)
|
||||
RasterTiming = timespent = std::max(std::initializer_list<s32> {rastertimingeven, rastertimingodd, FinalPassLen});
|
||||
|
@ -458,7 +458,7 @@ private:
|
||||
bool DoTimings(s32 cycles, s32* timingcounter);
|
||||
bool CheckTimings(s32 cycles, s32* timingcounter);
|
||||
u32 DoTimingsPixels(s32 pixels, s32* timingcounter);
|
||||
void FindFirstPolyDoTimings(int npolys, s32 y, s32* timingcountereven, s32*timingcounterodd);
|
||||
void FindFirstPolyDoTimings(int npolys, s32 y, int* firstpolyeven, int* firstpolyodd, s32* timingcountereven, s32*timingcounterodd);
|
||||
void TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const;
|
||||
u32 RenderPixel(const GPU& gpu, const Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t) const;
|
||||
void PlotTranslucentPixel(const GPU3D& gpu3d, u32 pixeladdr, u32 color, u32 z, u32 polyattr, u32 shadow);
|
||||
@ -469,7 +469,7 @@ private:
|
||||
void CheckSlope(RendererPolygon* rp, s32 y);
|
||||
template <bool accuracy> bool RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* rp, s32 y, s32* timingcounter);
|
||||
template <bool accuracy> bool RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s32 y, s32* timingcounter);
|
||||
template <bool accuracy> void RenderScanline(const GPU& gpu, s32 y, int npolys, s32* timingcounter);
|
||||
template <bool accuracy> void RenderScanline(const GPU& gpu, s32 y, int firstpoly, int npolys, s32* timingcounter);
|
||||
u32 CalculateFogDensity(const GPU3D& gpu3d, u32 pixeladdr) const;
|
||||
bool CheckEdgeMarkingPixel(u32 polyid, u32 z, u32 pixeladdr);
|
||||
bool CheckEdgeMarkingClearPlane(const GPU3D& gpu3d, u32 polyid, u32 z);
|
||||
|
Loading…
Reference in New Issue
Block a user