1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 10:24:10 +01:00

[d3d9] Try to create offscreen surfaces with render target usage

This commit is contained in:
Joshua Ashton 2020-02-13 23:31:25 +00:00 committed by Philip Rebohle
parent 1f5ddde411
commit 02c79d892c
2 changed files with 12 additions and 6 deletions

View File

@ -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<DxvkImage> D3D9CommonTexture::CreatePrimaryImage(D3DRESOURCETYPE ResourceType) const {
Rc<DxvkImage> 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

View File

@ -382,7 +382,7 @@ namespace dxvk {
*/
VkDeviceSize GetMipSize(UINT Subresource) const;
Rc<DxvkImage> CreatePrimaryImage(D3DRESOURCETYPE ResourceType) const;
Rc<DxvkImage> CreatePrimaryImage(D3DRESOURCETYPE ResourceType, bool TryOffscreenRT) const;
Rc<DxvkImage> CreateResolveImage() const;