1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[dxvk] Move getFormatLimits back to DxvkAdapter

This commit is contained in:
Philip Rebohle 2022-09-11 16:08:40 +02:00
parent c0fdf1449c
commit 0123e844b2
4 changed files with 52 additions and 43 deletions

View File

@ -73,6 +73,44 @@ namespace dxvk {
}
std::optional<DxvkFormatLimits> DxvkAdapter::getFormatLimits(
const DxvkFormatQuery& query) const {
VkPhysicalDeviceExternalImageFormatInfo externalInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO };
externalInfo.handleType = query.handleType;
VkPhysicalDeviceImageFormatInfo2 info = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 };
info.format = query.format;
info.type = query.type;
info.tiling = query.tiling;
info.usage = query.usage;
info.flags = query.flags;
if (externalInfo.handleType)
externalInfo.pNext = std::exchange(info.pNext, &externalInfo);
VkExternalImageFormatProperties externalProperties = { VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES };
VkImageFormatProperties2 properties = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 };
if (externalInfo.handleType)
externalProperties.pNext = std::exchange(properties.pNext, &externalProperties);
VkResult vr = m_vki->vkGetPhysicalDeviceImageFormatProperties2(
m_handle, &info, &properties);
if (vr != VK_SUCCESS)
return std::nullopt;
DxvkFormatLimits result = { };
result.maxExtent = properties.imageFormatProperties.maxExtent;
result.maxMipLevels = properties.imageFormatProperties.maxMipLevels;
result.maxArrayLayers = properties.imageFormatProperties.maxArrayLayers;
result.sampleCounts = properties.imageFormatProperties.sampleCounts;
result.maxResourceSize = properties.imageFormatProperties.maxResourceSize;
result.externalFeatures = externalProperties.externalMemoryProperties.externalMemoryFeatures;
return result;
}
DxvkAdapterQueueIndices DxvkAdapter::findQueueFamilies() const {
uint32_t graphicsQueue = findQueueFamily(
VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT,

View File

@ -1,5 +1,7 @@
#pragma once
#include <optional>
#include "dxvk_device_info.h"
#include "dxvk_extensions.h"
#include "dxvk_include.h"
@ -146,6 +148,15 @@ namespace dxvk {
DxvkFormatFeatures getFormatFeatures(
VkFormat format) const;
/**
* \brief Queries format limits
*
* \param [in] query Format query info
* \returns Format limits if the given image is supported
*/
std::optional<DxvkFormatLimits> getFormatLimits(
const DxvkFormatQuery& query) const;
/**
* \brief Retrieves queue family indices
* \returns Indices for all queue families

View File

@ -42,46 +42,6 @@ namespace dxvk {
}
std::optional<DxvkFormatLimits> DxvkDevice::getFormatLimits(
const DxvkFormatQuery& query) const {
auto vk = m_adapter->vki();
VkPhysicalDeviceExternalImageFormatInfo externalInfo = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO };
externalInfo.handleType = query.handleType;
VkPhysicalDeviceImageFormatInfo2 info = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 };
info.format = query.format;
info.type = query.type;
info.tiling = query.tiling;
info.usage = query.usage;
info.flags = query.flags;
if (externalInfo.handleType)
externalInfo.pNext = std::exchange(info.pNext, &externalInfo);
VkExternalImageFormatProperties externalProperties = { VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES };
VkImageFormatProperties2 properties = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 };
if (externalInfo.handleType)
externalProperties.pNext = std::exchange(properties.pNext, &externalProperties);
VkResult vr = vk->vkGetPhysicalDeviceImageFormatProperties2(
m_adapter->handle(), &info, &properties);
if (vr != VK_SUCCESS)
return std::nullopt;
DxvkFormatLimits result = { };
result.maxExtent = properties.imageFormatProperties.maxExtent;
result.maxMipLevels = properties.imageFormatProperties.maxMipLevels;
result.maxArrayLayers = properties.imageFormatProperties.maxArrayLayers;
result.sampleCounts = properties.imageFormatProperties.sampleCounts;
result.maxResourceSize = properties.imageFormatProperties.maxResourceSize;
result.externalFeatures = externalProperties.externalMemoryProperties.externalMemoryFeatures;
return result;
}
bool DxvkDevice::isUnifiedMemoryArchitecture() const {
return m_adapter->isUnifiedMemoryArchitecture();
}

View File

@ -1,7 +1,5 @@
#pragma once
#include <optional>
#include "dxvk_adapter.h"
#include "dxvk_buffer.h"
#include "dxvk_compute.h"
@ -190,7 +188,9 @@ namespace dxvk {
* \returns Format limits if the given image is supported
*/
std::optional<DxvkFormatLimits> getFormatLimits(
const DxvkFormatQuery& query) const;
const DxvkFormatQuery& query) const {
return m_adapter->getFormatLimits(query);
}
/**
* \brief Get device status