geometry/memory management system implementation (OpenGL)

Started by
8 comments, last by DJSnow 20 years, 4 months ago
today i got, again, focussed my thoughts on a good system to handle and manage geometry data and the memory for it; in general. the more detail on this topic for me is, how to do that by utilizing modern technologies, like VA/VAR/VBO, BY KEEPING UP: 1. the ease of programming for the developer/API user 2. a good performance (perhaps by using different. caching approaches) 3. BUT also by delivering "automatic" management/storing (~"ram locationing") of data/memory. i think some topics are really discussion-worth: - is it useful to write a "general" memory manager ? this would enable the API to log allocation activities and also relocate the RAM between sysmem <-> vidmem. - is the better approach to have one big buffer for everything, or several small one''s ? the latter case could be handle in an optimal manner by the memorymanager. especially for using standard OpenGL vertexarrays this could also come along with performance increases. - is it worth the effort to construct a "vertexbuffer" / "indexbuffer" class, "as seen on DirectX" () ?? above all with the memorymanger in mind, this would be an very-easy-to-add-feature. and with this vertexbuffer the programmer don''t have to care about the location of the memory of the vertices, because the vertexbuffer does it by using the memorymanager''s functions. - by using such concept, deploying a(ny) caching procedure would be no problem, because - again - the memorymanager would take up all actions regarding such tasks. has anyone also figured out the same topics ? how do you do it, IF you already do it ? has anyone detailed information on how really big projects do this ? DJSnow --- this post is manually created and therefore legally valid without a signature
DJSnow---this post is manually created and therefore legally valid without a signature
Advertisement
quote:Original post by DJSnow
- is it useful to write a "general" memory manager ? this would
enable the API to log allocation activities and also relocate
the RAM between sysmem <-> vidmem.

You're gonna write an API ? not use OpenGL/DirectGraphics ?
If not, then it might not be worth it.

quote:
- is the better approach to have one big buffer for everything,
or several small one's ? the latter case could be handle in an
optimal manner by the memorymanager. especially for using
standard OpenGL vertexarrays this could also come along with
performance increases.

Neither, small arrays add overhead and so are sub optimal, a giant one could no fit in VRAM and so be sub optimal too.
Either use streaming and a Vertex Buffer cache, or a simple VB per Mesh, provided tesselation isn't too poor.

quote:
- is it worth the effort to construct a "vertexbuffer" /
"indexbuffer" class, "as seen on DirectX" () ?? above all
with the memorymanger in mind, this would be an
very-easy-to-add-feature. and with this vertexbuffer the
programmer don't have to care about the location of the memory
of the vertices, because the vertexbuffer does it by using
the memorymanager's functions.

Surely if you want to add capabilities, and API independancy.
(I think I missed something about the memory manager, too tired to re read)

quote:
- by using such concept, deploying a(ny) caching procedure would
be no problem, because - again - the memorymanager would take
up all actions regarding such tasks.

I heard Unreal Engine (the first) did allocate plenty of memory and performed its own memory management because windows memory management was too slow.



-* So many things to do, so little time to spend. *-


[edited by - Ingenu on December 15, 2003 3:07:14 PM]
-* So many things to do, so little time to spend. *-
@Ingenu:
>>You''re gonna write an API ? not use OpenGL/DirectGraphics ?
>>If not, then it might not be worth it.
sorry for beeing unclear here:
with "API" i meant our engine''s API; the engine itself uses GL (hence the thread title), but it''s possible that we write an DirectX layer some day, too, yes.
but: talking about GL makes it clear: OpenGL has no memory management, it has only it''s ugly "objects" for textures, arrays and so on; but no memory management - and therefore i think that if you use GL, you should have something like a memory manager (because there is no one in original impl.).

>>Neither, small arrays add overhead and so are sub optimal, a
>>giant one could no fit in VRAM and so be sub optimal too.
>>Either use streaming and a Vertex Buffer cache, or a simple
>>VB per Mesh, provided tesselation isn''t too poor.
*argh* that''s the problem: we don''t want an approach which runs "on each machine under each circumtance on each driver on each OS" - we''re going to target R8500/GF3 at least, so thought of the best "most-cost-efficient"-way to do this; or perhaps on some values which would give me a hint; e.g. "having this size on X resulted in Y in our test; and having this size on B resulted in A in our test". some "orientation values".

>>Surely if you want to add capabilities, and API independancy.
>>(I think I missed something about the memory manager, too
>>tired to re read)
yes yes, but: is it useful - perhaps anyone already tried that, and resulted in totaly poor outcomes; this was the issue i meant.



DJSnow
---
this post is manually created and therefore legally valid without a signature
DJSnow---this post is manually created and therefore legally valid without a signature
I think this thread addresses some of the questions you''ve raised. You may have seen it before - its Yanns system for handling this problem.

Another thread that may be of help is this one.

The jist of the situation is that one large vertex buffer/array gives better performance, as long as its guaranteed to be in video memory. Since you cannot accurately determine the available video memory the best solution, according to Yann, is to have quality level parameters that the user sets. This way the buffer/array is assumed to be in vid mem. If the user sets the params to a quality level that exceeds the capabilities of the hardware, the performance loss will be huge as the buffer/array will be placed, by the driver, in system memory. But the responsibility is then on the user to lower the quality level to a more suitable one.

Cheers
Kyle
Oh! I recently came up with a method to (somewhat) abstract vertex buffers, which I believe to be pretty ingenious. Every object that has a mesh in my world has a pointer to a mesh object, (let''s call it CMesh just to make it clear). Each CMesh has a member pointer to a CVertexBuffer class, and has an offset into the vb. That is the most the client ever sees of the CVertexBuffer class; all manipulation is done by the API-specific CGraphics class. I have a CD3DGraphics class which derives from it, and can only deal with CD3DVertexBuffers. As of right now, I am limiting my engine to one instance of the CGraphics class at a time, and thus all CVertexBuffers must be CD3DVertexBuffers or COGLVertexBuffers. Simple, and encapsulated.

On second thought: I haven''t read many of Yann''s posts and ideas, so this might have been discussed already.
thanks for the links;
i''ll try to find some useful hints there.



DJSnow
---
this post is manually created and therefore legally valid without a signature
DJSnow---this post is manually created and therefore legally valid without a signature
search for frame based memory allocation. essentially you allocate a large amount of memory up front and then take chunks (or frames) of that out when you need them, useful for quickly loading data for levels etc...
-jonnii=========jon@voodooextreme.comwww.voodooextreme.com
yes, of course; i know how to implement this stuff; but the main reason for this thread, was the question behind the need for such techniques, and how you do it currently.

DJSnow
---
this post is manually created and therefore legally valid without a signature
DJSnow---this post is manually created and therefore legally valid without a signature
They''re used for gaining speed, debugging and manage complexity. The tradeoff is that it takes longer to code these things up and they''re more complicated than straight forward ways. However, as your project gets more and more complex the complexity management tools you build will start to kick in. You might never reach complexity threshold so all the time you''ve invested in such tools can be wasted. It''s up to you to judge the tradeoffs and it''s different for everyone here.
quote:
yes, of course; i know how to implement this stuff; but the main reason for this thread, was the question behind the need for such techniques, and how you do it currently.



I think the reason for such a system is obvious!

We all know that for efficient rendering, you must upload as much of your data, as you can, to your video card (VRAM/AGP). Now, what happens if you have a huge world that doesn''t fit into that memory? You must handle this case someway. This is why you must have a mem manager, so when you need to render something newly added to the scene (wasn''t visible some frames before), you must have a way to upload it to the "fast" memory, without rejecting somoething usefull (visible), and corrupting your data.

HellRaiZer
HellRaiZer

This topic is closed to new replies.

Advertisement