How to load a precompiled Effect in SharpDX

Started by
1 comment, last by DwarvesH 10 years, 4 months ago

HI everybody!

I am having problems with loading precompiled .hlsl effects in SharpdDX, DirectX 9 version. Creating the Effect file from the shader source works great, but it is kind of slow, so I was thinking of compiling the sources and loading the binary.

I am compiling using:


fxc /T fx_2_0 /Fo smaa.fxo SMAA.fx

This was the only combination of parameters I managed to use to compile.

I am using this to create the effect.


Effect.FromFile(Device, "SMAA.fxo", ShaderFlags.None);

But this seems to want to compile they already compiled shader. It complains about syntax errors.

Advertisement

PS: The shader sources:

http://dl.dropboxusercontent.com/u/45638513/smaa.hlsl

http://dl.dropboxusercontent.com/u/45638513/smaa.fx

I figured this one out on my own. You need to load the compiled shader using ShaderBytecode:


ShaderBytecode s = ShaderBytecode.FromFile("shaders/SMAA.fxo");
smaaEffect = Effect.FromStream(Device, s.Data, ShaderFlags.None);

The most expensive shader now load 63 times faster!

This topic is closed to new replies.

Advertisement