diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp index 9c9a7817..f52feb94 100644 --- a/src/d3d9/d3d9_common_texture.cpp +++ b/src/d3d9/d3d9_common_texture.cpp @@ -26,14 +26,19 @@ namespace dxvk { m_shadow = DetermineShadowState(); if (m_mapMode == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED) { + bool plainSurface = m_type == D3DRTYPE_SURFACE && + !(m_desc.Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)); + try { - m_image = CreatePrimaryImage(ResourceType); + m_image = CreatePrimaryImage(ResourceType, plainSurface); } catch (const DxvkError& e) { - if (m_desc.Usage & D3DUSAGE_AUTOGENMIPMAP) { + // D3DUSAGE_AUTOGENMIPMAP and offscreen plain is mutually exclusive + // so we can combine their retry this way. + if (m_desc.Usage & D3DUSAGE_AUTOGENMIPMAP || plainSurface) { m_desc.Usage &= ~D3DUSAGE_AUTOGENMIPMAP; m_desc.MipLevels = 1; - m_image = CreatePrimaryImage(ResourceType); + m_image = CreatePrimaryImage(ResourceType, false); } else throw e; @@ -185,7 +190,7 @@ namespace dxvk { } - Rc D3D9CommonTexture::CreatePrimaryImage(D3DRESOURCETYPE ResourceType) const { + Rc D3D9CommonTexture::CreatePrimaryImage(D3DRESOURCETYPE ResourceType, bool TryOffscreenRT) const { DxvkImageCreateInfo imageInfo; imageInfo.type = GetImageTypeFromResourceType(ResourceType); imageInfo.format = m_mapping.ConversionFormatInfo.VulkanFormat != VK_FORMAT_UNDEFINED @@ -231,7 +236,8 @@ namespace dxvk { imageInfo.viewFormats = m_mapping.Formats; } - if (m_desc.Usage & D3DUSAGE_RENDERTARGET || m_desc.Usage & D3DUSAGE_AUTOGENMIPMAP) { + // Are we an RT, need to gen mips or an offscreen plain surface? + if (m_desc.Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_AUTOGENMIPMAP) || TryOffscreenRT) { imageInfo.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; imageInfo.stages |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; imageInfo.access |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT diff --git a/src/d3d9/d3d9_common_texture.h b/src/d3d9/d3d9_common_texture.h index a5c918b7..9e487c59 100644 --- a/src/d3d9/d3d9_common_texture.h +++ b/src/d3d9/d3d9_common_texture.h @@ -382,7 +382,7 @@ namespace dxvk { */ VkDeviceSize GetMipSize(UINT Subresource) const; - Rc CreatePrimaryImage(D3DRESOURCETYPE ResourceType) const; + Rc CreatePrimaryImage(D3DRESOURCETYPE ResourceType, bool TryOffscreenRT) const; Rc CreateResolveImage() const;