From a3e0157ab0d9d7a71367ef45592d0ac2b07ae033 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 29 Apr 2019 10:39:31 +0200 Subject: [PATCH] [dxbc] Correctly report a size of 0 for unbound images --- src/dxbc/dxbc_compiler.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index c050103b8..2ffcd9227 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2945,7 +2945,6 @@ namespace dxvk { // (dst0) The destination register // (src0) Resource LOD to query // (src1) Resource to query - // TODO Check if resource is bound const DxbcBufferInfo resourceInfo = getBufferInfo(ins.src[1]); const DxbcResinfoType resinfoType = ins.controls.resinfoType(); @@ -5034,6 +5033,10 @@ namespace dxvk { // Report one LOD in case of UAVs result.id = m_module.constu32(1); } + + // Report zero LODs for unbound images + result.id = m_module.opSelect(getVectorTypeId(result.type), + info.specId, result.id, m_module.constu32(0)); return result; } @@ -5077,7 +5080,27 @@ namespace dxvk { getVectorTypeId(result.type), m_module.opLoad(info.typeId, info.varId)); } - + + // Report a size of zero for unbound textures + uint32_t zero = m_module.constu32(0); + uint32_t cond = info.specId; + + if (result.type.ccount > 1) { + std::array zeroes = {{ zero, zero, zero, zero }}; + std::array conds = {{ cond, cond, cond, cond }}; + + zero = m_module.opCompositeConstruct( + getVectorTypeId(result.type), + result.type.ccount, zeroes.data()); + + cond = m_module.opCompositeConstruct( + m_module.defVectorType(m_module.defBoolType(), result.type.ccount), + result.type.ccount, conds.data()); + } + + result.id = m_module.opSelect( + getVectorTypeId(result.type), + cond, result.id, zero); return result; }