从HD6790升级到HD7850后,从cl :: BufferGL返回错误的值

时间:2013-09-04 23:04:42

标签: opencl gpu amd-processor

我可以将数据写入cl :: BufferGL变量(在GPU上)并用它来绘制,但在读回主机时我得到了错误的值。我从AMD SDK中运行了几个例子,包括GL_CL interop,一切正常。我可以读写cl :: Buffer,即从主机复制到设备并从设备复制到主机。

源代码托管在link

要创建cl :: Buffer,我在下面执行以下步骤(按顺序,并在获取cl_gl上下文后):

  1. glGenBuffer
  2. glBindBuffer
  3. glBufferData
  4. clCreateFromGLBuffer
  5. glBindBuffer(绑定到0,或解除绑定)
  6. 该程序使用以下方式编写:

    • C ++
    • Ubuntu 12.06 64位,内核3.2.0-29-generic
    • OpenCL 1.2
    • Driver 1124.2(AMD的二进制驱动程序,Catalyst 13.4)
    • AMD APPSDK v2.8
    • OpenGL版本:4.2.12217
    • GLEW
    • Freeglut

    编辑:我创建了一个代码块来重现错误

    // Terminates OpenCL commands
    cl_int status = 0;
    status =  clFinish( (cq)() );
    if ( status != CL_SUCCESS ) { printf("File: %s:%d\n", __FILE__, __LINE__);  }
    
    // Create Vertex buffer object
    GLint  number = 5;
    GLuint buffer;
    CHk_ERR( glGenBuffers( 1, &buffer ));
    CHk_ERR( glBindBuffer( GL_ARRAY_BUFFER, buffer ) );
    
    // initialize buffer object
    GLsizeiptr     size = static_cast<GLsizeiptr>(sizeof(number));
    const GLvoid * data = static_cast<const GLvoid *>(&number);
    CHk_ERR( glBufferData( GL_ARRAY_BUFFER, size, data, GL_DYNAMIC_DRAW) );
    CHk_ERR( glBindBuffer(GL_ARRAY_BUFFER, 0) );
    glFinish();
    
    if ( glGetError() != GL_NO_ERROR ) { printf("File: %s:%d\n", __FILE__, __LINE__);  }
    
    // create OpenCL buffer from GL VBO
    cl_mem mem = clCreateFromGLBuffer( (context)(), CL_MEM_READ_WRITE, buffer, &status );
    if ( status != CL_SUCCESS ) { printf("File: %s:%d\n", __FILE__, __LINE__);  }
    
    // Acquire OpenCL memory objects that have been created from OpenGL objects
    if ( clEnqueueAcquireGLObjects( (cq)(), 1, &(mem), 0, NULL, NULL ) != CL_SUCCESS ){
        std::cout << "ERROR!";
    }
    
    // Read buffer
    GLint value;
    cq.enqueueReadBuffer( mem, CL_TRUE, 0, size, &value );
    std::cout << "Value: " << value << std::endl;
    

    任何帮助表示赞赏!!

0 个答案:

没有答案