diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2024-12-12 16:50:44 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-12 14:50:44 -0800 |
| commit | 78c9bd1c2fbd55889e62a2032e9bc96684ced3b5 (patch) | |
| tree | 63332e647aa597450b642751c8c6b2fd7f66439e /source/slang/core.meta.slang | |
| parent | b4e63d7bc44fc969d24202fc51a774378a489294 (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/core.meta.slang')
| -rw-r--r-- | source/slang/core.meta.slang | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 3a7df8e7a..625f8f608 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -2714,6 +2714,23 @@ __generic<T, U> __intrinsic_op($(kIROp_Reinterpret)) T reinterpret(U value); +/// `bitfieldInsert` inserts the bits least significant bits of `insert` into base at `offset` offset. +/// The returned value will have bits [offset, offset + bits + 1] taken from [0, bits - 1] of `insert` +/// and all other bits taken directly from the corresponding bits of `base`. +__generic<T> +[__readNone] +[__unsafeForceInlineEarly] +__intrinsic_op($(kIROp_BitfieldInsert)) +T bitfieldInsert(T base, T insert, uint offset, uint bits); + +/// `bitfieldExtract` extracts a subset of the bits of `value` and +/// returns it in the least significant bits of the result. The range of bits extracted is [offset, offset + bits - 1]. +__generic<T> +[__readNone] +[__unsafeForceInlineEarly] +__intrinsic_op($(kIROp_BitfieldExtract)) +T bitfieldExtract(T value, uint offset, uint bits); + /// Use an otherwise unused value /// This can be used to silence the warning about returning before initializing an out paramter. __generic<T> |
