From d5041337f53652d3eacd30524da07447aa08e0f7 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 29 Apr 2018 14:43:24 +0200 Subject: [PATCH] [d3d11] Use linar tiling for textures if optimal tiling is not supported Fixes texture creation issues in various Batman games. --- src/d3d11/d3d11_texture.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/d3d11/d3d11_texture.cpp b/src/d3d11/d3d11_texture.cpp index 9a28828a..1f3e6d9f 100644 --- a/src/d3d11/d3d11_texture.cpp +++ b/src/d3d11/d3d11_texture.cpp @@ -65,19 +65,10 @@ namespace dxvk { if (Dimension == D3D11_RESOURCE_DIMENSION_TEXTURE3D) imageInfo.flags |= VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR; - // Test whether the combination of image parameters is supported - if (!CheckImageSupport(&imageInfo, VK_IMAGE_TILING_OPTIMAL)) { - throw DxvkError(str::format( - "D3D11: Cannot create texture:", - "\n Format: ", imageInfo.format, - "\n Extent: ", imageInfo.extent.width, - "x", imageInfo.extent.height, - "x", imageInfo.extent.depth, - "\n Samples: ", imageInfo.sampleCount, - "\n Layers: ", imageInfo.numLayers, - "\n Levels: ", imageInfo.mipLevels, - "\n Usage: ", std::hex, imageInfo.usage)); - } + // Some image formats (i.e. the R32G32B32 ones) are + // only supported with linear tiling on most GPUs + if (!CheckImageSupport(&imageInfo, VK_IMAGE_TILING_OPTIMAL)) + imageInfo.tiling = VK_IMAGE_TILING_LINEAR; // Determine map mode based on our findings m_mapMode = DetermineMapMode(&imageInfo); @@ -102,6 +93,20 @@ namespace dxvk { if (imageInfo.tiling == VK_IMAGE_TILING_OPTIMAL) imageInfo.layout = OptimizeLayout(imageInfo.usage); + // Check if we can actually create the image + if (!CheckImageSupport(&imageInfo, imageInfo.tiling)) { + throw DxvkError(str::format( + "D3D11: Cannot create texture:", + "\n Format: ", imageInfo.format, + "\n Extent: ", imageInfo.extent.width, + "x", imageInfo.extent.height, + "x", imageInfo.extent.depth, + "\n Samples: ", imageInfo.sampleCount, + "\n Layers: ", imageInfo.numLayers, + "\n Levels: ", imageInfo.mipLevels, + "\n Usage: ", std::hex, imageInfo.usage)); + } + // If necessary, create the mapped linear buffer if (m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) m_buffer = CreateMappedBuffer();