Decreasing fps after buffer operation

In my application, I’m using an offscreen buffer which has 12 display regions (6 in 3d and 6 in 2d where I put texture) and 6 cameras for purpose of shading analysis.

sea_buffer = self.base.graphicsEngine.make_output(self.base.pipe, 'sea_buffer', 100, fb_prop, win_prop,
                                                              1)
display_regions = []

display_regions.append(
            SeaRegion(self.base, sea_buffer, 'FRONT', (0.0, 0.33, 0.5, 1.0), (0, 0, 0), [0, 2]))  # axis
        display_regions.append(SeaRegion(self.base, sea_buffer, 'LEFT', (0.33, 0.66, 0.5, 1.0), (90, 0, 0), [1, 2]))
        display_regions.append(SeaRegion(self.base, sea_buffer, 'RIGHT', (0.66, 1.0, 0.5, 1.0), (-90, 0, 0), [1, 2]))
        display_regions.append(SeaRegion(self.base, sea_buffer, 'TOP', (0.0, 0.33, 0.0, 0.5), (0, 90, 0), [0, 1]))
        display_regions.append(SeaRegion(self.base, sea_buffer, 'BACK', (0.33, 0.66, 0.0, 0.5), (180, 0, 0), [0, 2]))
        display_regions.append(SeaRegion(self.base, sea_buffer, 'BOTTOM', (0.66, 1.0, 0.0, 0.5), (0, -90, 0), [0, 1]))

class SeaRegion:
    def __init__(self, base, buffer, res, hpr):
        self.base = base
        self.texture = None

      self.camera = Camera(name)
        lens = PerspectiveLens()
        lens.setFov(92)
        lens.setNear(2)

      self.camera.setLens(lens)
        self.cam = NodePath(self.camera)
        self.cam.reparentTo(self.base.camera)
        self.cam.setHpr(hpr)

      self.region = buffer.makeDisplayRegion(res)
        self.region.setCamera(self.cam)

      cam2d = NodePath(Camera('cam2d'))
        lens = OrthographicLens()
        lens.setFilmSize(2, 2)
        lens.setNearFar(-1000, 1000)
        cam2d.node().setLens(lens)

      self.render2d = NodePath('myRender2d')
        self.render2d.setDepthTest(False)
        self.render2d.setDepthWrite(False)
        cam2d.reparentTo(self.render2d)
        region2d = buffer.makeDisplayRegion(res)
        region2d.setSort(20)
        region2d.setCamera(cam2d)

When I start the application I have 1ms on frame-rate-meter-milliseconds in my application window and everything looks ok.

On a model, I have a grid of points where I set the cameras from the buffer (for this example 7000 points). I’m getting a screenshot in each location and do some calculations. After this operation, I’m removing buffer by base.graphicsEngine.removeWindow(sea_buffer)

The problem is that after analysis my frame-rate-meter-milliseconds increases to 40ms in application window O_o. The strangest thing is, that after removing these lines:

        for region in display_regions:
            region.cam.setPos(self.base.render, point.p)
            region.cam.setHpr(self.base.render, region.hpr)

frame-rate-meter-milliseconds does not change after the analysis.

After positioning camera I’m doing base.graphicsEngine.renderFrame() to refresh the image in buffer

That is a bug (version 1.10.0) with cache in transforms.

Adding transform-cache false in config.prc solves the problem

ps. Thanks rdb for solution and help!

Thank you for finding this; the problem had to do with Panda not shrinking the cache back down after a lot of transforms were allocated in a single frame, so it would forever keep a really big transform cache around.

I have checked in a fix now.