[FIXED] 1.5.0 RC: strange slowdowns when looping animation

I am using Panda as it is after default installation, no any tweaks or anything else. It runs in OpenGL mode. I still don’t know how to switch to DirectX. I can run PStats, but since I am just a beginner, I don’t know how to provide with the required information. If you tell me what do to and how to do, I can do it quickly :slight_smile:

To switch to DirectX mode, locate your Config.prc file and edit it to change:
load-display pandagl
to:
load-display pandadx9
or:
load-display pandadx8

To use PStats, fire it up as described in the manual or as illustrated in the sample program, then compare the output between the two builds. Look for bands of color that are much wider in one build than in the other. Drill down into a band of color by double-clicking on it to subdivide it into detail categories–you can do this repeatedly if necessary until there are no more detail categories. (Go back up the the previous level by double-clicking on the white graph background.)

You can change the vertical scale of the graph as needed by clicking in the graph itself and dragging up or and.

When you find something suspiciously different between the builds, get to the lowest level that still shows the difference, then take a screenshot.

David

I changed Panda’s mode into DX9. Somehow I can’t set VSync off in DX9 mode. I have changed it in drivers but Panda runs at 60 fps all the time, doesn’t matter if the VSync is on or off… :confused: Do you know how to set it off in Panda configs?
Now I will try PStats.

Put:
sync-video 0
in your Config.prc file.

David

I made a few screenshots where I saw the difference.
Here are some screens for Panda 2008.02.27:
General view, Panda 2008.02.27:

General view, Panda 2008.02.28:

Cull view, Panda 2008.02.27:

Cull view, Panda 2008.02.28:

Window1 view, Panda 2008.02.27:

Window1 view, Panda 2008.02.28:

  • view, Panda 2008.02.27:
  • view, Panda 2008.02.28:

    Animation:Ralph view, Panda 2008.02.27:

    Animation:Ralph view, Panda 2008.02.28:

What concerns DX9 mode, yes, the problem is still there.
Panda 2008.02.27 runs at 1010 fps average, Panda 2008.02.28 - 370-390 fps.

I changed configs using loadPrcFileData module, it is the same as modifying Config.prc itself, as far as I have learned. The updated code I used now is following (posted it here in order to prevent any mistakes on my side):

from direct.actor.Actor import Actor
from direct.showbase.DirectObject import DirectObject
from direct.task.Task import Task
from pandac.PandaModules import loadPrcFileData

loadPrcFileData("", "load-display pandadx9")
loadPrcFileData("", "win-size 800 600")
loadPrcFileData("", "fullscreen 0")
loadPrcFileData("", "sync-video 0")
loadPrcFileData("", "show-frame-rate-meter 1")

#loadPrcFileData("", "even-animation 1")
#loadPrcFileData("", "interpolate-frames 1")

loadPrcFileData("", "want-pstats 1")

import direct.directbase.DirectStart

modelsDir = "Roaming-Ralph/models/"

class World(DirectObject):

    def __init__(self):
        self.actor = Actor(modelsDir+"ralph",
                                     {"run" : modelsDir+"ralph-run"})
        self.actor.reparentTo(render)
        self.actor.setScale(.3)

        self.keyMap = {"animate" : 1}
        self.accept("a", self.setKey, ["animate", 1])
        self.accept("z", self.setKey, ["animate", 0])

        self.animationLoops = 0

        self.actor.ls()
        self.actor.analyze()

        taskMgr.add(self.updateWorld, "updateWorldTask")

    def setKey(self, key, value):
        self.keyMap[key] = value

    def updateWorld(self, task):
        if self.keyMap["animate"] and not self.animationLoops:
            self.actor.loop("run")
            self.animationLoops = 1
        if not self.keyMap["animate"]:
            self.actor.stop()
            self.animationLoops = 0

        base.camera.setPos(10, 10, 10)
        base.camera.lookAt(self.actor)

        return Task.cont

w = World()

run()

Hmm. Your PStats seems to show that, in the 2-28 build, the animation is being computed every single frame, while in the 2-27 build, it is only being computed 24 times a second (which is the behavior I would expect).

It is as if either even-animation or interpolate-frames were defaulting on in the 2-28 build.

You said that turning these options on affects your frame rate for the worse (which I would expect). Does it do so for both builds? What happens if you explicitly turn them off (set them to zero)?

David

Setting them to zeros doesn’t change anything: old build is fast, new one is slow.
Setting “interpolate-frames 1” doesn’t affect any build.
Setting “even-animation 1” doesn’t affect the new slower build (it remains as slow as before), but the old build becomes as slow as the new one.
It looks like even-animation is always set to 1 in the new build, doesn’t matter what is in config.
This picture is the same for both OpenGL and DirectX.

This is indeed very strange. It might be that some code inside Panda is failing to detect that the animation hasn’t changed for some reason, but there don’t seem to be any relevant changes between the two source trees.

It doesn’t exhibit this behavior in my own build, from the CVS trunk. Josh, can you reproduce this in your own build?

David

While we’re waiting for Josh to weigh in, I’d like to pursue another line. You said:

That doesn’t seem right. It should have exactly the effect on performance as “even-animation 1”. Are you sure you didn’t spell it wrong somehow?

Try slowing your animation way, way down when you play it, like this:

self.actor.setPlayRate(0.01, "run")
self.actor.loop("run")

This should make an enormous visual difference between interpolate-frames being off or on: when it is off, you’ll see Ralph visually pop to each frame; when it is on, he’ll just be moving smoothly in slow motion.

Slowing the animation down should also exaggerate the difference between the builds, and make the difference particularly obvious in pstats.

Still having no luck reproducing the problem here. It seems to correctly recompute the animation only when it has actually changed. We have had some bugs in this code in the past, but I had thought they were fixed, so I’m still scratching my head.

David

I just tested it with my laptop: no difference between the two versions. OpenGL gives 440fps when running in both versions, DX9 gives 575fps with both versions.

Also, don’t forget that I tested these on my office computer a few days ago, same result.

I looked at the diffs on that day. There were a few modifications - some of them are mine, but mine are in areas of the code that we’re not even using, such as buffers and shaders. There are also David’s GeomMunger changes, but those don’t seem to have made any difference for me.

David,

I don’t see any performance impact of “interpolate-frames 1” on any build. They both run with the same speed as with “interpolate-frames 0” (I have just checked it again right now). If there is a difference, it seems to be very-very small.

Also, I slowed Ralph’s animation as you described. Panda 2008.02.27 works as you said: with “interpolate-frames 0” Ralph pops to each frame, while with “interpolate-frames 1” he is in slow motion.
What concerns Panda 2008.02.28, “interpolate-frames 1” doesn’t make any difference: Ralph still pops up to each frame, no slow motion.

Edit: I forgot to mention, that I use localized version of Windows XP SP2 Home Ed, Russian. Anyway, all paths to the Panda directory contain only English letters. I don’t know if this is important…

I use ATI card. Could this be somehow related to infamous ATI drivers? What graphics cards do you use?

My desktop has a radeon x700, my laptop has a radeon mobility 9600. Both have recent catalyst drivers.

ATI is very bad!
I bought an ATI T.V. wonder and it screwed up everything,
until I uninstalled it.
ATI is good if you need an insurance excuse for a house fire.
I still haven’t tried that 2008.02.28 build though,
so I’ll just let you guys get back to the bug solving.

It doesn’t seem to be related to your drivers at this point, or to OpenGL vs. DirectX. The best I can figure is there’s still some bug deep in the animation code that reveals itself intermittently, and you just happen to be getting it in the recent builds and not in the older builds, but neither Josh nor I happen to be getting it.

I know it seems improbable, but nothing else even seems possible.

I have to go out of town for a couple of days, but I’ll throw my head into it when I get back.

David

Thank you, David! If I can do anything to help, just let me know :slight_smile:

I have just checked the released Panda3D 1.5.0. The problem is still there.

This is what I want to investigate more closely now:

So, with interpolate-frames 1, he pops to each frame, and yet pstats shows that it is computing each animation frame every time? Very, very strange.

Can you repeat this experiment to confirm it?

Also, check the frameBlendFlag:

print self.actor.getPartBundle('modelRoot').getFrameBlendFlag()

This should be “1” when interpolate-frames is 1, and “0” when interpolate-frames is 0. Is this the case?

And interpolate-frames really has no visible effect on the animation, and no effect on reported frame rate, with the recent builds?

David