[dxbc] Bound-check mip level for resinfo instruction

This commit is contained in:
Philip Rebohle 2022-07-25 15:58:03 +02:00
parent abf5ed154f
commit 08da6d8ca4
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 8 additions and 1 deletions

View File

@ -3077,7 +3077,14 @@ namespace dxvk {
// result into a four-component vector later.
DxbcRegisterValue imageSize = emitQueryTextureSize(ins.src[1], mipLod);
DxbcRegisterValue imageLevels = emitQueryTextureLods(ins.src[1]);
// If the mip level is out of bounds, D3D requires us to return
// zero before applying modifiers, whereas SPIR-V is undefined,
// so we need to fix it up manually here.
imageSize.id = m_module.opSelect(getVectorTypeId(imageSize.type),
m_module.opULessThan(m_module.defBoolType(), mipLod.id, imageLevels.id),
imageSize.id, emitBuildZeroVector(imageSize.type).id);
// Convert intermediates to the requested type
if (returnType == DxbcScalarType::Float32) {
imageSize.type.ctype = DxbcScalarType::Float32;