Shared Buffers

I would like to know, if there is a way to share Z-buffer (with or without stencil) between back buffer and P-buffer? Or even between two P-buffers? Any extensions?

Second problem. I can use a single P-Buffer as the texture (color or depth texture) when I render into back buffer. Can I use the same P-buffer in two textures (one texture for color and one for depth/stencil)? I can copy P-Buffer to the textures, but I don’t think this is the fastest way.

Arek Waliszewski

[This message has been edited by arsil (edited 09-17-2002).]

[This message has been edited by arsil (edited 09-17-2002).]

  1. Why on earth would you want to share the Z buffer? To save memory?? If you’re so worried about adding one more 32bit texture to video memory, you’d better get a new video card… And if your target is a lower-end machine, you shouldn’t even be using PBuffers, because such a machine is not likely to support them.

  2. Do you mean to use the same PBuffer for two textures? Well, either way, my answer is, “Not that I know of, and VERY doubtful.”

[This message has been edited by pATChes11 (edited 09-17-2002).]

patches… think about it.
you render some informative data into a first buffer, and get there in the scene-depth. then you want to draw f.e. the shadows into another buffer. you do that with stencilbuffering. for this you need the depthvalues at each pixel. if you can share the depthbuffer, you can use it directly. else, you have to rerender, or copy the values… both is stupid…

Originally posted by pATChes11:
1. Why on earth would you want to share the Z buffer? To save memory??
2. Do you mean to use the same PBuffer for two textures?

  1. to reuse depth data written in previous passes, without this early Z culling will be wasted.
  2. WGL_NV_render_depth_texture allows this.

arsil, I suggest reading http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/007256-2.html

You need to preserve the Z (and possibly stencil) buffers for a number of techniques that involve first rendering Z, and then starting to render “other stuff”.

Luckily, you can do this by creating pbuffers that support double-buffering; there you have the front and back buffers available to you. Yes, it’s a total hack insofaras you’re not actually describing the semantics you want, but using something that just happens to be close enough. But it works.

Well, except for on the Intel Brookdale-G (i845). It doesn’t support double-buffered pbuffers :frowning:

I know, I can do some tricks with double buffered P-buffers…(but I have only 2 buffers in this situation) I was just wondering if there is a faster way (using double buffered P-buffers requires final copy to back buffer). And I think, that sharing Z-buffer is an essential “thing” in many algorithms.

Originally posted by arsil:
I know, I can do some tricks with double buffered P-buffers…(but I have only 2 buffers in this situation)

No, theoretically you can have more then 2: front_left, front_right, back_left, back_right, aux0, aux1, … .
Spec does allows this, but I don’t know if it actually works in drivers.

And I think, that sharing Z-buffer is an essential “thing” in many algorithms

GL2_buffer_object could solve this problem nicely…