Skip to main content
GameDev.net gamedev.net
🔒 Locked

how to load compiled effect file?

Started by anders211 May 8, 2016 at 7:45 PM 2 replies 1.6k views
Original Post
anders211
anders211

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.

JohnnyCode
JohnnyCode

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.

iedoc
iedoc

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?

21st Century Moose
21st Century Moose

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.