Reputation: 59
I am trying to load a precompiled shader in SlimDX(Direct3D11), but I don't know how to do it.
I searched this topic and only found the solution for C++ native version of DirectX. It seems like /Gch compile option and device->CreatePixelShader(data,ps).
The problem is, I cannot find this function in SlimDX. The functions in SlimDX compile the shader in run time.
How can I load the precompiled shader in SlimDX?
Upvotes: 2
Views: 621
Reputation: 8963
Considering your shader binary is held in a byte[] bytecode (since i'm not sure where you load it from, but it's just binary data once saved)
DataStream ds = new DataStream(bytecode.Length, true, true);
ds.Write(bytecode, 0, bytecode.Length);
ShaderBytecode bc = new ShaderBytecode(ds);
Then to load in dx11 Effect:
Effect effect = new Effect(device,bc);
Upvotes: 4