Silly question about optimization

you’re right @normen, I’ll go ahead and create one tonight…



thanks

2 Likes

so I prepared a testCase and surprisingly the fps is at 60 fps (great) and the only difference between the main project and the testcase is that in the testcase:



1- I attach all geoms to a node called parentNode

2- I batch parentNode after all geoms are attached

3- At the end, I attach the parentNode to the rootNode





in the main project (where I’m getting < 20 fps) due to design:



1- I attach the parentNode to the rootNode initially (it’s still empty)

2- I attach all geoms to the parentNode

3- I remove parentNode and detach from parent (rootNode)

4- I batch the parentNode

5- I reattach parentNode to rootNode



could that be a reason for the performance? isn’t it basically the same thing?

@nightwolf911 said:
so I prepared a testCase and surprisingly the fps is at 60 fps (great) and the only difference between the main project and the testcase is that in the testcase:

1- I attach all geoms to a node called parentNode
2- I batch parentNode after all geoms are attached
3- At the end, I attach the parentNode to the rootNode


in the main project (where I'm getting < 20 fps) due to design:

1- I attach the parentNode to the rootNode initially (it's still empty)
2- I attach all geoms to the parentNode
3- I remove parentNode and detach from parent (rootNode)
4- I batch the parentNode
5- I reattach parentNode to rootNode

could that be a reason for the performance? isn't it basically the same thing?


I don't know. Do that in your test case and see. I suspect there is some other difference that you are missing.

ok I dont get it!!! I mimicked the same code in Eclipse to JMP and I get 60 fps in JMP and only 20 fps in Eclipse:SSSSSS

@nightwolf911 said:
ok I dont get it!!!!! I mimicked the same code in Eclipse to JMP and I get 60 fps in JMP and only 20 fps in JMP :SSSSSS


Please edit to replace one of the JMPs so that the above sentence makes sense.

Also, what do you mean by "mimicked"? The exact same code should be able to run in both places... no mimicking required.

sorry about that… you’re right, I am using the SAME CODE and getting different performance.



the only difference I think is that in Eclipse I am using a nightly dated back to March and the JMP I am using a newer one (Can’t remember which) -

can’t update as it cause more problems.



Maybe I should try forking BatchNode

“I get different performance but the only difference is X.”



Then X is the reason. Q.E.D.

@nightwolf911 said:
Maybe I should try forking BatchNode

Please don't.

Well create the amterial only once and reuse it for every object.

→ As sonn as a shader material paramter is cahnged, it cannot be batched iwth another. Also it wont be bached if you load a new one each time.

Just use one in a static field, and see if that helps.

@EmpirePhoenix said:
Well create the amterial only once and reuse it for every object.
-> As sonn as a shader material paramter is cahnged, it cannot be batched iwth another. Also it wont be bached if you load a new one each time.
Just use one in a static field, and see if that helps.

Actually no.
The batchNode is now able to batch geometries that have "similar" materials. Material does not have to be the exact same instance.
But they have to :
- have the same param exactly (texture, or any other param defined in the j3md)
- have the same renderstate.

so basically if you create 300 geoms, and that you assign their material to myMat.clone() or reload the mat each time, they should be batched as one batch that will be assigned with the first found instance of the material.

But, this is only available if you are using latest stable JME version. The nightly from march probably does not have this feature, hence the difference between Garnaout eclipse and JMP setting.
1 Like

oh I didn’t know there was a newer stable past March!! I’ll give it a shot and then repost…



thanks

I’m sorry but this sounds as a really silly question… but I always get hte nightly builds… where can I get the latest stable from? :S

ok I dont get it!!!!! I mimicked the same code in Eclipse to JMP and I get 60 fps in JMP and only 20 fps in Eclipse:SSSSSS
Do you have breakpoints ? Conditional or disabled ?
Remove all your Breakpoints. That can explain your problem with Eclipse.

no I have none, I removed them all… I think the problem is obvious… shown by the high number of vertices in Eclipse compared to JMP I think I need to update my code to the latest stable

“help” → “check for updates”

I need it for Eclipse

You can use the repository on SVN to get the latest revision or any past stable revision from the date.

(You may have to guess how to import the sources or libraries in your project yourself).



http://code.google.com/p/jmonkeyengine/source/checkout

no, just check the stable update in JMP



go to tools/plugins in the “Settings” tab check JMonkeyEngine SDK Stable and uncheck the nightly

http://i.imgur.com/yH0Eg.jpg

doesnt make sense, I updated to the latest nightly (easier) where the batching is up to date.



the fps is still the same low at 20 fps with a very high number of vertices around 6 millions… thats in Eclipse…



same code in JMP updated to the latest nightly gets me 60 fps and 2 milion vertices!!!

Well you must use differnet jme version then.