FeizCNU
FeizCNU

Reputation: 73

The Internal format of OpenGL CUDA interop

I use CUDA surface Reference to write and read OpenGL 3D Texture fllowing this post Write to 3D OpenGL textures in CUDA ... .

There is a problem confused me. For example,this function

glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY, volDim_.x, volDim_.y
        , volDim_.z, 0, GL_LUMINANCE, getVolumeTypeGL(vol), vol->getData());

the third parameter is internal format.

In CUDA kernel,I need write or read the texture,like below code,

ElementType v;
surf3Dread(&v,surfaceRef,x*sizeof(ElementType),y,z);
surf3Dwrite(&v,surfaceRef,x*sizeof(ElementType),y,z);

I don't know how to match Internal Format with ElementType. Example

glTexImage3D(GL_TEXTURE_3D, 0, GL_INTENSITY, volDim_.x, volDim_.y
    , volDim_.z, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, vol->getData());

In host memory,the type of volume data type is unsigned char. Which ElementType shuld I choose?

uchar4 or uchar ,or float

My some code could find in here My GitHub

UPDATE:

I have solved this problem.

GL_RGBA32F ---- float4

GL_RGBA ---- uchar4

GL_INTENSITY -- uchar

Upvotes: 3

Views: 261

Answers (1)

FeizCNU
FeizCNU

Reputation: 73

If the internal format of glTeximage3D is GL_INTENSITY, the element type of surf3Dread or surf3Dwrite is unsigned char. GL_RGBA32F matches float4 and GL_RGBA matches uchar4.

Upvotes: 2

Related Questions