private void ConvertVertexShaderCaps( RenderSystemCapabilities rsc )
{
var major = 0xFF;
var minor = 0xFF;
SlimDX.Direct3D9.Capabilities minVsCaps = null;
// Find the device with the lowest vertex shader caps.
foreach (var driver in _driverList)
{
var rkCurCaps = driver.D3D9DeviceCaps;
var currMajor = rkCurCaps.VertexShaderVersion.Major;
var currMinor = rkCurCaps.VertexShaderVersion.Minor;
if (currMajor < major)
{
major = currMajor;
minor = currMinor;
minVsCaps = rkCurCaps;
}
else if (currMajor == major && currMinor < minor)
{
minor = currMinor;
minVsCaps = rkCurCaps;
}
}
var vs2X = false;
var vs2A = false;
// Special case detection for vs_2_x/a support
if (major >= 2)
{
if ((minVsCaps.VS20Caps.Caps & VertexShaderCaps.Predication) != 0 &&
(minVsCaps.VS20Caps.DynamicFlowControlDepth > 0) &&
(minVsCaps.VS20Caps.TempCount >= 12))
{
vs2X = true;
}
if ((minVsCaps.VS20Caps.Caps & VertexShaderCaps.Predication) != 0 &&
(minVsCaps.VS20Caps.DynamicFlowControlDepth > 0) &&
(minVsCaps.VS20Caps.TempCount >= 13))
{
vs2A = true;
}
}
// Populate max param count
switch (major)
{
case 1:
// No boolean params allowed
rsc.VertexProgramConstantBoolCount = 0;
// No integer params allowed
rsc.VertexProgramConstantIntCount = 0;
// float params, always 4D
rsc.VertexProgramConstantFloatCount = minVsCaps.MaxVertexShaderConstants;
break;
case 2:
// 16 boolean params allowed
rsc.VertexProgramConstantBoolCount = 16;
// 16 integer params allowed, 4D
rsc.VertexProgramConstantIntCount = 16;
// float params, always 4D
rsc.VertexProgramConstantFloatCount = minVsCaps.MaxVertexShaderConstants;
break;
case 3:
// 16 boolean params allowed
rsc.VertexProgramConstantBoolCount = 16;
// 16 integer params allowed, 4D
rsc.VertexProgramConstantIntCount = 16;
// float params, always 4D
rsc.VertexProgramConstantFloatCount = minVsCaps.MaxVertexShaderConstants;
break;
}
// populate syntax codes in program manager (no breaks in this one so it falls through)
switch (major)
{
case 3:
rsc.AddShaderProfile( "vs_3_0" );
goto case 2;
case 2:
if ( vs2X )
rsc.AddShaderProfile( "vs_2_x" );
if ( vs2A )
rsc.AddShaderProfile( "vs_2_a" );
rsc.AddShaderProfile( "vs_2_0" );
goto case 1;
case 1:
rsc.AddShaderProfile( "vs_1_1" );
rsc.SetCapability( Graphics.Capabilities.VertexPrograms );
break;
}
}