Shader extensions

This commit is contained in:
ds5678 2025-11-04 03:40:02 -08:00
parent 6183a71996
commit 5ebaeb1d6f
2 changed files with 16 additions and 1 deletions

View File

@ -343,4 +343,18 @@ public static class ShaderGpuProgramTypeExtensions
throw new NotSupportedException($"Unsupported gpu program type {_this} [{platform}, {type}]");
}
public static int ToShaderModelVersion(this ShaderGpuProgramType _this)
{
return _this switch
{
ShaderGpuProgramType.DX9VertexSM20 or ShaderGpuProgramType.DX9PixelSM20 => 20,
ShaderGpuProgramType.DX9VertexSM30 or ShaderGpuProgramType.DX9PixelSM30 => 30,
ShaderGpuProgramType.DX10Level9Vertex or ShaderGpuProgramType.DX10Level9Pixel => 40,
ShaderGpuProgramType.DX11VertexSM40 or ShaderGpuProgramType.DX11PixelSM40 or ShaderGpuProgramType.DX11GeometrySM40 => 40,
ShaderGpuProgramType.DX11VertexSM50 or ShaderGpuProgramType.DX11PixelSM50 or ShaderGpuProgramType.DX11GeometrySM50 or
ShaderGpuProgramType.DX11HullSM50 or ShaderGpuProgramType.DX11DomainSM50 => 50,
_ => default,
};
}
}

View File

@ -10,6 +10,7 @@ public static class SerializedShaderStateExtensions
public static ZTest ZTestValue(this ISerializedShaderState state) => (ZTest)state.ZTest.Val;
public static ZWrite ZWriteValue(this ISerializedShaderState state) => (ZWrite)state.ZWrite.Val;
public static CullMode CullingValue(this ISerializedShaderState state) => (CullMode)state.Culling.Val;
public static bool AlphaToMaskValue(this ISerializedShaderState state) => state.AlphaToMask.Val > 0;
public static bool AlphaToMaskValue(this ISerializedShaderState state) => state.AlphaToMask.Val is not 0;
public static bool ConservativeValue(this ISerializedShaderState state) => state.Conservative?.Val is not null and not 0;
public static string LightingValue(this ISerializedShaderState state) => state.Lighting ? "On" : "Off";
}