1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 13:08:50 +01:00

[dxvk] Add format feature queries to DxvkDevice

This commit is contained in:
Philip Rebohle 2022-08-17 14:01:45 +02:00
parent 61025c0079
commit cc8010fb7c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 106 additions and 1 deletions

View File

@ -60,6 +60,19 @@ namespace dxvk {
}
DxvkFormatFeatures DxvkAdapter::getFormatFeatures(VkFormat format) const {
VkFormatProperties3 properties3 = { VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3 };
VkFormatProperties2 properties2 = { VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, &properties3 };
m_vki->vkGetPhysicalDeviceFormatProperties2(m_handle, format, &properties2);
DxvkFormatFeatures result;
result.optimal = properties3.optimalTilingFeatures;
result.linear = properties3.linearTilingFeatures;
result.buffer = properties3.bufferFeatures;
return result;
}
VkFormatProperties DxvkAdapter::formatProperties(VkFormat format) const {
VkFormatProperties formatProperties;
m_vki->vkGetPhysicalDeviceFormatProperties(m_handle, format, &formatProperties);

View File

@ -3,6 +3,7 @@
#include "dxvk_device_info.h"
#include "dxvk_extensions.h"
#include "dxvk_include.h"
#include "dxvk_format.h"
namespace dxvk {
@ -135,6 +136,15 @@ namespace dxvk {
*/
VkPhysicalDeviceMemoryProperties memoryProperties() const;
/**
* \brief Queries format feature support
*
* \param [in] format Format to query
* \returns Format feature bits
*/
DxvkFormatFeatures getFormatFeatures(
VkFormat format) const;
/**
* \brief Queries format support
*

View File

@ -43,6 +43,39 @@ namespace dxvk {
}
std::optional<DxvkFormatLimits> DxvkDevice::getFormatLimits(
VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkImageCreateFlags flags) const {
auto vk = m_adapter->vki();
VkPhysicalDeviceImageFormatInfo2 info = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 };
info.format = format;
info.type = type;
info.tiling = tiling;
info.usage = usage;
info.flags = flags;
VkImageFormatProperties2 properties = { VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 };
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;
return result;
}
bool DxvkDevice::isUnifiedMemoryArchitecture() const {
return m_adapter->isUnifiedMemoryArchitecture();
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <optional>
#include "dxvk_adapter.h"
#include "dxvk_buffer.h"
#include "dxvk_compute.h"
@ -178,6 +180,33 @@ namespace dxvk {
return m_properties;
}
/**
* \brief Queries format feature support
*
* \param [in] format Format to query
* \returns Format feature bits
*/
DxvkFormatFeatures getFormatFeatures(VkFormat format) const {
return m_adapter->getFormatFeatures(format);
}
/**
* \brief Queries format limits
*
* \param [in] format Image format to quers
* \param [in] type Image type
* \param [in] tiling Image tiling
* \param [in] usage Image usage flags
* \param [in] flags Image create flags
* \returns Format limits if the given image is supported
*/
std::optional<DxvkFormatLimits> getFormatLimits(
VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkImageCreateFlags flags) const;
/**
* \brief Get device status
*

View File

@ -13,7 +13,27 @@ namespace dxvk {
};
using DxvkFormatFlags = Flags<DxvkFormatFlag>;
/**
* \brief Format support info
*/
struct DxvkFormatFeatures {
VkFormatFeatureFlags2 optimal;
VkFormatFeatureFlags2 linear;
VkFormatFeatureFlags2 buffer;
};
/**
* \brief Format support limits for a given set of image usage flags
*/
struct DxvkFormatLimits {
VkExtent3D maxExtent;
uint32_t maxMipLevels;
uint32_t maxArrayLayers;
VkSampleCountFlags sampleCounts;
VkDeviceSize maxResourceSize;
};
/**
* \brief Planar format info
*/