From fdbfb2c92de57420c100839218265b2bb058f42f Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 4 Aug 2019 00:01:46 +0100 Subject: [PATCH] [spirv] Implement opInverse, opNormalize and opLength --- src/spirv/spirv_module.cpp | 45 ++++++++++++++++++++++++++++++++++++++ src/spirv/spirv_module.h | 12 ++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/spirv/spirv_module.cpp b/src/spirv/spirv_module.cpp index 9549bccf9..1f56aaa92 100644 --- a/src/spirv/spirv_module.cpp +++ b/src/spirv/spirv_module.cpp @@ -1974,6 +1974,21 @@ namespace dxvk { } + uint32_t SpirvModule::opInverse( + uint32_t resultType, + uint32_t matrix) { + uint32_t resultId = this->allocateId(); + + m_code.putIns(spv::OpExtInst, 6); + m_code.putWord(resultType); + m_code.putWord(resultId); + m_code.putWord(m_instExtGlsl450); + m_code.putWord(spv::GLSLstd450MatrixInverse); + m_code.putWord(matrix); + return resultId; + } + + uint32_t SpirvModule::opFFma( uint32_t resultType, uint32_t a, @@ -2553,6 +2568,36 @@ namespace dxvk { m_code.putWord(operand); return resultId; } + + + uint32_t SpirvModule::opNormalize( + uint32_t resultType, + uint32_t operand) { + uint32_t resultId = this->allocateId(); + + m_code.putIns (spv::OpExtInst, 6); + m_code.putWord(resultType); + m_code.putWord(resultId); + m_code.putWord(m_instExtGlsl450); + m_code.putWord(spv::GLSLstd450Normalize); + m_code.putWord(operand); + return resultId; + } + + + uint32_t SpirvModule::opLength( + uint32_t resultType, + uint32_t operand) { + uint32_t resultId = this->allocateId(); + + m_code.putIns (spv::OpExtInst, 6); + m_code.putWord(resultType); + m_code.putWord(resultId); + m_code.putWord(m_instExtGlsl450); + m_code.putWord(spv::GLSLstd450Length); + m_code.putWord(operand); + return resultId; + } uint32_t SpirvModule::opExp2( diff --git a/src/spirv/spirv_module.h b/src/spirv/spirv_module.h index bbdb3a807..8d3f89296 100644 --- a/src/spirv/spirv_module.h +++ b/src/spirv/spirv_module.h @@ -711,6 +711,10 @@ namespace dxvk { uint32_t opTranspose( uint32_t resultType, uint32_t matrix); + + uint32_t opInverse( + uint32_t resultType, + uint32_t matrix); uint32_t opFFma( uint32_t resultType, @@ -894,6 +898,14 @@ namespace dxvk { uint32_t opInverseSqrt( uint32_t resultType, uint32_t operand); + + uint32_t opNormalize( + uint32_t resultType, + uint32_t operand); + + uint32_t opLength( + uint32_t resultType, + uint32_t operand); uint32_t opExp2( uint32_t resultType,