Hey everybody, I need some help with some code, I don't quite understand why it behaves the way it does.
The (develop) code is here:
https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/rendering/opengl/LwjglRenderingProcess.java#L289
The lines of interest are 289-297.What seems to be happening here is that data is obtained from a GPU buffer and placed in the current one of two PBOs. Then the PBOs are swapped so that the current PBO is the other one. Finally a ByteBuffer is filled with the content of the new PBO.
This doesn't make sense to me, as it seems that the data read back in is at least one frame old, from the previous time the method was called when the new PBO was filled. As such, I tried to move the if-else block below the ByteBuffer pixels statement or above the readBackPBOCurrent.copyFromFBO statement, so that the copyFromFBO() and the readBackPixels() calls could be consecutive.
Well, in both cases the frame rate in my test setup drops from 30fps to 22fps. And I have no idea why. I mean, perhaps the code as it stands represents a bug and the frame rate drop is appropriate as all of a sudden some other parts of the code is working appropriately.
Thoughts?
The (develop) code is here:
https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/rendering/opengl/LwjglRenderingProcess.java#L289
The lines of interest are 289-297.What seems to be happening here is that data is obtained from a GPU buffer and placed in the current one of two PBOs. Then the PBOs are swapped so that the current PBO is the other one. Finally a ByteBuffer is filled with the content of the new PBO.
This doesn't make sense to me, as it seems that the data read back in is at least one frame old, from the previous time the method was called when the new PBO was filled. As such, I tried to move the if-else block below the ByteBuffer pixels statement or above the readBackPBOCurrent.copyFromFBO statement, so that the copyFromFBO() and the readBackPixels() calls could be consecutive.
Well, in both cases the frame rate in my test setup drops from 30fps to 22fps. And I have no idea why. I mean, perhaps the code as it stands represents a bug and the frame rate drop is appropriate as all of a sudden some other parts of the code is working appropriately.
Thoughts?