gpt4 book ai didi

assembly - 如何将 asm 着色器编译为 fxo 文件?

转载 作者:行者123 更新时间:2023-12-02 09:13:14 33 4
gpt4 key购买 nike

我有一个已编译的 fxo 着色器,我正在尝试对其进行稍微编辑(仅调整一些常量)。

使用 fxdis ( https://code.google.com/archive/p/fxdis-d3d1x/ ) 我可以反汇编这个着色器,这是输出:

# DXBC chunk  0: RDEF offset 52 size 972
# DXBC chunk 1: ISGN offset 1032 size 80
# DXBC chunk 2: OSGN offset 1120 size 44
# DXBC chunk 3: SHEX offset 1172 size 1592
# DXBC chunk 4: STAT offset 2772 size 148
ps_5_0
dcl_global_flags refactoringAllowed
dcl_constant_buffer cb0[30].xyzw, immediateIndexed
dcl_sampler sampler[0]
dcl_resource_texture2d resource[0]
dcl_resource_texture2d resource[1]
dcl_resource_texture2d resource[2]
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 5
ne r0.x, l(0, 0, 0, 0), cb0[29].y
mov r1.x, v1.x
add r2.xz, -v1.yyxy, l(1, 0, 1, 0)
eq r0.yzw, cb0[29].yyxz, l(0, 1, 1, 1)
movc r1.y, r0.y, r2.x, v1.y
add r2.y, -r1.y, l(1)
movc r0.xy, r0.xxxx, r2.yzyy, r1.xyxx
sample r1.xyzw, r0.xyxx, resource[1].xyzw, sampler[0]
sample r2.xyzw, r0.xyxx, resource[2].xyzw, sampler[0]
mad r0.xy, r1.zxzz, l(255, 255, 0, 0), r1.wyww
mad r0.xy, r0.xyxx, l(0.0078125, 0.0078125, 0, 0), l(-1, -1, 0, 0)
mul r0.y, r0.y, cb0[28].z
mad r1.x, -r0.x, cb0[28].y, l(1)
add r0.x, r0.x, cb0[28].y
div r0.xy, r0.xyxx, r1.xxxx
ge r1.x, l(1), r0.y
ge r1.y, r0.y, l(-1)
div r0.y, r0.y, cb0[28].x
and r1.x, r1.y, r1.x
ge r1.y, l(1), r0.x
and r1.x, r1.y, r1.x
ge r1.y, r0.x, l(-1)
div r0.x, r0.x, cb0[28].x
add r0.xy, r0.xyxx, l(1, 1, 0, 0)
and r1.x, r1.y, r1.x
and r1.x, r1.x, l(1065353216)
mul r1.y, r0.x, l(0.5)
mad r0.x, -r0.x, l(0.5), l(1)
movc r0.x, r0.z, r1.y, r0.x
add r0.z, -r0.x, l(1)
movc r3.y, r0.w, r0.z, r0.x
mul r3.x, r0.y, l(0.5)
add r3.x, r3.x, l(0.5)
sample r4.xyzw, r3.xyxx, resource[0].xyzw, sampler[0]
mul r1.xyzw, r1.xxxx, r4.xyzw
mul r1.xyzw, r2.xyzw, r1.xyzw
ge r0.x, l(2), r0.y
ge r0.y, r0.y, l(0)
and r0.x, r0.y, r0.x
ge r0.y, r3.y, l(0)
ge r0.z, l(1), r3.y
and r0.x, r0.y, r0.x
and r0.x, r0.z, r0.x
and r0.x, r0.x, l(1065353216)
mul o0.xyzw, r0.xxxx, r1.xyzw
ret

我了解程序集并可以对其进行编辑。问题是,我目前不知道如何将其编译回 fxo 文件。 Windows SDK 中的 fxc.exe 似乎不接受 asm 着色器文件。或者我忽略了什么?

最佳答案

不支持从程序集创建着色器。适用于 Shader Model 1.1 - 3.0 的旧版 DirectX SDK 中存在旧版 DirectX 组装工具 VSAPSA。它们最后一次在 DirectX SDK 中发布(2008 年 11 月),远早于 end-of-life DirectX SDK (June 2010)。 .

此外,对于 Shader Model 4.x 和 5.x,DirectX 运行时不会接受未使用正确哈希签名的着色器 blob,因此着色器 blob 的二进制编辑将无法加载。只有官方 HLSL 编译器才能为 DirectX 10.x 或 DirectX 11 生成有效的着色器 blob。

支持反汇编器输出,并且着色器汇编语言记录在MSDN上促进 HLSL 着色器的优化、调试 HLSL 编译器本身,并帮助人们在应用程序中调试着色器。

For DirectX 12 and the new Shader Model 6.x tools, see GitHub

关于assembly - 如何将 asm 着色器编译为 fxo 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059358/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com