350 Commits

Author SHA1 Message Date
IntegratedQuantum
2a46592454 Fix integer overflows when the chunk mesh memory gets past 2 GiB.
This was causing corrupt and missing meshes.
2023-11-30 00:38:49 +01:00
IntegratedQuantum
8d561dfff2 Old meshes must be freed before creating new meshes.
Otherwise issues might happen on teleportation.
2023-11-29 17:20:35 +01:00
IntegratedQuantum
76384d1e4d Fix problems with transparency sorting and other data races.
Fixes #207
2023-11-29 15:44:10 +01:00
IntegratedQuantum
6dcfc5d3c9 Bypass the network for local connections when sending chunks.
Fixes #206
Fixes #189
2023-11-29 13:10:55 +01:00
IntegratedQuantum
6b1ba8bbe5 Write directly to the mapped buffer to avoid an extra copy of the mesh data. 2023-11-29 12:48:33 +01:00
IntegratedQuantum
f758ba4c2e Restructure the mesh so it doesn't need to recalculate lighting info in the render thread.
Fixes #204
2023-11-29 12:34:05 +01:00
IntegratedQuantum
4623df4af2 Cleanup some stuff that isn't needed anymore. 2023-11-28 21:49:56 +01:00
IntegratedQuantum
00f8b79ec4 Debug mode is now a slide show.
Mesh generation is much faster though, especially in release.
Additionally a few concurrency bugs, a deadlock and some other minor issues were fixed.
2023-11-28 21:30:58 +01:00
IntegratedQuantum
a61fe26fab Update zig: Andrew broke it all. 2023-11-28 00:04:01 +01:00
IntegratedQuantum
a028d22029 Calculate some available neighbor mesh borders outside the render thread.
While pretty insignificant on its own, this is an important step towards #168 and #61
2023-11-27 21:12:00 +01:00
IntegratedQuantum
e65928fd09 Make the log function work properly when logging in a defer that comes after the stackAllocator is freed. 2023-11-27 21:00:04 +01:00
IntegratedQuantum
d95b19c263 No longer use persistent mapping for the larger gpu buffer.
Apparently there is still some weird synchronization issue in there?
I tried many things to make it work, but ultimately I gave up.

I'm now using glMapBufferRange, which doesn't seem to have any issues.

Fixes #181
2023-11-26 22:55:46 +01:00
m-m-0-m
5a2c3936e5
Update README.md (#196)
* Update README.md

I fixed grammar, capitalization, formality and I altered the YouTube link at the end, so that it skips the intro (not the video will start at the 11 second mark).

* Update README.md

Changed "(AKA a Minecraft clone)" to "(inspired by Minecraft)," as this is more fitting.
2023-11-26 21:23:12 +01:00
IntegratedQuantum
d5dcc4d9be Fix calculation of used memory in LargeBuffer, which caused a crash in the debug window. 2023-11-26 20:41:27 +01:00
IntegratedQuantum
e0ac22668b Fix a stupid bug in the gpu allocator. It maximized fragmentation instead of minimizing it.
Fixes #175
2023-11-26 18:22:46 +01:00
IntegratedQuantum
410db62d85 Prepare some interfaces for multithreaded mesh access. 2023-11-26 17:07:21 +01:00
IntegratedQuantum
a6248dc5c2 Dynamically switch to higher lod chunks, when otherwise a high-to-low lod border would be drawn(I have no mesh data for these).
This required dynamically re-uploading some chunk meshes.
Fixes #130
2023-11-25 16:20:05 +01:00
IntegratedQuantum
0b8c4b455b Keep the faces to lod neighbors stored even if a neighbor of the same lod exists.
This is required for #130 to allow swapping between lod and non-lod connections on demand.
2023-11-23 23:03:04 +01:00
IntegratedQuantum
0c4f705082 Floor the pixel positions of the text to the nearest integer.
Seems like multisampling, which appears to be enabled by default for some people even if disabled in glfw, does weird stuff when the positions are not pixel aligned.
Should fix #177
2023-11-22 21:41:10 +01:00
IntegratedQuantum
e6b08081b2 Remove meshes from the updatelist when they get outside of the render distance.
fixes #182
2023-11-22 19:53:49 +01:00
IntegratedQuantum
c1c6aa7138 Further improve allocator usage in the network thread.
This finally fixes #171 (although CPUs with even more threads, or a future game with even better optimized terrain generation will still have this problem)
2023-11-21 22:19:52 +01:00
IntegratedQuantum
2d8f964ad9 Implement network statistics.
Fixes #153
2023-11-21 17:32:53 +01:00
IntegratedQuantum
4f789c4cca Update zig, forcing constness 2023-11-21 16:23:24 +01:00
IntegratedQuantum
e61709cb69 Rethink the allocation strategy.
Instead of one general purpose allocator per thread, there now is one stack allocator per thread, which behaves like a basic stack.
Using this allocator for all the trivial allocations, makes the game overall more efficient, even if some larger allocations now require going through the global allocator.
Maybe in the future the stack allocator could be extended with a temporary arena allocator functionality?

This should help with #171 by almost halfing the CPU usage of the receiving network thread. However the issue remains.
2023-11-21 16:06:19 +01:00
IntegratedQuantum
498222d3a8 Properly check if a mesh is in render distance before generating it.
Fixes a weird bug that happened when travelling too fast.
2023-11-20 21:45:07 +01:00
IntegratedQuantum
0adfbbc79e We don't need 64 bits for timer queries.
32 bits is enough as long as the time is less than 4 seconds, and 64 bit isn't supported everywhere.
2023-11-20 10:38:24 +01:00
IntegratedQuantum
80a6a53170 Don't crash on thread renaming errors.
These happen sometimes, like name too long and on mac you can only rename a thread from within.
And since the thread name is really only used for debugging, there is no need to crash the game in that case.
2023-11-19 22:49:31 +01:00
IntegratedQuantum
35b436f26c Don't use tabs in comments. 2023-11-19 19:39:58 +01:00
IntegratedQuantum
55034b769e Return to the game when pressing escape while the mouse isn't grabbed.
This seems to be more intuitive than clicking on the background.
Fixes #179
2023-11-17 20:12:57 +01:00
IntegratedQuantum
e1c5a30a0d Only do the infinite GPU loop detection on Linux, as it generates false positives on Windows.
Fixes #178
2023-11-17 11:57:25 +01:00
IntegratedQuantum
df075aa7df Prevent signed integer modulo in the animation frame calculation.
fixes #176
This created negative values when the time was negative, resulting in wrong animation frames.
2023-11-17 11:39:37 +01:00
IntegratedQuantum
7a640132ff Set the timout for poll on windows to zero to prevent blocking the render and other threads.
Why does windows always have to make things complicated?

Fixes #154
2023-11-16 23:46:43 +01:00
IntegratedQuantum
d348946939 Explicitly disable multisampling.
Fixes #177
2023-11-16 22:49:57 +01:00
IntegratedQuantum
4d25e9820b Don't generate framebuffers with size 0.
Should fix #142
2023-11-16 22:04:02 +01:00
IntegratedQuantum
bcf5ecf3c8 Base the larger gpu buffer off of one specific type.
This improves alignment, so memcpy should be slightly faster.
Additionally this simplifies the code that uses this buffer.
And only allowing one type prevents future accidents from mixed alignment.
Now it also supports buffers that are (slightly) bigger than the i32 integer limit.
2023-11-16 18:20:50 +01:00
IntegratedQuantum
919d7d5a9d Dynamically resize the GPU buffer if needed.
It does create some lag, but that should only happen once.
Maybe in the future I should investigate some alternatives to the copying.
2023-11-16 17:49:45 +01:00
IntegratedQuantum
6fd5c4d896 Use a persistent buffer for the large chunk mesh buffer.
This is should be faster than glBufferSubData, since I know better what to synchronize than the driver.
Additionally on some drivers this should avoid stalls, fixing #137
2023-11-15 21:44:08 +01:00
IntegratedQuantum
d6ab3d587b Use glBufferStorage to tell the driver that certain buffers are only uploaded once and never changed.
Should fix #144
2023-11-15 17:42:07 +01:00
IntegratedQuantum
bfb6466f7e Improve OpenGL debug output and print it in release as well. 2023-11-14 22:11:38 +01:00
IntegratedQuantum
2b30454042 Fix italic text
fixes #147
2023-11-14 19:40:29 +01:00
IntegratedQuantum
f6c2d17940 Make the parallax raymarching more efficient, by limiting the step-width to 1 and using some optimizations.
Also make the gpu code more resilient against infinite loops, allowing the removal of the iteration count.
2023-11-13 20:02:39 +01:00
IntegratedQuantum
fd776fa83f Remove the LODFactor setting.
This was useful in the java version, since there the LOD chunks were faster to render due to having no light/transparency.
Since this is not true anymore and since the settings created a lot of confusion for players(and myself), I decided to remove it.
Fixes #166
The proposed solution in #166 top use a seperate slider for the max lod distance doesn't make much sense either since changing only the lod0 render distance separately wouldn't actually improve performance significantly. It's better to switch to different LOD byond that.
2023-11-12 21:45:35 +01:00
IntegratedQuantum
fe9c001fd8 Simplify some code using vector operations. 2023-11-10 20:25:07 +01:00
IntegratedQuantum
b8b30363d7 Transpose all matrices.
This just makes more sense. And matrix-vector multiplication should also be faster.
2023-11-10 19:38:40 +01:00
IntegratedQuantum
19e3353be8 Fix item textures.
Fixes #167
2023-11-09 22:22:06 +01:00
IntegratedQuantum
e7823fe805 Improve data access patterns when getting the light values for a face.
Still not optimal. Debug performance is pretty bad.
2023-11-08 17:36:20 +01:00
IntegratedQuantum
026e855eaa Merge the functionality of the bloom upscale shader into the final post processing shader.
Increases performance by ~300 µs per frame.
Fixes #97
2023-11-08 11:19:33 +01:00
IntegratedQuantum
0152b1363a Delay mesh updated on neighbor removal.
Fixes #165
Also introducing reference counting for chunk meshes, with delayed freeing(at the end of the frame)
2023-11-07 21:06:58 +01:00
IntegratedQuantum
5db903020a Don't reset the visibilityMask for every mesh, instead it's only reset for the meshes that get rendered.
This improved frame time by some 300 µs at default render distance.
2023-11-06 16:06:25 +01:00
IntegratedQuantum
fc70d99323 Prepare the meshing and shaders for light rendering, currently demonstrating just ambient occlusion.
Starts work on #61
2023-11-05 22:52:49 +01:00