Skip to main content
Participant
January 25, 2015

Black Screen

Hi, I'm trying to integrate the API into an existing game engine and am having a bit of trouble. As near as I can tell, I have everything hooked up (render wise), but when I pass the texture to the API (endFrame), all I get is a black screen (no errors or warnings, compile time or run-time).

Things to note:
-The engine uses DirectX 10.1.
-The game is built in VS2010.

Here are the actions I have taken so far:
-I checked the texture to see if it was successfully being rendered to by copying it into the swap chain's back buffer, then calling present as normal.
-I tried to use PIX to debug the issue, but kept being stopped by a supposed unhandled exception when calling D3D10CreateDevice1. More confusingly, PIX indicated the problem was in d3d11.dll when our engine uses DirectX 10.1. I noticed that PIX has, apparently, not been supported in quite some time. No, the VS Graphics Debugger is not an option since I'm working in VS2010.
-I tried NSight, the Nvidia graphics debugger, only to find "D3D10 devices are unsupported under Nsight".

If anyone has any suggestions on where I can go from here, or questions to help me clarify my predicament, they would be much appreciated.

    17 replies

    Inspiring
    January 25, 2015
    Have you called 'ovrHmdAttachToWindow'?

    You can also try creating a D3D11 device, then QueryInterface to D3D10.

    Hope that helps.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    kyosukeAuthor
    Participant
    January 28, 2015
    Thanks for the reply. Yes, I am calling 'ovrHmdAttachToWindow'.

    I'll give the D3D11 device a go, but I'm confused as to the point? The Oculus API is supposed to support D3D10, so my engine's current D3D10 device should suffice. Did I miss something?
    Inspiring
    January 28, 2015
    Yes, the SDK should support DX10, but I was just suggesting a possible work-around.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    kyosukeAuthor
    Participant
    January 28, 2015
    Well, going the D3D11 device route seems to have introduced a new problem. The first call to 'CreateVertexShader' fails with a result of 4. Checking the return codes from Microsoft, this seems to be a problem with the way the device context is being used. I guess I'll try to figure this out later.
    kyosukeAuthor
    Participant
    January 30, 2015
    Yeah, I'm not excited by this rabbit hole. I'm still trying to figure out how to deal with this context issue. Thanks for the suggestion, but surely someone has a thought for fixing my original problem?
    Inspiring
    January 30, 2015
    It may be the order you are initializing the hmd and context, etc.

    See the posts here (about OpenGL, but should also apply to you):

    viewtopic.php?f=20&t=19335&p=237359#p237480
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    kyosukeAuthor
    Participant
    January 30, 2015
    Unfortunately, that does not seem to be the problem. I started with the ordering laid out in the developer's guide and the samples, which is:

    ovr_Initialize()
    ovrHmd_Create()
    create the window
    initialize DirectX
    ovrHmd_AttachToWindow()
    ovrHmd_ConfigureRendering()
    ovrHmd_ConfigureTracking()

    I tried playing around with the ordering just for funnsies, but to no success. Would it help if I supplied some code samples? I'm following the RoomTiny example rather closely with minor adjustments for DX10 (using ovrD3D10Texture instead of ovrD3D11Texture and ovrD3D10Config instead of ovrD3D11Config, for example).
    Inspiring
    January 30, 2015
    If you don't mind posting the code, I'll see if I can have someone take a look.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    kyosukeAuthor
    Participant
    January 31, 2015
    Here's the initialization. It's broken up across multiple functions, classes, and files, but these pieces below do execute in the order shown. Let me know if anything is too ambiguous or you'd like to see more.


    ovr_Initialize();
    ...

    if (m_hmd)
    return true;

    m_hmd = ovrHmd_Create(0);

    if (!m_hmd)
    m_hmd = ovrHmd_CreateDebug(ovrHmd_DK2);
    ...

    HWND window = CreateWindow(m_appName,
    m_appName,
    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    m_type == Compute ? CW_USEDEFAULT : rect.left,
    m_type == Compute ? SW_MINIMIZE : rect.top,
    rect.right - rect.left,
    rect.bottom - rect.top,
    NULL,
    NULL,
    wc.hInstance,
    NULL);
    ...

    UINT flags = 0;//D3D10_CREATE_DEVICE_SINGLETHREADED;

    if (debug)
    flags |= D3D10_CREATE_DEVICE_DEBUG;

    for (UINT i = 0; ; i++) {
    res = m_factory->EnumAdapters(i, &m_adapter);
    if (res == S_OK) {
    res = D3D10CreateDevice1(m_adapter,
    D3D10_DRIVER_TYPE_HARDWARE,
    NULL,
    flags,
    D3D10_FEATURE_LEVEL_10_0,
    D3D10_1_SDK_VERSION,
    &m_device);
    if (res == S_OK)
    break;

    m_adapter->Release();
    }
    ...

    ovrBool attachRet = ovrHmd_AttachToWindow(hmd, window, NULL, NULL);
    coAssert(attachRet != 0);


    //Configure Stereo settings.
    OVR::Sizei recommendedTex0Size = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, hmd->DefaultEyeFov[0], 1.0f);
    OVR::Sizei recommendedTex1Size = ovrHmd_GetFovTextureSize(hmd, ovrEye_Right, hmd->DefaultEyeFov[1], 1.0f);
    OVR::Sizei RenderTargetSize;

    RenderTargetSize.w = recommendedTex0Size.w + recommendedTex1Size.w;
    RenderTargetSize.h = max(recommendedTex0Size.h, recommendedTex1Size.h);


    RECT rect;
    rect.left = 0;
    rect.top = 0;
    rect.right = rect.left + RenderTargetSize.w;
    rect.bottom = rect.top + RenderTargetSize.h;

    BOOL ret = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false);
    coAssertAlways(ret == TRUE);

    ret = SetWindowPos(window, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, /*SWP_NOMOVE |*/ SWP_NOOWNERZORDER | SWP_NOZORDER);
    coAssertAlways(ret == TRUE);

    m_camera = new grVRCamera(window, true, RenderTargetSize.w, RenderTargetSize.h);


    m_eyeRenderViewport[0].Pos = Vector2i(0,0);
    m_eyeRenderViewport[0].Size = Sizei(RenderTargetSize.w / 2, RenderTargetSize.h);
    m_eyeRenderViewport[1].Pos = Vector2i((RenderTargetSize.w + 1) / 2, 0);
    m_eyeRenderViewport[1].Size = m_eyeRenderViewport[0].Size;


    // Query D3D texture data.
    m_eyeTexture[0].D3D10.Header.API = ovrRenderAPI_D3D10;
    m_eyeTexture[0].D3D10.Header.TextureSize = RenderTargetSize;
    m_eyeTexture[0].D3D10.Header.RenderViewport = m_eyeRenderViewport[0];
    m_eyeTexture[0].D3D10.pTexture = m_camera->m_texture->m_texture;
    m_eyeTexture[0].D3D10.pSRView = m_camera->m_texture->m_srv;

    // Right eye uses the same texture, but different rendering viewport.
    m_eyeTexture[1] = m_eyeTexture[0];
    m_eyeTexture[1].D3D10.Header.RenderViewport = m_eyeRenderViewport[1];


    // Configure d3d10.
    ovrD3D10Config d3d10cfg;
    d3d10cfg.D3D10.Header.API = ovrRenderAPI_D3D10;
    d3d10cfg.D3D10.Header.RTSize = Sizei(hmd->Resolution.w, hmd->Resolution.h);
    d3d10cfg.D3D10.Header.Multisample = m_camera->getNumMultiSamples();
    d3d10cfg.D3D10.pDevice = grGraphics::getDevice();
    d3d10cfg.D3D10.pBackBufferRT = m_camera->m_rtv;
    d3d10cfg.D3D10.pSwapChain = m_camera->m_swapChain;

    if (!ovrHmd_ConfigureRendering(hmd, &d3d10cfg.Config,
    ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette |
    ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive,
    hmd->DefaultEyeFov, m_eyeRenderDesc)) return;


    ovrHmd_SetEnabledCaps(hmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);

    // Start the sensor which informs of the Rift's pose and motion
    ovrHmd_ConfigureTracking(hmd,
    ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection |
    ovrTrackingCap_Position,
    0);
    Inspiring
    February 3, 2015
    By any chance, do you have multiple GPUs in your machine?

    If so, you should use the one that the HMD is attached to when creating the Direct3D 10 device.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV