memcpy of cvertexarrays in map rendering

memcpy of cvertexarrays in map rendering

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

memcpy of cvertexarrays in map rendering

Post by Beherith »

Since my profiling is always showing dodrawgroundrow as a large hit, especially with high viewradii, I tried to optimize by storing the finished vertex array for each bigtex square by memcpy-ing the striparrays and drawarrays.

But now it seems that its memcpy hogging the cpu, and Im hardly getting a noticeable fps boost from this when the camera is static (which is when I use stored vertex arrays instead of making new ones)

:(
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: memcpy of cvertexarrays in map rendering

Post by jK »

That happens quite often and proves that profiling changes is very important. I dismissed many of those tweaking attempts myself ;)

PS: the only way to speedup the SMF renderer is to rewrite it.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: memcpy of cvertexarrays in map rendering

Post by Das Bruce »

Related tangent, did that improved map lod get implemented?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: memcpy of cvertexarrays in map rendering

Post by smoth »

no, roam is on ice untill someone unfucks the shadows shader IIRC
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: memcpy of cvertexarrays in map rendering

Post by Beherith »

But its just so wierd, that it hardly gives any boost. I wish I could just pass the pointers to the stored vertexarrays to the Drawvertexarray function. But somewhere after draw, the array gets freed, and I havent been able to pinpoint it.

I find it so hard to believe that a straight copy is not faster than doing the lookup of each vertexes height from the heightmap in a near random fashion. :(

Code: Select all

inline void CVertexArray::clone(CVertexArray * from){
        delete drawArray;
        delete stripArray;
        drawArray= new float[(from->drawArraySize - from->drawArray)];
        memcpy(    drawArray,from->drawArray,(from->drawArrayPos+1 - from->drawArray)*sizeof(float));
        
        drawArraySize=drawArray +(from->drawArraySize - from->drawArray);
        drawArrayPos=drawArray +(from->drawArrayPos - from->drawArray);
        
        stripArray= new unsigned int[(from->stripArraySize - from->stripArray)];
        memcpy(stripArray,from->stripArray,(from->stripArrayPos+1 - from->stripArray)*sizeof(unsigned int));
        stripArraySize=stripArray +(from->stripArraySize - from->stripArray);
        stripArrayPos=stripArray +(from->stripArrayPos - from->stripArray);
        maxVertices=from->maxVertices;
}
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: memcpy of cvertexarrays in map rendering

Post by Beherith »

Thanks for the inspiriation jK, I always value your input very highly.

Ah, It seems that I was gpu fill rate limited on the straight back-to-back tests with only map rendering.

With an additional 500 aks on screen, the (total) performance gain is about 6%. Which is not much, but doesnt look bad. Ill see if adding this for shadow vertex arrays as well helps ( since profiling shows that for some reason, dogroundshadowlod takes twice the cpu time of the normal dogroundrow)

No optimiziation: (row in question is highlighted)
Image

With memcpy and reuse of existing vertex arrays:
Image

So its 9% vs 3%. Me happy :D
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: memcpy of cvertexarrays in map rendering

Post by zerver »

Nice. Any problems with terrain deformation + static camera?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: memcpy of cvertexarrays in map rendering

Post by Beherith »

Havent put in hooks for that yet, because there is a wierd flickering issue I have to overcome first.
Post Reply

Return to “Engine”