Commit graph

79 commits

Author SHA1 Message Date
Clownacy
6b18ec91be Replace LockSurface with UploadSurface
The old locking/unlocking API was plain inefficient. Soon I'll move
upscaling to the backend anyway, to minimise the overhead where
possible.

Currently only the software renderer has been updated.
2020-09-14 23:03:23 +01:00
Clownacy
63e4ac9aa9 Remove RenderBackend_FlushGlyphs
No longer used for anything
2020-09-14 12:25:39 +01:00
Clownacy
daa55b1a3c Allow font atlases to be non-square
Saves a little memory in some cases. It's the backend's job to decide
if this is a problem or not, and pad it if it has to.
2020-09-14 12:08:27 +01:00
Clownacy
69f3fbcd5a Change a dumb parameter 2020-09-10 17:56:22 +01:00
Clownacy
988f1128dd Convert a bunch of ints to size_t
ints are dumb - only use them when you have to
2020-09-10 17:36:21 +01:00
Clownacy
8ad56ced43 Remove superfluous brackets 2020-09-10 16:08:53 +01:00
Clownacy
f42a0530b0 Handle the framebuffer failing to lock
Also needed by SDL2
2020-09-10 16:02:02 +01:00
Clownacy
e90b903692 Change some variables to size_t
Really need to change the whole backend API to use size_t
2020-09-10 15:50:06 +01:00
Clownacy
b6c9467151 Switch software renderer to lockable framebuffer
SDL2 surfaces may require locking
2020-09-10 15:47:27 +01:00
Clownacy
1d9446d425 Update SDLSurface renderer for new font batcher 2020-09-07 23:44:51 +01:00
Clownacy
096fa3b578 New custom font batcher
Previously, the font batching system was very shoddy: basically,
glyph bitmaps would be cached to system memory, and uploaded
on-demand to the GPU.

The OpenGL3, OpenGLES2, and SDLTexture backends relied on
`cute_spritebatch.h` to handle batching. While nice, this library is
overkill: it's intended for managing a whole game, not just a couple
of glyphs. It also depends on C++11, which is something I'd rather be
without.

Being so complex, it appears that internally it spams the backend
when merging atlases together. According to bug reports, this causes
the game to skip a lot of frames.

Instead, I've ditched the system-memory-side caching, and made the
game maintain its own atlas. Unlike `cute_spritebatch.h`, this one
doesn't purge glyphs after they've gone unused for 30(?) seconds -
instead, glyphs are only purged when room in the atlas runs out, at
which point the oldest glyph is replaced. This method doesn't involve
creating or destroying atlases at runtime, avoiding the overhead of
whatever OpenGL/DirectX do internally when that happens.

Currently only the OpenGL3, OpenGLES2, and Software renderers have
been updated with this - the others will fail to build.

I know immediate-mode renderers won't benefit from this, but it
replaces the leaky old caching system, so it's still an improvement.
2020-09-07 23:11:01 +01:00
Clownacy
5596c33b38 Fix stuff
Looks like the Null backend's been broken for a while though
2020-05-06 23:10:40 +01:00
Clownacy
a8d0595bcd Update other backends to current API
The only other backend besides the Wii U one to use `render_target`
is the SDLTexture one.
2020-04-23 14:38:45 +01:00
Clownacy
8524d1e349 Change software renderer backend API 2020-04-15 21:59:23 +01:00
Clownacy
073e62de46 Software renderer tweaks 2020-04-15 16:57:05 +01:00
Clownacy
c51a074fad Big disgusting backend rework
We need to avoid `WindowsWrapper.h` in the backends whenever we can,
to avoid name collisions (the Wii U homebrew library) defines its own
BOOL/TRUE/FALSE, which really doesn't work with CSE2.
2020-04-13 18:19:39 +01:00
Clownacy
aa9e486086 Handle WindowBackend_Software_CreateWindow fail
Must have been part of that commit I reverted
2020-04-13 13:49:21 +01:00
Clownacy
4f7cc9582d Revert "Backends: Added init/de-init messages for backends"
This reverts commit 9be8b9a493.
2020-04-13 13:28:57 +01:00
Gabriel Ravier
9be8b9a493 Backends: Added init/de-init messages for backends
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-04-12 02:26:51 +02:00
Clownacy
1f06027403 Added GLFW3 support for the software renderer
A few things need cleaning-up
2020-04-09 19:29:45 +01:00
Clownacy
1016411fa4 Cleanup 2020-04-06 13:37:53 +01:00
Gabriel Ravier
1d9048c8a6 Merge branch 'portable' into improvePerformance2
# Conflicts:
#	src/Backends/Rendering/Software.cpp
2020-04-05 01:16:09 +02:00
Clownacy
1ae63bea96 Move window ownership to the window backend 2020-04-04 20:51:07 +01:00
Clownacy
cdd69496c4 Fixes 2020-04-04 20:34:51 +01:00
Clownacy
135035bb1a Change 'PlatformBackend' namespace to 'Backend' 2020-04-04 20:31:27 +01:00
Clownacy
4d322be866 Change render backend namespace to RenderBackend_ 2020-04-04 20:24:34 +01:00
Clownacy
87e8a75df4 Rename GLFW3.h/SDL2.h 2020-04-04 19:18:46 +01:00
Clownacy
1543521625 Fix more errors x_x 2020-04-03 18:36:48 +01:00
Clownacy
f548044464 Cleanup 2020-04-03 18:05:41 +01:00
Clownacy
8266db3372 Shut-up another warning 2020-04-03 02:08:19 +01:00
Gabriel Ravier
f68984bd58 Merge branch 'portable' into improvePerformance2
# Conflicts:
#	src/Backends/Audio/SDL2.cpp
2020-04-03 00:36:44 +02:00
Clownacy
49f7887930 More cleanup 2020-04-01 16:27:55 +01:00
Clownacy
ff70664604 Cleanup and fixes 2020-04-01 16:11:34 +01:00
Clownacy
142bca6578 Split SDL2 code from Draw.cpp 2020-03-31 16:11:31 +01:00
Gabriel Ravier
5d61641415 Added ATTRIBUTE_HOT to Backend_ColourFill
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-02-13 19:55:39 +01:00
Gabriel Ravier
f43bd4f876 Removed bad omp (it doesn't actually improve anything, i did my measurements wrong) 2020-02-13 19:55:39 +01:00
Gabriel Ravier
2adfef0035 Got Backend_Blit to go from 17% CPU usage to 11% :
- used __builtin_expect to get a 8.5% performance improvement
- used #pragma omp for to get a 30% performance improvement

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
2020-02-13 19:55:39 +01:00
Gabriel Ravier
e8ec6a8ffb Optimize Backend_Blit a bit 2020-02-13 19:55:39 +01:00
Clownacy
a767c16d83 Un-un-const a few things 2020-02-09 18:55:41 +00:00
Clownacy
d4004fe99a Store glyph pixels as chars, not floats
Smaller memory footprint, and probably-insignificant performance
impact.
2020-02-09 13:56:45 +00:00
Clownacy
bb11cd567d Software renderer cleanup 2020-02-09 13:44:02 +00:00
Clownacy
59a8c2617f Tweak some variable naming
The enhanced branch calls them the 'internal *screen* width/height',
which I think is more appropriate.
2020-02-05 15:52:43 +00:00
Clownacy
1140ab0916 Clean-up renderer backend initialisation 2020-02-04 15:51:19 +00:00
Clownacy
1b2d4fdb4d Fix the other rendering backends
Also finished ripping-out the sub-pixel support
2020-02-01 22:57:07 +00:00
Clownacy
eaf2de05b6 Add glyph-batching to the SDLTexture backend
Hope it will be this easy for the OpenGL backend
2020-02-01 17:49:26 +00:00
Clownacy
639039ce3a Added Backend_PrepareToDrawGlyphs
This is to reduce OpenGL context changes, and help pave the way for
glyph-batching
2020-02-01 16:40:23 +00:00
Clownacy
e3db7749ba Add verbose error-reporting to backends
Should fix #98
2020-02-01 12:22:44 +00:00
Clownacy
ed1ff2f275 Tweak MIN/MAX macros in software renderer 2020-01-29 23:45:22 +00:00
Clownacy
48b7a878ba Convert software renderer 2020-01-22 22:24:23 +00:00
Clownacy
a0eb646a1f Add ability to lock certain parts of a surface
This avoids conditional jumps based on uninitalised memory, and
should be faster, and should be lighter on memory.
2020-01-07 03:52:37 +00:00