cancel
Showing results for 
Search instead for 
Did you mean: 

Turning VR On/Off for a PC application.

Anonymous
Not applicable
Hi,
is there any code sample or document or explanation about what would be the correct pratice/way of doing ( using DX10/11 ) on a Windows (10) PC to allow the user to switch "On/Off" the VR ?

I mean we'd like to have the behavior where the program starts "on the main PC display" but in one menu if the user let's say decides "Go VR mode" presses a button and the OR goes on, likewise if he's working with OR and at the same time it decides "Stop VR mode" it presses a button and it returns back to the desktop mode.

I suppose I need to go "along the lines" of when an ovrError_DisplayLost, so I think I need to destroy the swapchains and the ovr_session.

But that point I suspect I need to re-enumerate/find another display adapter.

Does it mean I need to destroy ALL the graphic resources/device ( vertex buffers, everything, etc. ) and re-create a whole new device ?

Is any sample that show something about this ?

Thanks in advance.


2 REPLIES 2

Anonymous
Not applicable
Hi again,

I am getting quite nuts trying to understand "what is actually going on".

I mean when I have the Oculus attached I noted this piece of code :

            do
            {
                Adapter = nullptr;

                hr = DXGIFactory->EnumAdapters(adapterNum, &Adapter.GetRawRef());

                PRINTF(" adapterNum %d, HR %08x\n", adapterNum, hr);

                if (SUCCEEDED(hr) && Adapter)
                {
                    DXGI_ADAPTER_DESC adapterDesc;

                    Adapter->GetDesc(&adapterDesc);
                    if (adapterDesc.AdapterLuid.HighPart == pLuid->HighPart &&
                        adapterDesc.AdapterLuid.LowPart == pLuid->LowPart)
                    {
                        adapterFound = true;
                        PRINTF("Matching LUID.H %08x, LUID.L %08x \n", pLuid->HighPart, pLuid->LowPart);
                        break;
                    }

Always tells me that the "Adapter found" is 0 and that the

Matching LUID.H 00000000, LUID.L 0000ae8b
ADAPTER FOUND with LUID we wanted, adapter num 0

Now, suppose I want to 'disable' the OR, I have a define in my code I call #define NO_OCULUS
that when defined DOES NOT call the ovr_intialise(), forces the ovr_session to be a NULLPTR and skips some rest of code.

Yet, even in that case the "Adapter" found is always at 'adapterNum = 0', rightly so because I have only ONE graphic card where there is multiple outputs one of which is the "desktop monitor" and the other is the "OR".

But, at this point I can't really understand when you get here :

   Device = NULL;
    Context = NULL;

    if (Adapter) PRINTF("Before D3D11CreateDevice, we have adapterer !\n");

    hr = D3D11CreateDevice(Adapter, Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE,
                            NULL, flags, NULL, 0, D3D11_SDK_VERSION,
                            &Device.GetRawRef(), NULL, &Context.GetRawRef());

Given that "Adapter" will be always "the same" in the case of OR or NOT OR, WHAT causes the display output to actually go into the OR , what actually 'drives' the OR and who/what knows "how to output there" ?

Because for example I am getting the impression that "it's not possible to ONLY render on the OR", you always end up in rendering ( via mirror and/or something else ) even "in the main desktop".

I mean in my "not so deep knowledge" I was expecting assuming a thing like "ok there's no OR, you get Adapter 0, there's OR, you get adapter 1" .. but it's not like that.

At this point I am asking myself, I haven't tried, if I simply destroy the "session" ( and the associated stuff ), I set the RT as "the usual backbuffer" am I going to render on "the main screen" ?

I am really very puzzled at this point "what/where the output to the OR device is created ?" what literally causes to drive "the correct HDMI output" to the OR given that "nothing I can see here can understand where the OR output is".

I must admit I am quite a bit confused the more I am trying to understand what the ( sample ) code does.

Cheers.



Anonymous
Not applicable
Hi,
I also tried to add those lines to my code :
// Giles, added for test
if (session)
{
IDXGIOutput* pOutput = NULL;
int numOutput = 0;
DXGI_OUTPUT_DESC outDesc;

if (Adapter)
{
do {
hr = Adapter->EnumOutputs(numOutput, &pOutput);
if (SUCCEEDED(hr))
{
hr = pOutput->GetDesc(&outDesc);
if (SUCCEEDED(hr))
{
PRINTFW(L"Output found : %s\n", outDesc.DeviceName);
PRINTF("Attached to desktop : %d\n", outDesc.AttachedToDesktop);
PRINTF("Rotation : %d\n", outDesc.Rotation);
}
}
numOutput++;
} while (SUCCEEDED(hr));
}
}

And .. OR "does not appear at all like a video output/device", I can see my two desktop displays I can't see the OR anywhere.

At this point I am really wondering "how OR works in Windows at all" ? 🙂

Still trying to understand how to possibly swtich VR on/off.