以下代码是由Intel GPA工具生成的 我一直在研究这些HLSL代码,但在理解代码中使用的l寄存器及其内容时遇到了麻烦。 我们怎么知道寄存器中的值是什么值?
dcl_constantbuffer CB2[16], immediateIndexed
dcl_constantbuffer CB12[13], immediateIndexed
dcl_sampler s6, mode_default
dcl_resource_texture2d (float,float,float,float) t6
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 6
mov r0.x, cb2[15].z
mov r0.yw, l(0,0,0,0)
add r0.xy, r0.xyxx, v1.xyxx
mad r1.xy, r0.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
sample_l r2.xyzw, r0.xyxx, t6.xyzw, s6, l(0.000000)
mul r1.xy, r1.xyxx, cb12[0].xyxx
mov r1.z, l(1.000000)
mul r1.xyz, r2.xxxx, r1.xyzx
mov r0.z, -cb2[15].z
add r0.xy, r0.zwzz, v1.xyxx
mad r0.zw, r0.xxxy, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000)
sample_l r2.xyzw, r0.xyxx, t6.xyzw, s6, l(0.000000)
mul r0.xy, r0.zwzz, cb12[0].xyxx
mov r0.z, l(1.000000)
mul r0.xyz, r2.xxxx, r0.xyzx
mad r2.xy, v1.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
mul r2.xy, r2.xyxx, cb12[0].xyxx
sample_l r3.xyzw, v1.xyxx, t6.xyzw, s6, l(0.000000)
mov r2.z, l(1.000000)
mad r3.yzw, r2.xxyz, r3.xxxx, -r0.xxyz
dp3 r0.w, r3.yzwy, r3.yzwy
sqrt r0.w, r0.w
mad r3.yzw, r2.xxyz, r3.xxxx, -r1.xxyz
dp3 r1.w, r3.yzwy, r3.yzwy
sqrt r1.w, r1.w
lt r0.w, r0.w, r1.w
movc r0.xyz, r0.wwww, r0.xyzx, r1.xyzx
mad r0.xyz, -r2.xyzx, r3.xxxx, r0.xyzx
dp3 r0.x, r0.xyzx, r0.xyzx
sqrt r0.x, r0.x
mov r1.y, cb2[15].w
mov r1.xz, l(0,0,0,0)
add r0.yz, r1.xxyx, v1.xxyx
mad r1.xy, r0.yzyy, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
sample_l r4.xyzw, r0.yzyy, t6.xyzw, s6, l(0.000000)
mul r5.xy, r1.xyxx, cb12[0].xyxx
mov r5.z, l(1.000000)
mul r0.yzw, r4.xxxx, r5.xxyz
mad r3.yzw, r2.xxyz, r3.xxxx, -r0.yyzw
dp3 r1.x, r3.yzwy, r3.yzwy
sqrt r1.x, r1.x
mov r1.w, -cb2[15].w
add r1.yz, r1.zzwz, v1.xxyx
mad r3.yz, r1.yyzy, l(0.000000, 2.000000, -2.000000, 0.000000), l(0.000000, -1.000000, 1.000000, 0.000000)
sample_l r4.xyzw, r1.yzyy, t6.xyzw, s6, l(0.000000)
mul r5.xy, r3.yzyy, cb12[0].xyxx
mov r5.z, l(1.000000)
mul r1.yzw, r4.xxxx, r5.xxyz
mad r3.yzw, r2.xxyz, r3.xxxx, -r1.yyzw
dp3 r2.w, r3.yzwy, r3.yzwy
sqrt r2.w, r2.w
lt r1.x, r1.x, r2.w
movc r0.yzw, r1.xxxx, r0.yyzw, r1.yyzw
mad r0.yzw, -r2.xxyz, r3.xxxx, r0.yyzw
dp3 r0.y, r0.yzwy, r0.yzwy
sqrt r0.y, r0.y
lt r0.xy, r0.xyxx, cb12[12].wwww
and r0.x, r0.y, r0.x
and o0.xyzw, r0.xxxx, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
ret
我们可以看到上面的代码中l被多次使用,而方括号中的值却不同
mad r1.xy, r0.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
和
and o0.xyzw, r0.xxxx, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
我了解和操作,但是我如何获得这些值以及最终的输出结果是什么
我对此很陌生,如果它的接缝非常愚蠢,请原谅
答案 0 :(得分:0)
读取着色器字节码确实不是一件容易的事,因为如此复杂的着色器需要一点耐心。为了更深入地了解,我建议您阅读documentation,以便您可以轻松查找运算符或寄存器。
对您的问题:
xy
中有一个,并且声明了纹理,我假设它描述的是传递给着色器的某种纹理坐标< / li>
mad r1.xy, r0.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
=>
r1.xy = r0.xy * float2(2,-2) + float2(-1, 1)
and o0.xyzw, r0.xxxx, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
有点特殊。它是寄存器的组成部分,在上面的两行是lt
,这意味着现在r0.x
中的布尔值为0xFFFFFFFF
(true)或0x00000000
(false )。通过使用{和{1}}(即1.0的浮点表示形式),它实际上将布尔值转换为1.0或0.0的浮点数。因此,关于0x3f800000
的布尔值,每个通道中着色器的输出为1.0或0.0。