0

GL で gpgpu 計算を行っており、フレームバッファから結果を読み取りたいと考えています。私のフレームバッファ テクスチャは論理的には 1D 配列ですが、より大きな領域を持つために 2D にしました。ここで、フレームバッファテクスチャ内の任意のピクセルから任意の長さで読み取りたいと考えています。

これは、すべての計算が GPU 側で既に行われていることを意味し、テクスチャの境界を越えて位置合わせできる特定のデータを CPU に渡すだけで済みます。

これは可能ですか?はいの場合、画像全体よりも遅い/速いのでglReadPixels、必要なものを切り取りますか?

編集 もちろん、OpenCL/CUDAについては知っていますが、(ほぼ)すべてのプラットフォームでプログラムをそのまま実行したいので、それらは望ましくありません。

また、glReadPixels が非常に遅いことも知っています。その理由の 1 つは、必要のない機能 (2D での操作) を提供している可能性があるためです。したがって、より高速な、より基本的な機能を求めました。

4

2 に答える 2

2

Reading the whole framebuffer with glReadPixels just to discard it all except for a few pixels/lines would be grossly inefficient. But glReadPixels lets you specify a rect within the framebuffer, so why not just restrict it to fetching the few rows of interest ? So you maybe end up fetching some extra data at the start and end of the first and last lines fetched, but I suspect the overhead of that is minimal compared with making multiple calls.

Possibly writing your data to the framebuffer in tiles and/or using Morton order might help structure it so a tighter bounding box can be be found and the extra data retrieved minimised.

于 2011-08-03T23:20:00.280 に答える
1

ピクセル バッファー オブジェクト (PBO) を使用してピクセル データをフレームバッファーから PBO に転送し、 を使用glMapBufferARBしてデータを直接読み取ることができます。

http://www.songho.ca/opengl/gl_pbo.html

于 2011-08-03T20:53:58.043 に答える