• Advertisement
Sign in to follow this  

how to load compiled effect file?

This topic is 715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In order to load not compiled effect file You use function D3DXCreateEffectFromFile.

In order to load comipled shader file You do:

byte * data = loadFile("compiledShaderFile.fxc");
IDirect3DPixelShader9 *ps = NULL;
HRESULT hr = device->CreatePixelShader(data, ps);

The similar history with compiled vertex shader.

 

But how to load compiled effect file? I didn't find the similar method.

The problem with D3DXCreateEffectFromFile is that I cannot tell this method to compile effect file with x64 compiler.

 

Share this post


Link to post
Share on other sites
Advertisement

You really should compile the effect file and shaders on the very machine they are supposed to run at.

I am also sure you have plenty of preprocessor declarations you can write in HLSL or effect files that should suit up your compilation custom issues.

 

Share this post


Link to post
Share on other sites

As far as I know, there is no real benefit for compiling the shaders on the end users machine (unlike OpenGL, where i believe it is the only option since it is platform independent and has many different drivers). When you compile the shaders into bytecode, that is producing hardware independent shader assembly, not to be confused with the binary that the GPU actually runs, which is the result of the D3D drivers compiling the shader bytecode into the binary at runtime. The way compiling HLSL works is similar to how "compiling" Java works, where it is compiled to an intermediate language (IL) which is then interpreted at runtime.

 

You shouldn't have to tell D3DXCreateEffectFromFile what architecture your using, the D3D drivers will compile the shader bytecode to native GPU binary for you.

 

Are you getting errors when compiling your effect file with this function?

Edited by iedoc

Share this post


Link to post
Share on other sites

You really should compile the effect file and shaders on the very machine they are supposed to run at.

 

That's not the way D3D shader compilation works.

 

It's a two-step process, step one being compilation of the shader to byte code.  This is hardware-independent, and doesn't even need a D3D device or context to be created.  This is the step that the OP is talking about, and is performed by D3DXCompile/D3DXCreate/D3DCompile/etc.

 

Step two takes that hardware-independent bytecode and compiles it to a hardware-dependent representation.  This is not the step that the OP is talking about, and is performed by device->Create*Shader calls.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement