Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Weird question.Draw calls vs instances

Author
Message
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 12th Feb 2014 15:31 Edited at: 12th Feb 2014 15:35
Hi! I spent some time to write code for draw call optimization.Wi all know that more draw calls --> less fps we have.So idea is simple - attach group of objects in to one mesh if they have same textures and shaders.
But today I made this small test: 1000 objects.One test I use object instances - in second attach 6 objects to one.And fps is almost the same!! 1000 draw calls and 143 draw calls have the same fps....What the matter??
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 12th Feb 2014 15:50 Edited at: 12th Feb 2014 15:53
Were your 6 objects added as limbs to the main object? Or was the entire (combined) object one big limb? If they were attached as limbs then I believe you are still performing 1000 draw calls. If they were indeed limbs, try running your combined object(s) through the following function which will combine them into one:

Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 12th Feb 2014 16:03
yes I used add vertex data command.Also if you use add limb command the draw call count will be the same (1 limb=1 draw call)
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 13th Feb 2014 01:53
How do you record the number of draw calls?
Didn't know that was possible from DBPro.


"Why do programmers get Halloween and Christmas mixed up?"
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 13th Feb 2014 02:04 Edited at: 13th Feb 2014 02:06
Quote: "How do you record the number of draw calls?"

drawCalls = statistic(5)



I know it's not much, but it does look like you gain a ~20% increase in FPS with the method on the left.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 13th Feb 2014 11:44
Quote: "I know it's not much, but it does look like you gain a ~20% increase in FPS with the method on the left."

yeah its not bad))) I just have opinion that the difference will be like 80%. I think that instanced objects renders different way then normal objects...Anyway its like I can use instances for grass,tress and so on.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Feb 2014 14:05
In my experience instanced objects give no improvement in fps - but they do require a lot less memory and are much faster to create.



Powered by Free Banners
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 13th Feb 2014 20:27
Quote: "In my experience instanced objects give no improvement in fps - but they do require a lot less memory and are much faster to create."
Its about 5% percent faster. Is any other way to attach two objects in one?
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 13th Feb 2014 21:23
Sorry, I don't have DBP here on my computer at work so it'll be semi-psuedodbp code. I have had some success doing something like the following as long as the objects are the same FVF:

Make Mesh 10 from object 100
make Mesh 11 from Object 101
make memblock 1 from mesh 10
make memblock 2 from mesh 11

delete object 100
delete object 101

make memblock 3 with a size of memblock size(1) + memblock size(2) -12
copy memblock 1 from 0 position into memblock 3 at 0 position
copy memblock 2 from 12 position into memblock 3 at memblock size(1) position.

make mesh 12 from memblock 3
make object from mesh 12

delete mesh 10
delete mesh 11
delete mesh 12

delete memblock 1
delete memblock 2
delete memblock 3


I will check the actual math when I get home tonight, but doing something like this will get it into one object. I think there are also some IanM's Util commands that could simplify it. But I don't know what they are off the top of my head.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 13th Feb 2014 22:00
@zeroSlave is it faster then add meshdata? looks interesting.. one more thing: when you attach some objects into one - ther must be way hide/unhide them.I just move vertex to -99999,-999999,-99999 to do this.But it is to heavy to DBPro.Must be way to hide polygons or smthing like this
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 13th Feb 2014 23:02
I'm not sure. I haven't messed much with Add meshdata. I have only used the above method. I'm not sure about hiding faces. I would probably just keep a copy of an object in memory, hide it, then have a function that remakes objects when needed.

I just noticed that you've got roughly 2,300,000 triangles being displayed. That is quite a bit of tris to be doing a lot with... Could the objects be optimized any more before importing into DBP? That would be my first step towards a higher FPS.

Making and editing objects that large, would be pretty intensive for any function.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 14th Feb 2014 08:10 Edited at: 14th Feb 2014 08:11
@zeroSlave yes 2,300,000 polys is too much. I just use it to get maximum load of my GPU for test(nvidia gtx580). Anyway add meshdata or add memblock functions works fine if mesh is static.You load it - convert to single object - and get FPS increase.Simple.But here is the problem - for example you have couple of trees .You convert them into single object but when player gets far enough from one of them you need to hide one of tree.For this I just move polys of it far far away.Camera dont render them if polys are further then camera range.The problem is that one tree have 700 polys or more and it is too hard for DBPro to move them each time I want to hide something.I havent find any solution for this yet =((
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Feb 2014 13:23
Quote: "but when player gets far enough from one of them you need to hide one of tree.For this I just move polys of it far far away.Camera dont render them if polys are further then camera range"


Why is it too hard to simply hide or exclude them? Exclude object on/off is better than simply hiding them. Also, why is simply moving an object too hard for DBPro? Moving an object out of range is a trivial task using position object surely? However, I'd exclude them though instead.



Powered by Free Banners
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 14th Feb 2014 14:34 Edited at: 14th Feb 2014 14:34
Quote: "Why is it too hard to simply hide or exclude them?"
It is easy when you use normal objects but I speak about multiple objects which are attached into one.You load for eaxample 10 tree models - then you use vertexdata commands to make one single object from 10.I draw image I hope t will be easier to understand
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 14th Feb 2014 20:38
I see. Yes, that would be slow.

What happens if you use limbs instead? That would use just one draw call according to a test with an object containing 48 limbs. You could then use limb commands such as exclude limb on/off.



Powered by Free Banners
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Feb 2014 01:56
I'm almost certain each limb requires at least one draw call.
If the limb encompasses more than one mesh (which it probably can't in DBPro though) it would be more than that.

I think it seems like you're trying to over-optimize Brightside_. Is there any particular reason you actually need to do this to get a playable framerate? Or is it just to try to max it out as best as you can for the sake of it? On 90% of today's monitors a frame rate over 60 or 72 is completely irrelevant to the user as the screen won't update faster than that anyway.
In the end I believe modifying vertex data of large meshes for each frame will be slower than just having multiple draw calls. Of course it depends on the ratio.


"Why do programmers get Halloween and Christmas mixed up?"
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 15th Feb 2014 02:39
I would suggest 2d array of chunks of trees. Maybe the array can be 200 meters by 200 meters (sizes relative to your needs). Each tree chunk could be an object with maybe 20 or so trees in it. Do a distance check from the center of the chunk. If it is out of view, hide the chunk instead manipulating the objects. You'd get the benefit of less drawcalls without the overhead of object manipulation each frame.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Feb 2014 11:31
Quote: "I'm almost certain each limb requires at least one draw call."


Not according to the DBPro statistic(5) function. Are you saying that is bugged? If so, how do you know? You could be right though - nothing is guaranteed in DBPro.

Quote: "I think it seems like you're trying to over-optimize Brightside_. "


That was my thought too - but it's still good to know what works and what doesn't.



Powered by Free Banners
Brightside_
12
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 15th Feb 2014 12:53
Quote: "Not according to the DBPro statistic(5) function. Are you saying that is bugged? If so, how do you know? You could be right though - nothing is guaranteed in DBPro."
I have always one drawcall for limb.
Quote: "That was my thought too - but it's still good to know what works and what doesn't."
Anyway its works fine and give you extra fps if you use a lot of static mesh.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Feb 2014 13:08
Quote: "I have always one drawcall for limb."


I guess the model I used was a single boned mesh consisting of animated limbs. Didn't think to check the other case which I guess you're using. Food for thought. I used the "tiny.x" model that comes with the MS DX9 SDK.

Quote: "Anyway its works fine and give you extra fps if you use a lot of static mesh."


That's good to know anyway.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-07 01:54:41
Your offset time is: 2026-07-07 01:54:41