游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1666|回复: 3

How to convert HLSL shader code to Assembly shader code

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2007-11-29 15:42:00 | 显示全部楼层 |阅读模式
原始的HLSL Shader Code(AmbientTexture.fx)如下:

//AmbientTexture.fx/////////////////////
float4x4 World : WORLD;float4x4 View;float4x4 Projection;float4 AmbientColor : COLOR0;float4x4 WorldViewProjection : WORLDVIEWPROJECTION;texture Texture;sampler TextureSampler = sampler_state{ texture = <Texture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = mirror; AddressV = mirror;};struct VertexInput{ float4 Position : POSITION; float2 TexCoord : TEXCOORD0;};struct VertexOutput{ float4 Position : POSITION; float2 TexCoord : TEXCOORD0;};VertexOutput vertexShader(VertexInput input){ VertexOutput output; WorldViewProjection = mul(mul(World, View), Projection); output.Position = mul(input.Position, WorldViewProjection); output.TexCoord = input.TexCoord; return( output );}struct PixelInput{ float2 TexCoord : TEXCOORD0; };float4 pixelShader(PixelInput input) : COLOR{ return( tex2D(TextureSampler, input.TexCoord) * AmbientColor);}technique Default{ pass P0 { VertexShader = compile vs_1_1 vertexShader(); PixelShader = compile ps_1_1 pixelShader(); }}

我想要??Q??ssembly Shade Code如下:
???fxc.exe可以?到????等绾蜗履?

//////output.fx///////////////////////
technique Default{ pass P0 { vertexshader = asm { // // Generated by Microsoft (R) D3DX9 Shader Compiler // // Parameters: // // float4x4 Projection; // float4x4 View; // float4x4 World; // // // Registers: // // Name Reg Size // ------------ ----- ---- // World c0 4 // View c4 4 // Projection c8 4 // preshader mul r0, c4.x, c0 mul r1, c4.y, c1 add r2, r0, r1 mul r0, c4.z, c2 add r1, r2, r0 mul r0, c4.w, c3 add r2, r1, r0 mul r0, c8.x, r2 mul r1, c5.x, c0 mul r3, c5.y, c1 add r4, r1, r3 mul r1, c5.z, c2 add r3, r4, r1 mul r1, c5.w, c3 add r4, r3, r1 mul r1, c8.y, r4 add r3, r0, r1 mul r0, c6.x, c0 mul r1, c6.y, c1 add r5, r0, r1 mul r0, c6.z, c2 add r1, r5, r0 mul r0, c6.w, c3 add r5, r1, r0 mul r0, c8.z, r5 add r1, r3, r0 mul r0, c7.x, c0 mul r3, c7.y, c1 add r6, r0, r3 mul r0, c7.z, c2 add r3, r6, r0 mul r0, c7.w, c3 add r6, r3, r0 mul r0, c8.w, r6 add c0, r1, r0 mul r0, c9.x, r2 mul r1, c9.y, r4 add r3, r0, r1 mul r0, c9.z, r5 add r1, r3, r0 mul r0, c9.w, r6 add c1, r1, r0 mul r0, c10.x, r2 mul r1, c11.x, r2 mul r2, c10.y, r4 mul r3, c11.y, r4 add r4, r0, r2 mul r0, c10.z, r5 mul r2, c11.z, r5 add r5, r4, r0 mul r0, c10.w, r6 mul r4, c11.w, r6 add c2, r5, r0 add r0, r1, r3 add r1, r2, r0 add c3, r4, r1 // approximately 56 instructions used // // Generated by Microsoft (R) D3DX9 Shader Compiler vs_2_0 dcl_position v0 dcl_texcoord v1 dp4 oPos.x, v0, c0 dp4 oPos.y, v0, c1 dp4 oPos.z, v0, c2 dp4 oPos.w, v0, c3 mov oT0.xy, v1 // approximately 5 instruction slots used }; pixelshader = asm { // // Generated by Microsoft (R) D3DX9 Shader Compiler // // Parameters: // // float4 AmbientColor; // sampler2D TextureSampler; // // // Registers: // // Name Reg Size // -------------- ----- ---- // AmbientColor c0 1 // TextureSampler s0 1 // ps_2_0 dcl t0.xy dcl_2d s0 texld r0, t0, s0 mul r0, r0, c0 mov oC0, r0 // approximately 3 instruction slots used (1 texture, 2 arithmetic) }; }}

0

主题

243

帖子

357

积分

中级会员

Rank: 3Rank: 3

积分
357
发表于 2007-11-29 17:59:00 | 显示全部楼层

Re:How to convert HLSL shader code to Assembly shader code

There is a great tool called RenderMonkey..........

34

主题

629

帖子

629

积分

高级会员

Rank: 4

积分
629
发表于 2007-11-29 18:09:00 | 显示全部楼层

Re:How to convert HLSL shader code to Assembly shader code

首先D3DXCompileShaderFromFile
然后D3DXDisassembleShader

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
 楼主| 发表于 2007-11-29 21:42:00 | 显示全部楼层

Re:How to convert HLSL shader code to Assembly shader code

NVIDIA的FX Composer2有???功能??
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-6-17 04:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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