cpt-max / OculusRift4MonoGame

MIT License
13 stars 0 forks source link

Disable monitor Vsync to allow Oculus Rift frame rates (90Hhz) #3

Closed nkast closed 7 years ago

nkast commented 7 years ago

Currently the gameloop is limited ftom the monitor frame rate (typically =60fps)

cpt-max commented 7 years ago

Good catch, thanks. It's definitely smoother now.

nkast commented 7 years ago

Good!

Still no luck with the virtual HMD though. Maybe I have to update the libraries to the latest SDK.

cpt-max commented 7 years ago

What do you mean by virtual HMD?

cpt-max commented 7 years ago

Ahh I see, there's an Oculus Debug Tool. I never used that before. I just tried it and it didn't drop frames while running the sample. Are you trying that without a connected Oculus Rift? Is that supposed to work?

cpt-max commented 7 years ago

I originally built this sample with a now 2-year-old version of MonoGame. I just replaced the old version with the new 3.6 version and now I'm getting an "initialization error" in the C++ dll in this line

result = ovr_CreateTextureSwapChainDX(session, dxDevice, &desc, &swapChain);

I guess that's why you have problems with it. It almost looks like the DirectX device changed somehow between the old and the new MonoGame version, but I'm not sure about that. I tried to switch to the newest Oculus SDK, to see if that helps. It doesn't, same error. If I find some time I can look into this some more, not sure what's going on there.

nkast commented 7 years ago

I think the error you are getting is with Graphics Profile. older monogame set the profile to HiDef (if supported). Newer versions always begin with Reach as the default. I tested it with MG 3.6 and develop 3.7.0.0741 (Aug 2017).

I don't have a device and I am trying to see what I can do with it before going out and bye one.

I thing the debug HMD is supposed to show me the output. At least it does show me the virtual room + store/main menu when I start it up. But when my app begin it's all black. The only thing I can see is the performance/ debug layer.

Another thing I tried was to paint the target with the following code. Everything is still black.

// dxContext->CopyResource(res, eye == 0 ? texLeft : texRight);
FLOAT color[4] = { 0.5f,1,1,0.5f};
dxContext->ClearRenderTargetView(view, color);
nkast commented 7 years ago

I downloaded the SDK and run the precompiled WorldDemo. It runs fine with the virtual Device.

oculus

cpt-max commented 7 years ago

I see, you enable the debug view by setting Debug HMD Type to CV1. Just tried, and it doesn't work even when you have the Rift connected. The window stays black. There must be something you have to do differently for this to work.

nkast commented 7 years ago

I upgraded the library and tried a couple of things from the OculusRoomTiny sample until I make it work! Now I have to see if it's a couple of thing that fixed it or just the last one.

nkast commented 7 years ago

The problem was this line here which leaves the layer.RenderPose uninitialized. https://github.com/steemwheedle/OculusRift4MonoGame/blob/946b4fe12106b3ab2b2f40379161cada8806a691/OculusRift/OculusRift.cpp#L200

ts.StatusFlags is 0 under the virtual device. Is it OK if we remove it completely?

oculusdebug

cpt-max commented 7 years ago

I just tested it without the if statement, everything still works fine, and the Debug HMD is indeed working now. So yeah, we can remoe it.

nkast commented 7 years ago

Good! I send a PR