AnsweredAssumed Answered

DirectGMA Buffer to Texture Linux

Question asked by c1229gpu on Feb 16, 2017
Latest reply on Feb 20, 2017 by dwitczak


Recently was able to get DirectGMA functionality working on a homebrewed input card on windows.  I had no problem getting this to work and was able to DMA directly into AMD GPU memory.  Works great!  Currently using an e8860 to test.

I then rendered this buffer by creating a 2D Texture and used glTexSubImage2D() to subsitute the buffer data into the texture before drawing it.  See below:

glBindBuffer(GL_BUS_ADDRESSABLE_MEMORY_AMD, m_pBuffer[index]); //binding to buffer handle
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,1920,1080, GL_BGRA, GL_UNSIGNED_BYTE, NULL);  // passing NULL in so it uses the most recently binded buffer instead of discrete data.

This rendered on Windows without any issues.  Again this all works perfect on Windows.


I am now working on porting this to Linux (RHEL6).  Following advice from this thread: enabling directgma feature problem, can't get extension  I was able to successfully get the driver to provide me with accurate addresses to DMA into.  I then set my capture driver to DMA into those addresses and it works beautifully!

Using CodeXL and stepping through I can visibly see the allocated buffers in the debugger and my pixel data in those buffers.  Using color bars as an input to verify, I can confirm the data looks as expected and is real pixel data.  So it looks like the DirectGMA is working as expected.


Next task is to get this buffer to render into a texture and that is where things are not working

Capturing a buffer w/o DirectGMA into user memory and then using glTexSubImage2D works fine.  But doing it from a binded buffer does not work.


For the sake of space i won't post my whole source here.  This is the basic though.

for (unsigned int i = 0; i < m_uiNumBuffers; i++)
glBindBuffer(GL_BUS_ADDRESSABLE_MEMORY_AMD, m_pBuffer[i]);//bind to the buffer
glBufferData(GL_BUS_ADDRESSABLE_MEMORY_AMD, m_uiBufferSize, 0, GL_DYNAMIC_DRAW);//create a buffer which will be changed often and will be drawn.
glMakeBuffersResidentAMD(m_uiNumBuffers, m_pBuffer, m_pBufferBusAddress, m_pMarkerBusAddress);
glBindBuffer(GL_BUS_ADDRESSABLE_MEMORY_AMD, 0);//unbind buffer
 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1920x1080, 0,GL_RGBA, GL_UNSIGNED_BYTE, (pDest+256));//pDest contains a bunch of "0xAA".
 //I can confirm via CodeXL this texture is created and contains only "0xAA"
glBindBuffer(GL_BUS_ADDRESSABLE_MEMORY_AMD, m_pBuffer[index]);
 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,1920,1080,GL_BGRA, GL_UNSIGNED_BYTE, NULL);//this should substitute buffer into texture


Any help as to why this buffer won't copy to the texture would be great!  Again i think the directgma is working fine and its just the act of rendering that is causing an issue.  Works on Windows so may be a linux issue.  Let me know if more details are needed.  Also note I am using GLUT to render the window not that that should be a factor.


Message was edited by: Christopher Fadeley (Added Code Blocks Syntax)