mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[vr] Refactor compositor initialization
This commit is contained in:
parent
bc1384b7b4
commit
cf6e3c1fbf
@ -34,15 +34,13 @@ namespace dxvk {
|
||||
void VrInstance::initInstanceExtensions() {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_initializedInsExt)
|
||||
return;
|
||||
|
||||
vr::IVRCompositor* compositor = this->getCompositor();
|
||||
if (m_compositor == nullptr)
|
||||
m_compositor = this->getCompositor();
|
||||
|
||||
if (compositor == nullptr)
|
||||
if (m_compositor == nullptr || m_initializedInsExt)
|
||||
return;
|
||||
|
||||
m_insExtensions = this->queryInstanceExtensions(compositor);
|
||||
m_insExtensions = this->queryInstanceExtensions();
|
||||
m_initializedInsExt = true;
|
||||
}
|
||||
|
||||
@ -50,35 +48,33 @@ namespace dxvk {
|
||||
void VrInstance::initDeviceExtensions(const DxvkInstance* instance) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (m_initializedDevExt)
|
||||
return;
|
||||
|
||||
vr::IVRCompositor* compositor = this->getCompositor();
|
||||
|
||||
if (compositor == nullptr)
|
||||
if (m_compositor == nullptr || m_initializedDevExt)
|
||||
return;
|
||||
|
||||
for (uint32_t i = 0; instance->enumAdapters(i) != nullptr; i++) {
|
||||
m_devExtensions.push_back(this->queryDeviceExtensions(
|
||||
compositor, instance->enumAdapters(i)->handle()));
|
||||
instance->enumAdapters(i)->handle()));
|
||||
}
|
||||
|
||||
if (m_initializedOpenVr)
|
||||
/* shutdown */;
|
||||
|
||||
m_initializedDevExt = true;
|
||||
}
|
||||
|
||||
|
||||
vk::NameSet VrInstance::queryInstanceExtensions(vr::IVRCompositor* compositor) const {
|
||||
uint32_t len = compositor->GetVulkanInstanceExtensionsRequired(nullptr, 0);
|
||||
vk::NameSet VrInstance::queryInstanceExtensions() const {
|
||||
uint32_t len = m_compositor->GetVulkanInstanceExtensionsRequired(nullptr, 0);
|
||||
std::vector<char> extensionList(len);
|
||||
len = compositor->GetVulkanInstanceExtensionsRequired(extensionList.data(), len);
|
||||
len = m_compositor->GetVulkanInstanceExtensionsRequired(extensionList.data(), len);
|
||||
return parseExtensionList(std::string(extensionList.data(), len));
|
||||
}
|
||||
|
||||
|
||||
vk::NameSet VrInstance::queryDeviceExtensions(vr::IVRCompositor* compositor, VkPhysicalDevice adapter) const {
|
||||
uint32_t len = compositor->GetVulkanDeviceExtensionsRequired(adapter, nullptr, 0);
|
||||
vk::NameSet VrInstance::queryDeviceExtensions(VkPhysicalDevice adapter) const {
|
||||
uint32_t len = m_compositor->GetVulkanDeviceExtensionsRequired(adapter, nullptr, 0);
|
||||
std::vector<char> extensionList(len);
|
||||
len = compositor->GetVulkanDeviceExtensionsRequired(adapter, extensionList.data(), len);
|
||||
len = m_compositor->GetVulkanDeviceExtensionsRequired(adapter, extensionList.data(), len);
|
||||
return parseExtensionList(std::string(extensionList.data(), len));
|
||||
}
|
||||
|
||||
@ -128,7 +124,7 @@ namespace dxvk {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Logger::warn("OpenVR: Compositor interface found");
|
||||
Logger::info("OpenVR: Compositor interface found");
|
||||
return compositor;
|
||||
}
|
||||
|
||||
|
@ -63,19 +63,19 @@ namespace dxvk {
|
||||
|
||||
private:
|
||||
|
||||
std::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
vr::IVRCompositor* m_compositor;
|
||||
|
||||
bool m_initializedOpenVr = false;
|
||||
bool m_initializedInsExt = false;
|
||||
bool m_initializedDevExt = false;
|
||||
|
||||
vk::NameSet m_insExtensions;
|
||||
std::vector<vk::NameSet> m_devExtensions;
|
||||
|
||||
vk::NameSet queryInstanceExtensions(
|
||||
vr::IVRCompositor* compositor) const;
|
||||
vk::NameSet queryInstanceExtensions() const;
|
||||
|
||||
vk::NameSet queryDeviceExtensions(
|
||||
vr::IVRCompositor* compositor,
|
||||
VkPhysicalDevice adapter) const;
|
||||
|
||||
static vk::NameSet parseExtensionList(const std::string& str);
|
||||
|
Loading…
Reference in New Issue
Block a user