glDrawVkImageNV crash (OpenVR integration) - SOLVED sort of


I’m trying to get a couple of Vulkan images copied over to openGL (framebuffers backed by color images) so that I can submit them to OpenVR. It looks like I have everything confirmed working(*) but when I do the actual copy I’m getting “Access Violation reading location 0x0000000000000064”. The vulkan render loop is working in the same thread as the OpenGL context (but not the main thread) if that matters. (EDIT: it doesn’t)

Are there any limitations that I need to know about that would cause such a crash? i.e. Vulkan/OpenGL Image formats, layouts, etc.?

glDrawVkImageNV = (…) wglGetProcAddress(“glDrawVkImageNV”); // Successful
glDrawVkImageNV( (DTuint64) vki, 0, 0, 0, _width, _height, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); // vki = VkImage, _width = 1512 & _height = 1680


(*) Vulkan images confirmed with RenderDoc, OpenVR sees pre initialized textures just fine, Framebuffers are complete and I can glClear them just fine.

EDIT: It doesn’t appear related to be anything thread related. Also, the access violation location seems proportional to the VkImage index so there’s an array access there - it just seems like the base address is NULL-ish for some reason.

EDIT2: More details that are probably relevant. This is all on Windows. Normally, I’m using the Vulkan Swap chain for presenting to a window. However since OpenVR doesn’t accept VkImages I wrote a hacky conversion class. Basically it creates a second offscreen window with and OpenGL context on which I create framebuffers to render into (using the original vulkan window fails with an error). I’m trying to use these framebuffers as a target of glDrawVkImageNV. As an aside, how does glDrawVkImageNV know which vulkan device it’s dealing with? Could the fact I’m using 2 windows be the source of my issues?

Have you bound your GL_FRAMEBUFFER/GL_DRAW_FRAMEBUFFER correctly before executing the call?

Your sampling coordinates are all zero. Look at specifically “Section 18.4.X, Drawing Textures”

Since your s1 and t1 are both 0 you’re sampling nothing from the Vulkan texture. You need to have for example s0 and t0 as 0 then s1 and t1 as 1.f in order to sample from the whole texture.

Thanks for the reply. I mistyped those coordinates when I made the post ;)

Anyway, I tracked it down using divide and conquer. I copied and pasted some very basic code that I was using into a separate project and it didn’t crash. So I just kept removing code from my original project until it disappeared.
Weirdly if I enable VK_LAYER_LUNARG_standard_validation and VK_EXT_debug_report then I get the crash. As soon as I remove it, it all works fine. It’s going to require more investigation but at least I’m up and running now.

Vulkan Drivers and nVidia Drivers 368.39

Nice to hear!

I’ve been working on something similar, I just uploaded a change:

It’s a very simple example of OpenVR and Vulkan with the GL_NV_draw_vulkan_image extension, maybe you won’t find it interesting anymore though.