From c7e5601bb67d2a5ebadb7f84c6968b5912e7566d Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 13 Apr 2023 23:49:00 +0800 Subject: Matrix swizzle writes (#2713) * Add a bunch of builder emit wrappers for constant indices To avoid cluttering any calling code with int instruction construction * Matrix swizzle stores Closes https://github.com/shader-slang/slang/issues/2512 * Matrix swizzle store tests * Squash vs warnings * Select scalar for singular swizzles * Test singular swizzle materialization * Use IRIntegerValue over UInt for IR wrappers * Correct size of swizzle vector type * Remove variable shadowing --- source/slang/slang-ir.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index bd2271953..e624ef1fd 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -2809,6 +2809,13 @@ namespace Slang operands); } + IRVectorType* IRBuilder::getVectorType( + IRType* elementType, + IRIntegerValue elementCount) + { + return getVectorType(elementType, getIntValue(getIntType(), elementCount)); + } + IRMatrixType* IRBuilder::getMatrixType( IRType* elementType, IRInst* rowCount, @@ -4605,6 +4612,13 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitElementExtract( + IRInst* base, + IRIntegerValue index) + { + return emitElementExtract(base, getIntValue(getIntType(), index)); + } + IRInst* IRBuilder::emitElementExtract( IRInst* base, const ArrayView& accessChain) @@ -4651,6 +4665,13 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitElementAddress( + IRInst* basePtr, + IRIntegerValue index) + { + return emitElementAddress(basePtr, getIntValue(getIntType(), index)); + } + IRInst* IRBuilder::emitElementAddress( IRInst* basePtr, IRInst* index) @@ -4726,6 +4747,11 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitUpdateElement(IRInst* base, IRIntegerValue index, IRInst* newElement) + { + return emitUpdateElement(base, getIntValue(getIntType(), index), newElement); + } + IRInst* IRBuilder::emitUpdateElement(IRInst* base, const List& accessChain, IRInst* newElement) { List args; -- cgit v1.2.3