Hey all
I’m trying to register a texture in CUDA, so I can output the result of my raytracing, but CUDA is giving me an “unspecified driver error”, which to be honest doesn’t really help me pinpoint the error. :p
The code that fails is
GLint tex;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT,
&tex);
CHECK_FOR_GL_ERROR();
cudaGraphicsResource *backBuffer;
cudaGraphicsGLRegisterImage(&backBuffer, tex, GL_TEXTURE_2D, cudaGraphicsMapFlagsWriteDiscard);
CHECK_FOR_CUDA_ERROR();
cudaGraphicsMapResources(1, &backBuffer, 0);
CHECK_FOR_CUDA_ERROR();
size_t bytes;
uchar4* pixels;
cudaGraphicsResourceGetMappedPointer((void**)&pixels, &bytes,
backBuffer);
CHECK_FOR_CUDA_ERROR(); // CUDA ERROR: unspecified driver error
The texture that I’m trying to register is bound as a color texture in an fbo which itself is bound.
I have tried unbinding the fbo and binding the texture, but got the same error. I’ve checked that I am indeed using unsigned char with RGBA format. The texture is created with 0 border, so that’s not it.
I’m hoping someone in here can spot the error or perhaps tell me an easier/different way to write my results into an OpenGL texture. Right now I’m starting to consider using a pbo and copy from it instead.
/papaboo