AdyAdy
AdyAdy

Reputation: 1028

OpenGL - Can I use texture after querying its data into PBO?

I render into a texture via FBO. I want to copy the texture data into a PBO so I use glGetTexImage. I will use glMapBuffer on this PBO but only in the next frame (or later) so it should not cause a stall.

However, can I use the texture immediately after the glGetTexImage call without causing a stall? Can I bind it to a texture unit and render from it? Can I render to it again via FBO?

Upvotes: 0

Views: 148

Answers (1)

datenwolf
datenwolf

Reputation: 162164

However, can I use the texture immediately after the glGetTexImage call without causing a stall?

That's implementation dependent behavior. It may or may not cause a stall, depending on how the implementation does actual data transfers.

Can I bind it to a texture unit and render from it?

Yes.

Can I render to it again via FBO?

Yes. This however might or might not cause a stall, depending on how the implementation internally deals with data consistency requirements. I.e. before modifying the data, the texture data either must be completely transferred into the PBO, or if the implementation can detect, that the entire thing will get altered (e.g. by issuing a glClear call that matches the attachment of the texture), it might simply orphan the internal data structure and start with a fresh memory region, avoiding that stall.

This is one of those corner cases which are nigh impossible to predict. You'll have to profile the performance and see for yourself. The deadsure way to avoid stalls is to use a fresh texture object.

Upvotes: 2

Related Questions