mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
fix build but also sw renderer crashes now
This commit is contained in:
parent
4c2e03af53
commit
8cc42490de
@ -366,7 +366,7 @@ public:
|
|||||||
// GPU 3D rasterization timing III, for first polygon exclusive timing characteristics
|
// GPU 3D rasterization timing III, for first polygon exclusive timing characteristics
|
||||||
// should be done first, as these are "async" pre-calcs of polygon attributes
|
// should be done first, as these are "async" pre-calcs of polygon attributes
|
||||||
|
|
||||||
static constexpr int FirstVSlope = 0 * TimingFrac; // 1 | the first polygon in a scanline having two vertical slopes adds 1 to timings...?
|
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 FirstNull = 1 * TimingFrac; // 1 | if the first polygon is "null" (probably wrong?)
|
||||||
|
|
||||||
// static constexpr int RasterTimingCap = 51116 * TimingFrac;
|
// static constexpr int RasterTimingCap = 51116 * TimingFrac;
|
||||||
|
@ -114,7 +114,7 @@ void SoftRenderer::SetThreaded(bool threaded, GPU& gpu) noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftRenderer::DoTimings(s32 cycles, bool odd)
|
bool SoftRenderer::DoTimings(GPU3D& gpu3d, s32 cycles, bool odd)
|
||||||
{
|
{
|
||||||
// add timings to a counter and check if underflowed.
|
// add timings to a counter and check if underflowed.
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ bool SoftRenderer::DoTimings(s32 cycles, bool odd)
|
|||||||
*counter += cycles;
|
*counter += cycles;
|
||||||
if (RasterTiming - *counter > 0) return false;
|
if (RasterTiming - *counter > 0) return false;
|
||||||
|
|
||||||
GPU.GPU3D.DispCnt |= (1<<12);
|
gpu3d.DispCnt |= (1<<12);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ bool SoftRenderer::CheckTimings(s32 cycles, bool odd)
|
|||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 SoftRenderer::DoTimingsPixels(s32 pixels, bool odd)
|
u32 SoftRenderer::DoTimingsPixels(GPU3D& gpu3d, s32 pixels, bool odd)
|
||||||
{
|
{
|
||||||
// calculate and return the difference between the old span and the new span, while adding timings to the timings counter
|
// calculate and return the difference between the old span and the new span, while adding timings to the timings counter
|
||||||
|
|
||||||
@ -170,31 +170,31 @@ u32 SoftRenderer::DoTimingsPixels(s32 pixels, bool odd)
|
|||||||
|
|
||||||
if (pixels <= 0) return 0;
|
if (pixels <= 0) return 0;
|
||||||
|
|
||||||
GPU.GPU3D.DispCnt |= (1<<12);
|
gpu3d.DispCnt |= (1<<12);
|
||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftRenderer::DoTimingsSlopes(RendererPolygon* rp, s32 y, bool odd)
|
bool SoftRenderer::DoTimingsSlopes(GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd)
|
||||||
{
|
{
|
||||||
// determine the timing impact of the first polygon's slopes.
|
// determine the timing impact of the first polygon's slopes.
|
||||||
|
|
||||||
Polygon* polygon = rp->PolyData;
|
Polygon* polygon = rp->PolyData;
|
||||||
|
|
||||||
if (polygon->YTop == polygon->YBottom) return false;
|
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 (y == polygon->YTop) return false;
|
||||||
|
|
||||||
s32* counter;
|
s32* counter;
|
||||||
if (odd) counter = &RasterTimingOdd;
|
if (odd) counter = &RasterTimingOdd;
|
||||||
else counter = &RasterTimingEven;
|
else counter = &RasterTimingEven;
|
||||||
|
|
||||||
if (y >= polygon->Vertices[rp->NextVL]->FinalPosition[1] && rp->CurVL != polygon->VBottom) *counter += 1;
|
if (y >= polygon->Vertices[rp->NextVL]->FinalPosition[1] && rp->CurVL != polygon->VBottom) *counter += FirstPerSlope;
|
||||||
|
|
||||||
if (y >= polygon->Vertices[rp->NextVR]->FinalPosition[1] && rp->CurVR != polygon->VBottom) *counter += 1;
|
if (y >= polygon->Vertices[rp->NextVR]->FinalPosition[1] && rp->CurVR != polygon->VBottom) *counter += FirstPerSlope;
|
||||||
|
|
||||||
return DoTimings(2, odd); // CHECKME: does this need to be done time its incremented here?
|
return DoTimings(gpu3d, FirstPerSlope*2, odd); // CHECKME: does this need to be done every time its incremented here? does this even need to be done *at all?*
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftRenderer::TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha)
|
void SoftRenderer::TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const
|
||||||
{
|
{
|
||||||
u32 vramaddr = (texparam & 0xFFFF) << 3;
|
u32 vramaddr = (texparam & 0xFFFF) << 3;
|
||||||
|
|
||||||
@ -778,7 +778,7 @@ void SoftRenderer::CheckSlope(RendererPolygon* rp, s32 y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd)
|
bool SoftRenderer::RenderShadowMaskScanline(GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd)
|
||||||
{
|
{
|
||||||
Polygon* polygon = rp->PolyData;
|
Polygon* polygon = rp->PolyData;
|
||||||
|
|
||||||
@ -913,7 +913,7 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon*
|
|||||||
|
|
||||||
// determine if the span can be rendered within the time allotted to the scanline
|
// determine if the span can be rendered within the time allotted to the scanline
|
||||||
// TODO: verify the timing characteristics of shadow masks are the same as regular polygons.
|
// TODO: verify the timing characteristics of shadow masks are the same as regular polygons.
|
||||||
s32 diff = DoTimingsPixels(xend-x, odd);
|
s32 diff = DoTimingsPixels(gpu3d, xend-x, odd);
|
||||||
if (diff != 0)
|
if (diff != 0)
|
||||||
{
|
{
|
||||||
xend -= diff;
|
xend -= diff;
|
||||||
@ -1006,7 +1006,7 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon*
|
|||||||
return abortscanline;
|
return abortscanline;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s32 y, bool odd)
|
bool SoftRenderer::RenderPolygonScanline(GPU& gpu, RendererPolygon* rp, s32 y, bool odd)
|
||||||
{
|
{
|
||||||
Polygon* polygon = rp->PolyData;
|
Polygon* polygon = rp->PolyData;
|
||||||
u32 polyattr = (polygon->Attr & 0x3F008000);
|
u32 polyattr = (polygon->Attr & 0x3F008000);
|
||||||
@ -1163,7 +1163,7 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
|||||||
if (xend > 256) xend = 256;
|
if (xend > 256) xend = 256;
|
||||||
|
|
||||||
// determine if the span can be rendered within the time allotted to the scanline
|
// determine if the span can be rendered within the time allotted to the scanline
|
||||||
s32 diff = DoTimingsPixels(xend-x, odd);
|
s32 diff = DoTimingsPixels(gpu.GPU3D, xend-x, odd);
|
||||||
if (diff != 0)
|
if (diff != 0)
|
||||||
{
|
{
|
||||||
xend -= diff;
|
xend -= diff;
|
||||||
@ -1460,7 +1460,7 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
|||||||
return abortscanline;
|
return abortscanline;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftRenderer::RenderScanline(const GPU& gpu, s32 y, int npolys, bool odd)
|
bool SoftRenderer::RenderScanline(GPU& gpu, s32 y, int npolys, bool odd)
|
||||||
{
|
{
|
||||||
bool abort = false;
|
bool abort = false;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@ -1471,16 +1471,16 @@ bool SoftRenderer::RenderScanline(const GPU& gpu, s32 y, int npolys, bool odd)
|
|||||||
|
|
||||||
if (y == polygon->YBottom && y != polygon->YTop)
|
if (y == polygon->YBottom && y != polygon->YTop)
|
||||||
{
|
{
|
||||||
if (!abort) abort = (first && DoTimings(FirstNull, odd)) || DoTimings(EmptyPolyScanline, odd);
|
if (!abort) abort = (first && DoTimings(gpu.GPU3D, FirstNull, odd)) || DoTimings(gpu.GPU3D, EmptyPolyScanline, odd);
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
else if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop)))
|
else if (y >= polygon->YTop && (y < polygon->YBottom || (y == polygon->YTop && polygon->YBottom == polygon->YTop)))
|
||||||
{
|
{
|
||||||
//if (y == polygon->YTop) if(DoTimings(FirstPolyScanline, odd)) abort = true;
|
//if (y == polygon->YTop) if(DoTimings(gpu.GPU3D, FirstPolyScanline, odd)) abort = true;
|
||||||
|
|
||||||
if (!abort) abort = (first && DoTimingsSlopes(rp, y, odd)) // incorrect. needs research; behavior is strange...
|
if (!abort) abort = (first && DoTimingsSlopes(gpu.GPU3D, rp, y, odd)) // incorrect. needs research; behavior is strange...
|
||||||
|| DoTimings(PerPolyScanline, odd)
|
|| DoTimings(gpu.GPU3D, PerPolyScanline, odd)
|
||||||
|| (!CheckTimings(MinToStartPoly, odd));
|
|| (!CheckTimings(MinToStartPoly, odd));
|
||||||
|
|
||||||
if (abort)
|
if (abort)
|
||||||
@ -1784,7 +1784,7 @@ void SoftRenderer::ClearBuffers(const GPU& gpu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoftRenderer::RenderPolygons(const GPU& gpu, bool threaded, Polygon** polygons, int npolys)
|
void SoftRenderer::RenderPolygons(GPU& gpu, bool threaded, Polygon** polygons, int npolys)
|
||||||
{
|
{
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < npolys; i++)
|
for (int i = 0; i < npolys; i++)
|
||||||
@ -1799,7 +1799,7 @@ void SoftRenderer::RenderPolygons(const GPU& gpu, bool threaded, Polygon** polyg
|
|||||||
s8 buffersize = 0;
|
s8 buffersize = 0;
|
||||||
RasterTiming = InitialTiming;
|
RasterTiming = InitialTiming;
|
||||||
bool abort = false;
|
bool abort = false;
|
||||||
ClearBuffers();
|
ClearBuffers(gpu);
|
||||||
s32 gpu2dtracking = InitGPU2DTimeout;
|
s32 gpu2dtracking = InitGPU2DTimeout;
|
||||||
s32 gpu2dfreetime = InitGPU2DTimeout;
|
s32 gpu2dfreetime = InitGPU2DTimeout;
|
||||||
s32 prev2dtime;
|
s32 prev2dtime;
|
||||||
@ -1867,7 +1867,7 @@ void SoftRenderer::RenderPolygons(const GPU& gpu, bool threaded, Polygon** polyg
|
|||||||
|
|
||||||
// seems to display the lowest scanline buffer count reached during the current frame.
|
// seems to display the lowest scanline buffer count reached during the current frame.
|
||||||
// we also caps it to 46 here, because this reg does that too for some reason.
|
// we also caps it to 46 here, because this reg does that too for some reason.
|
||||||
if (GPU.GPU3D.RDLines > buffersize) GPU.GPU3D.RDLines = buffersize;
|
if (gpu.GPU3D.RDLines > buffersize) gpu.GPU3D.RDLines = buffersize;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (s32 y = 1; y < 192; y++)
|
for (s32 y = 1; y < 192; y++)
|
||||||
|
@ -453,10 +453,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
RendererPolygon PolygonList[2048];
|
RendererPolygon PolygonList[2048];
|
||||||
bool DoTimings(s32 cycles, bool odd);
|
bool DoTimings(GPU3D& gpu3d, s32 cycles, bool odd);
|
||||||
bool CheckTimings(s32 cycles, bool odd);
|
bool CheckTimings(s32 cycles, bool odd);
|
||||||
u32 DoTimingsPixels(s32 pixels, bool odd);
|
u32 DoTimingsPixels(GPU3D& gpu3d, s32 pixels, bool odd);
|
||||||
bool DoTimingsSlopes(RendererPolygon* rp, s32 y, bool odd);
|
bool DoTimingsSlopes(GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd);
|
||||||
void TextureLookup(const GPU& gpu, u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha) const;
|
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;
|
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);
|
void PlotTranslucentPixel(const GPU3D& gpu3d, u32 pixeladdr, u32 color, u32 z, u32 polyattr, u32 shadow);
|
||||||
@ -465,13 +465,13 @@ private:
|
|||||||
void SetupPolygon(RendererPolygon* rp, Polygon* polygon) const;
|
void SetupPolygon(RendererPolygon* rp, Polygon* polygon) const;
|
||||||
void Step(RendererPolygon* rp);
|
void Step(RendererPolygon* rp);
|
||||||
void CheckSlope(RendererPolygon* rp, s32 y);
|
void CheckSlope(RendererPolygon* rp, s32 y);
|
||||||
bool RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd);
|
bool RenderShadowMaskScanline(GPU3D& gpu3d, RendererPolygon* rp, s32 y, bool odd);
|
||||||
bool RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s32 y, bool odd);
|
bool RenderPolygonScanline(GPU& gpu, RendererPolygon* rp, s32 y, bool odd);
|
||||||
bool RenderScanline(const GPU& gpu, s32 y, int npolys, bool odd);
|
bool RenderScanline(GPU& gpu, s32 y, int npolys, bool odd);
|
||||||
u32 CalculateFogDensity(const GPU3D& gpu3d, u32 pixeladdr) const;
|
u32 CalculateFogDensity(const GPU3D& gpu3d, u32 pixeladdr) const;
|
||||||
void ScanlineFinalPass(const GPU3D& gpu3d, s32 y, u8 rdbufferoffset, bool odd, s32 uhohzone);
|
void ScanlineFinalPass(const GPU3D& gpu3d, s32 y, u8 rdbufferoffset, bool odd, s32 uhohzone);
|
||||||
void ClearBuffers((const GPU& gpu);
|
void ClearBuffers(const GPU& gpu);
|
||||||
void RenderPolygons(const GPU& gpu, bool threaded, Polygon** polygons, int npolys);
|
void RenderPolygons(GPU& gpu, bool threaded, Polygon** polygons, int npolys);
|
||||||
|
|
||||||
void RenderThreadFunc(GPU& gpu);
|
void RenderThreadFunc(GPU& gpu);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user