[dxbc] Do not emit depth compare for unsupported image types

Fixes invalid SPIR-V.
This commit is contained in:
Philip Rebohle 2024-03-07 16:10:50 +01:00
parent 707ad6f328
commit 69a52b3da0
1 changed files with 113 additions and 98 deletions

View File

@ -3881,6 +3881,7 @@ namespace dxvk {
if (imageOperands.sparse) if (imageOperands.sparse)
resultTypeId = getSparseResultTypeId(texelTypeId); resultTypeId = getSparseResultTypeId(texelTypeId);
if (sampledImageId) {
switch (ins.op) { switch (ins.op) {
// Simple image gather operation // Simple image gather operation
case DxbcOpcode::Gather4: case DxbcOpcode::Gather4:
@ -3909,6 +3910,10 @@ namespace dxvk {
ins.op)); ins.op));
return; return;
} }
} else {
Logger::warn(str::format("DxbcCompiler: ", ins.op, ": Unsupported image type"));
resultId = m_module.constNull(resultTypeId);
}
// If necessary, deal with the sparse result // If necessary, deal with the sparse result
DxbcRegisterValue result; DxbcRegisterValue result;
@ -4035,6 +4040,7 @@ namespace dxvk {
if (imageOperands.sparse) if (imageOperands.sparse)
resultTypeId = getSparseResultTypeId(texelTypeId); resultTypeId = getSparseResultTypeId(texelTypeId);
if (sampledImageId) {
switch (ins.op) { switch (ins.op) {
// Simple image sample operation // Simple image sample operation
case DxbcOpcode::Sample: case DxbcOpcode::Sample:
@ -4103,6 +4109,10 @@ namespace dxvk {
ins.op)); ins.op));
return; return;
} }
} else {
Logger::warn(str::format("DxbcCompiler: ", ins.op, ": Unsupported image type"));
resultId = m_module.constNull(resultTypeId);
}
DxbcRegisterValue result; DxbcRegisterValue result;
result.type = texelType; result.type = texelType;
@ -5147,9 +5157,14 @@ namespace dxvk {
const DxbcShaderResource& textureResource, const DxbcShaderResource& textureResource,
const DxbcSampler& samplerResource, const DxbcSampler& samplerResource,
bool isDepthCompare) { bool isDepthCompare) {
const uint32_t sampledImageType = isDepthCompare uint32_t baseId = isDepthCompare
? m_module.defSampledImageType(textureResource.depthTypeId) ? textureResource.depthTypeId
: m_module.defSampledImageType(textureResource.colorTypeId); : textureResource.colorTypeId;
if (!baseId)
return 0;
uint32_t sampledImageType = m_module.defSampledImageType(baseId);
return m_module.opSampledImage(sampledImageType, return m_module.opSampledImage(sampledImageType,
m_module.opLoad(textureResource.imageTypeId, textureResource.varId), m_module.opLoad(textureResource.imageTypeId, textureResource.varId),