#Refactoring Rendering
1 messages · Page 2 of 1
Chunkgeometry is just a container for the geometry. We need to stage it in the scene??
Tell the renderer we want to render this geometry at this coordinate
How will handling rebuilding meshes?
you can just request a new resource or do you think we can just update the data in the buffer :?
you can in theory just reuse the buffer
I think in this way.
for now lets say we're lazy and just request a new mesh
discard the buffer and the mesh
Then ChunkView became invalid (if take your example below)
the chunkView can hold a weak refernce
once its freed then its dead
if we have a scene with chunks that have meshes attached to them.
a scene will have one camera for now lets keep it simple i think :?
Scene {
Camera
chunkViews
}
a chunkView has a mesh and a location to render it in the world
the view can have a set method to update the chunk resource
the future plan would be to make this all indirect rendering
I think that will better
Then current api should looks like:
Scene#addChunk
Scene#removeChunk
Scene#settings - basic rendering settings?
Scene#Camera - return camera api?
ChunkMesh#setTransform
ChunkMesh#updateBuffer
chunkMesh also encapsulates its transformation :?
I guess that makes sense
that's simpler lets go with that
we need to index into a uniform buffer
Oh. That was mistype :3
we don't want to have a buffer per chunk
it would be like 60 or so bytes thats a lottt of tiny allocations
umm we still need a logger bridge ... 😦
Are you suggest bake world meshes at java side and then update it all at once? On every world change?
Take logger crate for rust :3
you need to copy the mesh data generated on java side to rust but the actual uniform data will be in one large buffer
each chunk view will get an index into one large uniform buffer
we can slice it into block per chunk
Nice. But what is problem with update buffer for one chunk, when it will change?
umm for now lets be a little wastful and say we need a new muesh its immutable
you can add the API, if you want to
just want to get it working then improve
here is what I'm thinking about for the scene you have a scene chunk with an index handle since that will index into a buffer
when you get a chunk it will return a mutator that lets you update some chunk state, what do you think
Chunk state like:
- Meshes
- ???
At current state at least.
Mutator can be nice idea, as control item for single structs
Another variants:
- Jni calls via single point
- Sync objects (from java or rust side)
- Events
@heavy bloom
We try to integrate lowlevel graphics for performace issue.
Current trying - rust lib which using wgpu crate(rust's library)
For reference, this my test set-up. Just for comparison.
OS: Windows 10 (21H2)
CPU: Intel i7-6700K
Memory: 16GiB
GPU: Nvidia GeForce RTX 4070
I have two machines, a laptop and a tower
Laptop has integreated gpu and tower has a 980ti
Windows 11 and 10 respectively
I'm testing on Linux Mint
Kernel: 6.2.0-31-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 5.4.12 tk: GTK 3.24.33
wm: Mutter dm: LightDM Distro: Linux Mint 21 Vanessa base: Ubuntu 22.04 jammy
Machine:
Type: Desktop Mobo: Gigabyte model: B550 AORUS PRO AC v: x.x serial: <superuser required>
UEFI: American Megatrends v: F2 date: 07/07/2020
CPU:
Info: 8-core model: AMD Ryzen 7 3700X bits: 64 type: MT MCP arch: Zen 2 rev: 0 cache:
L1: 512 KiB L2: 4 MiB L3: 32 MiB
Speed (MHz): avg: 3448 high: 4337 min/max: 2200/4426 boost: enabled cores: 1: 4279 2: 2154
3: 2151 4: 3887 5: 3576 6: 4331 7: 4337 8: 4297 9: 4125 10: 2200 11: 2164 12: 2200 13: 3521
14: 3600 15: 4161 16: 4197 bogomips: 114980
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
Device-1: NVIDIA GP104 [GeForce GTX 1070] vendor: ZOTAC driver: nvidia v: 525.125.06 pcie:
speed: 8 GT/s lanes: 16 ports: active: none off: DP-1,DP-2 empty: DP-3,DVI-D-1,HDMI-A-1
bus-ID: 09:00.0 chip-ID: 10de:1b81
Device-2: Logitech HD Pro Webcam C920 type: USB driver: snd-usb-audio,uvcvideo bus-ID: 3-1.3:6
chip-ID: 046d:08e5
Display: x11 server: X.Org v: 1.21.1.4 driver: X: loaded: nvidia
unloaded: fbdev,modesetting,nouveau,vesa gpu: nvidia display-ID: :0 screens: 1
Screen-1: 0 s-res: 4480x1440 s-dpi: 122
Monitor-1: DP-0 pos: bottom-r res: 1920x1080 dpi: 96 diag: 585mm (23")
Monitor-2: DP-2 pos: primary,top-left res: 2560x1440 dpi: 123 diag: 604mm (23.8")
OpenGL: renderer: NVIDIA GeForce GTX 1070/PCIe/SSE2 v: 4.6.0 NVIDIA 525.125.06
direct render: Yes```
Personal and strongly opinionated rant about why one should never use deferred shading.
Slides: https://docs.google.com/presentation/d/1kaeg2qMi3_8nQqoR3Y2Ax9fJKUYLigPLPfdjfuEGowY/edit?usp=sharing
Links:
https://github.com/zeux/meshoptimizer
https://vkguide.dev/docs/gpudriven/gpu_driven_engines/
https://vkguide.dev/docs/gpudriven/compute_culli...
@tawny veldt is your crash backtrace still the same as #1125142900154564701 message ?
I don't have time to watch a 30 minute video at the moment (but I'm interested when I can find the time to focus). If you don't want to implement a deferred renderer then any other kind is fine, as I believe you replaced the entire rendering loop with the rust library? So you could possibly implement rendering using whatever technique you prefer.
Ill either do it first here or terasology first https://github.com/OSS-Cosmic/AmnesiaTheDarkDescent
So, I just did one test with
workspace
engine ts-rusty feature/wgpu-ren… 221e454e
libs
lib TeraRusty fix/choose_high_… ac1a2c1e```
Have a look a the build scan, it also ahs the console output and such: https://scans.gradle.com/s/makn3gz2fjely/console-log?anchor=626&page=1
I think that https://github.com/MovingBlocks/TeraRusty/pull/4 (which it looks like you're using) is not rebased onto the current main branch. So, that's probably why the compilation is failing. The changes from that PR can probably be cherry picked (git cherry-pick ac1a2c1ebc4543597d4b523f41c15a5dfff6ebb8) onto the main branch locally for a quick test.
I rebase the PR onto main, still not working. I see the splash, but not window showing up. Here's another build scan: https://scans.gradle.com/s/duxvlcoq6f6ma
workspace
engine ts-rusty feature/wgpu-ren… 221e454e
libs
lib TeraRusty ± fix/choose_high_… 22de534a```
I can look at this on sunday
With my finger broke I’ll be a little slow but should get a chance to look at code later
I'm going to try and reproduce this under WSL but, in the meantime, could you possibly provide some even more detailed debug logs? It might be useful in determining why wgpu is doing what it's doing.
- Apply the changes from https://github.com/MovingBlocks/TeraRusty/commit/7aee4e37e3c90a406241a46bdb9214a4cf2fd6c3 (or just use the
wgpu-loggingbranch) export RUST_LOG=debuggradlew --console=plain game > game.log 2>&1
I'll include my logs here for comparison (just in-case anybody else is also looking into it).
[2023-09-11T17:45:27Z INFO wgpu_hal::gles::egl] Unable to open libEGL: Library(LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } })
This does seem interesting, to be fair. Why is it even trying to load EGL in the first place?
there you go
The crash points towards https://github.com/timothee-haudebourg/khronos-egl/blob/4.1.0/src/lib.rs#L961, which implies that the crash is in eglMakeCurrent. I'm not sure why it would be calling that in the first place, since we don't want an GLES/EGL context.
Can we try forcing the Vulkan back-end in wgpu? It might be trying to initialise both and then failing on EGL before it gets a chance to try Vulkan properly.
- Apply the changes fromhttps://github.com/MovingBlocks/TeraRusty/commit/b84d00acff315e52a82c2a103219e1291d5f089f (or just use the
wgpu-force-backend-envbranch) export WGPU_BACKEND=vulkangradlew game
(It might also be worth tryingWGPU_BACKEND=glfor comparison - which certainly should not work.)
I am rather guessing here though. Let me know if I'm wasting too much time.
Err(self.get_error().unwrap())
whoop whoop!
just in case, logs for
WGPU_BACKEND=vulkan RUST_LOG=debug gradlew --console=plain game > vulkan.log 2>&1
and as expected, does not work with backend GL. Also, logs for reference if needed.
WGPU_BACKEND=gl RUST_LOG=debug gradlew --console=plain game > gl.log 2>&1
Super odd, vulkan should be first in backend chain, and egl as fallback.. (looked in wgpu code)
We can disable gles/egl from wgpu build, by disabling gles feature flag :3
Good that you got that working
So quick question, are we actually tailoring this to just terasology, or should we be steering this to be multi purpose?
Imo the effort making multi purpose is huge, and if we tailor to just Terasology we can really squeeze as much performance as we can
from my pov it should be just for Terasology - we don't need that kind of rendering for DestSol and we're not going to make another game that would need it anytime soon.
the part that is disputable is the NUI stuff - @leaden widget can you comment on DestSol's needs here if any? if DestSol is fine with the current state and feature set of NUI we could also argue that it sticks to that and Terasology can use whatever the future rendering approach provides. @tawny veldt and I have previously mentored projects in the direction of UI overhauls and would definitely be interested in getting into that, provided the technical foundation exists and is usable.
NUI is already self-contained and should not be affected by a change of renderer by Terasology. NUI provides its own canvas abstraction that widgets rely on, independent of the actual renderer underneath (it's all in https://github.com/MovingBlocks/TeraNUI/tree/master/nui/src/main/java/org/terasology/nui/canvas). Terasology provides its own implementation of the Canvas interface for NUI already.
Yes, I was thinking more along the line of - if we invest here for Terasology, would it make sense if it's done in a way that DestSol can benefit too...? After all NUI is a bit buggy and limited in places IIRC (please don't ask for details on that I'd have to refresh my memory first).
That's why I was asking about whether DestSol is fine with the current state and feature set of NUI
It gets along. I've seem more offputting bugs from NUI than I'd like but it stil beats the old system by far. The current state of NUI is enough for Destination Sol, even if it has been a bit awkward to work with.
Great, then @heavy bloom I'd say: just Terasology in all regards
great job but I'm more impressed by the Gradle glue code you wrote. It all works so seamlessly. I'm working on something similar and I'm the process of converting the groovy scripts from TeraRusty to kotlin kts for my project. Let's see how this goes 😄
nice! we're always happy about people interested in that stuff 😁
it is a bit messy and hard to understand in some places though, so feel free to contribute (back) any improvements 😉
Soo I also needed to create jni bindigs of Rust for a personal project of mine thus took a lot of inspiration from TeraRusty and its gradle scripts ultimately converting the groovy scripts into kotlin dsl. If you think you can benefit from this here's my fork. https://github.com/ThanosFisherman/TeraRusty I certainly benefit from kotlin's static typing and IDE support in my gradle scripts.
I think you can make more interesting things and investigations in future.
Feel free to create PR about conversion back :p (i wish this almost :D)
Will create a PR soon so that you can test it yourselves too in case I missed something. 😁
thank you that would be wonderful 💚
Gave +1 Slime Tokens to @pseudo compass
PR is up 🙂
nice, thanks! want to share a link?
Gave +1 Slime Tokens to @pseudo compass
Yeap here you go https://github.com/MovingBlocks/TeraRusty/pull/11
Been giving the rendering a go, things have been slow though so apologies for the lack of communication
@leaden widget did you manage to run Terasology from WSL?
Yes, I had it running in WSL2 a while ago, I think. The main issue was that you can't get hardware-accelerated Vulkan rendering on there easily - It's possible but quite a bit of work. Did I miss something?
I'm trying to get a minimal setup on my Windows machine so that I can at least compile the projet and test out PRs without rebooting into Linux... thought I'd give WSL another try.
Trying to compile from develop fails because of missing natives I think, so I thought maybe this re-write might work 🤷♂️
The new renderer can't even load a save game right now, unless it's got further on since I last checked. You might need to enable the WSLg features to get the graphical bits working.
develop should be fine? I'll just test that quickly now though.
The develop branch runs just fine under WSL2 for me. You'll probably need WSLg enabled for the graphical bits (see https://github.com/microsoft/wslg).
Windows 10 here, it's not just a Windows 11 feature anymore.
hm, I'm puzzled. I am on WSL2, and I don't understand what I need to do in order to enable WSLg