Commit Graph

63 Commits

Author SHA1 Message Date
d1eff4acf5 update copyright headers (about time) 2025-05-27 00:31:37 +02:00
8fc403cdad update copyright headers 2024-06-15 17:01:19 +02:00
8e9b88d01d Actually generate DownscaleFramebuffer (#2059) 2024-06-08 20:48:42 +02:00
043244a56d Compute shader renderer (#2041)
* nothing works yet

* don't double buffer 3D framebuffers for the GL Renderer
looks like leftovers from when 3D+2D composition was done in the frontend

* oops

* it works!

* implement display capture for compute renderer
it's actually just all stolen from the regular OpenGL renderer

* fix bad indirect call

* handle cleanup properly

* add hires rendering to the compute shader renderer

* fix UB
also misc changes to use more unsigned multiplication
also fix framebuffer resize

* correct edge filling behaviour when AA is disabled

* fix full color textures

* fix edge marking (polygon id is 6-bit not 5)
also make the code a bit nicer

* take all edge cases into account for XMin/XMax calculation

* use hires coordinate again

* stop using fixed size buffers based on scale factor in shaders
this makes shader compile times tolerable on Wintel
- beginning of the shader cache
- increase size of tile idx in workdesc to 20 bits

* apparently & is not defined on bvec4
why does this even compile on Intel and Nvidia?

* put the texture cache into it's own file

* add compute shader renderer properly to the GUI
also add option to toggle using high resolution vertex coordinates

* unbind sampler object in compute shader renderer

* fix GetRangedBitMask for 64 bit aligned 64 bits
pretty embarassing

* convert NonStupidBitfield.h back to LF only new lines

* actually adapt to latest changes

* fix stupid merge

* actually make compute shader renderer work with newest changes

* show progress on shader compilation

* remove merge leftover
2024-05-13 17:17:39 +02:00
a4b2b0c40d Resolve or silence some warnings (#1905)
* Resolve some warnings

- Their frequent appearance in the build logs is driving me nuts

* Silence warnings about `offsetof`

* Don't apply `-Wno-invalid-offset` to C, only to C++
2023-12-28 14:54:31 +01:00
c867a7f1c0 Make the initial 3D renderer configurable via NDSArgs (#1913)
* Allow 3D renderers to be created without passing `GPU` to the constructor

* Make the initial 3D renderer configurable via `NDSArgs`

* Fix a compiler error
2023-12-15 14:53:31 +01:00
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
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
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
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
ac38faef14 update copyright years 2023-11-04 00:21:46 +01:00
db963aa002 Make the NDS teardown more robust (#1798)
* Make cleanup a little more robust to mitigate undefined behavior

- Add some null checks before cleaning up the GPU3D renderer
- Make sure that all deleted objects are null
- Move cleanup logic out of an assert call
- Note that deleting a null pointer is a no-op, so there's no need to check for null beforehand
- Use RAII for GLCompositor instead of Init/DeInit methods

* Replace a DeInit call that I missed

* Make ARMJIT_Memory less likely to generate errors

- Set FastMem7/9Start to nullptr at the end
- Only close and unmap the file if it's initialized

* Make Renderer3D manage its resources with RAII

* Don't try to deallocate frontend resources that aren't loaded

* Make ARMJIT_Memory::DeInit more robust on the Switch

* Reset MemoryFile on Windows to INVALID_HANDLE_VALUE, not nullptr

- There is a difference

* Don't explicitly store a Valid state in GLCompositor or the 3D renderers

- Instead, create them with static methods while making the actual constructors private

* Make initialization of OpenGL resources fail if OpenGL isn't loaded

* assert that OpenGL is loaded instead of returning failure
2023-09-15 15:31:05 +02:00
35cc79787d update copyright headers 2022-01-09 02:15:50 +01:00
19ddaee13b finally decouple Config from the core. baahhahahahah 2021-11-18 01:17:51 +01:00
2ff065e5ea Fix some compiler warnings 2021-05-03 13:40:44 +01:00
436b3c4c1d update copyright year and add missing GPL headers 2021-03-12 20:07:40 +01:00
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
a3f4aaf503 call glFlush only once
that seems to atleast get rid of the flicker
the weird issue that clears don't work is still there
2021-01-29 12:38:31 +01:00
43348210f9 Fix some compiler warnings 2021-01-25 14:12:13 +00:00
8a3a8b7c68 include polygon attr opaqueness for translucent polygons in render key 2021-01-22 12:19:51 +01:00
8a068c2294 GL: ensure to set depthmask to TRUE before rendering opaque shit 2021-01-21 21:10:43 +01:00
53d5def919 pad ShaderConfig to a multiple of 16 2021-01-17 17:15:03 +01:00
7d448d911d use C++ style structs everywhere 2021-01-02 11:38:06 +01:00
aac843c7de GL: don't break rendering order when translucent polygons contain opaque pixels.
fixes #831

(also disable edgemarking for now. it sucked anyway)
2020-12-11 04:38:11 +01:00
a47a3fa692 GL: align uniform-buffer size to 16-byte boundary. atleast makes RenderDoc happy. 2020-12-11 03:29:37 +01:00
50cdfd0137 fix edge indices count 2020-11-19 17:46:21 +01:00
21dbca9543 use proper index buffers 2020-11-16 15:58:23 +01:00
e7025abcdc * fix build error
* make betterer polygon splitting an option
* add GL_LEQUAL depth test for 'equal' mode, might help
2020-08-24 19:32:07 +02:00
c29e630314 oops.
fixes #725
2020-08-24 12:00:13 +02:00
b5f9278b3a GL: hopefully finally fix the checkerboard issue 2020-08-20 03:01:05 +02:00
0688a15e47 blarg 2020-08-20 01:37:33 +02:00
959e7f568d GL: be more careful with framebuffer mappings. might fix issues. 2020-08-20 01:19:09 +02:00
00f33343e4 3D/GL: experimental attempt at reducing warping on quads, pentagons, etc... 2020-08-19 14:53:42 +02:00
de19ce6250 3D/GL: make polygon generation code cleaner, add quicker codepath for triangles (also laying ground for some evil experiment)
also fix stupid bug with line polygons
2020-08-19 13:02:54 +02:00
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
0a68eb7803 make it hiDPI compliant (I hope)
also misc tweaks
2020-05-28 11:52:12 +02:00
e8849db78a we don't need a GLShim.
blarg.

I don't understand this anymore.
2020-05-27 21:40:02 +02:00
36f4cdbbbf get the OpenGL renderer going.
sorta.

(also make the blackmagic_II branch obsolete in the process)
2020-05-25 18:25:50 +02:00
83f8e11bc1 update copyright years 2020-02-14 20:18:08 +01:00
c064f738ea OpenGL: fix bug when rendering translucent polygons coming after shadow polygons, against a zero-alpha clear-plane (would use wrong shader, resulting in broken transparency) 2019-11-03 09:55:52 +01:00
204b5d8700 HARK HARK HARK 2019-06-25 19:29:21 +02:00
dac9ccc577 fix OGL renderer not working at all on some GPUs 2019-06-17 13:14:52 +02:00
34c60eaca4 fix bugs with line polygons 2019-06-12 13:14:11 +02:00
27f758d353 hack so that the GL renderer can render lines 2019-06-12 03:55:40 +02:00
a3fed77da3 somewhat better edge marking 2019-06-12 02:23:40 +02:00
9ab331c6dd fix more stupid shit. askzjkdsf 2019-06-09 20:44:35 +02:00
c056dfe509 fix fog alpha 2019-06-09 19:53:28 +02:00
086354a420 miserable, feeble little attempt at edge marking 2019-06-09 19:32:02 +02:00
8fc30d69c5 fix last bugs when changing video settings with no game loaded 2019-06-08 13:06:36 +02:00
06e08b053f do binding of VS inputs and FS outputs before linking shader programs, as per OpenGL standard.
should fix the rendering issues with strict drivers (AMD, Intel).
2019-05-31 02:26:13 +02:00