makamys / Neodymium

Reimplements chunk rendering using modern OpenGL features to improve performance (1.7.10)
Other
115 stars 10 forks source link

Certain modded biomes may be too heavy for the default 512MB VRAM amount #20

Open shadow7483147 opened 1 year ago

shadow7483147 commented 1 year ago

Using a default installation of Gregtech New Horizons 2.3.2 (Java 17) in Prism Launcher, the game appears to constantly build more VRAM without letting any go. When it hits the maximum amount, all chunks get rebuilt.

It happens testing on a specific world seed, where you spawn in a BoP Coniferous Forest, exploring northwest towards the middle of it.

Triggering a chunk rebuild can be as simple as moving your view quickly in the opposite direction.

[20:41:06] [Client thread/INFO]: [CHAT] [§dneodymium§r/§cERROR§r] VRAM keeps getting full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible.
[20:41:06] [Client thread/WARN] [neodymium]: Critical: Not enough VRAM
[20:41:06] [Client thread/WARN] [neodymium]: Critical: Neodymium has been disabled due to a critical incompatibility.
[20:41:23] [Client thread/INFO]: [CHAT] Seed: -2551839124501105014

This video was recorded before I isolated the problem to a standard installation & this specific world. https://youtu.be/zpTipDM-xIA

By the way, it may help indicate to users if you log to the java console when a rebuild occurs due to vram exhaustion. That was the first place I looked when I discovered my world kept flashing out.

Looks like it settles around 800-1000MB in this biome.

makamys commented 1 year ago

I plan to make the VRAM buffer dynamically expand in the future, until then this kind of issue is inevitable. What's your render distance set to, by the way? The default value was selected assuming a 12 chunk render distance.

shadow7483147 commented 1 year ago

Render distance is 16 right now.

zeff9801 commented 8 months ago

I plan to make the VRAM buffer dynamically expand in the future, until then this kind of issue is inevitable. What's your render distance set to, by the way? The default value was selected assuming a 12 chunk render distance.

do you have any ideas on how I can retrieve the maximum available gpu vram without using external libraries?

makamys commented 8 months ago

I've looked into it before and it seems there is no reliable way to do it, just some vendor-specific extensions. Allocating a buffer and checking for an error also doesn't seem to work: if I allocate one larger than my maximum, it succeeds but causes a crash later down the line. So the correct approach seems to be to allocate as much as you need and hope you don't run out.

Some solutions I've been pondering are:

  1. Destroy the buffer and allocate one larger by, say, 256 MB every time it gets full. Easy but would cause a lag spike when that happens.
  2. Have some kind of chunked approach where I allocate 256 MB "chunks" and if the last one gets full, I add another one. Probably better but harder to implement.
  3. The combination of 1+2. Since I render world regions separately now, I could also store their meshes in separate buffers, and expand those dynamically. Smaller buffers mean faster resizing (but smaller regions also mean more draw calls). This is more or less how Sodium does it.

I'm currently holding back on any major changes since the MEGA people are looking into hooking up some mod compat, but it's something I (we?) want to experiment with in the future.