Update :
I thought something moved between mapping and unmapping would could have explained the errors :D
Anyways look at the code below
CVideoMemoryCUDA* m_videoMemoryCUDA;
m_videoMemoryCUDA= (CVideoMemoryCUDA*)g_videoMemory;
CTextureUpdateCUDA* m_textureUpdateCuda;
m_textureUpdateCuda = (CTextureUpdateCUDA*)textureUpdate;
for (int i = 0; i<3; i++)
{
unsigned char *m_video = NULL;
int *m_indices = NULL;
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(m_videoMemoryCUDA->getVideoTextureWrite(i)));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_video, m_videoMemoryCUDA->getVideoTextureWrite(i)));
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(m_textureUpdateCuda->getBuffer(i)));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_indices, m_textureUpdateCuda->getBuffer(i)));
CUDA_SAFE_CALL(cudaGLUnmapBufferObject(m_textureUpdateCuda->getBuffer(i)));
CUDA_SAFE_CALL(cudaGLUnregisterBufferObject(m_textureUpdateCuda->getBuffer(i)));
cudaError_t errRegisterBuffer = cudaGLUnmapBufferObject(m_videoMemoryCUDA->getVideoTextureWrite(i));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_video, m_videoMemoryCUDA->getVideoTextureWrite(i)));
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(m_textureUpdateCuda->getBuffer(i+3)));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_indices, m_textureUpdateCuda->getBuffer(i+3)));
CUDA_SAFE_CALL(cudaGLUnmapBufferObject(m_textureUpdateCuda->getBuffer(i+3)));
CUDA_SAFE_CALL(cudaGLUnregisterBufferObject(m_textureUpdateCuda->getBuffer(i+3)));
errRegisterBuffer = cudaGLUnmapBufferObject(m_videoMemoryCUDA->getVideoTextureWrite(i));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_video, m_videoMemoryCUDA->getVideoTextureWrite(i)));
CUDA_SAFE_CALL(cudaGLRegisterBufferObject(m_textureUpdateCuda->getBuffer(i+6)));
CUDA_SAFE_CALL(cudaGLMapBufferObject((void**)&m_indices, m_textureUpdateCuda->getBuffer(i+6)));
CUDA_SAFE_CALL(cudaGLUnmapBufferObject(m_textureUpdateCuda->getBuffer(i+6)));
errRegisterBuffer = cudaGLUnmapBufferObject(m_videoMemoryCUDA->getVideoTextureWrite(i));
CUDA_SAFE_CALL(cudaGLUnregisterBufferObject(m_videoMemoryCUDA->getVideoTextureWrite(i)));
CUDA_SAFE_CALL(cudaGLUnregisterBufferObject(m_textureUpdateCuda->getBuffer(i+6)));
}
Sorry it’s a lot of code.
Anyways, this runs fine and if i keep a watch on the errRegisterBuffer it says :
//i = 0
cudaErrorInvalidDevicePointer
cudaErrorInvalidDevicePointer
cudaSucces
//i = 1
cudaSucces
cudaSucces
cudaSucces
//i = 2
cudaErrorInvalidDevicePointer
cudaSucces
cudaErrorInvalidDevicePointer
Hope anybody can explain why this all happening, and why this is all happening on unmapping the before (not at registering/mapping/unregistering)
When i comment out everything with textureupdate it’s working without spawning cuda_errors at unmapping.
And last but not least :
GLuint m_indexBuffer[9];
glGenBuffersARB(m_NumberOfGroups, m_indexBuffer);
for ( i = 0; i < m_NumberOfGroups; i++)
{
if ( i % 3)
{
glBindBufferARB(GL_ARRAY_BUFFER, m_indexBuffer[i]);
glBufferDataARB(GL_ARRAY_BUFFER, w8 * h8/4, NULL, GL_DYNAMIC_COPY_ARB);
}
else
{
glBindBufferARB(GL_ARRAY_BUFFER, m_indexBuffer[i]);
glBufferDataARB(GL_ARRAY_BUFFER, w8 * h8, NULL, GL_DYNAMIC_COPY_ARB);
}
}
glBindBufferARB(GL_ARRAY_BUFFER, 0);
That part is used for initializing the buffer of textureupdate. I don’t use them at all, I haven’t mapped/unmapped them any cpu code. (it’s all commented out at the moment)
Best regards and thx for those taking the time to read all this :D
Niels