From d522e19babd4f68d8c7bedadaf1a4e32f4be3d69 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 20 Jan 2018 10:21:27 +0100 Subject: [PATCH] [dxbc] Implemented SampleB instruction --- src/dxbc/dxbc_compiler.cpp | 21 +++++++++++++++------ src/dxbc/dxbc_defs.cpp | 8 +++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index e2cd6f86..81eb7c1e 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2564,8 +2564,6 @@ namespace dxvk { void DxbcCompiler::emitTextureSample(const DxbcShaderInstruction& ins) { - // TODO support remaining sample ops - // All sample instructions have at least these operands: // (dst0) The destination register // (src0) Texture coordinates @@ -2622,10 +2620,11 @@ namespace dxvk { ? emitRegisterLoad(ins.src[4], coordLayerMask) : DxbcRegisterValue(); - // Explicit LOD value for certain sample operations - const bool hasExplicitLod = ins.op == DxbcOpcode::SampleL; + // LOD for certain sample operations + const bool hasLod = ins.op == DxbcOpcode::SampleL + || ins.op == DxbcOpcode::SampleB; - const DxbcRegisterValue explicitLod = hasExplicitLod + const DxbcRegisterValue lod = hasLod ? emitRegisterLoad(ins.src[3], DxbcRegMask(true, false, false, false)) : DxbcRegisterValue(); @@ -2716,13 +2715,23 @@ namespace dxvk { // Sample operation with explicit LOD case DxbcOpcode::SampleL: { imageOperands.flags |= spv::ImageOperandsLodMask; - imageOperands.sLod = explicitLod.id; + imageOperands.sLod = lod.id; result.id = m_module.opImageSampleExplicitLod( getVectorTypeId(result.type), sampledImageId, coord.id, imageOperands); } break; + // Sample operation with LOD bias + case DxbcOpcode::SampleB: { + imageOperands.flags |= spv::ImageOperandsBiasMask; + imageOperands.sLodBias = lod.id; + + result.id = m_module.opImageSampleImplicitLod( + getVectorTypeId(result.type), sampledImageId, coord.id, + imageOperands); + } break; + default: Logger::warn(str::format( "DxbcCompiler: Unhandled instruction: ", diff --git a/src/dxbc/dxbc_defs.cpp b/src/dxbc/dxbc_defs.cpp index 945b5941..cd265a5e 100644 --- a/src/dxbc/dxbc_defs.cpp +++ b/src/dxbc/dxbc_defs.cpp @@ -372,7 +372,13 @@ namespace dxvk { { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, } }, /* SampleB */ - { }, + { 5, DxbcInstClass::TextureSample, { + { DxbcOperandKind::DstReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, + { DxbcOperandKind::SrcReg, DxbcScalarType::Float32 }, + } }, /* Sqrt */ { 2, DxbcInstClass::VectorAlu, { { DxbcOperandKind::DstReg, DxbcScalarType::Float32 },