mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
even more cleanup!
This commit is contained in:
parent
57e590269f
commit
635bfa0c29
@ -74,7 +74,6 @@ GPU::GPU(melonDS::NDS& nds, std::unique_ptr<Renderer3D>&& renderer3d, std::uniqu
|
||||
NDS.RegisterEventFunc(Event_LCD, LCD_StartScanline, MemberEventFunc(GPU, StartScanline));
|
||||
NDS.RegisterEventFunc(Event_LCD, LCD_FinishFrame, MemberEventFunc(GPU, FinishFrame));
|
||||
NDS.RegisterEventFunc(Event_DisplayFIFO, 0, MemberEventFunc(GPU, DisplayFIFO));
|
||||
NDS.RegisterEventFunc(Event_DisplayFIFO, 0, MemberEventFunc(GPU, DisplayFIFO));
|
||||
|
||||
InitFramebuffers();
|
||||
}
|
||||
@ -916,6 +915,7 @@ void GPU::StartHBlank(u32 line) noexcept
|
||||
|
||||
if (DispStat[0] & (1<<4)) NDS.SetIRQ(0, IRQ_HBlank);
|
||||
if (DispStat[1] & (1<<4)) NDS.SetIRQ(1, IRQ_HBlank);
|
||||
|
||||
if (VCount < 262)
|
||||
NDS.ScheduleEvent(Event_LCD, true, (LINE_CYCLES - HBLANK_CYCLES), LCD_StartScanline, line+1);
|
||||
else
|
||||
|
@ -821,6 +821,8 @@ void GPU3D::StallPolygonPipeline(s32 delay, s32 nonstalldelay) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<int comp, s32 plane, bool attribs>
|
||||
void ClipSegment(Vertex* outbuf, Vertex* vin, Vertex* vout)
|
||||
{
|
||||
@ -2678,7 +2680,7 @@ u16 GPU3D::Read16(u32 addr) noexcept
|
||||
return DispCnt;
|
||||
|
||||
case 0x04000320:
|
||||
return RDLines; // CHECKME: Can this always be read? Even when the gpu is powered off? also check 8 bit reads
|
||||
return RDLines;
|
||||
|
||||
case 0x04000600:
|
||||
{
|
||||
|
@ -972,7 +972,7 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon*
|
||||
}
|
||||
else abortscanline = false;
|
||||
}
|
||||
else abortscanline = true;
|
||||
// note: if accuracy mode isn't enabled the abort flag never gets set, this is fine, because it also never gets used by fast mode.
|
||||
|
||||
// for shadow masks: set stencil bits where the depth test fails.
|
||||
// draw nothing.
|
||||
@ -1053,7 +1053,7 @@ bool SoftRenderer::RenderShadowMaskScanline(const GPU3D& gpu3d, RendererPolygon*
|
||||
StencilBuffer[256*(y&0x1) + x] |= 0x2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Step(rp);
|
||||
return abortscanline;
|
||||
}
|
||||
@ -1227,7 +1227,7 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
||||
}
|
||||
else abortscanline = false;
|
||||
}
|
||||
else abortscanline = false;
|
||||
// note: if accuracy mode isn't enabled the abort flag never gets set, this is fine, because it also never gets used by fast mode.
|
||||
|
||||
// part 1: left edge
|
||||
edge = yedge | 0x1;
|
||||
@ -1238,12 +1238,11 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
||||
xcov = (l_edgecov >> 12) & 0x3FF;
|
||||
if (xcov == 0x3FF) xcov = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!l_filledge) x = xlimit;
|
||||
else for (; x < xlimit; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
u32 dstattr = AttrBuffer[pixeladdr];
|
||||
|
||||
// check stencil buffer for shadows
|
||||
@ -1337,7 +1336,7 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
||||
if (wireframe && !edge) x = std::max(x, xlimit);
|
||||
else for (; x < xlimit; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
u32 dstattr = AttrBuffer[pixeladdr];
|
||||
|
||||
// check stencil buffer for shadows
|
||||
@ -1424,11 +1423,11 @@ bool SoftRenderer::RenderPolygonScanline(const GPU& gpu, RendererPolygon* rp, s3
|
||||
xcov = (r_edgecov >> 12) & 0x3FF;
|
||||
if (xcov == 0x3FF) xcov = 0;
|
||||
}
|
||||
|
||||
|
||||
if (r_filledge)
|
||||
for (; x < xlimit; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
u32 dstattr = AttrBuffer[pixeladdr];
|
||||
|
||||
// check stencil buffer for shadows
|
||||
@ -1620,7 +1619,7 @@ void SoftRenderer::ScanlineFinalPass(const GPU3D& gpu3d, s32 y, bool checkprev,
|
||||
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
|
||||
u32 attr = AttrBuffer[pixeladdr];
|
||||
if (!(attr & 0xF)) continue;
|
||||
@ -1702,7 +1701,7 @@ void SoftRenderer::ScanlineFinalPass(const GPU3D& gpu3d, s32 y, bool checkprev,
|
||||
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
u32 density, srccolor, srcR, srcG, srcB, srcA;
|
||||
|
||||
u32 attr = AttrBuffer[pixeladdr];
|
||||
@ -1767,7 +1766,7 @@ void SoftRenderer::ScanlineFinalPass(const GPU3D& gpu3d, s32 y, bool checkprev,
|
||||
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
|
||||
u32 attr = AttrBuffer[pixeladdr];
|
||||
if (!(attr & 0xF)) continue;
|
||||
@ -1843,7 +1842,7 @@ void SoftRenderer::ClearBuffers(const GPU& gpu)
|
||||
|
||||
u32 z = ((val3 & 0x7FFF) * 0x200) + 0x1FF;
|
||||
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
ColorBuffer[pixeladdr] = color;
|
||||
DepthBuffer[pixeladdr] = z;
|
||||
AttrBuffer[pixeladdr] = polyid | (val3 & 0x8000);
|
||||
@ -1866,12 +1865,12 @@ void SoftRenderer::ClearBuffers(const GPU& gpu)
|
||||
u32 color = r | (g << 8) | (b << 16) | (a << 24);
|
||||
|
||||
polyid |= (gpu.GPU3D.RenderClearAttr1 & 0x8000);
|
||||
|
||||
|
||||
for (int y = 0; y < 192; y++)
|
||||
{
|
||||
for (int x = 0; x < 256; x++)
|
||||
{
|
||||
u32 pixeladdr = (y * ScanlineWidth) + x;
|
||||
u32 pixeladdr = (y*ScanlineWidth) + x;
|
||||
ColorBuffer[pixeladdr] = color;
|
||||
DepthBuffer[pixeladdr] = clearz;
|
||||
AttrBuffer[pixeladdr] = polyid;
|
||||
@ -1882,6 +1881,7 @@ void SoftRenderer::ClearBuffers(const GPU& gpu)
|
||||
|
||||
void SoftRenderer::RenderPolygonsFast(GPU& gpu, Polygon** polygons, int npolys)
|
||||
{
|
||||
gpu.GPU3D.RDLinesTemp = 46; // dumb way of making sure it gets updated to a "normal" value when the gpu starts rasterizing.
|
||||
int j = 0;
|
||||
for (int i = 0; i < npolys; i++)
|
||||
{
|
||||
@ -2138,7 +2138,7 @@ u32* SoftRenderer::GetLine(int line)
|
||||
// so we don't need to wait for a specific row)
|
||||
Platform::Semaphore_Wait(Sema_ScanlineCount);
|
||||
}
|
||||
return &FinalBuffer[line * ScanlineWidth];
|
||||
return &FinalBuffer[line*ScanlineWidth];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -488,16 +488,6 @@ private:
|
||||
s32 ScanlineTimeout;
|
||||
s32 RasterTiming;
|
||||
|
||||
enum
|
||||
{
|
||||
RenderStart = 0,
|
||||
ScanlineRead,
|
||||
PushScanline,
|
||||
PushScanlineP2,
|
||||
RenderFinal,
|
||||
RasterEvents_MAX,
|
||||
};
|
||||
|
||||
// buffer dimensions are 258x194 to add a offscreen 1px border
|
||||
// which simplifies edge marking tests
|
||||
// buffer is duplicated to keep track of the two topmost pixels
|
||||
@ -506,16 +496,16 @@ private:
|
||||
|
||||
static constexpr int ScanlineWidth = 256;
|
||||
static constexpr int NumScanlinesIntBuf = 192;
|
||||
static constexpr int NumScanlinesRD = 48;
|
||||
//static constexpr int NumScanlinesRD = 48;
|
||||
static constexpr int NumScanlinesFinal = 192;
|
||||
static constexpr int BufferSize = ScanlineWidth * NumScanlinesIntBuf;
|
||||
static constexpr int RDBufferSize = ScanlineWidth * NumScanlinesRD;
|
||||
//static constexpr int RDBufferSize = ScanlineWidth * NumScanlinesRD;
|
||||
static constexpr int FinalBufferSize = ScanlineWidth * NumScanlinesFinal;
|
||||
|
||||
u32 ColorBuffer[BufferSize * 2];
|
||||
u32 DepthBuffer[BufferSize * 2];
|
||||
u32 AttrBuffer[BufferSize * 2];
|
||||
u32 RDBuffer[RDBufferSize]; // is this buffer ever initialized by hw before writing to it? what is its initial value? can you transfer 3d framebuffer data between games?
|
||||
//u32 RDBuffer[RDBufferSize]; // is this buffer ever initialized by hw before writing to it? what is its initial value? can you transfer 3d framebuffer data between games?
|
||||
u32 FinalBuffer[FinalBufferSize];
|
||||
|
||||
// attribute buffer:
|
||||
|
Loading…
Reference in New Issue
Block a user