Skip to main content
gamedev.net
🔒 Locked

Scene management Memory copy

Started by idreamlovey Aug 8, 2007 at 8:51 AM 7 replies 1.9k views
Original Post
idreamlovey
idreamlovey
In my first engine which is basically intent to render outdoor environment. I am using one large Dynamic Vertex and Index Buffer to make no Vertex-Index buffer switches. I am using GridBased system. Each grid has been further divided into OCTREE. At each leaf node static Polygon Lists(Dynamic Link Lists) have been created which stores info about Vertices and Indices sepearted by material types. Now at the time of culling, i am copying the polygon lists data of each leaf into another dynamic polygon Linklist. So i traverse each grid and each octree leaf that is currently in view and copy the polygons seperated by their material type. Now Doing this i can Batch the whole triangles according to thier material type thus reducing the DrawIndexPrimitive call. All i am doing like this as in two steps:- step 1: 1.Cull Tree 2. At leaf Node for (int i=0;i<numMaterials;i++) Copy LeafPolygonLists(i) to MainPolygonLists(i) (i used link list here but showing as array just to make u understand what i m doing) (memset is used here) step 2: start vertexCache for (int i=0;i<numMaterials;i++) { SetMaterial(i) Copy MainPolygonLists(i) to Vertex Buffer and Index Buffer; (memcpy is used here) Flush the vertex cache } Now here u see i have to do two copies. Engine can render 20000 tris at 18 frame rate at NVIDIA 5200 fx card. But i want to increase it more and i am thinking that two copies can be avoided by only one copies.... In my engine u can see 3200 tris with light mapping, 1800 with pixel based splatting, 5500 tris with environmental texturing (vertex shader used)and soft shadow(pixel shader used), 6000 with alpha blending transperent obects some with no BackfaceCull and rest are with lights on (without specular). SkyBox with sunflare. And i think my engine is not good as i see FLATOUT and NFS Carbon demo runs at 30 frame rate with more poly and shader.. I want to know what u guys do actually in scene management. Is the above one is good approach and need additional optimization in same engine....Please tell me what should i do to make a good managed engine...If u have link to any article...It will be great to me....
ET3D
ET3D
You might want to try keeping all your vertices in one large static buffer, and making only your index buffer dynamic. The dynamic index buffer will select which polygons to render, with a lot less copy overhead than copying the vertices too, and having the vertices already on the card will be faster than getting them from memory to the card each frame.
jollyjeffers
jollyjeffers
To extend on Eyal's reply - WHY are you going dynamic? I mean, really, have you thought it through?

Sure, there's a lot of available wisdom stating that pipeline changes are slow and therefore evil, but there is a threshold where reducing pipeline changes and increasing resouce changes is a loss - it is very possible that your method is actually past this threshold and slower as a result.

I have journal entries showing a 35 million triangle per second render on a GeForce 6800 AGP. The Nvidia 5-series suck in a big way, but you getting 20 thousand and less is just silly - no way is the 6800 I was using 1750x faster than your 5-series hardware.

By changing your algorithms to be a scalar lazy evaluation system you can find that sweet spot. With a bit of effort you can dynamically scale from totally static to totally dynamic (or as near as necessary) and you can measure peformance accordingly.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
idreamlovey
idreamlovey
I have 3.4 lacs vertices and 2.2 lacs triangle faces spread over 12.8km by 12.8km divided into 50 by 50 grids. So one large static vertex buffer is not possible and my device is created with pure hardware not using Software vertex processing. Here i can do one thing is that increase the grid size and put static vertex buffer in each grids. But i want to render at least 1 km distance with three level of detail and i have to render atleast 40000-50000 triangles for good visuals and details. Since i am using splatting for ground too. Hence i can't increase my 256 by 256 grids more than 512 by 512. So i am thinking of too increase grid size to 512 by 512. Now i have to make minimum 2 vb and 30-40 ib switches and more than 7-10 vb and 120-140 ib switches in worst case(At the corner of grids viewing towards diagonal way of square terrain).
Tell me is it really good for me to make vertices static for each grid. Cause changing my system means changing whole things. Since i m working alone and it took more than a year to know all these things. It will make me not only to change my App but also to change my Max exporter, Mesh optimizer and octree converter. I have two books but they are basically for indoor not outdoor. So i want to know the possible ways to improve my existing engine...Do multithreading can be the solution...PLease give me all available options otherwise i have to drop my master degree course...Cause my program incharge are already gets annoyed of my short attendence....
idreamlovey
idreamlovey
Help me out guys......i am loosing my hair...i went to the doctor and he said its not a malfunction nutrition problem but its a problem with my malfunction ideas that keeps circulating in my brain.....
Gage64
Gage64
You don't have to have that many vertex/index buffers. You can store vertex/index data for several terrain chunks in one index/vertex buffer, and this will avoid many state changes. Note that I'm not saying that you should create one huge buffer, but several buffers of a good size. What's a good size? That depends on your video card, but there are some papers on ATI's or nVidia's site that give some recommendations (like this one).

To make this easier, you can have a class like VertexBufferFactory, and whenever you ask it to create a vertex buffer, it will check if a buffer with the same vertex format has been created. If it has, and it has room to hold the new vertices, it will simply return this buffer instead of creating a new one. There are some more details to it, but you can probably find more info on this online.

BTW, when using dynamic vertex/index buffers, make sure you follow Microsoft's guidelines.

idreamlovey
idreamlovey
Quote:
Original post by Gage64
You don't have to have that many vertex/index buffers. You can store vertex/index data for several terrain chunks in one index/vertex buffer, and this will avoid many state changes. Note that I'm not saying that you should create one huge buffer, but several buffers of a good size. What's a good size? That depends on your video card, but there are some papers on ATI's or nVidia's site that give some recommendations (like this one).


Thnx Buddy that one is really a great link. i print out them. It solved lots of things that keeps bugging me. It has given a detailed information. Thnx once again.
Quote:

To make this easier, you can have a class like VertexBufferFactory, and whenever you ask it to create a vertex buffer, it will check if a buffer with the same vertex format has been created. If it has, and it has room to hold the new vertices, it will simply return this buffer instead of creating a new one. There are some more details to it, but you can probably find more info on this online.

BTW, when using dynamic vertex/index buffers, make sure you follow Microsoft's guidelines.


yes i am following those. I have CVertexCache class which is working in the same way given in the microsoft optimization guidelines.
ET3D
ET3D
Having checked the web to find out that 'lacs' means 100,000, I understand that you have 340,000 vertices, which is not all that much. If that's the number (though from your other figures, it might not be), then I don't see a problem with a static buffer.
idreamlovey
idreamlovey
One more thing i just get an idea that i keeps loading the texture into AGP using D3DPOOL_DEFAULT and meanwhile i keeps calculating the size of texture passed to the AGB. And there is a threshold, the limit of total texture memory in AGP. Reaching that threshold i will starts loading the texture using D3DPOOL_MANAGED. Am i thinking good on it. Note that vertex and index data size is already precalculated.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.