mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-13 07:08:50 +01:00
[d3d9] Use new format support queries
This commit is contained in:
parent
13152088d4
commit
80fc1d8b25
@ -717,32 +717,32 @@ namespace dxvk {
|
||||
VkFormat Format,
|
||||
DWORD Usage,
|
||||
D3DRESOURCETYPE RType) {
|
||||
VkFormatFeatureFlags checkFlags = 0;
|
||||
VkFormatFeatureFlags2 checkFlags = 0;
|
||||
|
||||
if (RType != D3DRTYPE_SURFACE)
|
||||
checkFlags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
checkFlags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
|
||||
|
||||
if (Usage & D3DUSAGE_RENDERTARGET) {
|
||||
checkFlags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
checkFlags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
if (Usage & D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING)
|
||||
checkFlags |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT;
|
||||
checkFlags |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT;
|
||||
}
|
||||
|
||||
if (Usage & D3DUSAGE_DEPTHSTENCIL)
|
||||
checkFlags |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
checkFlags |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
else
|
||||
checkFlags |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
checkFlags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
|
||||
|
||||
VkFormatFeatureFlags checkFlagsMipGen = checkFlags;
|
||||
VkFormatFeatureFlags2 checkFlagsMipGen = checkFlags;
|
||||
|
||||
if (Usage & D3DUSAGE_AUTOGENMIPMAP) {
|
||||
checkFlagsMipGen |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
checkFlagsMipGen |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
checkFlagsMipGen |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
|
||||
checkFlagsMipGen |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
VkFormatProperties fmtSupport = m_adapter->formatProperties(Format);
|
||||
VkFormatFeatureFlags imgFeatures = fmtSupport.optimalTilingFeatures | fmtSupport.linearTilingFeatures;
|
||||
DxvkFormatFeatures fmtSupport = m_adapter->getFormatFeatures(Format);
|
||||
VkFormatFeatureFlags2 imgFeatures = fmtSupport.optimal | fmtSupport.linear;
|
||||
|
||||
if ((imgFeatures & checkFlags) != checkFlags)
|
||||
return D3DERR_NOTAVAILABLE;
|
||||
|
@ -379,53 +379,49 @@ namespace dxvk {
|
||||
BOOL D3D9CommonTexture::CheckImageSupport(
|
||||
const DxvkImageCreateInfo* pImageInfo,
|
||||
VkImageTiling Tiling) const {
|
||||
const Rc<DxvkAdapter> adapter = m_device->GetDXVKDevice()->adapter();
|
||||
|
||||
VkImageFormatProperties formatProps = { };
|
||||
|
||||
VkResult status = adapter->imageFormatProperties(
|
||||
auto properties = m_device->GetDXVKDevice()->getFormatLimits(
|
||||
pImageInfo->format, pImageInfo->type, Tiling,
|
||||
pImageInfo->usage, pImageInfo->flags, formatProps);
|
||||
pImageInfo->usage, pImageInfo->flags);
|
||||
|
||||
if (status != VK_SUCCESS)
|
||||
if (!properties)
|
||||
return FALSE;
|
||||
|
||||
return (pImageInfo->extent.width <= formatProps.maxExtent.width)
|
||||
&& (pImageInfo->extent.height <= formatProps.maxExtent.height)
|
||||
&& (pImageInfo->extent.depth <= formatProps.maxExtent.depth)
|
||||
&& (pImageInfo->numLayers <= formatProps.maxArrayLayers)
|
||||
&& (pImageInfo->mipLevels <= formatProps.maxMipLevels)
|
||||
&& (pImageInfo->sampleCount & formatProps.sampleCounts);
|
||||
return (pImageInfo->extent.width <= properties->maxExtent.width)
|
||||
&& (pImageInfo->extent.height <= properties->maxExtent.height)
|
||||
&& (pImageInfo->extent.depth <= properties->maxExtent.depth)
|
||||
&& (pImageInfo->numLayers <= properties->maxArrayLayers)
|
||||
&& (pImageInfo->mipLevels <= properties->maxMipLevels)
|
||||
&& (pImageInfo->sampleCount & properties->sampleCounts);
|
||||
}
|
||||
|
||||
|
||||
VkImageUsageFlags D3D9CommonTexture::EnableMetaCopyUsage(
|
||||
VkFormat Format,
|
||||
VkImageTiling Tiling) const {
|
||||
VkFormatFeatureFlags requestedFeatures = 0;
|
||||
VkFormatFeatureFlags2 requestedFeatures = 0;
|
||||
|
||||
if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT)
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT)
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
if (requestedFeatures == 0)
|
||||
if (!requestedFeatures)
|
||||
return 0;
|
||||
|
||||
// Enable usage flags for all supported and requested features
|
||||
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format);
|
||||
DxvkFormatFeatures properties = m_device->GetDXVKDevice()->getFormatFeatures(Format);
|
||||
|
||||
requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL
|
||||
? properties.optimalTilingFeatures
|
||||
: properties.linearTilingFeatures;
|
||||
? properties.optimal
|
||||
: properties.linear;
|
||||
|
||||
VkImageUsageFlags requestedUsage = 0;
|
||||
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||
requestedUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT)
|
||||
requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
return requestedUsage;
|
||||
|
@ -3903,7 +3903,6 @@ namespace dxvk {
|
||||
enabled.core.features.vertexPipelineStoresAndAtomics = supported.core.features.vertexPipelineStoresAndAtomics;
|
||||
|
||||
// DXVK Meta
|
||||
enabled.core.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
|
||||
enabled.core.features.imageCubeArray = VK_TRUE;
|
||||
|
||||
// SM1 level hardware
|
||||
|
@ -435,14 +435,14 @@ namespace dxvk {
|
||||
// AMD do not support 24-bit depth buffers on Vulkan,
|
||||
// so we have to fall back to a 32-bit depth format.
|
||||
m_d24s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D24_UNORM_S8_UINT,
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
|
||||
VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT |
|
||||
VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT);
|
||||
|
||||
// NVIDIA do not support 16-bit depth buffers with stencil on Vulkan,
|
||||
// so we have to fall back to a 32-bit depth format.
|
||||
m_d16s8Support = CheckImageFormatSupport(adapter, VK_FORMAT_D16_UNORM_S8_UINT,
|
||||
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT |
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
|
||||
VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT |
|
||||
VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT);
|
||||
|
||||
// VK_EXT_4444_formats
|
||||
if (!m_d24s8Support)
|
||||
@ -538,11 +538,11 @@ namespace dxvk {
|
||||
bool D3D9VkFormatTable::CheckImageFormatSupport(
|
||||
const Rc<DxvkAdapter>& Adapter,
|
||||
VkFormat Format,
|
||||
VkFormatFeatureFlags Features) const {
|
||||
VkFormatProperties supported = Adapter->formatProperties(Format);
|
||||
VkFormatFeatureFlags2 Features) const {
|
||||
DxvkFormatFeatures supported = Adapter->getFormatFeatures(Format);
|
||||
|
||||
return (supported.linearTilingFeatures & Features) == Features
|
||||
|| (supported.optimalTilingFeatures & Features) == Features;
|
||||
return (supported.linear & Features) == Features
|
||||
|| (supported.optimal & Features) == Features;
|
||||
}
|
||||
|
||||
}
|
@ -209,7 +209,7 @@ namespace dxvk {
|
||||
bool CheckImageFormatSupport(
|
||||
const Rc<DxvkAdapter>& Adapter,
|
||||
VkFormat Format,
|
||||
VkFormatFeatureFlags Features) const;
|
||||
VkFormatFeatureFlags2 Features) const;
|
||||
|
||||
bool m_d24s8Support;
|
||||
bool m_d16s8Support;
|
||||
|
@ -97,14 +97,14 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
VkFormatFeatureFlags GetImageFormatFeatures(DWORD Usage) {
|
||||
VkFormatFeatureFlags features = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
VkFormatFeatureFlags2 GetImageFormatFeatures(DWORD Usage) {
|
||||
VkFormatFeatureFlags2 features = VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;
|
||||
|
||||
if (Usage & D3DUSAGE_DEPTHSTENCIL)
|
||||
features |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (Usage & D3DUSAGE_RENDERTARGET)
|
||||
features |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
return features;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ namespace dxvk {
|
||||
|
||||
VkFormat GetPackedDepthStencilFormat(D3D9Format Format);
|
||||
|
||||
VkFormatFeatureFlags GetImageFormatFeatures(DWORD Usage);
|
||||
VkFormatFeatureFlags2 GetImageFormatFeatures(DWORD Usage);
|
||||
|
||||
VkImageUsageFlags GetImageUsageFlags(DWORD Usage);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user