AnsweredAssumed Answered

ATI Pinned memory extension crash

Question asked by sarbrita on Jul 30, 2012
Latest reply on Jul 31, 2012 by sarbrita

Hi,

I am trying to use ATI's pinned memory extension to transfer data fast from GPU to CPU but I am getting crash while reading pixels.

 

Here is my code.

 

void getPixelDataFromATIGPU()

{

    int dataDize = width * height * 4;

    glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);

    glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_pinnedMemBuffer);

 

    /* Getting crash here in glReadPixels */

    glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, 0);

    GLsync s = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);

 

    if(glIsSync(s))

    {

        glClientWaitSync(s, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 1000);

        // Use memory here

    }

 

    // It is now safe to use 'memory'

}

/*****************************************************************************/

void initPinnedMemoryBuffer()

{

    int dataDize = width * height * 4;

 

    glGenBuffers(1, &m_pinnedMemBuffer);

    glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_pinnedMemBuffer);

 

    char* memory_temp = new char[dataDize + 0x1000];

    m_pinnedMemory = reinterpret_cast<char*>(unsigned(memory_temp + 0xfff) & (~0xfff));

    glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, dataDize, m_pinnedMemory, GL_STREAM_READ);

   

}

Outcomes