# how to load compiled effect file?

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

## Recommended Posts

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

byte * data = loadFile("compiledShaderFile.fxc");
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 on other sites

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 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 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.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 98
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009654
• ### Who's Online (See full list)

There are no registered users currently online

×