From adb1789571354141b4046882d88f654763ad3638 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 12 Apr 2018 13:57:15 +0200 Subject: [PATCH] [dxbc] Fixed incorrect result vector dimension for OpImageQuerySize --- src/dxbc/dxbc_compiler.cpp | 14 +++++++++++++- src/dxbc/dxbc_compiler.h | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index e6aff389..7ce5de49 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -4551,7 +4551,7 @@ namespace dxvk { DxbcRegisterValue result; result.type.ctype = DxbcScalarType::Uint32; - result.type.ccount = getTexCoordDim(info.image); + result.type.ccount = getTexSizeDim(info.image); if (info.image.ms == 0 && info.image.sampled == 1) { result.id = m_module.opImageQuerySizeLod( @@ -6185,6 +6185,18 @@ namespace dxvk { } + uint32_t DxbcCompiler::getTexSizeDim(const DxbcImageInfo& imageType) const { + switch (imageType.dim) { + case spv::DimBuffer: return 1 + imageType.array; + case spv::Dim1D: return 1 + imageType.array; + case spv::Dim2D: return 2 + imageType.array; + case spv::Dim3D: return 3 + imageType.array; + case spv::DimCube: return 2 + imageType.array; + default: throw DxvkError("DxbcCompiler: getTexLayerDim: Unsupported image dimension"); + } + } + + uint32_t DxbcCompiler::getTexLayerDim(const DxbcImageInfo& imageType) const { switch (imageType.dim) { case spv::DimBuffer: return 1; diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index a5a19427..98e91912 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -985,6 +985,9 @@ namespace dxvk { DxbcBufferInfo getBufferInfo( const DxbcRegister& reg); + uint32_t getTexSizeDim( + const DxbcImageInfo& imageType) const; + uint32_t getTexLayerDim( const DxbcImageInfo& imageType) const;