游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1831|回复: 5

求教一个关于SM3 ISA中Texture Sampling指令的问题。

[复制链接]

13

主题

312

帖子

312

积分

中级会员

Rank: 3Rank: 3

积分
312
发表于 2009-6-24 22:02:00 | 显示全部楼层 |阅读模式



Shader Model 3中有下面这个函数/指令。

ret Object.Load( int Location
                        [, int Offset ]
                        [, int SampleIndex ]
                        [, int Samples ] );

这个Offset的立即数偏移是很常见的,这是设置什么图形效果时候需要的?????理论上Shader可以搞定一切,这个立即数是冗余的巴?

5

主题

686

帖子

697

积分

高级会员

Rank: 4

积分
697
QQ
发表于 2009-6-25 15:38:00 | 显示全部楼层

Re:求教一个关于SM3 ISA中Texture Sampling指令的问题。

这好像是SM4.0的吧.......

13

主题

312

帖子

312

积分

中级会员

Rank: 3Rank: 3

积分
312
 楼主| 发表于 2009-6-25 20:23:00 | 显示全部楼层

Re:求教一个关于SM3 ISA中Texture Sampling指令的问题。

对,是SM4,我从别的论坛转过来的……忘记改了……

5

主题

686

帖子

697

积分

高级会员

Rank: 4

积分
697
QQ
发表于 2009-6-26 13:24:00 | 显示全部楼层

Re:求教一个关于SM3 ISA中Texture Sampling指令的问题。

offset肯定是做卷积用的多...就是方便写程序而已,中心采样的坐标不改,循环加offset
好像你写多了一个参数吧....sample方面的只有一个参数而已

13

主题

312

帖子

312

积分

中级会员

Rank: 3Rank: 3

积分
312
 楼主| 发表于 2009-6-26 21:05:00 | 显示全部楼层

Re:求教一个关于SM3 ISA中Texture Sampling指令的问题。

DX10 的Sample因该没有[, int SampleIndex ]这个参数,这是LOAD专用的。 用来访问MSAA生成的纹理。

好,我基本明白了,多谢楼上大牛~ 这样作的确比较节约Register,而且也节约时间,代价就是增加代码长度 :〉

13

主题

312

帖子

312

积分

中级会员

Rank: 3Rank: 3

积分
312
 楼主| 发表于 2009-6-26 21:08:00 | 显示全部楼层

Re: 求教一个关于SM3 ISA中Texture Sampling指令的问题。

还有一个问题是关于Dynamic Control Flow和Derivative Operation的。众所周知,如果要对MIPMAP作Sampling操作的话,必须要求导,以便计算LOD。但是DX的硬件规范手册上有下面这样的规定。这个比较令人费解~~

(a) The following uses of sample or derivative instructions are not permitted inside varying flow control:
·       sample, sample_b, or sample_c, when the texture address is a shader-computed temporary.
·         deriv_rtx and deriv_rty, when the input is a shader-computed temporary.

(b) Other uses of sample or derivative instructions have no restrictions with flow control. Examples are:
·         sample, sample_b, or sample_c, when the texture address is a shader input (regardless of interpolation mode) or statically indexed constant.
·        deriv_rtx and deriv_rty, when the input operand is a shader input (regardless of interpolation mode) or statically indexed constant, though the latter is not useful.
·         sample_l: here the application provides LOD as an operand, so no derivative calculation is required, and there is no issue with flow control.
·         sample_d: here the application provides derivatives as input operands, so there is no issue with flow control.
·         sample_c_lz: here the LOD is fixed at 0, so no derivative calculation is required, and there is no issue with flow control.

Regardless of the restriction above, shader authors still must ensure that before computing any derivative (or performing a texture sample that implicitly computes a derivative) where permitted, the register containing the source data must have been initialized for all execution paths beforehand. Initialization of temporary registers is not validated or enforced in general.



我依稀感觉这是个是为硬件简化,但是从硬件设计角度来看,并没有看到这个特性能为减小我们的HW复杂度提供什么帮助。不知道在SW上有什么玄妙之处?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-19 21:36

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表