summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-glsl.cpp
diff options
context:
space:
mode:
authorkaizhangNV <149626564+kaizhangNV@users.noreply.github.com>2024-12-12 16:50:44 -0600
committerGitHub <noreply@github.com>2024-12-12 14:50:44 -0800
commit78c9bd1c2fbd55889e62a2032e9bc96684ced3b5 (patch)
tree63332e647aa597450b642751c8c6b2fd7f66439e /source/slang/slang-emit-glsl.cpp
parentb4e63d7bc44fc969d24202fc51a774378a489294 (diff)
Bit extract (#5847)
* promoting bitfield extraction and insertion to become intrinsics for internal compiler use * removing duplicate intrinsics from glsl.meta.slang * refactor: update function signatures of bitfield extraction and insertion to use uint as the parameter type for offset and bits. --------- Co-authored-by: Nate Morrical <natemorrical@gmail.com> Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-emit-glsl.cpp')
-rw-r--r--source/slang/slang-emit-glsl.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index f22419147..2c2447c53 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -2949,6 +2949,45 @@ void GLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration)
}
}
+void GLSLSourceEmitter::emitBitfieldExtractImpl(IRInst* inst)
+{
+ m_writer->emit("bitfieldExtract(");
+
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ m_writer->emit(",");
+
+ m_writer->emit("int(");
+ emitOperand(inst->getOperand(1), getInfo(EmitOp::General));
+ m_writer->emit(")");
+ m_writer->emit(",");
+
+ m_writer->emit("int(");
+ emitOperand(inst->getOperand(2), getInfo(EmitOp::General));
+ m_writer->emit("))");
+}
+
+void GLSLSourceEmitter::emitBitfieldInsertImpl(IRInst* inst)
+{
+ m_writer->emit("bitfieldInsert(");
+
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ m_writer->emit(",");
+
+ emitOperand(inst->getOperand(1), getInfo(EmitOp::General));
+ m_writer->emit(",");
+
+ m_writer->emit("int(");
+ emitOperand(inst->getOperand(2), getInfo(EmitOp::General));
+ m_writer->emit(")");
+ m_writer->emit(",");
+
+ m_writer->emit("int(");
+ emitOperand(inst->getOperand(3), getInfo(EmitOp::General));
+ m_writer->emit(")");
+
+ m_writer->emit(")");
+}
+
void GLSLSourceEmitter::emitSimpleTypeImpl(IRType* type)
{
switch (type->getOp())