aboutsummaryrefslogtreecommitdiff
path: root/src/GPU3D_Soft.cpp
diff options
context:
space:
mode:
authorJesse Talavera-Greenberg <jesse@jesse.tg>2023-11-29 09:23:11 -0500
committerGitHub <noreply@github.com>2023-11-29 15:23:11 +0100
commit7caddf9615875e54b725bd7df266361c46d47b6f (patch)
tree966698578db1f764715ff4ee5e8ee4c787cbeb10 /src/GPU3D_Soft.cpp
parente973236203292637eb7bd009a4cfbd6fd785181f (diff)
Clean up the 3D renderer for enhanced flexibility (#1895)
* Give `GPU2D::Unit` a virtual destructor - Undefined behavior avoided! * Add an `array2d` alias * Move various parts of `GPU2D::SoftRenderer` to `constexpr` - `SoftRenderer::MosaicTable` is now initialized at compile-time - Most of the `SoftRenderer::Color*` functions are now `constexpr` - The aforementioned functions are used with a constant value in at least one place, so they'll be at least partially computed at compile-time * Generalize `GLRenderer::PrepareCaptureFrame` - Declare it in the base `Renderer3D` class, but make it empty * Remove unneeded `virtual` specifiers * Store `Framebuffer`'s memory in `unique_ptr`s - Reduce the risk of leaks this way * Clean up how `GLCompositor` is initialized - Return it as an `std::optional` instead of a `std::unique_ptr` - Make `GLCompositor` movable - Replace `GLCompositor`'s plain arrays with `std::array` to simplify moving * Pass `GPU` to `GLCompositor`'s important functions instead of passing it to the constructor * Move `GLCompositor` to be a field within `GLRenderer` - Some methods were moved up and made `virtual` * Fix some linker errors * Set the renderer in the frontend * Remove unneeded `virtual` specifiers * Remove `RenderSettings` in favor of just exposing the relevant member variables * Update the frontend to accommodate the core changes * Add `constexpr` and `const` to places in the interpolator * Qualify references to `size_t` * Construct the `optional` directly instead of using `make_optional` - It makes the Linux build choke - I think it's because `GLCompositor`'s constructor is `private`
Diffstat (limited to 'src/GPU3D_Soft.cpp')
-rw-r--r--src/GPU3D_Soft.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp
index 809bd59..03c6265 100644
--- a/src/GPU3D_Soft.cpp
+++ b/src/GPU3D_Soft.cpp
@@ -71,14 +71,13 @@ void SoftRenderer::SetupRenderThread()
}
-SoftRenderer::SoftRenderer(melonDS::GPU& gpu) noexcept
- : Renderer3D(false), GPU(gpu)
+SoftRenderer::SoftRenderer(melonDS::GPU& gpu, bool threaded) noexcept
+ : Renderer3D(false), GPU(gpu), Threaded(threaded)
{
Sema_RenderStart = Platform::Semaphore_Create();
Sema_RenderDone = Platform::Semaphore_Create();
Sema_ScanlineCount = Platform::Semaphore_Create();
- Threaded = false;
RenderThreadRunning = false;
RenderThreadRendering = false;
RenderThread = nullptr;
@@ -104,10 +103,13 @@ void SoftRenderer::Reset()
SetupRenderThread();
}
-void SoftRenderer::SetRenderSettings(const RenderSettings& settings) noexcept
+void SoftRenderer::SetThreaded(bool threaded) noexcept
{
- Threaded = settings.Soft_Threaded;
- SetupRenderThread();
+ if (Threaded != threaded)
+ {
+ Threaded = threaded;
+ SetupRenderThread();
+ }
}
void SoftRenderer::TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha)