Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCL - OpenGL Interop performance

I have a code where I create GL texture 8K(7680 x 4320) and I render to this texture. Then I switch it to CL and I do some stuff...

Problem is that "switching" is very slow.

If I don't run any CL code, only switch. It has around 40FPS on my GTS 450.

If I comment "clEnqueueAcquireGLObjects(..)" line => no switch. It has around 600FPS.

Is There some way how I can speed up?

I want to ask too If this is problem only with Nvidia or others like Ati, Intel and some SoC(ARM) have a same speed issue?

Creating GL-CL texture:

glGenFramebuffers(1, &m_fbo);
glGenTextures(1, &m_tex);
glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
glBindTexture(GL_TEXTURE_2D, m_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_imageSize.x, m_imageSize.y, 0, GL_RGBA, GL_INT, NULL);        //GL_ALPHA
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex, 0);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER)!=GL_FRAMEBUFFER_COMPLETE)
    return false;
glBindFramebuffer(GL_FRAMEBUFFER, 0);

int err;
m_memD = clCreateFromGLTexture2D(ecl.getContext(), CL_MEM_READ_WRITE, GL_TEXTURE_2D, 0, m_tex, &err);
if(ERR_CL)
    return false;

GL - CL Interop:

void activateCL()
{
    glFinish();
    int err = clEnqueueAcquireGLObjects(m_queue, 1, &m_memD, 0, 0, 0);
}    
void activateGL()
{
    int err;
    err = clFinish(m_queue);
    err = clEnqueueReleaseGLObjects(m_queue, 1, &m_memD, 0, 0, 0);

}

bool activateGLRendering()
{
    activateGL();
    glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
    return true;
}
bool deactivateGLRendering()
{
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    return true;
}
like image 548
Milan Avatar asked Nov 13 '22 00:11

Milan


1 Answers

Same similar question as asked in this thread: LINK

It is a problem in the driver of nVIDIA + Windows only. Not AMD, not Intel, and not in linux. But as the comment of @user2725937 says:

It is reported to nVIDIA and fixed in 331.xx beta drivers
like image 81
DarkZeros Avatar answered Nov 26 '22 09:11

DarkZeros