I have a very simple test effect file that I try to load with the following code:
using D3D = Microsoft.WindowsAPICodePack.DirectX.Direct3D10;
...
var DxDevice = CreateDevice(D3D.DriverType.Hardware);
var stream = Application.GetResourceStream(Global.MakePackUri("Resources/Effects/Test.ps"));
var DxEffect = DxDevice.CreateEffectFromCompiledBinary(stream.Stream);
MessageBox.Show(DxEffect.Description.Techniques);
The number of techniques in the effect always comes in as zero.
The effect file does nothing but colors the bitmap for easy recognition:
sampler2D input1 : register(S0);
float4 DoHorizontal(float2 uv : TEXCOORD) : COLOR
{
return float4(1, 0, 1, 1);
}
float4 DoVertical(float2 uv : TEXCOORD) : COLOR
{
return float4(1, 1, 0, 1);
}
technique Test
{
pass P0
{
PixelShader = compile ps_4_0 DoHorizontal();
}
pass P1
{
PixelShader = compile ps_4_0 DoVertical();
}
}
It compiles without any error (using fxc /T fx_4_0
). Is there any HLSL incompatiblity in Windows API Code Pack that might account for this strange behavior?
Your effect still uses old DirectX9 syntax, and you use Shader Model 4, that might create the problem.
Updated version, to fit DX10+ syntax:
SamplerState input1 : register(S0);
float4 DoHorizontal(float2 uv : TEXCOORD) : SV_Target
{
return float4(1, 0, 1, 1);
}
float4 DoVertical(float2 uv : TEXCOORD) : SV_Target
{
return float4(1, 1, 0, 1);
}
technique10 Test
{
pass P0
{
SetPixelShader( CompileShader( ps_4_0, DoHorizontal() ) );
}
pass P1
{
SetPixelShader( CompileShader( ps_4_0, DoVertical() ) );
}
}
Just tried to load it in SlimDX and SharpDX, I get techniques without a problem, so if you still don't have techniques enumerated, this is definitely a problem with Windows API Core Pack.