From 180cc35c8477e4f6e15538b084019f5afd81dd1c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 9 Jan 2018 00:51:10 +0100 Subject: [PATCH] [d3d11] Use VK_IMAGE_VIEW_TYPE_CUBE_ARRAY for non-array cube maps Games may bind simple cube map views to a resource slot that requires a cube map array view. Fixes GPU lockups in Nier: Automata. --- src/d3d11/d3d11_device.cpp | 6 +++++- src/dxbc/dxbc_compiler.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index ca33273d7..173f7ce83 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -283,7 +283,10 @@ namespace dxvk { break; case D3D11_SRV_DIMENSION_TEXTURECUBE: - viewInfo.type = VK_IMAGE_VIEW_TYPE_CUBE; + // Some applications bind non-array cube maps to cube map + // array slots. In order to support this, we'll use a cube + // map array view even for non-array cube maps. + viewInfo.type = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY; viewInfo.minLevel = desc.TextureCube.MostDetailedMip; viewInfo.numLevels = desc.TextureCube.MipLevels; viewInfo.minLayer = 0; @@ -1326,6 +1329,7 @@ namespace dxvk { enabled.samplerAnisotropy = VK_TRUE; enabled.shaderClipDistance = VK_TRUE; enabled.shaderCullDistance = VK_TRUE; + enabled.robustBufferAccess = VK_TRUE; } if (featureLevel >= D3D_FEATURE_LEVEL_9_2) { diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index e06da5360..d6295eba3 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -649,7 +649,8 @@ namespace dxvk { case DxbcResourceDim::Texture2DMs: return { spv::Dim2D, 0, 1, isUav ? 2u : 1u }; case DxbcResourceDim::Texture2DMsArr: return { spv::Dim2D, 1, 1, isUav ? 2u : 1u }; case DxbcResourceDim::Texture3D: return { spv::Dim3D, 0, 0, isUav ? 2u : 1u }; - case DxbcResourceDim::TextureCube: return { spv::DimCube, 0, 0, isUav ? 2u : 1u }; + // Some applications bind non-array cube maps to cube map array slots + case DxbcResourceDim::TextureCube: return { spv::DimCube, 1, 0, isUav ? 2u : 1u }; case DxbcResourceDim::TextureCubeArr: return { spv::DimCube, 1, 0, isUav ? 2u : 1u }; default: throw DxvkError(str::format("DxbcCompiler: Unsupported resource type: ", resourceType)); } @@ -660,6 +661,7 @@ namespace dxvk { case DxbcResourceDim::Buffer: m_module.enableCapability(spv::CapabilityImageBuffer); break; case DxbcResourceDim::Texture1D: m_module.enableCapability(spv::CapabilityImage1D); break; case DxbcResourceDim::Texture1DArr: m_module.enableCapability(spv::CapabilityImage1D); break; + case DxbcResourceDim::TextureCube: case DxbcResourceDim::TextureCubeArr: m_module.enableCapability(spv::CapabilityImageCubeArray); break; case DxbcResourceDim::Texture2DMsArr: m_module.enableCapability(spv::CapabilityImageMSArray); break; default: break; // No additional capabilities required @@ -1782,6 +1784,7 @@ namespace dxvk { const DxbcRegisterValue src = emitRegisterLoad(ins.src[2], ins.dst[0].mask); const uint32_t typeId = getVectorTypeId(src.type); + // TODO fix DxbcRegisterValue result; result.type = src.type; result.id = isSigned @@ -1804,6 +1807,7 @@ namespace dxvk { const DxbcRegisterValue insert = emitRegisterLoad(ins.src[2], ins.dst[0].mask); const DxbcRegisterValue base = emitRegisterLoad(ins.src[3], ins.dst[0].mask); + // TODO fix DxbcRegisterValue result; result.type = base.type; result.id = m_module.opBitFieldInsert(