HLSL 的内置函数 firstbithigh 和 firstbitlow

15 篇文章 1 订阅
10 篇文章 0 订阅

函数定义

firstbithigh function

Gets the location of the first set bit starting from the highest order bit and working downward, per component.

For a signed integer, the first significant bit is zero for a negative number.

firstbitlow function

Returns the location of the first set bit starting from the lowest order bit and working upward, per component.

函数调用参数及返回值对照表(-31 到 31)

decbinfirstbithigh()firstbitlow()
-311110000140
-301110001041
-291110001140
-281110010042
-271110010140
-261110011041
-251110011140
-241110100043
-231110100140
-221110101041
-211110101140
-201110110042
-191110110140
-181110111041
-171110111140
-161111000034
-151111000130
-141111001031
-131111001130
-121111010032
-111111010130
-101111011031
-91111011130
-81111100023
-71111100120
-61111101021
-51111101120
-41111110012
-31111110110
-21111111001
-111111111-10
000000000-1-1
10000000100
20000001011
30000001110
40000010022
50000010120
60000011021
70000011120
80000100033
90000100130
100000101031
110000101130
120000110032
130000110130
140000111031
150000111130
160001000044
170001000140
180001001041
190001001140
200001010042
210001010140
220001011041
230001011140
240001100043
250001100140
260001101041
270001101140
280001110042
290001110140
300001111041
310001111140

GLSL 相同功能的函数

findMSB

Returns the bit number of the most significant bit in the binary representation of value.

For positive integers, the result will be the bit number of the most significant bit set to 1. For negative integers, the result will be the bit number of the most significant bit set to 0. For a value of zero or negative one, -1 will be returned.

findLSB

Returns the bit number of the least significant bit set to 1 in the binary representation of value. If value is zero, -1will be returned.

参考

firstbithigh function

firstbitlow function

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值