mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-18 13:54:16 +01:00
[d3d11] Enable usage flags for meta copy formats
This is required in order to make meta copies work between images that do not have the necessary D3D11 bind flags set, and it may speed things up because it allows rendering to the destination image directly rather than requiring a temporary image.
This commit is contained in:
parent
509e6f1abf
commit
c5f7f9f3b0
@ -55,7 +55,7 @@ namespace dxvk {
|
||||
bool isMutable = formatFamily.FormatCount > 1;
|
||||
|
||||
if (isMutable && (formatProperties->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT)) {
|
||||
imageInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
||||
imageInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
|
||||
|
||||
// Typeless UAV images have relaxed reinterpretation rules
|
||||
if (!isTypeless || !(m_desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS)) {
|
||||
@ -139,6 +139,11 @@ namespace dxvk {
|
||||
// it is going to be used by the game.
|
||||
if (imageInfo.tiling == VK_IMAGE_TILING_OPTIMAL)
|
||||
imageInfo.layout = OptimizeLayout(imageInfo.usage);
|
||||
|
||||
// For some formats, we need to enable sampled and/or
|
||||
// render target capabilities if available, but these
|
||||
// should in no way affect the default image layout
|
||||
imageInfo.usage |= EnableMetaCopyUsage(imageInfo.format, imageInfo.tiling);
|
||||
|
||||
// Check if we can actually create the image
|
||||
if (!CheckImageSupport(&imageInfo, imageInfo.tiling)) {
|
||||
@ -308,6 +313,46 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
VkImageUsageFlags D3D11CommonTexture::EnableMetaCopyUsage(
|
||||
VkFormat Format,
|
||||
VkImageTiling Tiling) const {
|
||||
VkFormatFeatureFlags requestedFeatures = 0;
|
||||
|
||||
if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT) {
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
||||
| VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT) {
|
||||
requestedFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
||||
| VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
if (requestedFeatures == 0)
|
||||
return 0;
|
||||
|
||||
// Enable usage flags for all supported and requested features
|
||||
VkFormatProperties properties = m_device->GetDXVKDevice()->adapter()->formatProperties(Format);
|
||||
|
||||
requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL
|
||||
? properties.optimalTilingFeatures
|
||||
: properties.linearTilingFeatures;
|
||||
|
||||
VkImageUsageFlags requestedUsage = 0;
|
||||
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
|
||||
requestedUsage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
||||
requestedUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
|
||||
if (requestedFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)
|
||||
requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
return requestedUsage;
|
||||
}
|
||||
|
||||
|
||||
D3D11_COMMON_TEXTURE_MAP_MODE D3D11CommonTexture::DetermineMapMode(
|
||||
const DxvkImageCreateInfo* pImageInfo) const {
|
||||
// Don't map an image unless the application requests it
|
||||
|
@ -199,6 +199,10 @@ namespace dxvk {
|
||||
VkFormat Format,
|
||||
VkFormatFeatureFlags Features) const;
|
||||
|
||||
VkImageUsageFlags EnableMetaCopyUsage(
|
||||
VkFormat Format,
|
||||
VkImageTiling Tiling) const;
|
||||
|
||||
D3D11_COMMON_TEXTURE_MAP_MODE DetermineMapMode(
|
||||
const DxvkImageCreateInfo* pImageInfo) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user