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);//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"
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)
Thank you for the report. Would you mind sharing a project which reproduces this issue? It would be of tremendous help to the engineer who is going to work on this report. Thanks.
Thank you for reaching out.
Let me strip out some of the references to my code and my api to mask some things I'd prefer not to share.
Is there anyway I can direct message this zip to you instead of publicly posting?
Also interestingly enough this works proving the DirectGMA is working and it is truly the Buffer-->Texture operation which is failing.
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,1920,1080,GL_BGRA, GL_UNSIGNED_BYTE, (pDest));
Here I am binding the buffer, copying the contents of that buffer back to a local CPU buffer and then finally substituting that buffer back to the Texture.
So DirectGMABuffer-->CPUBuffer-->Texture works
DirectGMABuffer-->Texture doesnt work.
Fixed it I believe.
Seems calling glBindBuffer like the following:
before doing the glTexSubImage2D() works. I thought logically I would still call this buffer as GL_BUS_ADDRESSABLE_MEMORY_AMD (like when they are created) but that doesn't seem to be the case.
I still do not know why this works on windows and not linux but changing to GL_PIXEL_UNPACK_BUFFER works.
An answer as to why this is would be valuable to me if possible. Thanks!
Sure. Please send it over to dominik (dot) witczak at amd.com and I'll make sure to forward it to the relevant team. Even though you came up with a workaround, it's still going to be useful to find out why you are still running into problems under Linux.