__host__cudaError_t cudaGraphicsGLRegisterImage ( cudaGraphicsResource** resource, GLuint image, GLenum target, unsigned int flags )
Register an OpenGL texture or renderbuffer object.
Parameters
resource
- Pointer to the returned object handle
image
- name of texture or renderbuffer object to be registered
target
- Identifies the type of object specified by image
flags
- Register flags
Returns
cudaSuccess, cudaErrorInvalidDevice, cudaErrorInvalidValue, cudaErrorInvalidResourceHandle, cudaErrorUnknown
Description
Registers the texture or renderbuffer object specified by image for access by CUDA. A handle to the registered object is returned as resource.
target must match the type of the object, and must be one of GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_3D, GL_TEXTURE_2D_ARRAY, or GL_RENDERBUFFER.
The register flags flags specify the intended usage, as follows:
cudaGraphicsRegisterFlagsNone: Specifies no hints about how this resource will be used. It is therefore assumed that this resource will be read from and written to by CUDA. This is the default value.
-
cudaGraphicsRegisterFlagsReadOnly: Specifies that CUDA will not write to this resource.
-
cudaGraphicsRegisterFlagsWriteDiscard: Specifies that CUDA will not read from this resource and will write over the entire contents of the resource, so none of the data previously stored in the resource will be preserved.
-
cudaGraphicsRegisterFlagsSurfaceLoadStore: Specifies that CUDA will bind this resource to a surface reference.
-
cudaGraphicsRegisterFlagsTextureGather: Specifies that CUDA will perform texture gather operations on this resource.
The following image formats are supported. For brevity's sake, the list is abbreviated. For ex., {GL_R, GL_RG} X {8, 16} would expand to the following 4 formats {GL_R8, GL_R16, GL_RG8, GL_RG16} :
-
GL_RED, GL_RG, GL_RGBA, GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY
-
{GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
-
{GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
The following image classes are currently disallowed:
-
Textures with borders
-
Multisampled renderbuffers
Note:
Note that this function may also return error codes from previous, asynchronous launches.
See also:
cudaGraphicsUnregisterResource, cudaGraphicsMapResources, cudaGraphicsSubResourceGetMappedArray, cuGraphicsGLRegisterImage
__host__ cudaError_t cudaGraphicsGLRegisterImage(cudaGraphicsResource**资源,GLuint图像,GLenum目标,无符号整数标志)
注册 OpenGL 纹理或渲染缓冲区对象。
参数
资源
- 指向返回对象句柄的指针
图片 - 要注册的纹理或渲染缓冲区对象的名称
目标 - 识别图像指定的对象类型
旗帜 - 注册标志
退货
cudaSuccess,cudaErrorInvalidDevice,cudaErrorInvalidValue,cudaErrorInvalidResourceHandle,cudaErrorUnknown
描述
注册由图像指定的纹理或渲染缓冲区对象以供 CUDA 访问。注册对象的句柄作为资源返回。
target必须与对象的类型匹配,并且必须是 GL_TEXTURE_2D、GL_TEXTURE_RECTANGLE、GL_TEXTURE_CUBE_MAP、GL_TEXTURE_3D、GL_TEXTURE_2D_ARRAY 或 GL_RENDERBUFFER 之一。
寄存器标志标志指定预期用途,如下所示:
cudaGraphicsRegisterFlagsNone:不指定有关如何使用此资源的提示。因此,假定该资源将由 CUDA 读取和写入。这是默认值。
cudaGraphicsRegisterFlagsReadOnly:指定 CUDA 不会写入此资源。
cudaGraphicsRegisterFlagsWriteDiscard:指定 CUDA 不会从该资源中读取,而是会覆盖该资源的全部内容,因此不会保留之前存储在该资源中的任何数据。
cudaGraphicsRegisterFlagsSurfaceLoadStore:指定 CUDA 将此资源绑定到表面引用。
cudaGraphicsRegisterFlagsTextureGather:指定 CUDA 将对此资源执行纹理收集操作。
支持以下图像格式。为简洁起见,该列表是缩写的。例如,{GL_R, GL_RG} X {8, 16} 将扩展为以下 4 种格式 {GL_R8, GL_R16, GL_RG8, GL_RG16} :
GL_RED、GL_RG、GL_RGBA、GL_LUMINANCE、GL_ALPHA、GL_LUMINANCE_ALPHA、GL_INTENSITY
{GL_R, GL_RG, GL_RGBA} X {8, 16, 16F, 32F, 8UI, 16UI, 32UI, 8I, 16I, 32I}
{GL_LUMINANCE, GL_ALPHA, GL_LUMINANCE_ALPHA, GL_INTENSITY} X {8, 16, 16F_ARB, 32F_ARB, 8UI_EXT, 16UI_EXT, 32UI_EXT, 8I_EXT, 16I_EXT, 32I_EXT}
当前不允许使用以下图像类:
带边框的纹理
多重采样渲染缓冲区
笔记:
请注意,此函数还可能从以前的异步启动返回错误代码。