Commit Graph

49 Commits

Author SHA1 Message Date
Arisotura
8fc403cdad update copyright headers 2024-06-15 17:01:19 +02:00
Jesse Talavera
9bfc9c08ff
Sprinkle const around where appropriate (#1909)
* Sprinkle `const` around where appropriate

- This will make it easier to use `NDS` objects in `const` contexts (e.g. `const` parameters or methods)

* Remove the `const` qualifier on `DSi_DSP::DSPRead16`

- MMIO reads can be non-pure, so this may not be `const` in the future
2023-12-12 11:07:22 +01:00
Jesse Talavera-Greenberg
7caddf9615
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`
2023-11-29 15:23:11 +01:00
Jesse Talavera-Greenberg
346dd4006e
Move all core types into namespaces (#1886)
* Reorganize namespaces

- Most types are now moved into the `melonDS` namespace
- Only good chance to do this for a while, since a big refactor is next

* Fix the build
2023-11-25 18:32:09 +01:00
Jesse Talavera-Greenberg
4558be0d8e
Refactor the GPU to be object-oriented (#1873)
* Refactor GPU3D to be an object

- Who has two thumbs and is the sworn enemy of global state? This guy!

* Refactor GPU itself to be an object

- Wow, it's used in a lot of places
- Also introduce a new `Melon` namespace for a few classes
- I expect other classes will be moved into `Melon` over time

* Change signature of Renderer3D::SetRenderSettings

- Make it noexcept, and its argument const

* Remove some stray whitespace
2023-11-09 21:54:51 +01:00
Arisotura
ac38faef14 update copyright years 2023-11-04 00:21:46 +01:00
Arisotura
35cc79787d update copyright headers 2022-01-09 02:15:50 +01:00
RSDuck
436b3c4c1d update copyright year and add missing GPL headers 2021-03-12 20:07:40 +01:00
RSDuck
a046eb5038 separate GPU2D registers and renderer 2021-02-27 22:25:42 +01:00
Wunk
a7029aebae
Allow for a more modular renderer backends (#990)
* Draft GPU3D renderer modularization

* Update sources C++ standard to C++17

The top-level `CMakeLists.txt` is already using the C++17 standard.

* Move GLCompositor into class type

Some other misc fixes to push towards better modularity

* Make renderer-implementation types move-only

These types are going to be holding onto handles
of GPU-side resources and shouldn't ever be copied around.

* Fix OSX: Remove 'register' storage class specifier

`register` has been removed in C++17...
But this keyword hasn't done anything in years anyways.

OSX builds consider this "warning" an error and it
stops the whole build.

* Add RestartFrame to Renderer3D interface

* Move Accelerated property to Renderer3D interface

There are points in the code base where we do:
`renderer != 0` to know if we are feeding
an openGL renderer. Rather than that we can instead just have this be
a property of the renderer itself.
With this pattern a renderer can just say how it wants its data to come
in rather than have everyone know that they're talking to an OpenGL
renderer.

* Remove Accelerated flag from GPU

* Move 2D_Soft interface in separate header

Also make the current 2D engine an "owned" unique_ptr.

* Update alignment attribute to standard alignas

Uses standardized `alignas` rather than compiler-specific
attributes.

https://en.cppreference.com/w/cpp/language/alignas

* Fix Clang: alignas specifier

Alignment must be specified before the array to align the entire array.

https://en.cppreference.com/w/cpp/language/alignas

* Converted Renderer3D Accelerated to variable

This flag is checked a lot during scanline rasterization. So rather
than having an expensive vtable-lookup call during mainline rendering
code, it is now a public constant bool type that is written to only once
during Renderer3D initialization.
2021-02-09 23:38:51 +01:00
RSDuck
e34ce013df only start display capture on first line
fixes Spearpillar in Pokemon D/P/Pt
also fixes #782 and #474
2020-12-09 22:45:16 +01:00
RSDuck
d2cfd71c32 rename the class as well
this is getting emberassing
2020-12-07 18:45:50 +01:00
RSDuck
b80d5a04f3 lay base for multiple GPU2D backends 2020-12-06 17:40:16 +01:00
RSDuck
6e8bac3909 Merge vram dirty tracking
Squashed commit of the following:

commit b463a05d4b909372f0cd1ad91caa0c77a25e5901
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Mon Nov 30 01:55:35 2020 +0100

    minor fix

commit ce73cebbdf5da243d7ebade82d8799ded9cd6b28
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Mon Nov 30 00:43:08 2020 +0100

    fix dirty flags of BG/OBJ mappings not being reset

commit fc5d73a6178e3adc444398bdd23de8314b5ca8f8
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Mon Nov 30 00:11:13 2020 +0100

    use flat vram for gpu2d everywhere

commit 34ee9fe2bf04fcfa2a5a1c8d78d70007e606f1a2
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Sat Nov 28 19:10:34 2020 +0100

    mark VRAM dirty for display capture

commit e8778fa2f429c6df0eece19d6a5ee83ae23a0cf4
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Sat Nov 28 18:59:31 2020 +0100

    use flat VRAM for textures and texpals
    also skip rendering if nothing changed and a bunch of fixes

commit 53f2041e2e1a28b35702a2ed51de885c36689f71
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Fri Nov 27 18:29:56 2020 +0100

    use vram dirty tracking for extpals
    also preparations to take this further

commit 4cdfa329e95aed26d3b21319c8fd86a04abf20f7
Author: RSDuck <rsduck@users.noreply.github.com>
Date:   Mon Nov 16 23:32:22 2020 +0100

    VRAM dirty tracking
2020-11-30 19:49:18 +01:00
RSDuck
690eed9e26 GPU2D: don't an indirect call in tight loops 2020-11-16 18:33:58 +01:00
Arisotura
0804ab3c78 * rework GPU's settings interface, make it config-agnostic
* make video settings dialog functional, sorta
* fix dialogs that were resizable
2020-05-28 15:53:32 +02:00
Arisotura
83f8e11bc1 update copyright years 2020-02-14 20:18:08 +01:00
Arisotura
3561e93bf6 fix sprite y-flip
also, meaningless shenanigans
2019-11-03 04:32:47 +01:00
Arisotura
58c2790ea3 uuuh we should only do it once per scanline 2019-09-15 02:08:47 +02:00
Arisotura
cb90475b60 begin work on mosaic
OBJ Y mosaic emulated correctly, there's atleast that.
2019-09-15 01:31:09 +02:00
Arisotura
0010e296bd GPU2D: delay palette lookup for sprites 2019-09-05 11:42:08 +02:00
Arisotura
3c006fd361 GPU2D: fill gaps in BG modes
* mode6 actually works on the sub GPU, albeit limited to 1/4 the full bitmap size due to having only 128K of VRAM
* mode7 draws BG0, BG1 and sprites. no BG2/BG3.
2019-07-24 02:46:30 +02:00
Arisotura
d28035674a GPU2D: hardware renders sprites one scanline in advance.
fixes #375 (midframe OAM update)
2019-06-10 03:05:26 +02:00
StapleButter
ea669190aa fix crash when using -O3.
gcc will try to optimize the memfill with MMX opcodes, but those seem to crash if the memory isn't aligned to a 8-byte boundary.
2019-05-30 18:05:52 +02:00
Arisotura
70a3243714 simpler GPU-compositing. will make it easier to grab neighbor 2D/3D pixels individually for filtering. 2019-05-25 19:36:47 +02:00
Arisotura
db396e992b welp.
progress
2019-05-21 22:28:46 +02:00
Arisotura
cd8236303e begin botching the code
BAHAHAHAAAA
2019-05-19 19:37:13 +02:00
Arisotura
f1a970ec30 actually finish display capture in hardware-accel mode 2019-05-18 01:21:46 +02:00
Arisotura
c81bcccadc BAHAHAHAHAHAHAHAA 2019-05-16 16:27:45 +02:00
Arisotura
a32c5c99bb finish de-hardcoding it. also, code 4x variant (not that I guarantee it to be fast, but hey, it's here) 2019-05-12 15:58:12 +02:00
Arisotura
2a0bc4e700 make GPU2D somewhat more flexible. change LineScale to be log2. 2019-05-12 15:45:58 +02:00
Arisotura
fb4f972cad hires hax. somewhat functional 2019-05-08 01:58:34 +02:00
Arisotura
b0efde8bf7 also, update copyright name 2019-01-22 15:58:29 +01:00
StapleButter
d2701a0401 small optimization: avoid calling InterleaveSprites() if no sprites were drawn. 2019-01-06 23:16:10 +01:00
StapleButter
dd30b417b8 implement proper support for POWCNT1.
fixes #260
2018-12-18 17:04:42 +01:00
StapleButter
4b8cea3b38 revise windows to be even closer to hardware.
apparently hardware only ever updates its 'inside/outside window' status when reaching the coordinates. which becomes apparent if you, like, try to invert a window midframe.
2018-11-25 19:13:23 +01:00
StapleButter
a2cc7087f7 GPU done 2018-10-18 02:31:01 +02:00
StapleButter
fea7955675 fixor copyright years. 2018-09-15 02:32:13 +02:00
StapleButter
82e42c5be7 2D: mosaic
sprites might be mosaiced wrong, esp. rotscaled ones. blrgdfgdf
2017-07-23 18:36:00 +02:00
StapleButter
e6f5507c9e add some more GPU IO 2017-07-23 15:31:09 +02:00
StapleButter
cfb9e20fe1 * bump version number
* BLDALPHA is readable
2017-07-16 03:47:44 +02:00
StapleButter
93ab7064b2 2D: implement large BG, fix non-large bitmap BG. fixes #61 2017-07-05 19:31:13 +02:00
StapleButter
209a639461 2D: implement enough of mode6 to fix #65 -- shows 3D layer. large BG still needs to be done. 2017-06-28 17:01:20 +02:00
StapleButter
4afac28263 proper display FIFO emulation 2017-06-26 11:02:10 +02:00
StapleButter
bc70f00372 windows! 2017-04-09 03:35:32 +02:00
StapleButter
68eb4f6caf * implement missing graphics (affine BG, rotscaled bitmap sprite)
* fix potential crash upon exit
* more work on the input config UI
* misc fixes
2017-03-24 20:53:01 +01:00
StapleButter
cc86aa57ae fix that bug where NSMB's backgrounds lagged one frame behind 2017-03-21 02:11:49 +01:00
StapleButter
2150240cbd implement some obscure DMA types 2017-03-20 22:18:35 +01:00
StapleButter
8a4ed8f41c reorganize repo, move shit around 2017-03-16 23:01:22 +01:00