So my question is:
Why is there no performance boost?
Am I forgetting something?

Thanks in advance for all your replies!

skynet

01-12-2011, 05:56 AM

GL_FLOAT is unlikely the native format of your depthbuffer data...in worst case the driver reads the data back to sysmem, converts it into float and then uploads it into the PBO again.

Try
GL_DEPTH_STENCIL_EXT as format and GL_UNSIGNED_INT_24_8_EXT as type.

Menrix

01-12-2011, 06:08 AM

thx for your reply,

I changed it, but it doesn't seem to have much effect, it is still slow, but faster...

skynet

01-12-2011, 06:37 AM

Try GL_STATIC_DRAW for the PBO.
Additionally post your graphics card type and driver version.
How many milliseconds do glReadPixels() glDrawPixels() take for your framebuffer? How large is the framebuffer?
Consider using ARB_timer_query for the timing.

I probably need to mention that I am doing this restoring several times per frame, not only once.
at the scene i am testing now i do it 9 times 4 read and 5 draw

for 800*600 it takes about 0.04 seconds per frame

I still need to figure out how to use ARB_timer_query.

dukey

01-12-2011, 07:09 AM

I've seen this kind of insanity before in commercial apps. People trying to optimise by savings the scene to ram then restoring it later, failing to realise doing this is very very expensive.

You are better off just drawing the scene again, you can always disable writing to the colour buffer.

Menrix

01-12-2011, 07:20 AM

It's all about screenspace csg, I need 2 Depth Buffers or it simply just won't work!

times in milliseconds:

READ: on 800*600 4 - 7.5 ms
WRITE: on 800*600 4 - 6.5 ms

there were rarely execution times of ~ 10ms for read and write.

shadocko

01-12-2011, 09:04 AM

It seems to me that GL_DYNAMIC_COPY would be more appropriate for buffer usage as you want the GPU to read AND write to it.

By the way, are you doing CSG with concave shapes? If you can decompose your CSG "brushes" as convex shapes, you can do many operations with just 1 depth, 1 stencil, multiple passes and no copy.

Menrix

01-12-2011, 01:32 PM

concave objects can also occur :D
unfortunately decomposing them is rather tricky.

Nevertheless please show me a link to this algorithm.

Dark Photon

01-12-2011, 06:32 PM

what i basically want to do is saving and restoring my depth buffer. ... yeah, why copying the stuff to the cpu, lets leave it on the graphics card. Yeah so i initialized a PBO and did all that with PBO
Yeah, using buffers with good performance can be pretty tricky. Among many other issues, binding's expensive, and it may be in CPU memory... or may be in GPU memory... you just don't know and you can't control it. Argg.... Can't comment on the PBO thing other than that...

...but I would have tried two other options before buffer objects even occurred to me. First, use glBlitFramebuffer with DEPTH_BUFFER_BIT to copy from the depth buffer in one framebuffer to the depthbuffer in another. That target FBO could have a depth buffer that points to either a depth texture or a depth renderbuffer. Assuming std depth buffer format, use DEPTH24_STENCIL8 for the internal format.

Alternatively, use glCopyTexSubImage2D to copy the depth buffer into a depth texture.

Both of those should stay on the GPU (AFAIK).

shadocko

01-13-2011, 02:19 AM

Nevertheless please show me a link to this algorithm.
There's some information about that on OpenCSG's website: http://www.opencsg.org/