diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index b4429b2..770345c 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -343,6 +343,82 @@ class Module { /// Result is x if x >= 0; otherwise result is -x. Id OpFAbs(Id result_type, Id x); + Id OpSAbs(Id result_type, Id x); + + Id OpRound(Id result_type, Id x); + + Id OpRoundEven(Id result_type, Id x); + + Id OpTrunc(Id result_type, Id x); + + Id OpFSign(Id result_type, Id x); + + Id OpSSign(Id result_type, Id x); + + Id OpFloor(Id result_type, Id x); + + Id OpCeil(Id result_type, Id x); + + Id OpFract(Id result_type, Id x); + + Id OpSin(Id result_type, Id x); + + Id OpCos(Id result_type, Id x); + + Id OpAsin(Id result_type, Id x); + + Id OpAcos(Id result_type, Id x); + + Id OpPow(Id result_type, Id x, Id y); + + Id OpExp(Id result_type, Id x); + + Id OpLog(Id result_type, Id x); + + Id OpExp2(Id result_type, Id x); + + Id OpLog2(Id result_type, Id x); + + Id OpSqrt(Id result_type, Id x); + + Id OpInverseSqrt(Id result_type, Id x); + + Id OpFMin(Id result_type, Id x, Id y); + + Id OpUMin(Id result_type, Id x, Id y); + + Id OpSMin(Id result_type, Id x, Id y); + + Id OpFMax(Id result_type, Id x, Id y); + + Id OpUMax(Id result_type, Id x, Id y); + + Id OpSMax(Id result_type, Id x, Id y); + + Id OpFClamp(Id result_type, Id x, Id minVal, Id maxVal); + + Id OpUClamp(Id result_type, Id x, Id minVal, Id maxVal); + + Id OpSClamp(Id result_type, Id x, Id minVal, Id maxVal); + + Id OpFma(Id result_type, Id a, Id b, Id c); + + Id OpPackHalf2x16(Id result_type, Id v); + + Id OpUnpackHalf2x16(Id result_type, Id v); + + Id OpFindILsb(Id result_type, Id Value); + + Id OpFindSMsb(Id result_type, Id Value); + + Id OpFindUMsb(Id result_type, Id Value); + + Id OpInterpolateAtCentroid(Id result_type, Id interpolant); + + Id OpInterpolateAtSample(Id result_type, Id interpolant, Id sample); + + Id OpInterpolateAtOffset(Id result_type, Id interpolant, Id offset); + private: Id AddCode(std::unique_ptr op); diff --git a/src/insts/extension.cpp b/src/insts/extension.cpp index ad842b1..ab70e3f 100644 --- a/src/insts/extension.cpp +++ b/src/insts/extension.cpp @@ -21,8 +21,61 @@ Id Module::OpExtInst(Id result_type, Id set, u32 instruction, return AddCode(std::move(op)); } -Id Module::OpFAbs(Id result_type, Id x) { - return OpExtInst(result_type, GetGLSLstd450(), GLSLstd450FAbs, {x}); -} +#define DEFINE_UNARY(funcname, opcode) \ + Id Module::funcname(Id result_type, Id operand) { \ + return OpExtInst(result_type, GetGLSLstd450(), opcode, {operand}); \ + } -} // namespace Sirit \ No newline at end of file +#define DEFINE_BINARY(funcname, opcode) \ + Id Module::funcname(Id result_type, Id operand_1, Id operand_2) { \ + return OpExtInst(result_type, GetGLSLstd450(), opcode, \ + {operand_1, operand_2}); \ + } + +#define DEFINE_TRINARY(funcname, opcode) \ + Id Module::funcname(Id result_type, Id operand_1, Id operand_2, \ + Id operand_3) { \ + return OpExtInst(result_type, GetGLSLstd450(), opcode, \ + {operand_1, operand_2, operand_3}); \ + } + +DEFINE_UNARY(OpFAbs, GLSLstd450FAbs) +DEFINE_UNARY(OpSAbs, GLSLstd450SAbs) +DEFINE_UNARY(OpRound, GLSLstd450Round) +DEFINE_UNARY(OpRoundEven, GLSLstd450RoundEven) +DEFINE_UNARY(OpTrunc, GLSLstd450Trunc) +DEFINE_UNARY(OpFSign, GLSLstd450FSign) +DEFINE_UNARY(OpSSign, GLSLstd450SSign) +DEFINE_UNARY(OpFloor, GLSLstd450Floor) +DEFINE_UNARY(OpCeil, GLSLstd450Ceil) +DEFINE_UNARY(OpFract, GLSLstd450Fract) +DEFINE_UNARY(OpSin, GLSLstd450Sin) +DEFINE_UNARY(OpCos, GLSLstd450Cos) +DEFINE_UNARY(OpAsin, GLSLstd450Asin) +DEFINE_UNARY(OpAcos, GLSLstd450Acos) +DEFINE_BINARY(OpPow, GLSLstd450Pow) +DEFINE_UNARY(OpExp, GLSLstd450Exp) +DEFINE_UNARY(OpLog, GLSLstd450Log) +DEFINE_UNARY(OpExp2, GLSLstd450Exp2) +DEFINE_UNARY(OpLog2, GLSLstd450Log2) +DEFINE_UNARY(OpSqrt, GLSLstd450Sqrt) +DEFINE_UNARY(OpInverseSqrt, GLSLstd450InverseSqrt) +DEFINE_BINARY(OpFMin, GLSLstd450FMin) +DEFINE_BINARY(OpUMin, GLSLstd450UMin) +DEFINE_BINARY(OpSMin, GLSLstd450SMin) +DEFINE_BINARY(OpFMax, GLSLstd450FMax) +DEFINE_BINARY(OpUMax, GLSLstd450UMax) +DEFINE_BINARY(OpSMax, GLSLstd450SMax) +DEFINE_TRINARY(OpFClamp, GLSLstd450FClamp) +DEFINE_TRINARY(OpUClamp, GLSLstd450UClamp) +DEFINE_TRINARY(OpSClamp, GLSLstd450SClamp) +DEFINE_TRINARY(OpFma, GLSLstd450Fma) +DEFINE_UNARY(OpPackHalf2x16, GLSLstd450PackHalf2x16) +DEFINE_UNARY(OpUnpackHalf2x16, GLSLstd450UnpackHalf2x16) +DEFINE_UNARY(OpFindILsb, GLSLstd450FindILsb) +DEFINE_UNARY(OpFindSMsb, GLSLstd450FindSMsb) +DEFINE_UNARY(OpFindUMsb, GLSLstd450FindUMsb) +DEFINE_UNARY(OpInterpolateAtCentroid, GLSLstd450InterpolateAtCentroid) +DEFINE_BINARY(OpInterpolateAtSample, GLSLstd450InterpolateAtSample) +DEFINE_BINARY(OpInterpolateAtOffset, GLSLstd450InterpolateAtOffset) +} // namespace Sirit