2

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?

4

1 に答える 1

4

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);
于 2012-09-02T01:12:08.750 に答える