cancel
Showing results for 
Search instead for 
Did you mean: 

[Request, Bug Fix] CAPI_D3D1X_DistortionRenderer.cpp

Carandiru
Honored Guest
On lines 205 - 212:


if ( System::DirectDisplayEnabled())
{
Ptr<IUnknown> ovrSwapChain;
if (config->D3D_NS.pSwapChain->QueryInterface(IID_OVRDXGISwapchain, (void**)&ovrSwapChain.GetRawRef()) == E_NOINTERFACE)
{
OVR_DEBUG_LOG_TEXT(("ovr_Initialize() or ovr_InitializeRenderingShim() wasn't called before DXGISwapChain was created."));
}
}


can you please make a small change Oculus to:

if (config->D3D_NS.pSwapChain && System::DirectDisplayEnabled())
{
Ptr<IUnknown> ovrSwapChain;
if (config->D3D_NS.pSwapChain->QueryInterface(IID_OVRDXGISwapchain, (void**)&ovrSwapChain.GetRawRef()) == E_NOINTERFACE)
{
OVR_DEBUG_LOG_TEXT(("ovr_Initialize() or ovr_InitializeRenderingShim() wasn't called before DXGISwapChain was created."));
}
}


This then allows me to supply nullptr for

ovrD3D11Config d3d11cfg;
d3d11cfg.D3D11.pSwapChain = nullptr;


Reason: So I can move Present into my own code and supply ovrD3D11Config with a Deferred Content. I can then move the entire ovrHmd_EndFrame outside of a critical section. Which is really great due to WaitTillTime() in the function.
I use a Deferred Content also to minimize the amount of time I need to hold the critical section for the Immediate Context.

Thanks,
Jason
http://www.supersinfulsilicon.com/ supersinfulsilicon - software Home of the MaxVR Oculus Rift Video Player https://twitter.com/Carandiru
2 REPLIES 2

cybereality
Grand Champion
OK, I have put in a ticket for this.
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

Carandiru
Honored Guest
Thank you for implementing:

void DistortionRenderer::EndFrame(uint32_t frameIndex, bool swapBuffers)


The option to "swapBuffers" is great! However can you expose it to ovrHmd_EndFrame
with this change (default parameter needed to maintain code comptability)
OVR_PUBLIC_FUNCTION(void) ovrHmd_EndFrame(ovrHmd hmd,
const ovrPosef renderPose[2],
const ovrTexture eyeTexture[2],
bool const swapBuffers = true);


It's currently hardcoded in OVR_Capi.cpp to always call DistortionRenderer::EndFrame(uint32_t frameIndex, bool swapBuffers) with swapBuffers as true

It still works, as you have implemented the checks for a nullptr inside DistortionRenderer::EndFrame, which will cause the present to not be called, and the else statement "// TBD: Generate error - swapbuffer option used with null swapchain."

To clarify why/what using nullptr for pSwapChain is for :

d3d11cfg.D3D11.pDeviceContext = cMaxVRSingleton::getDirectX()->getD3DContextForOculus(); // Deferred Context
d3d11cfg.D3D11.pSwapChain = nullptr; // Moved Present into cDirectX EndFrame with Request for Bug Fix from Oculus, Minimize Critical Section Hold Time


void cDirectX::EndFrame()
{
ID3D11DeviceContext1* const __restrict d3dContext(m_pcDC->getDC());
ID3D11CommandList* __restrict pd3dCommandList(nullptr);

cMaxVRSingleton::getOculus()->EndFrame(d3dContext);

d3dContext->FinishCommandList(FALSE, &pd3dCommandList);

AcquireSRWLockShared(&m_SRWLockForIC);


m_d3dContextIC->ExecuteCommandList(pd3dCommandList, FALSE);

m_swapChain->Present(m_uiSyncInterval, 0);


ReleaseSRWLockShared(&m_SRWLockForIC);

pd3dCommandList->Release();

// State Reset for Next Frame Begins //
m_pcDC->Invalidate();
}


Great news, as the critical section would have had to encapsulate the Oculus Endframe, which added uneccessary time to the critical section lock - distortion rendering.

Thanks devs @ Oculus!
http://www.supersinfulsilicon.com/ supersinfulsilicon - software Home of the MaxVR Oculus Rift Video Player https://twitter.com/Carandiru