Skip to content

Test allow larger vertex mesh#1359

Open
adfriz wants to merge 3 commits into
leezer3:masterfrom
adfriz:test-allow-larger-vertex-mesh
Open

Test allow larger vertex mesh#1359
adfriz wants to merge 3 commits into
leezer3:masterfrom
adfriz:test-allow-larger-vertex-mesh

Conversation

@adfriz

@adfriz adfriz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Just a PR test for how capable current parser handling large mesh especially if in one meshbuilder contains the entire mesh.

Mainly tested in object viewer.

curently can load 250K triangle mesh, without texture, only single Color command.

But the memory usage when i try in release builds mode almost 1GB... idk why task manager report that... feels like memory leak or something allocated too much

Test file:
testA.zip

@adfriz adfriz changed the title First try, just deleting the vertex limits. Test allow larger vertex mesh Jul 20, 2026
@leezer3

leezer3 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

There shouldn't be anything per-se stopping it with larger meshes IIRC, although the rest of things may not be so happy.

The X parser and MSTS shape parser definitely support larger.

FWIW, the new parser is slightly higher at ~1.3gb for your file, but I don't see anything immediately wrong per-se.

Most of our memory allocations come in the CreateVAO method:
https://github.com/leezer3/OpenBVE/blob/master/source/LibRender2/openGL/VertexArrayObject.cs#L190

@leezer3

leezer3 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

This is a finger in the air wondering at the minute:
https://stackoverflow.com/a/4973190/722627

No idea how that would perform, but it likely wouldn't have some of the internal list optimisations...
Being limited to .Net 4.7 is a little problematic for 'clever' solutions, but the WinForms menu is the big issue with moving onto something later.

@leezer3

leezer3 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Interesting. Using that approach has basically no difference- shows that the people writing the CLR have probably thought of that.

Approximately 600mb of memory is being used by the normals generation though.
I suppose you could disable it for oversize models (pretty pointless unless you're hand-writing), but at the minute I suspect it's just a fact of life..

@adfriz

adfriz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

i noticed it that early, accidentally pressed N to show the normals and the FPS drops below 10. so i suspect that maybe the cause.

already done some fixing locally about normals generation and memory usage, but im pretty sure there more to it...

leezer3 added a commit that referenced this pull request Jul 20, 2026
@adfriz

adfriz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author
image

now the fps stable enough, and i have trim the vertex normals visual length a bit.
still get fps drop to 45 when too close to the mesh.

needs to sync with master...

adfriz added 2 commits July 20, 2026 18:03
- Build the normals debug VAO lazily and render it with a
  single DrawArrays call, avoiding a duplicate index buffer in RAM.
- Show normals in solid blue
- Force a GC collect when normals are hidden so RAM drops immediately.
- Add LibRenderVertex constructor and a
  DrawArrays overload for the normals
…ertex-mesh

# Conflicts:
#	source/Plugins/Object.CsvB3d/Plugin.Parser.cs
@leezer3

leezer3 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Yeah, I think that's just a case of too many total vertices though, probably pretty normal.


I've found one very minor memory leak in the fonts as a result of this, which master now fixes, but that's I think a GDI+ bug rather than us (returning the default typographic size should really use a shared object...)

The font subsystem itself is horrifically slow though, as it's doing some nasty concating to build the rendered strings. Replacing it is something I've looked at:
#1162

That works OK and is considerably faster (although would want rebasing to the current master, and probably some fixing), but it's somewhat limited as you can't easily choose the font, and you've realistically got to ship the font file with the build.
Not sure exactly how many people actually use custom fonts, but it was asked for at some point....


Anything else in terms of leaking appears to just be par for the course (first load of any object allocates a bunch of new strings for errors and stuff, which are then held by WinForms), and the GC sometimes takes a little while to get rid of the other bits.

@adfriz

adfriz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@leezer3 you can cherry pick the commit, my code is not the greatest anyway.

a note: i haven't fully test to the route viewer, but im pretty sure the code should works

@leezer3

leezer3 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Done, although I've found a slight timing issue when creating on the main thread.

I'm considering at the minute whether it's worth adding a color dropdown for the normals. Issue with that is that you've gotta hack a combo-box to do it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants