ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.12k stars 1.28k forks source link

Can`t choose proper display (extended mode) for SteamVR #200

Closed nikitos1550 closed 7 years ago

nikitos1550 commented 8 years ago

Hello!

I have built driver_sample for windows and hard code there settings for my custom display, like this:

` if ( pSettings ) { DriverLog( "Using settings values\n" ); m_flIPD = pSettings->GetFloat( k_pch_SteamVR_Section, k_pch_SteamVR_IPD_Float, 0.063f );

                    char buf[1024];
                    pSettings->GetString( k_pch_Sample_Section, k_pch_Sample_SerialNumber_String, buf, sizeof(buf), "244047" );
                    m_sSerialNumber = buf;

                    pSettings->GetString( k_pch_Sample_Section, k_pch_Sample_ModelNumber_String, buf, sizeof(buf), "W2243" );
                    m_sModelNumber = buf;

                    m_nWindowX = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowX_Int32, 1920 );
                    m_nWindowY = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowY_Int32, 0 );
                    m_nWindowWidth = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowWidth_Int32, 1920 );
                    m_nWindowHeight = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_WindowHeight_Int32, 1080 );
                    m_nRenderWidth = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_RenderWidth_Int32, 1920 );
                    m_nRenderHeight = pSettings->GetInt32( k_pch_Sample_Section, k_pch_Sample_RenderHeight_Int32, 1080 );
                    m_flSecondsFromVsyncToPhotons = pSettings->GetFloat( k_pch_Sample_Section, k_pch_Sample_SecondsFromVsyncToPhotons_Float, 0.0 );
                    m_flDisplayFrequency = pSettings->GetFloat( k_pch_Sample_Section, k_pch_Sample_DisplayFrequency_Float, 60.0 );
            }

` I have two displays, each is 1920x1080. Second is on the right of first(primary one). Everything start well. HMD icon is green, And even I can go through room setup calibration. I expect to see SteamVR demo on second monitor, but it is on first/primary monitor. Looks like as I set position to 0,0.

I also added answers to queries for EDID VID and PID to driver_sample.

What am I doing wrong? Is driver_sample is up to date? Or did I miss something?

P.S. Serial and Model numbers strings I fill with some sample values.

nikitos1550 commented 8 years ago

Also I found this issue https://github.com/ValveSoftware/openvr/issues/97

With sample config:

"driver_null" : { "displayFrequency" : 90, "enable" : true, "id" : "Null Driver", "modelNumber" : "Null Model Number", "renderHeight" : 1512, "renderWidth" : 1344, "secondsFromVsyncToPhotons" : 0.10000000000000001, "serialNumber" : "Null 4711", "windowHeight" : 1080, "windowWidth" : 1920, "windowX" : 100, "windowY" : 100 }

I can`t run it in window mode, always fullscreen, always on primary display.

shenyu0403 commented 8 years ago

"windowX" : 100, "windowY" : 100, is the problem you got. you'd better to use "EnumDisplayMonitors" to get the coordinate of your second monitor when initializing.

nikitos1550 commented 8 years ago

"windowX" : 100, "windowY" : 100 is invalid values. Compositor will not start. "windowX" : 1920, "windowY" : 0 is valid, but image is on primary screen (like "windowX" : 0, "windowY" : 0) This is the problem.

nikitos1550 commented 8 years ago

I also have SteamVR-OSVR plugin for testing, it runs on second display without any problem. I have sources of both plugins, but I cant find the difference in data exchange between SteamVR and plugins, seems it is same. So I cant understand why when I am positioning to 1920,0 I still have image on position 0,0.

HelenXR commented 7 years ago

@nikitos1550 ,I also have the same problem,Can you share your solution

cjlong1213 commented 7 years ago

@nikitos1550 I also have the same problem, Can you share your solution? Thanks.

HelenXR commented 7 years ago

@cjlong1213 I have get this . if you want to let your monitor enter direct mode ,#431,this post may help

then, I realized the HMD extended display and direct mode, if there is still a problem, you can contact my Email:helenhololens@gmail.com,

cjlong1213 commented 7 years ago

@HelenXR Thanks for your kindly help, actually I'm trying to build a custom driver for my HMD. Right now I have two computer monitors, the Lenovo display with solution of 1680x1050 and it is primary display, the Dell display with solution of 1920x1080 is my testing HMD display, I can load driver success and run compositer(Headset Window) OK in my primary display(Lenovo display). I want to run compositer at HMD display(Dell) with fullscreen whatever EXTEND mode or DIRECT mode. The default.vrsettings are as below: { "driver_sample" : { "enable" : true, "monitor" : "DELA09C", "supersample" : 1, "edid_vid" : 44048, "edid_pid" : 41116, "directMode" : false, "serialNumber" : "1234", "modelNumber" : "SampleModel 1", "windowX" : 1680, "windowY" : 0, "windowWidth" : 1920, "windowHeight" : 1080, "renderWidth" : 1920, "renderHeight" : 1080, "secondsFromVsyncToPhotons" : 0.011, "displayFrequency" : 60.0 } } I have set the values in my code as below: vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_UsesDriverDirectMode_Bool, false); vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, Prop_EdidVendorID_Int32, 0xAC10); vr::VRProperties()->SetInt32Property(m_ulPropertyContainer, Prop_EdidProductID_Int32, 0xA09C); IsDisplayOnDesktop() function return TRUE, and IsDisplayRealDisplay() function return TRUE in my code. I still can not run correctly. What am I doing wrong? Did I miss something? Any help is highly apprecciate!

HelenXR commented 7 years ago

@cjlong1213 "I still can not run correctly." Doesn't it sound like your driver doesn't work? Did you get 108 or 400 wrong When startup steamVR?

cjlong1213 commented 7 years ago

@HelenXR Thanks for your reply! I can startup steamVR with no errors, I want to run compositer window at second display(HMD) with fullscreen. In addition to rearrange the displays by windows, does any other way to solve this? Change settings?

HelenXR commented 7 years ago

@cjlong1213 About extend Mode: Displayed on the primary display (in the middle way of primary monitor,resolution is m_nWindowWidth *m_nWindowHeight), but did not try to be displayed on the second monitor, my custom HMD is work in direct mode(direct rendering mode can play better on VR graphics support, such as ATW, TW, VR-SLI and so on). Today I tried to make the extended display to the second monitor, and did not succeed for this I made a SCREEN class of the small program to implement an application to display second display function, it can work after debugging, but openVR I haven't found the answer, based on that, I think it should be with "m_nWindowX", but I try to modify later, did not play a role, because openVR does not completely open source: - (, I did not continue. @TheDeveloperGuy Can you give us some help for extern mode display in second monitor? About direct Mode(I am using):

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nvlddmkm] "1641970VRWhiteList"="SVR,*;"

HelenXR commented 7 years ago

hi,@cjlong1213 It took me some time today to be able to output the display image to the second monitor I have 2 monitors, the primary display is: 1920*1080, another display is: 1366*768. Windows is set to expand mode, modify the part of the code to allow the image to second monitors.

//CHeadMountDisplayDevice  is My HMD class.
bool CHeadMountDisplayDevice::IsDisplayOnDesktop() 
{
    return true;
}
bool CHeadMountDisplayDevice::IsDisplayRealDisplay() 
{
    return true;
    //return false;
}
//modify setting files:
      "windowX" : 1920,
      "windowY" : 0,
      "windowWidth" : 1366,
      "windowHeight" :768,
      "renderWidth" : 1366,
      "renderHeight" :768,

The steamVR home will be able to show up to second monitors (on the right of the Dell monitor): 111

cjlong1213 commented 7 years ago

hi, @HelenXR I have modified the settings as you suggested, but still can not run the steamVR home to second monitor. I have 2 monitors, the primary display resolution is: 19201080, another is: 16801050. setting files: "windowX" : 1920, "windowY" : 0, "windowWidth" : 1680, "windowHeight" :1050, "renderWidth" : 1680, "renderHeight" :1050,

The steamVR home show up to the middle of primary display as below:

image

Is there anything I am wrong?

HelenXR commented 7 years ago

@cjlong1213 It's normal for me to test on my openVR driver project. You can use the same code so that we have the same experimental environment.

nikitos1550 commented 7 years ago

Hello!

It is strange issue, and I also face it. Spent a lof of time to understand what is going on. Somehow you can`t name your driver null or sample (maybe some other names also). So, solution is to name your driver with your own project name. driver_null - will NOT work driver_sample - will NOT work driver_blablabla - will work

Maybe problem is more deep, I don`t know. But simple renaming of my driver solved it. Before I raised such question here, but it was closed by Valve developers.

nikitos1550 commented 7 years ago

P.S. this name issue is only applicable for extended mode.

nikitos1550 commented 7 years ago

P.P.S original driver_null that you can find in steamVR default installation has same issue.

HelenXR commented 7 years ago

@nikitos1550 yes,That's a cutey issue~~~ I find below message in vrcompositor.txt' when driver name is sample.

Forcing debug mode for sample driver.

other driver name will not display this message~ A bit annoying, openVR source code is not open source......

cjlong1213 commented 7 years ago

@nikitos1550 Great! Many thanks! This issue bothered me for a long time, so it is a naming compatibility of Valve...

nikitos1550 commented 7 years ago

Also thanks to https://github.com/sencercoltu @sencercoltu he also spent time with me researching this issue. @cjlong1213 pls check your email

@HelenXR I think openVR is somehow open, but not opensource, most interesting things are closed, so you have to research them by yourself, like sensor fusion, etc. Also spen a lot of time for NVIDIA white list, it is closed, but same time you can find solution in the internet (these days, seems, it is not a secret anymore). Also guys, most of you are from china, is it possible to chat with you some time, interesting what changed about VR there last half year, there were a lot of startups, a lot of new hardware announces, but still can`t find something new on taobao.

HelenXR commented 7 years ago

@nikitos1550 VR brings me to the new world, both in experience and in technology, for example: distortion, ATW, sensor, fusion, etc.. I haven't found any contact information in your data. If it's convenient, send me an email and look forward to communicating with you. my email:helenhololens@gmail.com.

r57zone commented 7 years ago

Debug mode activate Windowed Mode (borderless fullscreen) on "Headset Window" and you can move window to second screen with buttons (Shift + Win + Right or Left)

vr::VRProperties()->SetBoolProperty(m_ulPropertyContainer, Prop_DisplayDebugMode_Bool, true);

dashingstag commented 7 years ago

Debug mode activate Windowed Mode (borderless fullscreen) on "Headset Window" and you can move window to second screen with buttons (Shift + Win + Right or Left)

This feature is very useful for extended mode although might still have to programmatically change the size of the window after you shift it if you have different resolution windows.

r57zone commented 7 years ago

But there is a problem, a lock at 30 FPS.

dashingstag commented 7 years ago

But there is a problem, a lock at 30 FPS.

That is a big problem :(

JoeLudwig commented 7 years ago

Debug mode involves the Windows Desktop Compositor, which you don't want to be involved.

For normal operation, you should definitely use direct mode.

r57zone commented 7 years ago

@JoeLudwig Why? All modern games support Windowed Mode (borderless fullscreen window) and work fine. If I disable Debug Mode, then I can not start SteamVR on the second monitor (HMD).

Why is my GPU not 100% loaded, while rendering is slow in some games and program?

TheDeveloperGuy commented 7 years ago

@r57zone The "debug" mode is, well, for debugging. There isn't a valid reason for wanting windowed VR output, so if your reason for needing this is you can't place your VR ouput on the HMD, then you need to look at that issue instead (providing OpenVR with proper co-ordinates or finding them at runtime by searching for your HMD).

TheDeveloperGuy commented 7 years ago

@r57zone The reason is latency, btw... ;)

dashingstag commented 7 years ago

...(providing OpenVR with proper co-ordinates ...

There seems to an issue with that when I shift the coordinates to the proper window on startup with GetWindowBounds but it shifts right back to the primary monitor soon after clicking on the headset window (click is sometimes required when another window is overlayed over the headset window and the headset window turns red). Have also tried programmatically shifting the window every fixed interval but there's something that forces the compositor to draw/shift back to the primary monitor.

There isn't a valid reason for wanting windowed VR output

There is a valid reason for developers. As the screen technology improves there will be more and more displays coming into play and it is unlikely indie developers would be able to white list all of them. It would be convenient for consumers and developers to have their driver "support" on any hmd. It just seems like one less barrier given that vr already has so many components to them like tracking cameras, controllers, trackables, hmd, lens, gyros etc...

TheDeveloperGuy commented 7 years ago

You must be doing something wrong in your driver, as I am able to provide co-ordinates for other displays just fine and have SteamVR target that display. You don't need Windowed mode to be able to run an HMD in extended (desktop) mode, but you do need to provide the exact coordinates for the top left, and the exact size of the display or it won't work. I don't think trying to move the HMD window when SteamVR is running is a valid thing to do, nor is switching it in and out of fullscreen mode. I wouldn't expect that your driver should be doing anything to the SteamVR HMD output window, as it doesn't "belong" to you.

If for some reason (and there are very few) you need to "own" the output window, then you would need to use the IVRDriverDirectModeComponent or IVRVirtualDisplay interface and output the resultant texture to a display yourself.

dashingstag commented 7 years ago

You must be doing something wrong in your driver, as I am able to provide co-ordinates for other displays just fine and have SteamVR target that display. You don't need Windowed mode to be able to run an HMD in extended (desktop) mode, but you do need to provide the exact coordinates for the top left, and the exact size of the display or it won't work. I don't think trying to move the HMD window when SteamVR is running is a valid thing to do, nor is switching it in and out of fullscreen mode. I wouldn't expect that your driver should be doing anything to the SteamVR HMD output window, as it doesn't "belong" to you.

If for some reason (and there are very few) you need to "own" the output window, then you would need to use the IVRDriverDirectModeComponent or IVRVirtualDisplay interface and output the resultant texture to a display yourself.

If that is the case I have no idea what I am doing wrong as I am following the sample closely. From my understanding, the offset is only called in GetWindowBounds. This setting appears to only work when the headset display is not in focus(red screen) as it snaps back to the primary display when it is in focus and it snaps back to my intended position when it is out of focus(red screen).

Note: I am purely using extended mode to experiment. I can get it working on direct mode on a different device.

given 2 displays(both dell monitors)

primary(1) secondary(2 display i want steamvr to display on) [1920x1080] [1920x1080]

m_nWindowX = 1920; m_nWindowY = 0; m_nWindowWidth = 1920; m_nWindowHeight = 1080; m_nRenderWidth = 1920; m_nRenderHeight = 1080;

@HelenXR @cjlong1213 how did you solve the issue? my driver is not called sample or null

dashingstag commented 7 years ago

After testing several options I figured out the issue. Posting the solution here for other people to reference.

The key point, that might not be obvious at the start when you are just trying to get things to work, is to note that extended mode works when IsDisplayRealDisplay() is set returns false. Although it works in any given display situation, this causes the headset window to ignore some of the settings you might have set and post on the primary display of your pc regardless.

However, when IsDisplayRealDisplay() is set to return true, your window settings eg. m_nWindowX = 1920; m_nWindowY = 0; m_nWindowWidth = 1920; m_nWindowHeight = 1080; m_nRenderWidth = 1920; m_nRenderHeight =1080;

need to be 100% correct including any offset or window size or an ipc compositor error will emerge. In addition, it is only in this mode you would be able to set the offset from the primary monitor.

TheDeveloperGuy commented 7 years ago

@dashingstag Yes, that is correct. It should be set to 'true' for a HDMI connected display.