Skip to content

Commit

Permalink
[d3d9] Do not proactively enable meta copy usage flags
Browse files Browse the repository at this point in the history
Same as the corresponding D3D11 change, let the backend deal with this
when necessary.
  • Loading branch information
doitsujin committed Sep 28, 2024
1 parent 99c3eff commit dedbcf9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
48 changes: 0 additions & 48 deletions src/d3d9/d3d9_common_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,6 @@ namespace dxvk {
if (imageInfo.tiling == VK_IMAGE_TILING_OPTIMAL && imageInfo.sharing.mode == DxvkSharedHandleMode::None)
imageInfo.layout = OptimizeLayout(imageInfo.usage);

// For some formats, we need to enable render target
// capabilities if available, but these should
// in no way affect the default image layout
imageInfo.usage |= EnableMetaCopyUsage(imageInfo.format, imageInfo.tiling, imageInfo.sampleCount);

// Check if we can actually create the image
if (!CheckImageSupport(&imageInfo, imageInfo.tiling)) {
throw DxvkError(str::format(
Expand Down Expand Up @@ -459,49 +454,6 @@ namespace dxvk {
}


VkImageUsageFlags D3D9CommonTexture::EnableMetaCopyUsage(
VkFormat Format,
VkImageTiling Tiling,
VkSampleCountFlags SampleCount) const {
VkFormatFeatureFlags2 requestedFeatures = 0;

if (Format == VK_FORMAT_D16_UNORM || Format == VK_FORMAT_D32_SFLOAT)
requestedFeatures |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT;

if (Format == VK_FORMAT_R16_UNORM || Format == VK_FORMAT_R32_SFLOAT)
requestedFeatures |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT;

// We need SAMPLED_BIT for StretchRect.
// However, StretchRect does not allow stretching for DS formats,
// so unless we need to resolve, it should always hit code paths that only need TRANSFER_BIT.
if (!IsDepthStencilFormat(m_desc.Format) || SampleCount != VK_SAMPLE_COUNT_1_BIT)
requestedFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT;

if (!requestedFeatures)
return 0;

// Enable usage flags for all supported and requested features
DxvkFormatFeatures properties = m_device->GetDXVKDevice()->getFormatFeatures(Format);

requestedFeatures &= Tiling == VK_IMAGE_TILING_OPTIMAL
? properties.optimal
: properties.linear;

VkImageUsageFlags requestedUsage = 0;

if (requestedFeatures & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT)
requestedUsage |= VK_IMAGE_USAGE_SAMPLED_BIT;

if (requestedFeatures & VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)
requestedUsage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;

if (requestedFeatures & VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT)
requestedUsage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;

return requestedUsage;
}


VkImageType D3D9CommonTexture::GetImageTypeFromResourceType(D3DRESOURCETYPE Type) {
switch (Type) {
case D3DRTYPE_SURFACE:
Expand Down
5 changes: 0 additions & 5 deletions src/d3d9/d3d9_common_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,6 @@ namespace dxvk {
const DxvkImageCreateInfo* pImageInfo,
VkImageTiling Tiling) const;

VkImageUsageFlags EnableMetaCopyUsage(
VkFormat Format,
VkImageTiling Tiling,
VkSampleCountFlags SampleCount) const;

D3D9_COMMON_TEXTURE_MAP_MODE DetermineMapMode() const;

VkImageLayout OptimizeLayout(
Expand Down

0 comments on commit dedbcf9

Please sign in to comment.