MISDIAGNOSIS (I can glClearBufferfv w/ D3D11+OpenGL (WGL_NV_DX_interop2) but triangles aren't happening?)

I’m not sure this is the best place to ask, but maybe someone has experience with this. I’ve been trying to port OpenGL code to OpenXR using Microsoft’s OpenXR runtime that only has D3D11 and D3D12 targets, and has a block on mapping the xrSwapChain with WGL_NV_DX_interop2. So, to be efficient I’ve set up a simple effects pass in D3D11, and it copies from interop FBO bound textures. I can’t so far get a picture except for clearing the textures from OpenGL (which produces that color in the VR device.)

I’ve tried eliminate every contingency, and am drawing to the FBO with the exact same code that the software would normally use (even though it would be distorted when copied to the xrSwapChain) and am still drawing a blank. So I feel like something has to be missing, but I can’t think of anything. I’m at my wit’s end. Sorry! I’m hoping some kind elves will leave me a solution when I return home later this evening.

Random guess: are you doing a glFlush() to serialize the OpenGL work? I think you would need this before the call to xrReleaseSwapchain() your D3D11 copy. This would ensure that the OpenGL commands are sent to the device before you try to copy the content of your FBO to the swapchain images.

1 Like

One more thing: I highly recommend that you look at The Dark Mod VR source code: it has a great example of OpenGL/D3D11 interop for OpenXR:

1 Like

That’s a very good idea! (“random guess” is indeed what I’m looking for) but unfortunately it didn’t do it. I’m just going to have to keep groping in the dark it seems.

RE “The Dark Mod VR” I just took a quick scan of it, the following subroutine I find very troubling, since it looks like deep black magic as far as I can see. I find D3D11 is very poorly documented compared to D3D9, which I’m used to. And the search engines have become nigh useless to get actionable information nowadays. Edited: Thanks for this resource BTW!!

(Notice, it sets everything to “nullptr” and then draws a “triangle-list” with just 3 vertices, which ought to be a triangle. How does this draw a viewport I can’t conceive, but I know this isn’t a D3D forum!! I just thought, now this is an interesting head scratcher that deserves to be shared for no other reason…)

EDITED: I would Delete this post in hindsight except for Alfonse Reinheart (local guru) hearted it… probably because I said I’m “really stupid” j/k… probably for the glPuppyDog crack!

P.S. More info just in case anyone is still interested in lending a hand/idea… for the record, there’s nothing in the debug message callbacks, and no errors in the routines that return errors, and I confirmed that clearing the FBO/attachment is updating every frame (as opposed to working one time and appearing to work thereafter because the image is actually changing.) (And glFlush before switching to D3D doesn’t help either.) (FWIW I want to think I’m an idiot and somehow the drawing code is wrong, but I can’t see any reason why it should be and it’s a really, really big project to try to invent some trivial drawing code to test that theory since just drawing a triangle nowadays is 90% of all your engine’s code! I really miss glVertex here. Why can’t we have glPuppyDog, just for testing purposes!)

EDITED: Also, just for what it’s worth, the interop objects are textures, which I assume the xrSwapChain is as well. There is an alternative approach to interop that uses framebuffers. But that seems more useful for a real swap-chain. I’ve tried many things like removing the depth-buffer from the FBO to see if it somehow requires all the render-buffers to be inteop objects too, but that didn’t help. I’m just ruling out things I’ve tried now before I receive any recommendations. I just know there’s an answer and it’s going to be really, really stupid. It always is.

1 Like

The magic is the vertices are hard-coded in the shader here: thedarkmodvr/flip.vs.hlsl at 6532205504a421acafb80e1e2c7db495aa54782f · fholger/thedarkmodvr · GitHub

This has become a pretty common technique nowadays when drawing a full screen quad.

For your issue at this point I don’t think I could make any suggestion without seeing your code.

First time I had to do GL interop for OpenXR, I followed The Dark Mod VR code and everything worked out very easily, hence my recommendation to dig into it.

1 Like

Yes, my code is identical to its, at least in terms of the calls. Probably most interesting to add is I’ve downloaded/installed Dark Mod VR and have been looking for a PC VR game, never having found one!

I just know there’s an answer and it’s going to be a really stupid. It always is.

EDITED: I’m going to shorten this to save readers time. I hate myself (not really) but the answer was some minor code that did an early return if a PlayStationVR wasn’t connected, and that would switch to a different memory location for storing the view-matrix that wasn’t filled out. But I’m really glad to find this video game. I always wanted to play a Thief game, it’s very similar to the project I’m working on (KING'S FIELD 25th PROJECT by swordofmoonlight) here.

BTW, thanks for the crazy shader trick link too. I feel like that URL should appear in any place where the shader is used! Not just in the shader code.

1 Like

Oh the full screen triangle. I tried that once, failed, and went back to my two-triangle quad :slight_smile:

1 Like

I’m considering trying it… I wonder if map/unmap on the dumb little quad introduces significant overhead or not (it would depend on bottleneck/races, but I suppose in theory it’s possible. It does seem like making simple tasks require two dozen API calls would present a mounting problem at some stage.) (Edited: Alternatively they could be stored in a hash-table as permanent buffers in VRAM. I’m wondering if display-lists ever came back, because they’d be really useful in WebGL like situations, and D3D12/Vulkan are basically display-list systems. Ironically I read that D3D12 is the same philosophy as D3D1 that everyone rejected for being too labor intensive back in the early days.)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.