mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
VR: Properly support MSAA in OVR builds
Fixes #338 Create the swap chain without MSAA, and the eye textures with MSAA. The core issue was using the surface description for the backbuffer for the DSV on the eye textures which did not match. This meethod follows both the oculus and openvr guidance on MSAA - MSAA is configured on the eye render targets, but not on the swap chain.
This commit is contained in:
parent
ad4b2f134f
commit
9a1b1f892c
2 changed files with 27 additions and 7 deletions
|
@ -1725,18 +1725,29 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
|
|
||||||
DX_RELEASE(m_swapChain, 0);
|
DX_RELEASE(m_swapChain, 0);
|
||||||
|
|
||||||
|
SWAP_CHAIN_DESC_TYPE* scd = &m_scd;
|
||||||
|
#if BGFX_CONFIG_USE_OVR
|
||||||
|
SWAP_CHAIN_DESC_TYPE swapChainScd;
|
||||||
|
if ((m_flags & BGFX_RESET_HMD) && m_ovr.isInitialized())
|
||||||
|
{
|
||||||
|
swapChainScd = m_scd;
|
||||||
|
swapChainScd.SampleDesc = s_msaa[0];
|
||||||
|
scd = &swapChainScd;
|
||||||
|
}
|
||||||
|
#endif // BGFX_CONFIG_USE_OVR
|
||||||
|
|
||||||
#if BX_PLATFORM_WINRT
|
#if BX_PLATFORM_WINRT
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = m_factory->CreateSwapChainForCoreWindow(m_device
|
hr = m_factory->CreateSwapChainForCoreWindow(m_device
|
||||||
, (::IUnknown*)g_platformData.nwh
|
, (::IUnknown*)g_platformData.nwh
|
||||||
, &m_scd
|
, scd
|
||||||
, NULL
|
, NULL
|
||||||
, &m_swapChain
|
, &m_swapChain
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = m_factory->CreateSwapChain(m_device
|
hr = m_factory->CreateSwapChain(m_device
|
||||||
, &m_scd
|
, scd
|
||||||
, &m_swapChain
|
, &m_swapChain
|
||||||
);
|
);
|
||||||
#endif // BX_PLATFORM_WINRT
|
#endif // BX_PLATFORM_WINRT
|
||||||
|
@ -2294,7 +2305,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
bx::write(&writer, magic);
|
bx::write(&writer, magic);
|
||||||
|
|
||||||
TextureCreate tc;
|
TextureCreate tc;
|
||||||
tc.m_flags = BGFX_TEXTURE_RT;
|
tc.m_flags = BGFX_TEXTURE_RT|(((m_flags & BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT) << BGFX_TEXTURE_RT_MSAA_SHIFT);
|
||||||
tc.m_width = m_ovr.m_rtSize.w;
|
tc.m_width = m_ovr.m_rtSize.w;
|
||||||
tc.m_height = m_ovr.m_rtSize.h;
|
tc.m_height = m_ovr.m_rtSize.h;
|
||||||
tc.m_sides = 0;
|
tc.m_sides = 0;
|
||||||
|
@ -2702,10 +2713,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
bool m_wireframe;
|
bool m_wireframe;
|
||||||
|
|
||||||
#if BX_PLATFORM_WINRT
|
#if BX_PLATFORM_WINRT
|
||||||
DXGI_SWAP_CHAIN_DESC1 m_scd;
|
typedef DXGI_SWAP_CHAIN_DESC1 SWAP_CHAIN_DESC_TYPE;
|
||||||
#else
|
#else
|
||||||
DXGI_SWAP_CHAIN_DESC m_scd;
|
typedef DXGI_SWAP_CHAIN_DESC SWAP_CHAIN_DESC_TYPE;
|
||||||
#endif
|
#endif
|
||||||
|
SWAP_CHAIN_DESC_TYPE m_scd;
|
||||||
uint32_t m_flags;
|
uint32_t m_flags;
|
||||||
uint32_t m_maxAnisotropy;
|
uint32_t m_maxAnisotropy;
|
||||||
|
|
||||||
|
|
|
@ -2150,9 +2150,17 @@ namespace bgfx { namespace gl
|
||||||
m_resolution = _resolution;
|
m_resolution = _resolution;
|
||||||
m_resolution.m_flags = flags;
|
m_resolution.m_flags = flags;
|
||||||
|
|
||||||
|
uint32_t flags = m_resolution.m_flags;
|
||||||
|
#if BGFX_CONFIG_USE_OVR
|
||||||
|
if ((flags & BGFX_RESET_HMD) && m_ovr.isInitialized())
|
||||||
|
{
|
||||||
|
flags &= ~BGFX_RESET_MSAA_MASK;
|
||||||
|
}
|
||||||
|
#endif // BGFX_CONFIG_OVR
|
||||||
|
|
||||||
setRenderContextSize(m_resolution.m_width
|
setRenderContextSize(m_resolution.m_width
|
||||||
, m_resolution.m_height
|
, m_resolution.m_height
|
||||||
, m_resolution.m_flags
|
, flags
|
||||||
);
|
);
|
||||||
updateCapture();
|
updateCapture();
|
||||||
|
|
||||||
|
@ -2461,7 +2469,7 @@ namespace bgfx { namespace gl
|
||||||
bx::write(&writer, magic);
|
bx::write(&writer, magic);
|
||||||
|
|
||||||
TextureCreate tc;
|
TextureCreate tc;
|
||||||
tc.m_flags = BGFX_TEXTURE_RT;
|
tc.m_flags = BGFX_TEXTURE_RT|(((m_resolution.m_flags & BGFX_RESET_MSAA_MASK) >> BGFX_RESET_MSAA_SHIFT) << BGFX_TEXTURE_RT_MSAA_SHIFT);;
|
||||||
tc.m_width = m_ovr.m_rtSize.w;
|
tc.m_width = m_ovr.m_rtSize.w;
|
||||||
tc.m_height = m_ovr.m_rtSize.h;
|
tc.m_height = m_ovr.m_rtSize.h;
|
||||||
tc.m_sides = 0;
|
tc.m_sides = 0;
|
||||||
|
|
Loading…
Reference in a new issue