diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 061c68e7..9b062dbd 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2271,6 +2271,11 @@ namespace dxvk { // (dst0) The destination register // (src0) Source address // (src1) Source texture + // ld2dms has four operands: + // (dst0) The destination register + // (src0) Source address + // (src1) Source texture + // (src2) Sample number const uint32_t textureId = ins.src[1].idx[0].offset; // Image type, which stores the image dimensions etc. @@ -2302,18 +2307,24 @@ namespace dxvk { } // The LOD is not present when reading from a buffer - DxbcRegisterValue imageLod; - imageLod.type = address.type; - imageLod.id = 0; - if (imageType.dim != spv::DimBuffer) { - imageLod = emitRegisterExtract(address, - DxbcRegMask(false, false, false, true)); + DxbcRegisterValue imageLod = emitRegisterExtract( + address, DxbcRegMask(false, false, false, true)); imageOperands.flags |= spv::ImageOperandsLodMask; imageOperands.sLod = imageLod.id; } + // The ld2ms instruction also has a sample index, but + // we are only allowed to set it for multisample views + if (ins.op == DxbcOpcode::LdMs && imageType.ms == 1) { + DxbcRegisterValue sampleId = emitRegisterLoad( + ins.src[2], DxbcRegMask(true, false, false, false)); + + imageOperands.flags |= spv::ImageOperandsSampleMask; + imageOperands.sSampleId = sampleId.id; + } + // Extract coordinates from address const DxbcRegisterValue coord = emitRegisterExtract(address, coordArrayMask); diff --git a/src/dxbc/dxbc_defs.cpp b/src/dxbc/dxbc_defs.cpp index a7038f19..7856c01a 100644 --- a/src/dxbc/dxbc_defs.cpp +++ b/src/dxbc/dxbc_defs.cpp @@ -217,7 +217,12 @@ namespace dxvk { { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, } }, /* LdMs */ - { }, + { 4, DxbcInstClass::TextureFetch, { + { DxbcOperandKind::DstReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Sint32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Sint32 }, + } }, /* Log */ { 2, DxbcInstClass::VectorAlu, { { DxbcOperandKind::DstReg, DxbcScalarType::Float32 },