diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index 812e7b6e3..c762ce9a2 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -102,8 +102,10 @@ namespace dxvk { DxbcInterpolationMode im = DxbcInterpolationMode::Undefined; - if (hasInterpolationMode) - im = op.token().interpolationMode(); + if (hasInterpolationMode) { + im = static_cast( + bit::extract(ins.token().control(), 0, 3)); + } m_gen->dclInterfaceVar( op.token().type(), regId, regDim, diff --git a/src/dxbc/dxbc_decoder.h b/src/dxbc/dxbc_decoder.h index 96838e16a..3bafe3428 100644 --- a/src/dxbc/dxbc_decoder.h +++ b/src/dxbc/dxbc_decoder.h @@ -287,17 +287,6 @@ namespace dxvk { return DxbcComponentMask(bit::extract(m_token, 4, 5)); } - /** - * \brief Interpolatin mode - * - * Used by input declarations in pixel shaders. - * Undefined for all other instructions. - */ - DxbcInterpolationMode interpolationMode() const { - return static_cast( - bit::extract(m_token, 11, 14)); - } - /** * \brief Operand type * diff --git a/src/dxbc/dxbc_enums.h b/src/dxbc/dxbc_enums.h index 418ec8174..037b13e25 100644 --- a/src/dxbc/dxbc_enums.h +++ b/src/dxbc/dxbc_enums.h @@ -421,7 +421,7 @@ namespace dxvk { Linear = 2, LinearCentroid = 3, LinearNoPerspective = 4, - LinearNoperspectiveCentroid = 5, + LinearNoPerspectiveCentroid = 5, LinearSample = 6, LinearNoPerspectiveSample = 7, }; diff --git a/src/dxbc/gen/dxbc_gen_pixel.cpp b/src/dxbc/gen/dxbc_gen_pixel.cpp index 58e6f4f7a..ab26da7e7 100644 --- a/src/dxbc/gen/dxbc_gen_pixel.cpp +++ b/src/dxbc/gen/dxbc_gen_pixel.cpp @@ -58,6 +58,40 @@ namespace dxvk { m_module.decorateLocation(m_vRegs.at(regId).valueId, regId); m_module.setDebugName(m_vRegs.at(regId).valueId, str::format("v", regId).c_str()); + + switch (im) { + case DxbcInterpolationMode::Undefined: + Logger::err("Undefined interpolation mode"); + break; + case DxbcInterpolationMode::Linear: + Logger::err("Linear interpolation mode"); + break; + + case DxbcInterpolationMode::Constant: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationFlat); + break; + + case DxbcInterpolationMode::LinearCentroid: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationCentroid); + break; + + case DxbcInterpolationMode::LinearNoPerspective: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationNoPerspective); + break; + case DxbcInterpolationMode::LinearNoPerspectiveCentroid: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationNoPerspective); + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationCentroid); + break; + + case DxbcInterpolationMode::LinearSample: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationSample); + break; + + case DxbcInterpolationMode::LinearNoPerspectiveSample: + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationNoPerspective); + m_module.decorate(m_vRegs.at(regId).valueId, spv::DecorationSample); + break; + } } } break; diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index c4f78b40f..b5febb360 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -227,6 +227,15 @@ namespace dxvk { m_typeConstDefs.putWord(constIds[i]); return resultId; } + + + void SpirvModule::decorate( + uint32_t object, + spv::Decoration decoration) { + m_annotations.putIns (spv::OpDecorate, 3); + m_annotations.putWord (object); + m_annotations.putWord (decoration); + } void SpirvModule::decorateBinding( diff --git a/src/spirv/spirv_module.h b/src/spirv/spirv_module.h index 9bf8a19e4..a37b27fb8 100644 --- a/src/spirv/spirv_module.h +++ b/src/spirv/spirv_module.h @@ -84,6 +84,10 @@ namespace dxvk { uint32_t constCount, const uint32_t* constIds); + void decorate( + uint32_t object, + spv::Decoration decoration); + void decorateBinding( uint32_t object, uint32_t binding);