我正在尝试使用Vulkan和OVR创建VR应用程序。
以下是主要步骤:
ovrInitParams initParams = { ovrInit_RequestVersion | ovrInit_FocusAware, OVR_MINOR_VERSION, NULL, 0, 0 };
ovrResult result = ovr_Initialize(&initParams);
if (!OVR_SUCCESS(result))
{
Debug::sendError("Failed to initialize OVR");
return;
}
result = ovr_Create(&m_session, &m_luid);
if (!OVR_SUCCESS(result))
{
Debug::sendError("Failed to create OVR");
return;
}
ovr_GetSessionPhysicalDeviceVk(m_session, m_luid, m_instance, &m_physicalDevice);
ovrTextureSwapChainDesc colorDesc = {};
colorDesc.Type = ovrTexture_2D;
colorDesc.ArraySize = 1;
colorDesc.Format = OVR_FORMAT_B8G8R8A8_UNORM_SRGB;
colorDesc.Width = 1280;
colorDesc.Height = 720;
colorDesc.MipLevels = 1;
colorDesc.SampleCount = 1;
colorDesc.MiscFlags = ovrTextureMisc_DX_Typeless;
colorDesc.BindFlags = ovrTextureBind_DX_RenderTarget;
colorDesc.StaticImage = ovrFalse;
ovrResult result = ovr_CreateTextureSwapChainVk(m_session, device, &colorDesc, &m_textureChain);
if (!OVR_SUCCESS(result))
{
ovrErrorInfo errorInfo;
ovr_GetLastErrorInfo(&errorInfo);
Debug::sendError("Failed to create swapchain OVR");
return;
}
问题是程序在调用ovr_CreateTextureSwapChainVk
时崩溃。
问题是由于设备扩展。这是使用OVR的正确扩展:
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, "VK_KHR_external_memory_win32", VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, "VK_KHR_external_semaphore_win32", VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME };