Sign in to follow this  
zandarina

Differences between D3DXCompileShaderFromFile and D3DXAssembleShader

Recommended Posts

Hi, I was doing my school project and I compiled the shader and I wrote the assembler code in my app and I used D3DXAssembleShader to get the code to create the vertex shader, and the render was ok. But now I prefer to do it from a txt file, and I use D3DXCompileShaderFromFile with the same file I compiled and I get strange results, the render is like a shadow moving, I don't understand why it happens because I have compiled the txt file and I get the same assembler code as the input parameter of the D3DXAssembleShader function. I don't uderstand what's wrong. D3DXCompileShaderFromFile( "./Data/Shader/shader.txt", // shader filename 0, 0, "main", // entry point function name "vs_1_1", // shader version to compile to D3DXSHADER_DEBUG, // debug compile &pCode, &pError, 0); and the one is ok for me D3DXAssembleShader(vertexShaderStr,sizeof(vertexShaderStr),NULL, NULL, 0, &pCode, &pError) Thank you very much Ah !!! I use to compile fxc /Tvs_1_1 shader.fx.txt /Fc dx9_vs1_1.vsa /Zpr

Share this post


Link to post
Share on other sites
I have tried to read every line of the assembled code, and It is the same, it is so strange. Anyone has any idea ???. It can be that some parameters are no correct ???.

Thanks

Share this post


Link to post
Share on other sites
The "Compile" function does take HLSL shader code (plus apparently ASM shader code), while the "Assemble" function does accept ASM shaders only.

Share this post


Link to post
Share on other sites
I know, my problem is that the assembled code from the same file I use to read it from a file is different when I compile from my application

I mean:

1. I write my shader in txt format : shader.txt
2. I compile it with fxc /Tvs_1_1 shader.fx.txt /Fc dx9_vs1_1.vsa /Zpr
and I get the assembled code
3. I put the code in one string: vertexShaderStr
4. I call this funcion D3DXAssembleShader(vertexShaderStr,....
5. I get my bots rendered OK with vertex shader

But my problem is when instead of writing the code in my app I use D3DXCompileShaderFromFile, and I read the normal code from the file.

1. I write the shader, without using assembler, normal code,
(the same I compiled whith the other method)
2. I just use D3DXCompileShaderFromFile("./Data/Shader/shader.txt"....
to compile my code

It should be the same, but it is not, and I don't know why, I would prefer to read it from the file because It would be easier to change the code.

Thanks !!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this