[vr] Query required device extensions during instance creation

After the DXGI device refactor in c5deedef2d,
device extensions required for OpenVR interop would not be enabled correctly
because the VR-related code is now being called from both the D3D11 and DXGI
DLLs rather than just the DXGI DLL, and the D3D11 one is not in the expected
state when querying required device extensions. Querying them during instance
creation fixes that problem as it moves the relevant code back to the same
DLL which creates the Vulkan instance.
This commit is contained in:
Philip Rebohle 2018-12-20 01:27:49 +01:00
parent f638689b2a
commit 652525119f
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 23 additions and 13 deletions

View File

@ -208,6 +208,11 @@ namespace dxvk {
}
void DxvkAdapter::enableExtensions(const DxvkNameSet& extensions) {
m_extraExtensions.merge(extensions);
}
Rc<DxvkDevice> DxvkAdapter::createDevice(DxvkDeviceFeatures enabledFeatures) {
DxvkDeviceExtensions devExtensions;
@ -237,7 +242,7 @@ namespace dxvk {
throw DxvkError("DxvkAdapter: Failed to create device");
// Enable additional extensions if necessary
extensionsEnabled.merge(g_vrInstance.getDeviceExtensions(getAdapterIndex()));
extensionsEnabled.merge(m_extraExtensions);
DxvkNameList extensionNameList = extensionsEnabled.toNameList();
Logger::info("Enabled device extensions:");
@ -460,16 +465,6 @@ namespace dxvk {
m_vki->vkGetPhysicalDeviceQueueFamilyProperties(
m_handle, &numQueueFamilies, m_queueFamilies.data());
}
uint32_t DxvkAdapter::getAdapterIndex() const {
for (uint32_t i = 0; m_instance->enumAdapters(i) != nullptr; i++) {
if (m_instance->enumAdapters(i).ptr() == this)
return i;
}
return ~0u;
}
void DxvkAdapter::logNameList(const DxvkNameList& names) {

View File

@ -182,6 +182,17 @@ namespace dxvk {
bool checkFeatureSupport(
const DxvkDeviceFeatures& required) const;
/**
* \brief Enables extensions for this adapter
*
* When creating a device, all extensions that
* are added using this method will be enabled
* in addition to the ones required by DXVK.
* This is used for OpenVR support.
*/
void enableExtensions(
const DxvkNameSet& extensions);
/**
* \brief Creates a DXVK device
*
@ -244,6 +255,7 @@ namespace dxvk {
Rc<vk::InstanceFn> m_vki;
VkPhysicalDevice m_handle;
DxvkNameSet m_extraExtensions;
DxvkNameSet m_deviceExtensions;
DxvkDeviceInfo m_deviceInfo;
DxvkDeviceFeatures m_deviceFeatures;
@ -258,8 +270,6 @@ namespace dxvk {
void queryDeviceFeatures();
void queryDeviceQueues();
uint32_t getAdapterIndex() const;
static void logNameList(const DxvkNameList& names);
};

View File

@ -23,6 +23,11 @@ namespace dxvk {
m_adapters = this->queryAdapters();
g_vrInstance.initDeviceExtensions(this);
for (uint32_t i = 0; i < m_adapters.size(); i++) {
m_adapters[i]->enableExtensions(
g_vrInstance.getDeviceExtensions(i));
}
m_options = DxvkOptions(m_config);
}