[dxbc] Conditionally return zeroes for unbound textures in shader

May allow the driver to optimize away texture operations.
This commit is contained in:
Philip Rebohle 2020-11-24 18:39:20 +01:00
parent 45461ee54e
commit 538b55921e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 16 additions and 0 deletions

View File

@ -3543,6 +3543,14 @@ namespace dxvk {
result = emitRegisterSwizzle(result,
textureReg.swizzle, ins.dst[0].mask);
DxbcRegisterValue bound;
bound.type = { DxbcScalarType::Bool, 1 };
bound.id = m_textures.at(textureId).specId;
result.id = m_module.opSelect(getVectorTypeId(result.type),
emitBuildVector(bound, result.type.ccount).id, result.id,
emitBuildZeroVector(result.type).id);
emitRegisterStore(ins.dst[0], result);
}
@ -3695,6 +3703,14 @@ namespace dxvk {
textureReg.swizzle, ins.dst[0].mask);
}
DxbcRegisterValue bound;
bound.type = { DxbcScalarType::Bool, 1 };
bound.id = m_textures.at(textureId).specId;
result.id = m_module.opSelect(getVectorTypeId(result.type),
emitBuildVector(bound, result.type.ccount).id, result.id,
emitBuildZeroVector(result.type).id);
emitRegisterStore(ins.dst[0], result);
}