View Issue Details

IDProjectCategoryView StatusLast Update
0006101Spring engineGeneralpublic2018-12-17 20:36
Reportergajop Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionno change required 
Product Version104.0 +git 
Summary0006101: Large textures cannot be saved to disk
DescriptionTrying to save large textures (diffuse) to disk using gl.RenderToTexture + gl.SaveImage results in a fairly cryptic error:
[f=0002080] Error: gl.RenderToTexture: error(-1) = (null)

This error is caused by:
- bitmap.Alloc(width, height); https://github.com/spring/spring/blob/858b876e70244ebda54dac02dc0633220ce22598/rts/Lua/LuaOpenGL.cpp#L3482
- throw std::bad_alloc(); https://github.com/spring/spring/blob/858b876e70244ebda54dac02dc0633220ce22598/rts/Rendering/Textures/Bitmap.cpp#L97


This will happen on medium to large size maps (mapSize of 7168 x 7168) while not on smaller ones (mapSize of 5120 x 5120).

Version 104.0 of the engine, as well as current maintenance with "#define ENABLE_TEXMEMPOOL 0" works with all these sizes and above (tested on mapSize of 10240 x 10240, took 30s but hey, the 100MB PNG was successfully outputted).

I'd be happy if in cases of such big textures instead of // give up, throw std::bad_alloc(); we did the simple pre-TEXMEMPOOL allocation, set a flag and appropriately deallocated it in the destructor. Thoughts?

(Obviously this is a very important feature for SpringBoard, as I use this to export Spring diffuse, so I do need it to work)
TagsNo tags attached.
Checked infolog.txt for Errors

Activities

Kloot

2018-12-15 20:27

developer   ~0019610

Last edited: 2018-12-15 20:29

As I said in 0006089 to Silentwings you get 128MB to play with *by default*, which allows loading two 4K textures. This limit is important because main engine releases are still 32-bit.

For SpringBoard you can simply bump the TextureMemPoolSize config and forget about it.

gajop

2018-12-16 05:28

developer   ~0019611

Seems to work well, but with two issues:
1) I find it hard to figure out how big the pool size should be ( https://github.com/Spring-SpringBoard/SpringBoard-Core/blob/53b1ac397728477f84e7d387100d1043e3e33af2/scen_edit/view/actions/export_action.lua#L90 ). I'm trying to guesstimate it using the current diffuse size, but other things are also using the memory pool (e.g. editor's map Lua textures, undo/redo texture stack, GUI, etc.). If I make the pool too big, Spring might fail to start, which would be pretty bad UX. Any suggestions?

2) I can't seem to just Spring.Reload ( https://github.com/Spring-SpringBoard/SpringBoard-Core/blob/53b1ac397728477f84e7d387100d1043e3e33af2/scen_edit/util.lua#L706 ) after setting the TextureMemPoolSize size. It needs a complete shutdown and new start. This might be a wider issue (not sure how it applies to other springsettings).

Kloot

2018-12-16 19:48

developer   ~0019615

1) on a modern OS you can safely make it a gigabyte or so, which will work so long as the gamestate (everything else that consumes memory) remains minimal in SpringBoard

2) fixed

gajop

2018-12-17 16:32

developer   ~0019619

2) seems to not be working: http://logs.springrts.com/logfiles/47/
There's nothing between
[f=0000342] [SpringApp::Reload][7]
[f=0000342] [SpringApp::Reload][8]

I think this check might be wrong (size is in MBs, texMemPool is in bytes)
    // only allow expansion; config-size is in MB
    if (size > texMemPool.Size())
        texMemPool.Resize(size * 1024 * 1024);

Kloot

2018-12-17 20:36

developer   ~0019623

indeed it was.

PS: you should also consider setting system.pathfindersystem to -1 in modrules, which will instantiate a null PFS and free up more memory for textures.

Issue History

Date Modified Username Field Change
2018-12-15 19:10 gajop New Issue
2018-12-15 20:27 Kloot Note Added: 0019610
2018-12-15 20:29 Kloot Note Edited: 0019610
2018-12-15 20:30 Kloot Status new => closed
2018-12-15 20:30 Kloot Resolution open => no change required
2018-12-16 05:28 gajop Note Added: 0019611
2018-12-16 19:48 Kloot Note Added: 0019615
2018-12-17 16:32 gajop Note Added: 0019619
2018-12-17 20:36 Kloot Note Added: 0019623