mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 05:17:40 -07:00
return false if underflowed
misc cleanup
This commit is contained in:
parent
7f73dc35f9
commit
246fa18ab6
@ -403,7 +403,7 @@ public:
|
||||
static constexpr int FirstPerSlope = 1 * TimingFrac; // 1 | for each "slope" the first polygon has in this scanline increment it by 1.
|
||||
// (see DoTimingsSlopes() in GPU3D_Soft.cpp for more info)
|
||||
static constexpr int FirstNull = 1 * TimingFrac; // 1 | if the first polygon is "null" (probably wrong?)
|
||||
static constexpr int RastDelay = 4 * TimingFrac; // 4 | Min amount of cycles to begin a scanline? (minimum time it takes to init the first polygon?)
|
||||
static constexpr int FirstPolyDelay = 4 * TimingFrac; // 4 | Min amount of cycles to begin a scanline? (minimum time it takes to init the first polygon?)
|
||||
// (Amount of time before the end of the cycle a scanline must abort?)
|
||||
|
||||
// static constexpr int RasterTimingCap = 51116 * TimingFrac;
|
||||
|
@ -141,10 +141,10 @@ void SoftRenderer::SetThreaded(bool threaded, GPU& gpu) noexcept
|
||||
|
||||
bool SoftRenderer::DoTimings(s32 cycles, s32* timingcounter)
|
||||
{
|
||||
// add timings to a counter and check if underflowed.
|
||||
// add timings to a counter and return false if underflowed.
|
||||
*timingcounter += cycles;
|
||||
if (RasterTiming + *timingcounter <= ScanlineTimeout) return false;
|
||||
else return true;
|
||||
if (RasterTiming + *timingcounter <= ScanlineTimeout) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
bool SoftRenderer::CheckTimings(s32 cycles, s32* timingcounter)
|
||||
@ -158,7 +158,7 @@ u32 SoftRenderer::DoTimingsPixels(s32 pixels, s32* timingcounter)
|
||||
{
|
||||
// calculate and return the difference between the old span and the new span, while adding timings to the timings counter
|
||||
|
||||
// pixels dont count towards timings if they're the first 4 pixels in a scanline (for some reason?)
|
||||
// pixels dont count towards timings if they're the first 4 pixels in a polygon scanline (for some reason?)
|
||||
if (pixels <= NumFreePixels) return 0;
|
||||
|
||||
pixels -= NumFreePixels;
|
||||
@ -174,16 +174,19 @@ u32 SoftRenderer::DoTimingsPixels(s32 pixels, s32* timingcounter)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
bool SoftRenderer::DoTimingsSlopes(RendererPolygon* rp, s32 y, s32* timingcounter)
|
||||
bool SoftRenderer::DoTimingsFirstPoly(RendererPolygon* rp, s32 y, s32* timingcounter)
|
||||
{
|
||||
DoTimings(RastDelay, timingcounter);
|
||||
// The first polygon in each scanline has an additional timing penalty (presumably due to pipelining?)
|
||||
|
||||
// First polygon has a cost of 4 cycles
|
||||
if (!DoTimings(FirstPolyDelay, timingcounter)) return false;
|
||||
|
||||
// determine the timing impact of the first polygon's slopes.
|
||||
|
||||
Polygon* polygon = rp->PolyData;
|
||||
|
||||
if (polygon->YTop == polygon->YBottom) return false; // 0 px tall line polygons do not have slopes, and thus no timing penalty
|
||||
if (y == polygon->YTop) return false;
|
||||
if (polygon->YTop == polygon->YBottom) return true; // 0 px tall line polygons do not have slopes, and thus no timing penalty
|
||||
if (y == polygon->YTop) return true;
|
||||
|
||||
if (y >= polygon->Vertices[rp->NextVL]->FinalPosition[1] && rp->CurVL != polygon->VBottom) *timingcounter += FirstPerSlope;
|
||||
|
||||
@ -1470,16 +1473,16 @@ void SoftRenderer::RenderScanline(const GPU& gpu, s32 y, int npolys, s32* timing
|
||||
|
||||
if (y == polygon->YBottom && y != polygon->YTop)
|
||||
{
|
||||
if (!abort) abort = (first && DoTimings(FirstNull+RastDelay, timingcounter)) || DoTimings(EmptyPolyScanline, timingcounter);
|
||||
if (!abort) abort = (first && !DoTimings(FirstNull+EmptyPolyScanline, timingcounter)) || !DoTimings(EmptyPolyScanline, timingcounter);
|
||||
|
||||
first = false;
|
||||
}
|
||||
else if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop)))
|
||||
{
|
||||
//if (y == polygon->YTop) if(DoTimings(FirstPolyScanline, timingcounter)) abort = true;
|
||||
//if (y == polygon->YTop) if(!DoTimings(FirstPolyScanline, timingcounter)) abort = true;
|
||||
|
||||
if (!abort) abort = (first && DoTimingsSlopes(rp, y, timingcounter)) // incorrect. needs research; behavior is strange...
|
||||
|| DoTimings(PerPolyScanline, timingcounter)
|
||||
if (!abort) abort = (first && !DoTimingsFirstPoly(rp, y, timingcounter)) // incorrect. needs research; behavior is strange...
|
||||
|| !DoTimings(PerPolyScanline, timingcounter)
|
||||
|| (!CheckTimings(MinToStartPoly, timingcounter));
|
||||
|
||||
if (abort)
|
||||
|
@ -458,7 +458,7 @@ private:
|
||||
bool DoTimings(s32 cycles, s32* timingcounter);
|
||||
bool CheckTimings(s32 cycles, s32* timingcounter);
|
||||
u32 DoTimingsPixels(s32 pixels, s32* timingcounter);
|
||||
bool DoTimingsSlopes(RendererPolygon* rp, s32 y, s32* timingcounter);
|
||||
bool DoTimingsFirstPoly(RendererPolygon* rp, s32 y, s32* timingcounter);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user