ARB_precision_hint_fastest,ARB_precision_hint_nicest 的意义,作用

首先必须吐槽一下,百度搜任何跟技术相关的东西,简直是辣鸡的不行,还是vpn翻墙google王道,分分钟找到想要的内容。。。
其实之前知道这2个命令是干什么的,但是总是会忘记,鉴于这个情况,所以决定还是做一下笔记了~

首先,这2命令最权威解释的地方,肯定就是openGl官网了,以下是链接:
https://www.opengl.org/registry/specs/NV/fragment_program4.txt

这里有这么一段:

+ Precision Hints (ARB_precision_hint_fastest, ARB_precision_hint_nicest)

Fragment program computations are carried out at an implementation-
dependent precision.  However, some implementations may be able to perform
fragment program computations at more than one precision, and may be able
to trade off computation precision for performance.

If a fragment program specifies the "ARB_precision_hint_fastest" program
option, implementations should select precision to minimize program
execution time, with possibly reduced precision.  If a fragment program
specifies the "ARB_precision_hint_nicest" program option, implementations
should maximize the precision, with possibly increased execution time.

Only one precision control option may be specified by any given fragment
program.  A fragment program that specifies both the
"ARB_precision_hint_fastest" and "ARB_precision_hint_nicest" program
options will fail to load.

看标题也知道了,也就是精度提示。

ARB_precision_hint_fastest 最快的,意思就是会用低精度(一般是指fp16),以提升片段着色器的运行速度,减少时间。

ARB_precision_hint_nicest 最佳的,意思就是会用高精度(一般是指fp32),可能会降低运行速度,增加时间。

注意:这2个命令不可以同时使用

unity里的写法是 #pragma fragmentoption ARB_precision_hint_fastest

具体说fp16,fp32是什么的话,就涉及到GPU的知识了,我也不是太懂。
大概说说的话,fp16在gpu里一般被称为半精度计算

图形计算中使用的精度是:

FP16,16bit,半精度
FX10,10bit,都不是浮点,而是定点数了
FP32,32bit,单精度(最常见的)
FP64,64bit,双精度(不常见的,图像处理一般用不到)

虽然在实际应用中,这2种精度在表现上区别并不大,但是还是建议使用fp16精度的更好。

因为像在 ARM Mali, Imagination PowerVR 这种移动GPU上,都有独立的fp16单元,也就是说,fp16是从硬件电路级别上被支持的,我们知道,这就意味着一个字,那就是“快!”,所以你懂的!

不过据说NVIDIA的gpu里,都是用fp32 CUDA核心去处理fp16的。(这其实是比单独的fp16单元要慢的)

总结一下就是在写shader时可以顺手把这个命令给加上,但是如果你忘记了,或者懒,其实问题也不是太大,以上!

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值