(finally) make the threaded 3D renderer option actually work
This commit is contained in:
parent
568b9fbf49
commit
fa2db3826e
|
@ -113,6 +113,8 @@ bool Init();
|
||||||
void DeInit();
|
void DeInit();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
void SetupRenderThread();
|
||||||
|
|
||||||
void VCount144();
|
void VCount144();
|
||||||
void RenderFrame();
|
void RenderFrame();
|
||||||
void RequestLine(int line);
|
void RequestLine(int line);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "NDS.h"
|
#include "NDS.h"
|
||||||
#include "GPU.h"
|
#include "GPU.h"
|
||||||
|
#include "Config.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +66,42 @@ void* Sema_ScanlineCount;
|
||||||
void RenderThreadFunc();
|
void RenderThreadFunc();
|
||||||
|
|
||||||
|
|
||||||
|
void StopRenderThread()
|
||||||
|
{
|
||||||
|
if (RenderThreadRunning)
|
||||||
|
{
|
||||||
|
RenderThreadRunning = false;
|
||||||
|
Platform::Semaphore_Post(Sema_RenderStart);
|
||||||
|
Platform::Thread_Wait(RenderThread);
|
||||||
|
Platform::Thread_Free(RenderThread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetupRenderThread()
|
||||||
|
{
|
||||||
|
if (Config::Threaded3D)
|
||||||
|
{
|
||||||
|
if (!RenderThreadRunning)
|
||||||
|
{
|
||||||
|
RenderThreadRunning = true;
|
||||||
|
RenderThread = Platform::Thread_Create(RenderThreadFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RenderThreadRendering)
|
||||||
|
Platform::Semaphore_Wait(Sema_RenderDone);
|
||||||
|
|
||||||
|
Platform::Semaphore_Reset(Sema_RenderStart);
|
||||||
|
Platform::Semaphore_Reset(Sema_ScanlineCount);
|
||||||
|
|
||||||
|
Platform::Semaphore_Post(Sema_RenderStart);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StopRenderThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
Sema_RenderStart = Platform::Semaphore_Create();
|
Sema_RenderStart = Platform::Semaphore_Create();
|
||||||
|
@ -79,13 +116,7 @@ bool Init()
|
||||||
|
|
||||||
void DeInit()
|
void DeInit()
|
||||||
{
|
{
|
||||||
if (RenderThreadRunning)
|
StopRenderThread();
|
||||||
{
|
|
||||||
RenderThreadRunning = false;
|
|
||||||
Platform::Semaphore_Post(Sema_RenderStart);
|
|
||||||
Platform::Thread_Wait(RenderThread);
|
|
||||||
Platform::Thread_Free(RenderThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform::Semaphore_Free(Sema_RenderStart);
|
Platform::Semaphore_Free(Sema_RenderStart);
|
||||||
Platform::Semaphore_Free(Sema_RenderDone);
|
Platform::Semaphore_Free(Sema_RenderDone);
|
||||||
|
@ -100,20 +131,7 @@ void Reset()
|
||||||
|
|
||||||
PrevIsShadowMask = false;
|
PrevIsShadowMask = false;
|
||||||
|
|
||||||
// TODO: make it configurable
|
SetupRenderThread();
|
||||||
if (!RenderThreadRunning)
|
|
||||||
{
|
|
||||||
RenderThreadRunning = true;
|
|
||||||
RenderThread = Platform::Thread_Create(RenderThreadFunc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RenderThreadRendering)
|
|
||||||
Platform::Semaphore_Wait(Sema_RenderDone);
|
|
||||||
|
|
||||||
Platform::Semaphore_Reset(Sema_RenderStart);
|
|
||||||
Platform::Semaphore_Reset(Sema_ScanlineCount);
|
|
||||||
|
|
||||||
Platform::Semaphore_Post(Sema_RenderStart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -921,7 +939,8 @@ void RenderPolygonScanline(RendererPolygon* rp, s32 y)
|
||||||
// * right edge is filled if slope > 1
|
// * right edge is filled if slope > 1
|
||||||
// * left edge is filled if slope <= 1
|
// * left edge is filled if slope <= 1
|
||||||
// * edges with slope = 0 are always filled
|
// * edges with slope = 0 are always filled
|
||||||
// edges are always filled if antialiasing is enabled or if the pixels are translucent
|
// right vertical edges are pushed 1px to the left
|
||||||
|
// edges are always filled if antialiasing/edgemarking are enabled or if the pixels are translucent
|
||||||
|
|
||||||
if (wireframe || (RenderDispCnt & (1<<5)))
|
if (wireframe || (RenderDispCnt & (1<<5)))
|
||||||
{
|
{
|
||||||
|
@ -1382,6 +1401,8 @@ void ScanlineFinalPass(s32 y)
|
||||||
{
|
{
|
||||||
// edge marking
|
// edge marking
|
||||||
|
|
||||||
|
// TODO: is it applied to bottom pixels?
|
||||||
|
|
||||||
for (int x = 0; x < 256; x++)
|
for (int x = 0; x < 256; x++)
|
||||||
{
|
{
|
||||||
u32 pixeladdr = FirstPixelOffset + (y*ScanlineWidth) + x;
|
u32 pixeladdr = FirstPixelOffset + (y*ScanlineWidth) + x;
|
||||||
|
@ -1666,16 +1687,22 @@ void RenderPolygons(bool threaded, Polygon* polygons, int npolys)
|
||||||
|
|
||||||
void VCount144()
|
void VCount144()
|
||||||
{
|
{
|
||||||
|
if (RenderThreadRunning)
|
||||||
Platform::Semaphore_Wait(Sema_RenderDone);
|
Platform::Semaphore_Wait(Sema_RenderDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderFrame()
|
void RenderFrame()
|
||||||
{
|
{
|
||||||
//ClearBuffers();
|
if (RenderThreadRunning)
|
||||||
//RenderPolygons(false, polygons, npolys);
|
{
|
||||||
|
|
||||||
Platform::Semaphore_Post(Sema_RenderStart);
|
Platform::Semaphore_Post(Sema_RenderStart);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ClearBuffers();
|
||||||
|
RenderPolygons(false, RenderPolygonRAM, RenderNumPolygons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RenderThreadFunc()
|
void RenderThreadFunc()
|
||||||
{
|
{
|
||||||
|
@ -1695,6 +1722,7 @@ void RenderThreadFunc()
|
||||||
|
|
||||||
void RequestLine(int line)
|
void RequestLine(int line)
|
||||||
{
|
{
|
||||||
|
if (RenderThreadRunning)
|
||||||
Platform::Semaphore_Wait(Sema_ScanlineCount);
|
Platform::Semaphore_Wait(Sema_ScanlineCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../Config.h"
|
#include "../Config.h"
|
||||||
#include "../NDS.h"
|
#include "../NDS.h"
|
||||||
#include "../GPU.h"
|
#include "../GPU.h"
|
||||||
|
#include "../GPU3D.h"
|
||||||
#include "../SPU.h"
|
#include "../SPU.h"
|
||||||
|
|
||||||
#include "InputConfig.h"
|
#include "InputConfig.h"
|
||||||
|
@ -283,8 +284,16 @@ void MainFrame::OnReset(wxCommandEvent& event)
|
||||||
|
|
||||||
void MainFrame::OnEmuConfig(wxCommandEvent& event)
|
void MainFrame::OnEmuConfig(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
|
bool oldpause = emuthread->EmuIsPaused();
|
||||||
|
if (!oldpause) emuthread->EmuPause();
|
||||||
|
|
||||||
EmuConfigDialog dlg(this);
|
EmuConfigDialog dlg(this);
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
|
|
||||||
|
// apply threaded 3D setting
|
||||||
|
GPU3D::SoftRenderer::SetupRenderThread();
|
||||||
|
|
||||||
|
if (!oldpause) emuthread->EmuRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainFrame::OnInputConfig(wxCommandEvent& event)
|
void MainFrame::OnInputConfig(wxCommandEvent& event)
|
||||||
|
|
Loading…
Reference in New Issue