cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

StefanS
Journeyman III

D3D12-GL Interop: GL extension GL_EXT_memory_object results in invalid enum error

I am currently trying to share a preallocated d3d12 vertex buffer and make it available in opengl using the opengl extension GL_EXT_memory_object and GL_EXT_memory_object_win32

https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_objects.txt https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_external_objects_win32.txt

The following code snippet works on my NVIDIA machine:

HANDLE sharedHandle = 0;
d3dclass.m_device->CreateSharedHandle(d3dclass.m_vertexBuffer.Get(), nullptr, GENERIC_ALL, 0, &sharedHandle);
GLuint memObject;
glCreateMemoryObjectsEXT(1, &memObject);
glImportMemoryWin32HandleEXT(memObject, sizeof(vertices), GL_HANDLE_TYPE_D3D12_RESOURCE_EXT, sharedHandle);
glGenBuffers(1, &m_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glBufferStorageMemEXT(GL_ARRAY_BUFFER, sizeof(vertices), memObject, 0);

However on my AMD machine (Windows 10 64 Bit, AMD Radeon RX 480 drivers 20.45.01.28) I get an gl error 0x0500 (Invalid enum) when calling glImportMemoryWin32HandleEXT(..). The call to CreateSharedHandle returns 0x0 (S_OK) so the shared handle should be valid.

I also tried to access the vertex buffer by name using glImportMemoryWin32NameEXT - again works on my NVDIA system - but not an my AMD.

So my question is: Should these extensions work on AMD? At least GLEW tells me, the extension is available on my platform. And if so, any ideas what I am doing wrong?

Any help is greatly appreciated!

Thanks
Stefan

0 Likes
1 Solution
StefanS
Journeyman III

Short update. I fixed the problem now - it was caused by a wrong paramter when calling glImportMemoryWin32HandleExt. Seems like the correct way to import a vertex / index buffer is to use GL_HANDLE_TYPE_OPAQUE_WIN32_EXT instead of GL_HANDLE_TYPE_D3D12_RESOURCE_EXT  as the handle type.

View solution in original post

0 Likes
1 Reply
StefanS
Journeyman III

Short update. I fixed the problem now - it was caused by a wrong paramter when calling glImportMemoryWin32HandleExt. Seems like the correct way to import a vertex / index buffer is to use GL_HANDLE_TYPE_OPAQUE_WIN32_EXT instead of GL_HANDLE_TYPE_D3D12_RESOURCE_EXT  as the handle type.

0 Likes