如何将asm着色器编译为fxo文件? [英] How can I compile asm shader to fxo file?

查看:181
本文介绍了如何将asm着色器编译为fxo文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已编译的fxo着色器,我正在尝试对其进行一些编辑(只需调整一些常量即可).

I have a compiled fxo shader which I'm trying to edit slightly (just adjusting some constants).

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

Using fxdis (https://code.google.com/archive/p/fxdis-d3d1x/) I can disassemble this shader, this is the output:

# 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着色器文件.还是我忽略了什么?

I understand the assembly and can edit it. The problem is, I currently don't know how I can compile this back into an fxo file. It seems fxc.exe from the Windows SDK does not accept asm shader files. Or am I overlooking something?

推荐答案

不支持从程序集中创建着色器. Shader Model 1.1-3.0的旧版DirectX SDK中有旧的DirectX组装工具VSAPSA.它们最后一次发布在DirectX SDK中(2008年11月),早于 DirectX寿命终止的SDK(2010年6月).

Creating shaders from assembly is not supported. There were old DirectX assembly tools VSA and PSA in the legacy DirectX SDKs for Shader Model 1.1 - 3.0. They were last shipped in the DirectX SDK (November 2008), well before the end-of-life DirectX SDK (June 2010).

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

In addition for Shader Model 4.x and 5.x, the DirectX Runtime will not accept a shader blob that is not signed with the correct hash, so binary edits of a shader blob will fail to load. Only the official HLSL compiler can generate a valid shader blob for DirectX 10.x or DirectX 11.

支持Diassembler输出,并且在 MSDN 有助于优化HLSL着色器,调试HLSL编译器本身,并帮助人们调试应用程序中的着色器.

Diassembler output is supported and the shader assembly language is documented on MSDN to facilitate optimization of HLSL shaders, debugging the HLSL compiler itself, and to help with people debugging shaders in applications.

对于DirectX 12和新的Shader Model 6.x工具,请参见 GitHub

这篇关于如何将asm着色器编译为fxo文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆