Host-zero-copy CUDA-to-OpenGL texture transfer via direct image interop. More...
Public Member Functions | |
| void | cleanup () |
| Release all GPU resources (CUDA registration, stream, texture). | |
| void | init (int w, int h) |
| Create (or recreate) the GL texture and CUDA image registration. | |
Public Attributes | |
| int | height = 0 |
| Current texture height in pixels. | |
| GLuint | textureID = 0 |
| OpenGL texture receiving the frame data. | |
| int | width = 0 |
| Current texture width in pixels. | |
Host-zero-copy CUDA-to-OpenGL texture transfer via direct image interop.
Registers the OpenGL texture directly with CUDA (cudaGraphicsGLRegisterImage) so that a cv::cuda::GpuMat can be copied straight into the texture's backing cudaArray with a single device-to-device cudaMemcpy2DToArrayAsync. This removes the intermediate PBO and the per-frame glTexSubImage2D DMA that the old PBO path required, halving the per-frame interop cost.
The copy is issued on a dedicated CUDA stream so it does not serialise with other default-stream work (e.g. the GPU filter chain that produced the GpuMat). A CUDA event orders that copy after the producer's default-stream work, while cudaGraphicsUnmapResources provides the GL↔CUDA synchronisation that subsequent OpenGL draws need.
Definition at line 2446 of file ACMX2/acmx.cpp.
|
inline |
Release all GPU resources (CUDA registration, stream, texture).
Unregisters the texture from CUDA, destroys the upload stream, and deletes the OpenGL texture. Safe to call multiple times—each resource handle is tested for non-zero before deletion and reset to zero / nullptr afterwards.
Definition at line 2542 of file ACMX2/acmx.cpp.
References CHECK_CUDA, and textureID.
Referenced by init(), and ACView::~ACView().
|
inline |
Create (or recreate) the GL texture and CUDA image registration.
Allocates an RGBA8 OpenGL texture of the requested dimensions and registers it with the CUDA runtime via cudaGraphicsGLRegisterImage, which exposes the texture's backing storage as a cudaArray that subsequent update() calls write into directly.
If the uploader was previously initialised, cleanup() is called first so that old resources are released before new ones are created.
| w | Texture width in pixels. |
| h | Texture height in pixels. |
Definition at line 2471 of file ACMX2/acmx.cpp.
References CHECK_CUDA, cleanup(), height, textureID, and width.
Referenced by ACView::load().
| int TextureUploader::height = 0 |
Current texture height in pixels.
Definition at line 2455 of file ACMX2/acmx.cpp.
Referenced by init().
| GLuint TextureUploader::textureID = 0 |
OpenGL texture receiving the frame data.
Definition at line 2448 of file ACMX2/acmx.cpp.
Referenced by cleanup(), ACView::draw(), init(), and ACView::load().
| int TextureUploader::width = 0 |
Current texture width in pixels.
Definition at line 2454 of file ACMX2/acmx.cpp.
Referenced by init().