mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-18 13:54:16 +01:00
[dxvk] Add extended device info structure
This uses VK_KHR_get_physical_device_properties2 to query extension-specific device properties. Queries info for VK_EXT_vertex_attribute_divisor.
This commit is contained in:
parent
91407098d5
commit
ebb7902b2c
@ -13,13 +13,9 @@ namespace dxvk {
|
||||
: m_instance (instance),
|
||||
m_vki (instance->vki()),
|
||||
m_handle (handle) {
|
||||
uint32_t numQueueFamilies = 0;
|
||||
m_vki->vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
m_handle, &numQueueFamilies, nullptr);
|
||||
|
||||
m_queueFamilies.resize(numQueueFamilies);
|
||||
m_vki->vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
m_handle, &numQueueFamilies, m_queueFamilies.data());
|
||||
this->queryExtensions();
|
||||
this->queryDeviceInfo();
|
||||
this->queryDeviceQueues();
|
||||
}
|
||||
|
||||
|
||||
@ -33,21 +29,6 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
VkPhysicalDeviceProperties DxvkAdapter::deviceProperties() const {
|
||||
VkPhysicalDeviceProperties properties;
|
||||
m_vki->vkGetPhysicalDeviceProperties(m_handle, &properties);
|
||||
|
||||
if (DxvkGpuVendor(properties.vendorID) == DxvkGpuVendor::Nvidia) {
|
||||
properties.driverVersion = VK_MAKE_VERSION(
|
||||
VK_VERSION_MAJOR(properties.driverVersion),
|
||||
VK_VERSION_MINOR(properties.driverVersion >> 0) >> 2,
|
||||
VK_VERSION_PATCH(properties.driverVersion >> 2) >> 4);
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
VkPhysicalDeviceMemoryProperties DxvkAdapter::memoryProperties() const {
|
||||
VkPhysicalDeviceMemoryProperties memoryProperties;
|
||||
m_vki->vkGetPhysicalDeviceMemoryProperties(m_handle, &memoryProperties);
|
||||
@ -177,9 +158,8 @@ namespace dxvk {
|
||||
}};
|
||||
|
||||
DxvkNameSet extensionsEnabled;
|
||||
DxvkNameSet extensionsAvailable = DxvkNameSet::enumDeviceExtensions(m_vki, m_handle);
|
||||
|
||||
if (!extensionsAvailable.enableExtensions(
|
||||
if (!m_deviceExtensions.enableExtensions(
|
||||
devExtensionList.size(),
|
||||
devExtensionList.data(),
|
||||
extensionsEnabled))
|
||||
@ -275,6 +255,44 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkAdapter::queryExtensions() {
|
||||
m_deviceExtensions = DxvkNameSet::enumDeviceExtensions(m_vki, m_handle);
|
||||
}
|
||||
|
||||
|
||||
void DxvkAdapter::queryDeviceInfo() {
|
||||
m_deviceInfo = DxvkDeviceInfo();
|
||||
m_deviceInfo.core.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||
m_deviceInfo.core.pNext = nullptr;
|
||||
|
||||
if (m_deviceExtensions.supports(VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME)) {
|
||||
m_deviceInfo.extVertexAttributeDivisor.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT;
|
||||
m_deviceInfo.extVertexAttributeDivisor.pNext = std::exchange(m_deviceInfo.core.pNext, &m_deviceInfo.extVertexAttributeDivisor);
|
||||
}
|
||||
|
||||
m_vki->vkGetPhysicalDeviceProperties2KHR(m_handle, &m_deviceInfo.core);
|
||||
|
||||
// Nvidia reports the driver version in a slightly different format
|
||||
if (DxvkGpuVendor(m_deviceInfo.core.properties.vendorID) == DxvkGpuVendor::Nvidia) {
|
||||
m_deviceInfo.core.properties.driverVersion = VK_MAKE_VERSION(
|
||||
VK_VERSION_MAJOR(m_deviceInfo.core.properties.driverVersion),
|
||||
VK_VERSION_MINOR(m_deviceInfo.core.properties.driverVersion >> 0) >> 2,
|
||||
VK_VERSION_PATCH(m_deviceInfo.core.properties.driverVersion >> 2) >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DxvkAdapter::queryDeviceQueues() {
|
||||
uint32_t numQueueFamilies = 0;
|
||||
m_vki->vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
m_handle, &numQueueFamilies, nullptr);
|
||||
|
||||
m_queueFamilies.resize(numQueueFamilies);
|
||||
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)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxvk_device_info.h"
|
||||
#include "dxvk_extensions.h"
|
||||
#include "dxvk_include.h"
|
||||
|
||||
@ -60,10 +61,25 @@ namespace dxvk {
|
||||
/**
|
||||
* \brief Physical device properties
|
||||
*
|
||||
* Retrieves information about the device itself.
|
||||
* \returns Physical device properties
|
||||
* Returns a read-only reference to the core
|
||||
* properties of the Vulkan physical device.
|
||||
* \returns Physical device core properties
|
||||
*/
|
||||
VkPhysicalDeviceProperties deviceProperties() const;
|
||||
const VkPhysicalDeviceProperties& deviceProperties() const {
|
||||
return m_deviceInfo.core.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Device info
|
||||
*
|
||||
* Returns a read-only reference to the full
|
||||
* device info structure, including extended
|
||||
* properties.
|
||||
* \returns Device info struct
|
||||
*/
|
||||
const DxvkDeviceInfo& devicePropertiesExt() const {
|
||||
return m_deviceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Memory properties
|
||||
@ -165,11 +181,18 @@ namespace dxvk {
|
||||
Rc<DxvkInstance> m_instance;
|
||||
Rc<vk::InstanceFn> m_vki;
|
||||
VkPhysicalDevice m_handle;
|
||||
|
||||
DxvkNameSet m_deviceExtensions;
|
||||
DxvkDeviceInfo m_deviceInfo;
|
||||
|
||||
std::vector<VkQueueFamilyProperties> m_queueFamilies;
|
||||
|
||||
uint32_t getAdapterIndex() const;
|
||||
void queryExtensions();
|
||||
void queryDeviceInfo();
|
||||
void queryDeviceQueues();
|
||||
|
||||
uint32_t getAdapterIndex() const;
|
||||
|
||||
static void logNameList(const DxvkNameList& names);
|
||||
|
||||
};
|
||||
|
20
src/dxvk/dxvk_device_info.h
Normal file
20
src/dxvk/dxvk_device_info.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxvk_include.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Device info
|
||||
*
|
||||
* Stores core properties and a bunch of extension-specific
|
||||
* properties, if the respective extensions are available.
|
||||
* Structures for unsupported extensions will be undefined,
|
||||
* so before using them, check whether they are supported.
|
||||
*/
|
||||
struct DxvkDeviceInfo {
|
||||
VkPhysicalDeviceProperties2KHR core;
|
||||
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT extVertexAttributeDivisor;
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user