(ded4a3e0a) v0.9.0.7
This commit is contained in:
@@ -0,0 +1,428 @@
|
||||
// MonoGame Effect Parser
|
||||
//
|
||||
// For use with our fork of the "Tiny Parser Generator"
|
||||
// https://github.com/SickheadGames/TinyPG
|
||||
//
|
||||
|
||||
<% @TinyPG Namespace="TwoMGFX.TPGParser" Language="C#"%>
|
||||
|
||||
[Skip] BlockComment -> @"/\*([^*]|\*[^/])*\*/";
|
||||
[Skip] Comment -> @"//[^\n\r]*";
|
||||
[Skip] Whitespace -> @"[ \t\n\r]+";
|
||||
[FileAndLine] LinePragma -> @"^[ \t]*#line[ \t]*(?<Line>\d*)[ \t]*(\""(?<File>[^\""\\]*(?:\\.[^\""\\]*)*)\"")?\n";
|
||||
|
||||
// TOKENS
|
||||
[IgnoreCase] Pass -> @"pass";
|
||||
[IgnoreCase] Technique -> @"technique";
|
||||
[IgnoreCase] Sampler -> @"sampler1D|sampler2D|sampler3D|samplerCUBE|SamplerState|sampler";
|
||||
[IgnoreCase] SamplerState -> @"sampler_state";
|
||||
[IgnoreCase] VertexShader -> @"VertexShader";
|
||||
[IgnoreCase] PixelShader -> @"PixelShader";
|
||||
[IgnoreCase] Register -> @"register";
|
||||
[IgnoreCase] Boolean -> @"true|false|0|1";
|
||||
Number -> @"[+-]? ?[0-9]?\.?[0-9]+[fF]?";
|
||||
[IgnoreCase] HexColor -> @"0x[0-9a-f]{6}([0-9a-f][0-9a-f])?";
|
||||
Identifier -> @"[A-Za-z_][A-Za-z0-9_]*";
|
||||
OpenBracket -> @"{";
|
||||
CloseBracket -> @"}";
|
||||
Equals -> @"=";
|
||||
Colon -> @":";
|
||||
Comma -> @",";
|
||||
Semicolon -> @";";
|
||||
Or -> @"\|";
|
||||
OpenParenthesis -> @"\(";
|
||||
CloseParenthesis -> @"\)";
|
||||
OpenSquareBracket -> @"\[";
|
||||
CloseSquareBracket -> @"\]";
|
||||
LessThan -> @"<";
|
||||
GreaterThan -> @">";
|
||||
[IgnoreCase] Compile -> @"compile";
|
||||
ShaderModel -> @"[A-Za-z_][A-Za-z0-9_]*";
|
||||
Code -> @"[\S]+";
|
||||
EndOfFile -> @"^$";
|
||||
|
||||
// Sampler states
|
||||
[IgnoreCase] MinFilter -> @"MinFilter";
|
||||
[IgnoreCase] MagFilter -> @"MagFilter";
|
||||
[IgnoreCase] MipFilter -> @"MipFilter";
|
||||
[IgnoreCase] Filter -> @"Filter";
|
||||
[IgnoreCase] Texture -> @"Texture";
|
||||
[IgnoreCase] AddressU -> @"AddressU";
|
||||
[IgnoreCase] AddressV -> @"AddressV";
|
||||
[IgnoreCase] AddressW -> @"AddressW";
|
||||
[IgnoreCase] BorderColor -> @"BorderColor";
|
||||
[IgnoreCase] MaxAnisotropy -> @"MaxAnisotropy";
|
||||
[IgnoreCase] MaxMipLevel -> @"MaxMipLevel|MaxLod";
|
||||
[IgnoreCase] MipLodBias -> @"MipLodBias";
|
||||
|
||||
// Address Mode
|
||||
[IgnoreCase] Clamp -> @"Clamp";
|
||||
[IgnoreCase] Wrap -> @"Wrap";
|
||||
[IgnoreCase] Mirror -> @"Mirror";
|
||||
[IgnoreCase] Border -> @"Border";
|
||||
|
||||
// Texture Filters
|
||||
[IgnoreCase] None -> @"None";
|
||||
[IgnoreCase] Linear -> @"Linear";
|
||||
[IgnoreCase] Point -> @"Point";
|
||||
[IgnoreCase] Anisotropic -> @"Anisotropic";
|
||||
|
||||
// Render states
|
||||
[IgnoreCase] AlphaBlendEnable -> @"AlphaBlendEnable";
|
||||
[IgnoreCase] SrcBlend -> @"SrcBlend";
|
||||
[IgnoreCase] DestBlend -> @"DestBlend";
|
||||
[IgnoreCase] BlendOp -> @"BlendOp";
|
||||
[IgnoreCase] ColorWriteEnable -> @"ColorWriteEnable";
|
||||
[IgnoreCase] ZEnable -> @"ZEnable";
|
||||
[IgnoreCase] ZWriteEnable -> @"ZWriteEnable";
|
||||
[IgnoreCase] ZFunc-> @"ZFunc";
|
||||
[IgnoreCase] DepthBias -> @"DepthBias";
|
||||
[IgnoreCase] CullMode -> @"CullMode";
|
||||
[IgnoreCase] FillMode -> @"FillMode";
|
||||
[IgnoreCase] MultiSampleAntiAlias -> @"MultiSampleAntiAlias";
|
||||
[IgnoreCase] ScissorTestEnable -> @"ScissorTestEnable";
|
||||
[IgnoreCase] SlopeScaleDepthBias -> @"SlopeScaleDepthBias";
|
||||
[IgnoreCase] StencilEnable -> @"StencilEnable";
|
||||
[IgnoreCase] StencilFail -> @"StencilFail";
|
||||
[IgnoreCase] StencilFunc -> @"StencilFunc";
|
||||
[IgnoreCase] StencilMask -> @"StencilMask";
|
||||
[IgnoreCase] StencilPass -> @"StencilPass";
|
||||
[IgnoreCase] StencilRef -> @"StencilRef";
|
||||
[IgnoreCase] StencilWriteMask -> @"StencilWriteMask";
|
||||
[IgnoreCase] StencilZFail -> @"StencilZFail";
|
||||
|
||||
|
||||
// Compare function
|
||||
[IgnoreCase] Never -> @"Never";
|
||||
[IgnoreCase] Less -> @"Less";
|
||||
[IgnoreCase] Equal -> @"Equal";
|
||||
[IgnoreCase] LessEqual -> @"LessEqual";
|
||||
[IgnoreCase] Greater -> @"Greater";
|
||||
[IgnoreCase] NotEqual -> @"NotEqual";
|
||||
[IgnoreCase] GreaterEqual -> @"GreaterEqual";
|
||||
[IgnoreCase] Always -> @"Always";
|
||||
|
||||
// Stencil operation
|
||||
[IgnoreCase] Keep -> @"Keep";
|
||||
[IgnoreCase] Zero -> @"Zero";
|
||||
[IgnoreCase] Replace -> @"Replace";
|
||||
[IgnoreCase] IncrSat -> @"IncrSat";
|
||||
[IgnoreCase] DecrSat -> @"DecrSat";
|
||||
[IgnoreCase] Invert -> @"Invert";
|
||||
[IgnoreCase] Incr -> @"Incr";
|
||||
[IgnoreCase] Decr -> @"Decr";
|
||||
|
||||
// Colors
|
||||
[IgnoreCase] Red -> @"Red";
|
||||
[IgnoreCase] Green -> @"Green";
|
||||
[IgnoreCase] Blue -> @"Blue";
|
||||
[IgnoreCase] Alpha -> @"Alpha";
|
||||
[IgnoreCase] All -> @"All";
|
||||
|
||||
// Cull mode
|
||||
[IgnoreCase] Cw -> @"Cw";
|
||||
[IgnoreCase] Ccw -> @"Ccw";
|
||||
|
||||
// Fill mode
|
||||
[IgnoreCase] Solid -> @"Solid";
|
||||
[IgnoreCase] WireFrame -> @"WireFrame";
|
||||
|
||||
// Blend function
|
||||
[IgnoreCase] Add -> @"Add";
|
||||
[IgnoreCase] Subtract -> @"Subtract";
|
||||
[IgnoreCase] RevSubtract -> @"RevSubtract";
|
||||
[IgnoreCase] Min -> @"Min";
|
||||
[IgnoreCase] Max -> @"Max";
|
||||
|
||||
// Blend
|
||||
[IgnoreCase] Zero -> @"Zero";
|
||||
[IgnoreCase] One -> @"One";
|
||||
[IgnoreCase] SrcColor -> @"SrcColor";
|
||||
[IgnoreCase] InvSrcColor -> @"InvSrcColor";
|
||||
[IgnoreCase] SrcAlpha -> @"SrcAlpha";
|
||||
[IgnoreCase] InvSrcAlpha -> @"InvSrcAlpha";
|
||||
[IgnoreCase] DestAlpha -> @"DestAlpha";
|
||||
[IgnoreCase] InvDestAlpha -> @"InvDestAlpha";
|
||||
[IgnoreCase] DestColor -> @"DestColor";
|
||||
[IgnoreCase] InvDestColor -> @"InvDestColor";
|
||||
[IgnoreCase] SrcAlphaSat -> @"SrcAlphaSat";
|
||||
[IgnoreCase] BlendFactor -> @"BlendFactor";
|
||||
[IgnoreCase] InvBlendFactor -> @"InvBlendFactor";
|
||||
|
||||
|
||||
// Productions
|
||||
Start -> (Code | Technique_Declaration | Sampler_Declaration)* EndOfFile
|
||||
{
|
||||
var shader = new ShaderInfo();
|
||||
|
||||
foreach (var node in Nodes)
|
||||
node.Eval(tree, shader);
|
||||
|
||||
return shader;
|
||||
};
|
||||
|
||||
Technique_Declaration -> Technique Identifier? OpenBracket Pass_Declaration+ CloseBracket
|
||||
{
|
||||
var technique = new TechniqueInfo();
|
||||
technique.name = $Identifier as string ?? string.Empty;
|
||||
technique.startPos = Token.StartPos;
|
||||
technique.length = Token.Length;
|
||||
|
||||
foreach (var node in Nodes)
|
||||
node.Eval(tree, technique);
|
||||
|
||||
// Make sure we have at least one pass.
|
||||
if (technique.Passes.Count > 0)
|
||||
{
|
||||
var shaderInfo = paramlist[0] as ShaderInfo;
|
||||
shaderInfo.Techniques.Add(technique);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
FillMode_Solid -> Solid { return FillMode.Solid; };
|
||||
FillMode_WireFrame -> WireFrame { return FillMode.WireFrame; };
|
||||
FillModes -> (FillMode_Solid|FillMode_WireFrame)
|
||||
{
|
||||
return $FillMode_Solid ?? $FillMode_WireFrame;
|
||||
};
|
||||
|
||||
CullMode_None -> None { return CullMode.None; };
|
||||
CullMode_Cw -> Cw { return CullMode.CullClockwiseFace; };
|
||||
CullMode_Ccw -> Ccw { return CullMode.CullCounterClockwiseFace; };
|
||||
CullModes -> (CullMode_None|CullMode_Cw|CullMode_Ccw)
|
||||
{
|
||||
return $CullMode_None ?? $CullMode_Cw ?? $CullMode_Ccw;
|
||||
};
|
||||
|
||||
Colors_None -> None { return ColorWriteChannels.None; };
|
||||
Colors_Red -> Red { return ColorWriteChannels.Red; };
|
||||
Colors_Green -> Green { return ColorWriteChannels.Green; };
|
||||
Colors_Blue -> Blue { return ColorWriteChannels.Blue; };
|
||||
Colors_Alpha -> Alpha { return ColorWriteChannels.Alpha; };
|
||||
Colors_All -> All { return ColorWriteChannels.All; };
|
||||
Colors_Boolean -> Boolean { return ParseTreeTools.ParseBool((string)$Boolean) ? ColorWriteChannels.All : ColorWriteChannels.None; };
|
||||
Colors -> (Colors_Red|Colors_Green|Colors_Blue|Colors_Alpha|Colors_None|Colors_All|Colors_Boolean)
|
||||
{
|
||||
return $Colors_Red ?? $Colors_Green ?? $Colors_Blue ?? $Colors_Alpha ?? $Colors_None ?? $Colors_All ?? $Colors_Boolean;
|
||||
};
|
||||
ColorsMasks -> Colors (Or Colors)? (Or Colors)? (Or Colors)?
|
||||
{
|
||||
return (ColorWriteChannels)($Colors[0] ?? 0) |
|
||||
(ColorWriteChannels)($Colors[1] ?? 0) |
|
||||
(ColorWriteChannels)($Colors[2] ?? 0) |
|
||||
(ColorWriteChannels)($Colors[3] ?? 0);
|
||||
};
|
||||
|
||||
Blend_Zero -> Zero { return Blend.Zero; };
|
||||
Blend_One -> One { return Blend.One; };
|
||||
Blend_SrcColor -> SrcColor { return Blend.SourceColor; };
|
||||
Blend_InvSrcColor -> InvSrcColor { return Blend.InverseSourceColor; };
|
||||
Blend_SrcAlpha -> SrcAlpha { return Blend.SourceAlpha; };
|
||||
Blend_InvSrcAlpha -> InvSrcAlpha { return Blend.InverseSourceAlpha; };
|
||||
Blend_DestAlpha -> DestAlpha { return Blend.DestinationAlpha; };
|
||||
Blend_InvDestAlpha -> InvDestAlpha { return Blend.InverseDestinationAlpha; };
|
||||
Blend_DestColor -> DestColor { return Blend.DestinationColor; };
|
||||
Blend_InvDestColor -> InvDestColor { return Blend.InverseDestinationColor; };
|
||||
Blend_SrcAlphaSat -> SrcAlphaSat { return Blend.SourceAlphaSaturation; };
|
||||
Blend_BlendFactor -> BlendFactor { return Blend.BlendFactor; };
|
||||
Blend_InvBlendFactor -> InvBlendFactor { return Blend.InverseBlendFactor; };
|
||||
Blends -> ( Blend_Zero|Blend_One|Blend_SrcColor|Blend_InvSrcColor|Blend_SrcAlpha|Blend_InvSrcAlpha|
|
||||
Blend_DestAlpha|Blend_InvDestAlpha|Blend_DestColor|Blend_InvDestColor|Blend_SrcAlphaSat|
|
||||
Blend_BlendFactor|Blend_InvBlendFactor)
|
||||
{
|
||||
return $Blend_Zero ?? $Blend_One ?? $Blend_SrcColor ?? $Blend_InvSrcColor ?? $Blend_SrcAlpha ?? $Blend_InvSrcAlpha ??
|
||||
$Blend_DestAlpha ?? $Blend_InvDestAlpha ?? $Blend_DestColor ?? $Blend_InvDestColor ?? $Blend_SrcAlphaSat ??
|
||||
$Blend_BlendFactor ?? $Blend_InvBlendFactor;
|
||||
};
|
||||
|
||||
BlendOp_Add -> Add { return BlendFunction.Add; };
|
||||
BlendOp_Subtract -> Subtract { return BlendFunction.Subtract; };
|
||||
BlendOp_RevSubtract -> RevSubtract { return BlendFunction.ReverseSubtract; };
|
||||
BlendOp_Min -> Min { return BlendFunction.Min; };
|
||||
BlendOp_Max -> Max { return BlendFunction.Max; };
|
||||
BlendOps -> (BlendOp_Add|BlendOp_Subtract|BlendOp_RevSubtract|BlendOp_Min|BlendOp_Max)
|
||||
{
|
||||
return $BlendOp_Add ?? $BlendOp_Subtract ?? $BlendOp_RevSubtract ?? $BlendOp_Min ?? $BlendOp_Max;
|
||||
};
|
||||
|
||||
CmpFunc_Never -> Never { return CompareFunction.Never; };
|
||||
CmpFunc_Less -> Less { return CompareFunction.Less; };
|
||||
CmpFunc_Equal -> Equal { return CompareFunction.Equal; };
|
||||
CmpFunc_LessEqual -> LessEqual { return CompareFunction.LessEqual; };
|
||||
CmpFunc_Greater -> Greater { return CompareFunction.Greater; };
|
||||
CmpFunc_NotEqual -> NotEqual { return CompareFunction.NotEqual; };
|
||||
CmpFunc_GreaterEqual -> GreaterEqual { return CompareFunction.GreaterEqual; };
|
||||
CmpFunc_Always -> Always { return CompareFunction.Always; };
|
||||
CmpFunc -> (CmpFunc_Never|CmpFunc_Less|CmpFunc_Equal|CmpFunc_LessEqual|CmpFunc_Greater|CmpFunc_NotEqual|CmpFunc_GreaterEqual|CmpFunc_Always)
|
||||
{
|
||||
return $CmpFunc_Never ?? $CmpFunc_Less ?? $CmpFunc_Equal ?? $CmpFunc_LessEqual ?? $CmpFunc_Greater ?? $CmpFunc_NotEqual ?? $CmpFunc_GreaterEqual ?? $CmpFunc_Always;
|
||||
};
|
||||
|
||||
StencilOp_Keep -> Keep { return StencilOperation.Keep; };
|
||||
StencilOp_Zero -> Zero { return StencilOperation.Zero; };
|
||||
StencilOp_Replace -> Replace { return StencilOperation.Replace; };
|
||||
StencilOp_IncrSat -> IncrSat { return StencilOperation.IncrementSaturation; };
|
||||
StencilOp_DecrSat -> DecrSat { return StencilOperation.DecrementSaturation; };
|
||||
StencilOp_Invert -> Invert { return StencilOperation.Invert; };
|
||||
StencilOp_Incr -> Incr { return StencilOperation.Increment; };
|
||||
StencilOp_Decr -> Decr { return StencilOperation.Decrement; };
|
||||
StencilOp -> (StencilOp_Keep|StencilOp_Zero|StencilOp_Replace|StencilOp_IncrSat|StencilOp_DecrSat|StencilOp_Invert|StencilOp_Incr|StencilOp_Decr)
|
||||
{
|
||||
return $StencilOp_Keep ?? $StencilOp_Zero ?? $StencilOp_Replace ?? $StencilOp_IncrSat ?? $StencilOp_DecrSat ?? $StencilOp_Invert ?? $StencilOp_Incr ?? $StencilOp_Decr;
|
||||
};
|
||||
|
||||
// Render states
|
||||
Render_State_CullMode -> CullMode Equals CullModes Semicolon { (paramlist[0] as PassInfo).CullMode = (CullMode)$CullModes; return null; };
|
||||
Render_State_FillMode -> FillMode Equals FillModes Semicolon { (paramlist[0] as PassInfo).FillMode = (FillMode)$FillModes; return null; };
|
||||
Render_State_AlphaBlendEnable -> AlphaBlendEnable Equals Boolean Semicolon { (paramlist[0] as PassInfo).AlphaBlendEnable = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_SrcBlend -> SrcBlend Equals Blends Semicolon { (paramlist[0] as PassInfo).SrcBlend = (Blend)$Blends; return null; };
|
||||
Render_State_DestBlend -> DestBlend Equals Blends Semicolon { (paramlist[0] as PassInfo).DestBlend = (Blend)$Blends; return null; };
|
||||
Render_State_BlendOp -> BlendOp Equals BlendOps Semicolon { (paramlist[0] as PassInfo).BlendOp = (BlendFunction)$BlendOps; return null; };
|
||||
Render_State_ColorWriteEnable -> ColorWriteEnable Equals ColorsMasks Semicolon { (paramlist[0] as PassInfo).ColorWriteEnable = (ColorWriteChannels)$ColorsMasks; return null; };
|
||||
Render_State_DepthBias -> DepthBias Equals Number Semicolon { (paramlist[0] as PassInfo).DepthBias = ParseTreeTools.ParseFloat((string)$Number); return null; };
|
||||
Render_State_SlopeScaleDepthBias -> SlopeScaleDepthBias Equals Number Semicolon { (paramlist[0] as PassInfo).SlopeScaleDepthBias = ParseTreeTools.ParseFloat((string)$Number); return null; };
|
||||
Render_State_ZEnable -> ZEnable Equals Boolean Semicolon { (paramlist[0] as PassInfo).ZEnable = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_ZWriteEnable -> ZWriteEnable Equals Boolean Semicolon { (paramlist[0] as PassInfo).ZWriteEnable = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_ZFunc -> ZFunc Equals CmpFunc Semicolon { (paramlist[0] as PassInfo).DepthBufferFunction = (CompareFunction)$CmpFunc; return null; };
|
||||
Render_State_MultiSampleAntiAlias -> MultiSampleAntiAlias Equals Boolean Semicolon { (paramlist[0] as PassInfo).MultiSampleAntiAlias = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_ScissorTestEnable -> ScissorTestEnable Equals Boolean Semicolon { (paramlist[0] as PassInfo).ScissorTestEnable = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_StencilEnable -> StencilEnable Equals Boolean Semicolon { (paramlist[0] as PassInfo).StencilEnable = ParseTreeTools.ParseBool((string)$Boolean); return null; };
|
||||
Render_State_StencilFail -> StencilFail Equals StencilOp Semicolon { (paramlist[0] as PassInfo).StencilFail = (StencilOperation)$StencilOp; return null; };
|
||||
Render_State_StencilFunc -> StencilFunc Equals CmpFunc Semicolon { (paramlist[0] as PassInfo).StencilFunc = (CompareFunction)$CmpFunc; return null; };
|
||||
Render_State_StencilMask -> StencilMask Equals Number Semicolon { (paramlist[0] as PassInfo).StencilMask = ParseTreeTools.ParseInt((string)$Number); return null; };
|
||||
Render_State_StencilPass -> StencilPass Equals StencilOp Semicolon { (paramlist[0] as PassInfo).StencilPass = (StencilOperation)$StencilOp; return null; };
|
||||
Render_State_StencilRef -> StencilRef Equals Number Semicolon { (paramlist[0] as PassInfo).StencilRef = ParseTreeTools.ParseInt((string)$Number); return null; };
|
||||
Render_State_StencilWriteMask -> StencilWriteMask Equals Number Semicolon { (paramlist[0] as PassInfo).StencilWriteMask = ParseTreeTools.ParseInt((string)$Number); return null; };
|
||||
Render_State_StencilZFail -> StencilZFail Equals StencilOp Semicolon { (paramlist[0] as PassInfo).StencilZFail = (StencilOperation)$StencilOp; return null; };
|
||||
|
||||
|
||||
Render_State_Expression ->
|
||||
Render_State_CullMode |
|
||||
Render_State_FillMode |
|
||||
Render_State_AlphaBlendEnable |
|
||||
Render_State_SrcBlend |
|
||||
Render_State_DestBlend |
|
||||
Render_State_BlendOp |
|
||||
Render_State_ColorWriteEnable |
|
||||
Render_State_DepthBias |
|
||||
Render_State_SlopeScaleDepthBias |
|
||||
Render_State_ZEnable |
|
||||
Render_State_ZWriteEnable |
|
||||
Render_State_ZFunc |
|
||||
Render_State_MultiSampleAntiAlias |
|
||||
Render_State_ScissorTestEnable |
|
||||
Render_State_StencilEnable |
|
||||
Render_State_StencilFail |
|
||||
Render_State_StencilFunc |
|
||||
Render_State_StencilMask |
|
||||
Render_State_StencilPass |
|
||||
Render_State_StencilRef |
|
||||
Render_State_StencilWriteMask |
|
||||
Render_State_StencilZFail;
|
||||
|
||||
Pass_Declaration -> Pass Identifier? OpenBracket (VertexShader_Pass_Expression | PixelShader_Pass_Expression | Render_State_Expression)* CloseBracket
|
||||
{
|
||||
var pass = new PassInfo();
|
||||
pass.name = $Identifier as string ?? string.Empty;
|
||||
|
||||
foreach (var node in Nodes)
|
||||
node.Eval(tree, pass);
|
||||
|
||||
// We need to have a pixel or vertex shader to keep this pass.
|
||||
if (!string.IsNullOrEmpty(pass.psFunction) || !string.IsNullOrEmpty(pass.vsFunction))
|
||||
{
|
||||
var technique = paramlist[0] as TechniqueInfo;
|
||||
technique.Passes.Add(pass);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
VertexShader_Pass_Expression -> VertexShader Equals Compile ShaderModel Identifier OpenParenthesis CloseParenthesis Semicolon
|
||||
{
|
||||
var pass = paramlist[0] as PassInfo;
|
||||
pass.vsModel = $ShaderModel as string;
|
||||
pass.vsFunction = $Identifier as string;
|
||||
return null;
|
||||
};
|
||||
|
||||
PixelShader_Pass_Expression -> PixelShader Equals Compile ShaderModel Identifier OpenParenthesis CloseParenthesis Semicolon
|
||||
{
|
||||
var pass = paramlist[0] as PassInfo;
|
||||
pass.psModel = $ShaderModel as string;
|
||||
pass.psFunction = $Identifier as string;
|
||||
return null;
|
||||
};
|
||||
|
||||
AddressMode_Clamp -> Clamp { return TextureAddressMode.Clamp; };
|
||||
AddressMode_Wrap -> Wrap { return TextureAddressMode.Wrap; };
|
||||
AddressMode_Mirror -> Mirror { return TextureAddressMode.Mirror; };
|
||||
AddressMode_Border -> Border { return TextureAddressMode.Border; };
|
||||
AddressMode -> (AddressMode_Clamp|AddressMode_Wrap|AddressMode_Mirror|AddressMode_Border)
|
||||
{
|
||||
return $AddressMode_Clamp ?? $AddressMode_Wrap ?? $AddressMode_Mirror ?? $AddressMode_Border;
|
||||
};
|
||||
|
||||
TextureFilter_None -> None { return TextureFilterType.None; };
|
||||
TextureFilter_Linear -> Linear { return TextureFilterType.Linear; };
|
||||
TextureFilter_Point -> Point { return TextureFilterType.Point; };
|
||||
TextureFilter_Anisotropic -> Anisotropic { return TextureFilterType.Anisotropic; };
|
||||
TextureFilter -> (TextureFilter_None|TextureFilter_Linear|TextureFilter_Point|TextureFilter_Anisotropic)
|
||||
{
|
||||
return $TextureFilter_None ?? $TextureFilter_Linear ?? $TextureFilter_Point ?? $TextureFilter_Anisotropic;
|
||||
};
|
||||
|
||||
// Sampler States
|
||||
Sampler_State_Texture -> Texture Equals (LessThan|OpenParenthesis) Identifier (GreaterThan|CloseParenthesis) Semicolon { (paramlist[0] as SamplerStateInfo).TextureName = (string)$Identifier; return null; };
|
||||
Sampler_State_MinFilter -> MinFilter Equals TextureFilter Semicolon { (paramlist[0] as SamplerStateInfo).MinFilter = (TextureFilterType)$TextureFilter; return null; };
|
||||
Sampler_State_MagFilter -> MagFilter Equals TextureFilter Semicolon { (paramlist[0] as SamplerStateInfo).MagFilter = (TextureFilterType)$TextureFilter; return null; };
|
||||
Sampler_State_MipFilter -> MipFilter Equals TextureFilter Semicolon { (paramlist[0] as SamplerStateInfo).MipFilter = (TextureFilterType)$TextureFilter; return null; };
|
||||
Sampler_State_Filter -> Filter Equals TextureFilter Semicolon { (paramlist[0] as SamplerStateInfo).Filter = (TextureFilterType)$TextureFilter; return null; };
|
||||
Sampler_State_AddressU -> AddressU Equals AddressMode Semicolon { (paramlist[0] as SamplerStateInfo).AddressU = (TextureAddressMode)$AddressMode; return null; };
|
||||
Sampler_State_AddressV -> AddressV Equals AddressMode Semicolon { (paramlist[0] as SamplerStateInfo).AddressV = (TextureAddressMode)$AddressMode; return null; };
|
||||
Sampler_State_AddressW -> AddressW Equals AddressMode Semicolon { (paramlist[0] as SamplerStateInfo).AddressW = (TextureAddressMode)$AddressMode; return null; };
|
||||
Sampler_State_BorderColor -> BorderColor Equals HexColor Semicolon { (paramlist[0] as SamplerStateInfo).BorderColor = ParseTreeTools.ParseColor((string)$HexColor); return null; };
|
||||
Sampler_State_MaxMipLevel -> MaxMipLevel Equals Number Semicolon { (paramlist[0] as SamplerStateInfo).MaxMipLevel = ParseTreeTools.ParseInt((string)$Number); return null; };
|
||||
Sampler_State_MaxAnisotropy -> MaxAnisotropy Equals Number Semicolon { (paramlist[0] as SamplerStateInfo).MaxAnisotropy = ParseTreeTools.ParseInt((string)$Number); return null; };
|
||||
Sampler_State_MipLodBias -> MipLodBias Equals Number Semicolon { (paramlist[0] as SamplerStateInfo).MipMapLevelOfDetailBias = ParseTreeTools.ParseFloat((string)$Number); return null; };
|
||||
|
||||
|
||||
Sampler_State_Expression ->
|
||||
Sampler_State_Texture |
|
||||
Sampler_State_MinFilter |
|
||||
Sampler_State_MagFilter |
|
||||
Sampler_State_MipFilter |
|
||||
Sampler_State_Filter |
|
||||
Sampler_State_AddressU |
|
||||
Sampler_State_AddressV |
|
||||
Sampler_State_AddressW |
|
||||
Sampler_State_BorderColor |
|
||||
Sampler_State_MaxMipLevel |
|
||||
Sampler_State_MaxAnisotropy |
|
||||
Sampler_State_MipLodBias;
|
||||
|
||||
Sampler_Register_Expression -> Colon Register OpenParenthesis Identifier (Comma Identifier (OpenSquareBracket Number CloseSquareBracket)?)? CloseParenthesis
|
||||
{
|
||||
return null;
|
||||
};
|
||||
|
||||
Sampler_Declaration_States -> (Equals SamplerState)? OpenBracket Sampler_State_Expression* CloseBracket;
|
||||
|
||||
Sampler_Declaration -> Sampler Identifier Sampler_Register_Expression* Sampler_Declaration_States? (Semicolon | Comma | CloseParenthesis)
|
||||
{
|
||||
// if there is a comma or closing paren at the end this is a sampler as a parameter of a function
|
||||
if ($Semicolon == null) return null;
|
||||
|
||||
var sampler = new SamplerStateInfo();
|
||||
sampler.Name = $Identifier[0] as string;
|
||||
|
||||
foreach (ParseNode node in Nodes)
|
||||
node.Eval(tree, sampler);
|
||||
|
||||
var shaderInfo = paramlist[0] as ShaderInfo;
|
||||
shaderInfo.SamplerStates.Add(sampler.Name, sampler);
|
||||
|
||||
return null;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
public static class ParseTreeTools
|
||||
{
|
||||
public static float ParseFloat(string value)
|
||||
{
|
||||
// Remove all whitespace and trailing F or f.
|
||||
value = value.Replace(" ", "");
|
||||
value = value.TrimEnd('f', 'F');
|
||||
return float.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static int ParseInt(string value)
|
||||
{
|
||||
// We read it as a float and cast it down to
|
||||
// an integer to match Microsoft FX behavior.
|
||||
return (int)Math.Floor(ParseFloat(value));
|
||||
}
|
||||
|
||||
public static bool ParseBool(string value)
|
||||
{
|
||||
if (value.ToLowerInvariant() == "true" || value == "1")
|
||||
return true;
|
||||
if (value.ToLowerInvariant() == "false" || value == "0")
|
||||
return false;
|
||||
|
||||
throw new Exception("Invalid boolean value '" + value + "'");
|
||||
}
|
||||
|
||||
public static Color ParseColor(string value)
|
||||
{
|
||||
var hexValue = Convert.ToUInt32(value, 16);
|
||||
|
||||
byte r, g, b, a;
|
||||
if (value.Length == 8)
|
||||
{
|
||||
r = (byte) ((hexValue >> 16) & 0xFF);
|
||||
g = (byte) ((hexValue >> 8) & 0xFF);
|
||||
b = (byte) ((hexValue >> 0) & 0xFF);
|
||||
a = 255;
|
||||
}
|
||||
else if (value.Length == 10)
|
||||
{
|
||||
r = (byte) ((hexValue >> 24) & 0xFF);
|
||||
g = (byte) ((hexValue >> 16) & 0xFF);
|
||||
b = (byte) ((hexValue >> 8) & 0xFF);
|
||||
a = (byte) ((hexValue >> 0) & 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
return new Color(r, g, b, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
public class PassInfo
|
||||
{
|
||||
public string name;
|
||||
|
||||
public string vsModel;
|
||||
public string vsFunction;
|
||||
|
||||
public string psModel;
|
||||
public string psFunction;
|
||||
|
||||
public BlendState blendState;
|
||||
public RasterizerState rasterizerState;
|
||||
public DepthStencilState depthStencilState;
|
||||
|
||||
private static Blend ToAlphaBlend(Blend blend)
|
||||
{
|
||||
switch (blend)
|
||||
{
|
||||
case Blend.SourceColor:
|
||||
return Blend.SourceAlpha;
|
||||
case Blend.InverseSourceColor:
|
||||
return Blend.InverseSourceAlpha;
|
||||
case Blend.DestinationColor:
|
||||
return Blend.DestinationAlpha;
|
||||
case Blend.InverseDestinationColor:
|
||||
return Blend.InverseDestinationAlpha;
|
||||
}
|
||||
return blend;
|
||||
}
|
||||
|
||||
public bool AlphaBlendEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (blendState == null)
|
||||
{
|
||||
blendState = new BlendState();
|
||||
blendState.ColorSourceBlend = Blend.One;
|
||||
blendState.AlphaSourceBlend = Blend.One;
|
||||
blendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
|
||||
blendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
|
||||
}
|
||||
}
|
||||
else if (!value)
|
||||
{
|
||||
if (blendState == null)
|
||||
blendState = new BlendState();
|
||||
blendState.ColorSourceBlend = Blend.One;
|
||||
blendState.AlphaSourceBlend = Blend.One;
|
||||
blendState.ColorDestinationBlend = Blend.Zero;
|
||||
blendState.AlphaDestinationBlend = Blend.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FillMode FillMode
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.FillMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CullMode CullMode
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.CullMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ZEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.DepthBufferEnable = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ZWriteEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.DepthBufferWriteEnable = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CompareFunction DepthBufferFunction
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.DepthBufferFunction = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MultiSampleAntiAlias
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.MultiSampleAntiAlias = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ScissorTestEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.ScissorTestEnable = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool StencilEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilEnable = value;
|
||||
}
|
||||
}
|
||||
|
||||
public StencilOperation StencilFail
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilFail = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CompareFunction StencilFunc
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilFunction = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int StencilMask
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilMask = value;
|
||||
}
|
||||
}
|
||||
|
||||
public StencilOperation StencilPass
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilPass = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int StencilRef
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.ReferenceStencil = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int StencilWriteMask
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilWriteMask = value;
|
||||
}
|
||||
}
|
||||
|
||||
public StencilOperation StencilZFail
|
||||
{
|
||||
set
|
||||
{
|
||||
if (depthStencilState == null)
|
||||
depthStencilState = new DepthStencilState();
|
||||
depthStencilState.StencilDepthBufferFail = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Blend SrcBlend
|
||||
{
|
||||
set
|
||||
{
|
||||
if (blendState == null)
|
||||
blendState = new BlendState();
|
||||
blendState.ColorSourceBlend = value;
|
||||
blendState.AlphaSourceBlend = ToAlphaBlend(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Blend DestBlend
|
||||
{
|
||||
set
|
||||
{
|
||||
if (blendState == null)
|
||||
blendState = new BlendState();
|
||||
blendState.ColorDestinationBlend = value;
|
||||
blendState.AlphaDestinationBlend = ToAlphaBlend(value);
|
||||
}
|
||||
}
|
||||
|
||||
public BlendFunction BlendOp
|
||||
{
|
||||
set
|
||||
{
|
||||
if (blendState == null)
|
||||
blendState = new BlendState();
|
||||
blendState.AlphaBlendFunction = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ColorWriteChannels ColorWriteEnable
|
||||
{
|
||||
set
|
||||
{
|
||||
if (blendState == null)
|
||||
blendState = new BlendState();
|
||||
blendState.ColorWriteChannels = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float DepthBias
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.DepthBias = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float SlopeScaleDepthBias
|
||||
{
|
||||
set
|
||||
{
|
||||
if (rasterizerState == null)
|
||||
rasterizerState = new RasterizerState();
|
||||
rasterizerState.SlopeScaleDepthBias = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
public class SamplerStateInfo
|
||||
{
|
||||
private SamplerState _state;
|
||||
|
||||
private bool _dirty;
|
||||
|
||||
private TextureFilterType _minFilter;
|
||||
private TextureFilterType _magFilter;
|
||||
private TextureFilterType _mipFilter;
|
||||
|
||||
private TextureAddressMode _addressU;
|
||||
private TextureAddressMode _addressV;
|
||||
private TextureAddressMode _addressW;
|
||||
|
||||
private Color _borderColor;
|
||||
|
||||
private int _maxAnisotropy;
|
||||
private int _maxMipLevel;
|
||||
private float _mipMapLevelOfDetailBias;
|
||||
|
||||
public SamplerStateInfo()
|
||||
{
|
||||
// NOTE: These match the defaults of SamplerState.
|
||||
_minFilter = TextureFilterType.Linear;
|
||||
_magFilter = TextureFilterType.Linear;
|
||||
_mipFilter = TextureFilterType.Linear;
|
||||
_addressU = TextureAddressMode.Wrap;
|
||||
_addressV = TextureAddressMode.Wrap;
|
||||
_addressW = TextureAddressMode.Wrap;
|
||||
_borderColor = Color.White;
|
||||
_maxAnisotropy = 4;
|
||||
_maxMipLevel = 0;
|
||||
_mipMapLevelOfDetailBias = 0.0f;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string TextureName { get; set; }
|
||||
|
||||
public TextureFilterType MinFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
_minFilter = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureFilterType MagFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
_magFilter = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureFilterType MipFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
_mipFilter = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureFilterType Filter
|
||||
{
|
||||
set
|
||||
{
|
||||
_minFilter = _magFilter = _mipFilter = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureAddressMode AddressU
|
||||
{
|
||||
set
|
||||
{
|
||||
_addressU = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureAddressMode AddressV
|
||||
{
|
||||
set
|
||||
{
|
||||
_addressV = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public TextureAddressMode AddressW
|
||||
{
|
||||
set
|
||||
{
|
||||
_addressW = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Color BorderColor
|
||||
{
|
||||
set
|
||||
{
|
||||
_borderColor = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxAnisotropy
|
||||
{
|
||||
set
|
||||
{
|
||||
_maxAnisotropy = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int MaxMipLevel
|
||||
{
|
||||
set
|
||||
{
|
||||
_maxMipLevel = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public float MipMapLevelOfDetailBias
|
||||
{
|
||||
set
|
||||
{
|
||||
_mipMapLevelOfDetailBias = value;
|
||||
_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSamplerState()
|
||||
{
|
||||
// Get the existing state or create it.
|
||||
if (_state == null)
|
||||
_state = new SamplerState();
|
||||
|
||||
_state.AddressU = _addressU;
|
||||
_state.AddressV = _addressV;
|
||||
_state.AddressW = _addressW;
|
||||
|
||||
_state.BorderColor = _borderColor;
|
||||
|
||||
_state.MaxAnisotropy = _maxAnisotropy;
|
||||
_state.MaxMipLevel = _maxMipLevel;
|
||||
_state.MipMapLevelOfDetailBias = _mipMapLevelOfDetailBias;
|
||||
|
||||
// Figure out what kind of filter to set based on each
|
||||
// individual min, mag, and mip filter settings.
|
||||
//
|
||||
// NOTE: We're treating "None" and "Point" the same here
|
||||
// and disabling mipmapping further below.
|
||||
//
|
||||
if (_minFilter == TextureFilterType.Anisotropic)
|
||||
_state.Filter = TextureFilter.Anisotropic;
|
||||
else if (_minFilter == TextureFilterType.Linear && _magFilter == TextureFilterType.Linear && _mipFilter == TextureFilterType.Linear)
|
||||
_state.Filter = TextureFilter.Linear;
|
||||
else if (_minFilter == TextureFilterType.Linear && _magFilter == TextureFilterType.Linear && _mipFilter <= TextureFilterType.Point)
|
||||
_state.Filter = TextureFilter.LinearMipPoint;
|
||||
else if (_minFilter == TextureFilterType.Linear && _magFilter <= TextureFilterType.Point && _mipFilter == TextureFilterType.Linear)
|
||||
_state.Filter = TextureFilter.MinLinearMagPointMipLinear;
|
||||
else if (_minFilter == TextureFilterType.Linear && _magFilter <= TextureFilterType.Point && _mipFilter <= TextureFilterType.Point)
|
||||
_state.Filter = TextureFilter.MinLinearMagPointMipPoint;
|
||||
else if (_minFilter <= TextureFilterType.Point && _magFilter == TextureFilterType.Linear && _mipFilter == TextureFilterType.Linear)
|
||||
_state.Filter = TextureFilter.MinPointMagLinearMipLinear;
|
||||
else if (_minFilter <= TextureFilterType.Point && _magFilter == TextureFilterType.Linear && _mipFilter <= TextureFilterType.Point)
|
||||
_state.Filter = TextureFilter.MinPointMagLinearMipPoint;
|
||||
else if (_minFilter <= TextureFilterType.Point && _magFilter <= TextureFilterType.Point && _mipFilter <= TextureFilterType.Point)
|
||||
_state.Filter = TextureFilter.Point;
|
||||
else if (_minFilter <= TextureFilterType.Point && _magFilter <= TextureFilterType.Point && _mipFilter == TextureFilterType.Linear)
|
||||
_state.Filter = TextureFilter.PointMipLinear;
|
||||
|
||||
// Do we need to disable mipmapping?
|
||||
if (_mipFilter == TextureFilterType.None)
|
||||
{
|
||||
// TODO: This is the only option we have right now for
|
||||
// disabling mipmapping. We should add support for MinLod
|
||||
// and MaxLod which potentially does a better job at this.
|
||||
_state.MipMapLevelOfDetailBias = -16.0f;
|
||||
_state.MaxMipLevel = 0;
|
||||
}
|
||||
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
public SamplerState State
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dirty)
|
||||
UpdateSamplerState();
|
||||
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,986 @@
|
||||
// Generated by TinyPG v1.3 available at www.codeproject.com
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
#region Scanner
|
||||
|
||||
public partial class Scanner
|
||||
{
|
||||
public string Input;
|
||||
public int StartPos = 0;
|
||||
public int EndPos = 0;
|
||||
public string CurrentFile;
|
||||
public int CurrentLine;
|
||||
public int CurrentColumn;
|
||||
public int CurrentPosition;
|
||||
public List<Token> Skipped; // tokens that were skipped
|
||||
public Dictionary<TokenType, Regex> Patterns;
|
||||
|
||||
private Token LookAheadToken;
|
||||
private List<TokenType> Tokens;
|
||||
private List<TokenType> SkipList; // tokens to be skipped
|
||||
private readonly TokenType FileAndLine;
|
||||
|
||||
public Scanner()
|
||||
{
|
||||
Regex regex;
|
||||
Patterns = new Dictionary<TokenType, Regex>();
|
||||
Tokens = new List<TokenType>();
|
||||
LookAheadToken = null;
|
||||
Skipped = new List<Token>();
|
||||
|
||||
SkipList = new List<TokenType>();
|
||||
SkipList.Add(TokenType.BlockComment);
|
||||
SkipList.Add(TokenType.Comment);
|
||||
SkipList.Add(TokenType.Whitespace);
|
||||
SkipList.Add(TokenType.LinePragma);
|
||||
FileAndLine = TokenType.LinePragma;
|
||||
|
||||
regex = new Regex(@"/\*([^*]|\*[^/])*\*/", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.BlockComment, regex);
|
||||
Tokens.Add(TokenType.BlockComment);
|
||||
|
||||
regex = new Regex(@"//[^\n\r]*", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Comment, regex);
|
||||
Tokens.Add(TokenType.Comment);
|
||||
|
||||
regex = new Regex(@"[ \t\n\r]+", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Whitespace, regex);
|
||||
Tokens.Add(TokenType.Whitespace);
|
||||
|
||||
regex = new Regex(@"^[ \t]*#line[ \t]*(?<Line>\d*)[ \t]*(\""(?<File>[^\""\\]*(?:\\.[^\""\\]*)*)\"")?\n", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.LinePragma, regex);
|
||||
Tokens.Add(TokenType.LinePragma);
|
||||
|
||||
regex = new Regex(@"pass", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Pass, regex);
|
||||
Tokens.Add(TokenType.Pass);
|
||||
|
||||
regex = new Regex(@"technique", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Technique, regex);
|
||||
Tokens.Add(TokenType.Technique);
|
||||
|
||||
regex = new Regex(@"sampler1D|sampler2D|sampler3D|samplerCUBE|SamplerState|sampler", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Sampler, regex);
|
||||
Tokens.Add(TokenType.Sampler);
|
||||
|
||||
regex = new Regex(@"sampler_state", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SamplerState, regex);
|
||||
Tokens.Add(TokenType.SamplerState);
|
||||
|
||||
regex = new Regex(@"VertexShader", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.VertexShader, regex);
|
||||
Tokens.Add(TokenType.VertexShader);
|
||||
|
||||
regex = new Regex(@"PixelShader", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.PixelShader, regex);
|
||||
Tokens.Add(TokenType.PixelShader);
|
||||
|
||||
regex = new Regex(@"register", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Register, regex);
|
||||
Tokens.Add(TokenType.Register);
|
||||
|
||||
regex = new Regex(@"true|false|0|1", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Boolean, regex);
|
||||
Tokens.Add(TokenType.Boolean);
|
||||
|
||||
regex = new Regex(@"[+-]? ?[0-9]?\.?[0-9]+[fF]?", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Number, regex);
|
||||
Tokens.Add(TokenType.Number);
|
||||
|
||||
regex = new Regex(@"0x[0-9a-f]{6}([0-9a-f][0-9a-f])?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.HexColor, regex);
|
||||
Tokens.Add(TokenType.HexColor);
|
||||
|
||||
regex = new Regex(@"[A-Za-z_][A-Za-z0-9_]*", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Identifier, regex);
|
||||
Tokens.Add(TokenType.Identifier);
|
||||
|
||||
regex = new Regex(@"{", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.OpenBracket, regex);
|
||||
Tokens.Add(TokenType.OpenBracket);
|
||||
|
||||
regex = new Regex(@"}", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.CloseBracket, regex);
|
||||
Tokens.Add(TokenType.CloseBracket);
|
||||
|
||||
regex = new Regex(@"=", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Equals, regex);
|
||||
Tokens.Add(TokenType.Equals);
|
||||
|
||||
regex = new Regex(@":", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Colon, regex);
|
||||
Tokens.Add(TokenType.Colon);
|
||||
|
||||
regex = new Regex(@",", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Comma, regex);
|
||||
Tokens.Add(TokenType.Comma);
|
||||
|
||||
regex = new Regex(@";", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Semicolon, regex);
|
||||
Tokens.Add(TokenType.Semicolon);
|
||||
|
||||
regex = new Regex(@"\|", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Or, regex);
|
||||
Tokens.Add(TokenType.Or);
|
||||
|
||||
regex = new Regex(@"\(", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.OpenParenthesis, regex);
|
||||
Tokens.Add(TokenType.OpenParenthesis);
|
||||
|
||||
regex = new Regex(@"\)", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.CloseParenthesis, regex);
|
||||
Tokens.Add(TokenType.CloseParenthesis);
|
||||
|
||||
regex = new Regex(@"\[", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.OpenSquareBracket, regex);
|
||||
Tokens.Add(TokenType.OpenSquareBracket);
|
||||
|
||||
regex = new Regex(@"\]", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.CloseSquareBracket, regex);
|
||||
Tokens.Add(TokenType.CloseSquareBracket);
|
||||
|
||||
regex = new Regex(@"<", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.LessThan, regex);
|
||||
Tokens.Add(TokenType.LessThan);
|
||||
|
||||
regex = new Regex(@">", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.GreaterThan, regex);
|
||||
Tokens.Add(TokenType.GreaterThan);
|
||||
|
||||
regex = new Regex(@"compile", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Compile, regex);
|
||||
Tokens.Add(TokenType.Compile);
|
||||
|
||||
regex = new Regex(@"[A-Za-z_][A-Za-z0-9_]*", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.ShaderModel, regex);
|
||||
Tokens.Add(TokenType.ShaderModel);
|
||||
|
||||
regex = new Regex(@"[\S]+", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.Code, regex);
|
||||
Tokens.Add(TokenType.Code);
|
||||
|
||||
regex = new Regex(@"^$", RegexOptions.Compiled);
|
||||
Patterns.Add(TokenType.EndOfFile, regex);
|
||||
Tokens.Add(TokenType.EndOfFile);
|
||||
|
||||
regex = new Regex(@"MinFilter", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MinFilter, regex);
|
||||
Tokens.Add(TokenType.MinFilter);
|
||||
|
||||
regex = new Regex(@"MagFilter", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MagFilter, regex);
|
||||
Tokens.Add(TokenType.MagFilter);
|
||||
|
||||
regex = new Regex(@"MipFilter", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MipFilter, regex);
|
||||
Tokens.Add(TokenType.MipFilter);
|
||||
|
||||
regex = new Regex(@"Filter", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Filter, regex);
|
||||
Tokens.Add(TokenType.Filter);
|
||||
|
||||
regex = new Regex(@"Texture", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Texture, regex);
|
||||
Tokens.Add(TokenType.Texture);
|
||||
|
||||
regex = new Regex(@"AddressU", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.AddressU, regex);
|
||||
Tokens.Add(TokenType.AddressU);
|
||||
|
||||
regex = new Regex(@"AddressV", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.AddressV, regex);
|
||||
Tokens.Add(TokenType.AddressV);
|
||||
|
||||
regex = new Regex(@"AddressW", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.AddressW, regex);
|
||||
Tokens.Add(TokenType.AddressW);
|
||||
|
||||
regex = new Regex(@"BorderColor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.BorderColor, regex);
|
||||
Tokens.Add(TokenType.BorderColor);
|
||||
|
||||
regex = new Regex(@"MaxAnisotropy", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MaxAnisotropy, regex);
|
||||
Tokens.Add(TokenType.MaxAnisotropy);
|
||||
|
||||
regex = new Regex(@"MaxMipLevel|MaxLod", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MaxMipLevel, regex);
|
||||
Tokens.Add(TokenType.MaxMipLevel);
|
||||
|
||||
regex = new Regex(@"MipLodBias", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MipLodBias, regex);
|
||||
Tokens.Add(TokenType.MipLodBias);
|
||||
|
||||
regex = new Regex(@"Clamp", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Clamp, regex);
|
||||
Tokens.Add(TokenType.Clamp);
|
||||
|
||||
regex = new Regex(@"Wrap", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Wrap, regex);
|
||||
Tokens.Add(TokenType.Wrap);
|
||||
|
||||
regex = new Regex(@"Mirror", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Mirror, regex);
|
||||
Tokens.Add(TokenType.Mirror);
|
||||
|
||||
regex = new Regex(@"Border", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Border, regex);
|
||||
Tokens.Add(TokenType.Border);
|
||||
|
||||
regex = new Regex(@"None", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.None, regex);
|
||||
Tokens.Add(TokenType.None);
|
||||
|
||||
regex = new Regex(@"Linear", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Linear, regex);
|
||||
Tokens.Add(TokenType.Linear);
|
||||
|
||||
regex = new Regex(@"Point", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Point, regex);
|
||||
Tokens.Add(TokenType.Point);
|
||||
|
||||
regex = new Regex(@"Anisotropic", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Anisotropic, regex);
|
||||
Tokens.Add(TokenType.Anisotropic);
|
||||
|
||||
regex = new Regex(@"AlphaBlendEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.AlphaBlendEnable, regex);
|
||||
Tokens.Add(TokenType.AlphaBlendEnable);
|
||||
|
||||
regex = new Regex(@"SrcBlend", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SrcBlend, regex);
|
||||
Tokens.Add(TokenType.SrcBlend);
|
||||
|
||||
regex = new Regex(@"DestBlend", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.DestBlend, regex);
|
||||
Tokens.Add(TokenType.DestBlend);
|
||||
|
||||
regex = new Regex(@"BlendOp", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.BlendOp, regex);
|
||||
Tokens.Add(TokenType.BlendOp);
|
||||
|
||||
regex = new Regex(@"ColorWriteEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.ColorWriteEnable, regex);
|
||||
Tokens.Add(TokenType.ColorWriteEnable);
|
||||
|
||||
regex = new Regex(@"ZEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.ZEnable, regex);
|
||||
Tokens.Add(TokenType.ZEnable);
|
||||
|
||||
regex = new Regex(@"ZWriteEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.ZWriteEnable, regex);
|
||||
Tokens.Add(TokenType.ZWriteEnable);
|
||||
|
||||
regex = new Regex(@"ZFunc", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.ZFunc, regex);
|
||||
Tokens.Add(TokenType.ZFunc);
|
||||
|
||||
regex = new Regex(@"DepthBias", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.DepthBias, regex);
|
||||
Tokens.Add(TokenType.DepthBias);
|
||||
|
||||
regex = new Regex(@"CullMode", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.CullMode, regex);
|
||||
Tokens.Add(TokenType.CullMode);
|
||||
|
||||
regex = new Regex(@"FillMode", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.FillMode, regex);
|
||||
Tokens.Add(TokenType.FillMode);
|
||||
|
||||
regex = new Regex(@"MultiSampleAntiAlias", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.MultiSampleAntiAlias, regex);
|
||||
Tokens.Add(TokenType.MultiSampleAntiAlias);
|
||||
|
||||
regex = new Regex(@"ScissorTestEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.ScissorTestEnable, regex);
|
||||
Tokens.Add(TokenType.ScissorTestEnable);
|
||||
|
||||
regex = new Regex(@"SlopeScaleDepthBias", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SlopeScaleDepthBias, regex);
|
||||
Tokens.Add(TokenType.SlopeScaleDepthBias);
|
||||
|
||||
regex = new Regex(@"StencilEnable", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilEnable, regex);
|
||||
Tokens.Add(TokenType.StencilEnable);
|
||||
|
||||
regex = new Regex(@"StencilFail", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilFail, regex);
|
||||
Tokens.Add(TokenType.StencilFail);
|
||||
|
||||
regex = new Regex(@"StencilFunc", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilFunc, regex);
|
||||
Tokens.Add(TokenType.StencilFunc);
|
||||
|
||||
regex = new Regex(@"StencilMask", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilMask, regex);
|
||||
Tokens.Add(TokenType.StencilMask);
|
||||
|
||||
regex = new Regex(@"StencilPass", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilPass, regex);
|
||||
Tokens.Add(TokenType.StencilPass);
|
||||
|
||||
regex = new Regex(@"StencilRef", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilRef, regex);
|
||||
Tokens.Add(TokenType.StencilRef);
|
||||
|
||||
regex = new Regex(@"StencilWriteMask", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilWriteMask, regex);
|
||||
Tokens.Add(TokenType.StencilWriteMask);
|
||||
|
||||
regex = new Regex(@"StencilZFail", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.StencilZFail, regex);
|
||||
Tokens.Add(TokenType.StencilZFail);
|
||||
|
||||
regex = new Regex(@"Never", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Never, regex);
|
||||
Tokens.Add(TokenType.Never);
|
||||
|
||||
regex = new Regex(@"Less", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Less, regex);
|
||||
Tokens.Add(TokenType.Less);
|
||||
|
||||
regex = new Regex(@"Equal", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Equal, regex);
|
||||
Tokens.Add(TokenType.Equal);
|
||||
|
||||
regex = new Regex(@"LessEqual", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.LessEqual, regex);
|
||||
Tokens.Add(TokenType.LessEqual);
|
||||
|
||||
regex = new Regex(@"Greater", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Greater, regex);
|
||||
Tokens.Add(TokenType.Greater);
|
||||
|
||||
regex = new Regex(@"NotEqual", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.NotEqual, regex);
|
||||
Tokens.Add(TokenType.NotEqual);
|
||||
|
||||
regex = new Regex(@"GreaterEqual", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.GreaterEqual, regex);
|
||||
Tokens.Add(TokenType.GreaterEqual);
|
||||
|
||||
regex = new Regex(@"Always", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Always, regex);
|
||||
Tokens.Add(TokenType.Always);
|
||||
|
||||
regex = new Regex(@"Keep", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Keep, regex);
|
||||
Tokens.Add(TokenType.Keep);
|
||||
|
||||
regex = new Regex(@"Zero", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Zero, regex);
|
||||
Tokens.Add(TokenType.Zero);
|
||||
|
||||
regex = new Regex(@"Replace", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Replace, regex);
|
||||
Tokens.Add(TokenType.Replace);
|
||||
|
||||
regex = new Regex(@"IncrSat", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.IncrSat, regex);
|
||||
Tokens.Add(TokenType.IncrSat);
|
||||
|
||||
regex = new Regex(@"DecrSat", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.DecrSat, regex);
|
||||
Tokens.Add(TokenType.DecrSat);
|
||||
|
||||
regex = new Regex(@"Invert", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Invert, regex);
|
||||
Tokens.Add(TokenType.Invert);
|
||||
|
||||
regex = new Regex(@"Incr", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Incr, regex);
|
||||
Tokens.Add(TokenType.Incr);
|
||||
|
||||
regex = new Regex(@"Decr", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Decr, regex);
|
||||
Tokens.Add(TokenType.Decr);
|
||||
|
||||
regex = new Regex(@"Red", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Red, regex);
|
||||
Tokens.Add(TokenType.Red);
|
||||
|
||||
regex = new Regex(@"Green", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Green, regex);
|
||||
Tokens.Add(TokenType.Green);
|
||||
|
||||
regex = new Regex(@"Blue", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Blue, regex);
|
||||
Tokens.Add(TokenType.Blue);
|
||||
|
||||
regex = new Regex(@"Alpha", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Alpha, regex);
|
||||
Tokens.Add(TokenType.Alpha);
|
||||
|
||||
regex = new Regex(@"All", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.All, regex);
|
||||
Tokens.Add(TokenType.All);
|
||||
|
||||
regex = new Regex(@"Cw", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Cw, regex);
|
||||
Tokens.Add(TokenType.Cw);
|
||||
|
||||
regex = new Regex(@"Ccw", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Ccw, regex);
|
||||
Tokens.Add(TokenType.Ccw);
|
||||
|
||||
regex = new Regex(@"Solid", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Solid, regex);
|
||||
Tokens.Add(TokenType.Solid);
|
||||
|
||||
regex = new Regex(@"WireFrame", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.WireFrame, regex);
|
||||
Tokens.Add(TokenType.WireFrame);
|
||||
|
||||
regex = new Regex(@"Add", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Add, regex);
|
||||
Tokens.Add(TokenType.Add);
|
||||
|
||||
regex = new Regex(@"Subtract", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Subtract, regex);
|
||||
Tokens.Add(TokenType.Subtract);
|
||||
|
||||
regex = new Regex(@"RevSubtract", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.RevSubtract, regex);
|
||||
Tokens.Add(TokenType.RevSubtract);
|
||||
|
||||
regex = new Regex(@"Min", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Min, regex);
|
||||
Tokens.Add(TokenType.Min);
|
||||
|
||||
regex = new Regex(@"Max", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.Max, regex);
|
||||
Tokens.Add(TokenType.Max);
|
||||
|
||||
regex = new Regex(@"One", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.One, regex);
|
||||
Tokens.Add(TokenType.One);
|
||||
|
||||
regex = new Regex(@"SrcColor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SrcColor, regex);
|
||||
Tokens.Add(TokenType.SrcColor);
|
||||
|
||||
regex = new Regex(@"InvSrcColor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.InvSrcColor, regex);
|
||||
Tokens.Add(TokenType.InvSrcColor);
|
||||
|
||||
regex = new Regex(@"SrcAlpha", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SrcAlpha, regex);
|
||||
Tokens.Add(TokenType.SrcAlpha);
|
||||
|
||||
regex = new Regex(@"InvSrcAlpha", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.InvSrcAlpha, regex);
|
||||
Tokens.Add(TokenType.InvSrcAlpha);
|
||||
|
||||
regex = new Regex(@"DestAlpha", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.DestAlpha, regex);
|
||||
Tokens.Add(TokenType.DestAlpha);
|
||||
|
||||
regex = new Regex(@"InvDestAlpha", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.InvDestAlpha, regex);
|
||||
Tokens.Add(TokenType.InvDestAlpha);
|
||||
|
||||
regex = new Regex(@"DestColor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.DestColor, regex);
|
||||
Tokens.Add(TokenType.DestColor);
|
||||
|
||||
regex = new Regex(@"InvDestColor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.InvDestColor, regex);
|
||||
Tokens.Add(TokenType.InvDestColor);
|
||||
|
||||
regex = new Regex(@"SrcAlphaSat", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.SrcAlphaSat, regex);
|
||||
Tokens.Add(TokenType.SrcAlphaSat);
|
||||
|
||||
regex = new Regex(@"BlendFactor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.BlendFactor, regex);
|
||||
Tokens.Add(TokenType.BlendFactor);
|
||||
|
||||
regex = new Regex(@"InvBlendFactor", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
Patterns.Add(TokenType.InvBlendFactor, regex);
|
||||
Tokens.Add(TokenType.InvBlendFactor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Init(string input)
|
||||
{
|
||||
Init(input, "");
|
||||
}
|
||||
|
||||
public void Init(string input, string fileName)
|
||||
{
|
||||
this.Input = input;
|
||||
StartPos = 0;
|
||||
EndPos = 0;
|
||||
CurrentFile = fileName;
|
||||
CurrentLine = 1;
|
||||
CurrentColumn = 1;
|
||||
CurrentPosition = 0;
|
||||
LookAheadToken = null;
|
||||
}
|
||||
|
||||
public Token GetToken(TokenType type)
|
||||
{
|
||||
Token t = new Token(this.StartPos, this.EndPos);
|
||||
t.Type = type;
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// executes a lookahead of the next token
|
||||
/// and will advance the scan on the input string
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Token Scan(params TokenType[] expectedtokens)
|
||||
{
|
||||
Token tok = LookAhead(expectedtokens); // temporarely retrieve the lookahead
|
||||
LookAheadToken = null; // reset lookahead token, so scanning will continue
|
||||
StartPos = tok.EndPos;
|
||||
EndPos = tok.EndPos; // set the tokenizer to the new scan position
|
||||
CurrentLine = tok.Line + (tok.Text.Length - tok.Text.Replace("\n", "").Length);
|
||||
CurrentFile = tok.File;
|
||||
return tok;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns token with longest best match
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Token LookAhead(params TokenType[] expectedtokens)
|
||||
{
|
||||
int i;
|
||||
int startpos = StartPos;
|
||||
int endpos = EndPos;
|
||||
int currentline = CurrentLine;
|
||||
string currentFile = CurrentFile;
|
||||
Token tok = null;
|
||||
List<TokenType> scantokens;
|
||||
|
||||
|
||||
// this prevents double scanning and matching
|
||||
// increased performance
|
||||
if (LookAheadToken != null
|
||||
&& LookAheadToken.Type != TokenType._UNDETERMINED_
|
||||
&& LookAheadToken.Type != TokenType._NONE_) return LookAheadToken;
|
||||
|
||||
// if no scantokens specified, then scan for all of them (= backward compatible)
|
||||
if (expectedtokens.Length == 0)
|
||||
scantokens = Tokens;
|
||||
else
|
||||
{
|
||||
scantokens = new List<TokenType>(expectedtokens);
|
||||
scantokens.AddRange(SkipList);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
int len = -1;
|
||||
TokenType index = (TokenType)int.MaxValue;
|
||||
string input = Input.Substring(startpos);
|
||||
|
||||
tok = new Token(startpos, endpos);
|
||||
|
||||
for (i = 0; i < scantokens.Count; i++)
|
||||
{
|
||||
Regex r = Patterns[scantokens[i]];
|
||||
Match m = r.Match(input);
|
||||
if (m.Success && m.Index == 0 && ((m.Length > len) || (scantokens[i] < index && m.Length == len )))
|
||||
{
|
||||
len = m.Length;
|
||||
index = scantokens[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0 && len >= 0)
|
||||
{
|
||||
tok.EndPos = startpos + len;
|
||||
tok.Text = Input.Substring(tok.StartPos, len);
|
||||
tok.Type = index;
|
||||
}
|
||||
else if (tok.StartPos == tok.EndPos)
|
||||
{
|
||||
if (tok.StartPos < Input.Length)
|
||||
tok.Text = Input.Substring(tok.StartPos, 1);
|
||||
else
|
||||
tok.Text = "EOF";
|
||||
}
|
||||
|
||||
// Update the line and column count for error reporting.
|
||||
tok.File = currentFile;
|
||||
tok.Line = currentline;
|
||||
if (tok.StartPos < Input.Length)
|
||||
tok.Column = tok.StartPos - Input.LastIndexOf('\n', tok.StartPos);
|
||||
|
||||
if (SkipList.Contains(tok.Type))
|
||||
{
|
||||
startpos = tok.EndPos;
|
||||
endpos = tok.EndPos;
|
||||
currentline = tok.Line + (tok.Text.Length - tok.Text.Replace("\n", "").Length);
|
||||
currentFile = tok.File;
|
||||
Skipped.Add(tok);
|
||||
}
|
||||
else
|
||||
{
|
||||
// only assign to non-skipped tokens
|
||||
tok.Skipped = Skipped; // assign prior skips to this token
|
||||
Skipped = new List<Token>(); //reset skips
|
||||
}
|
||||
|
||||
// Check to see if the parsed token wants to
|
||||
// alter the file and line number.
|
||||
if (tok.Type == FileAndLine)
|
||||
{
|
||||
var match = Patterns[tok.Type].Match(tok.Text);
|
||||
var fileMatch = match.Groups["File"];
|
||||
if (fileMatch.Success)
|
||||
currentFile = fileMatch.Value.Replace("\\\\", "\\");
|
||||
var lineMatch = match.Groups["Line"];
|
||||
if (lineMatch.Success)
|
||||
currentline = int.Parse(lineMatch.Value, NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
while (SkipList.Contains(tok.Type));
|
||||
|
||||
LookAheadToken = tok;
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Token
|
||||
|
||||
public enum TokenType
|
||||
{
|
||||
|
||||
//Non terminal tokens:
|
||||
_NONE_ = 0,
|
||||
_UNDETERMINED_= 1,
|
||||
|
||||
//Non terminal tokens:
|
||||
Start = 2,
|
||||
Technique_Declaration= 3,
|
||||
FillMode_Solid= 4,
|
||||
FillMode_WireFrame= 5,
|
||||
FillModes= 6,
|
||||
CullMode_None= 7,
|
||||
CullMode_Cw= 8,
|
||||
CullMode_Ccw= 9,
|
||||
CullModes= 10,
|
||||
Colors_None= 11,
|
||||
Colors_Red= 12,
|
||||
Colors_Green= 13,
|
||||
Colors_Blue= 14,
|
||||
Colors_Alpha= 15,
|
||||
Colors_All= 16,
|
||||
Colors_Boolean= 17,
|
||||
Colors = 18,
|
||||
ColorsMasks= 19,
|
||||
Blend_Zero= 20,
|
||||
Blend_One= 21,
|
||||
Blend_SrcColor= 22,
|
||||
Blend_InvSrcColor= 23,
|
||||
Blend_SrcAlpha= 24,
|
||||
Blend_InvSrcAlpha= 25,
|
||||
Blend_DestAlpha= 26,
|
||||
Blend_InvDestAlpha= 27,
|
||||
Blend_DestColor= 28,
|
||||
Blend_InvDestColor= 29,
|
||||
Blend_SrcAlphaSat= 30,
|
||||
Blend_BlendFactor= 31,
|
||||
Blend_InvBlendFactor= 32,
|
||||
Blends = 33,
|
||||
BlendOp_Add= 34,
|
||||
BlendOp_Subtract= 35,
|
||||
BlendOp_RevSubtract= 36,
|
||||
BlendOp_Min= 37,
|
||||
BlendOp_Max= 38,
|
||||
BlendOps= 39,
|
||||
CmpFunc_Never= 40,
|
||||
CmpFunc_Less= 41,
|
||||
CmpFunc_Equal= 42,
|
||||
CmpFunc_LessEqual= 43,
|
||||
CmpFunc_Greater= 44,
|
||||
CmpFunc_NotEqual= 45,
|
||||
CmpFunc_GreaterEqual= 46,
|
||||
CmpFunc_Always= 47,
|
||||
CmpFunc = 48,
|
||||
StencilOp_Keep= 49,
|
||||
StencilOp_Zero= 50,
|
||||
StencilOp_Replace= 51,
|
||||
StencilOp_IncrSat= 52,
|
||||
StencilOp_DecrSat= 53,
|
||||
StencilOp_Invert= 54,
|
||||
StencilOp_Incr= 55,
|
||||
StencilOp_Decr= 56,
|
||||
StencilOp= 57,
|
||||
Render_State_CullMode= 58,
|
||||
Render_State_FillMode= 59,
|
||||
Render_State_AlphaBlendEnable= 60,
|
||||
Render_State_SrcBlend= 61,
|
||||
Render_State_DestBlend= 62,
|
||||
Render_State_BlendOp= 63,
|
||||
Render_State_ColorWriteEnable= 64,
|
||||
Render_State_DepthBias= 65,
|
||||
Render_State_SlopeScaleDepthBias= 66,
|
||||
Render_State_ZEnable= 67,
|
||||
Render_State_ZWriteEnable= 68,
|
||||
Render_State_ZFunc= 69,
|
||||
Render_State_MultiSampleAntiAlias= 70,
|
||||
Render_State_ScissorTestEnable= 71,
|
||||
Render_State_StencilEnable= 72,
|
||||
Render_State_StencilFail= 73,
|
||||
Render_State_StencilFunc= 74,
|
||||
Render_State_StencilMask= 75,
|
||||
Render_State_StencilPass= 76,
|
||||
Render_State_StencilRef= 77,
|
||||
Render_State_StencilWriteMask= 78,
|
||||
Render_State_StencilZFail= 79,
|
||||
Render_State_Expression= 80,
|
||||
Pass_Declaration= 81,
|
||||
VertexShader_Pass_Expression= 82,
|
||||
PixelShader_Pass_Expression= 83,
|
||||
AddressMode_Clamp= 84,
|
||||
AddressMode_Wrap= 85,
|
||||
AddressMode_Mirror= 86,
|
||||
AddressMode_Border= 87,
|
||||
AddressMode= 88,
|
||||
TextureFilter_None= 89,
|
||||
TextureFilter_Linear= 90,
|
||||
TextureFilter_Point= 91,
|
||||
TextureFilter_Anisotropic= 92,
|
||||
TextureFilter= 93,
|
||||
Sampler_State_Texture= 94,
|
||||
Sampler_State_MinFilter= 95,
|
||||
Sampler_State_MagFilter= 96,
|
||||
Sampler_State_MipFilter= 97,
|
||||
Sampler_State_Filter= 98,
|
||||
Sampler_State_AddressU= 99,
|
||||
Sampler_State_AddressV= 100,
|
||||
Sampler_State_AddressW= 101,
|
||||
Sampler_State_BorderColor= 102,
|
||||
Sampler_State_MaxMipLevel= 103,
|
||||
Sampler_State_MaxAnisotropy= 104,
|
||||
Sampler_State_MipLodBias= 105,
|
||||
Sampler_State_Expression= 106,
|
||||
Sampler_Register_Expression= 107,
|
||||
Sampler_Declaration_States= 108,
|
||||
Sampler_Declaration= 109,
|
||||
|
||||
//Terminal tokens:
|
||||
BlockComment= 110,
|
||||
Comment = 111,
|
||||
Whitespace= 112,
|
||||
LinePragma= 113,
|
||||
Pass = 114,
|
||||
Technique= 115,
|
||||
Sampler = 116,
|
||||
SamplerState= 117,
|
||||
VertexShader= 118,
|
||||
PixelShader= 119,
|
||||
Register= 120,
|
||||
Boolean = 121,
|
||||
Number = 122,
|
||||
HexColor= 123,
|
||||
Identifier= 124,
|
||||
OpenBracket= 125,
|
||||
CloseBracket= 126,
|
||||
Equals = 127,
|
||||
Colon = 128,
|
||||
Comma = 129,
|
||||
Semicolon= 130,
|
||||
Or = 131,
|
||||
OpenParenthesis= 132,
|
||||
CloseParenthesis= 133,
|
||||
OpenSquareBracket= 134,
|
||||
CloseSquareBracket= 135,
|
||||
LessThan= 136,
|
||||
GreaterThan= 137,
|
||||
Compile = 138,
|
||||
ShaderModel= 139,
|
||||
Code = 140,
|
||||
EndOfFile= 141,
|
||||
MinFilter= 142,
|
||||
MagFilter= 143,
|
||||
MipFilter= 144,
|
||||
Filter = 145,
|
||||
Texture = 146,
|
||||
AddressU= 147,
|
||||
AddressV= 148,
|
||||
AddressW= 149,
|
||||
BorderColor= 150,
|
||||
MaxAnisotropy= 151,
|
||||
MaxMipLevel= 152,
|
||||
MipLodBias= 153,
|
||||
Clamp = 154,
|
||||
Wrap = 155,
|
||||
Mirror = 156,
|
||||
Border = 157,
|
||||
None = 158,
|
||||
Linear = 159,
|
||||
Point = 160,
|
||||
Anisotropic= 161,
|
||||
AlphaBlendEnable= 162,
|
||||
SrcBlend= 163,
|
||||
DestBlend= 164,
|
||||
BlendOp = 165,
|
||||
ColorWriteEnable= 166,
|
||||
ZEnable = 167,
|
||||
ZWriteEnable= 168,
|
||||
ZFunc = 169,
|
||||
DepthBias= 170,
|
||||
CullMode= 171,
|
||||
FillMode= 172,
|
||||
MultiSampleAntiAlias= 173,
|
||||
ScissorTestEnable= 174,
|
||||
SlopeScaleDepthBias= 175,
|
||||
StencilEnable= 176,
|
||||
StencilFail= 177,
|
||||
StencilFunc= 178,
|
||||
StencilMask= 179,
|
||||
StencilPass= 180,
|
||||
StencilRef= 181,
|
||||
StencilWriteMask= 182,
|
||||
StencilZFail= 183,
|
||||
Never = 184,
|
||||
Less = 185,
|
||||
Equal = 186,
|
||||
LessEqual= 187,
|
||||
Greater = 188,
|
||||
NotEqual= 189,
|
||||
GreaterEqual= 190,
|
||||
Always = 191,
|
||||
Keep = 192,
|
||||
Zero = 193,
|
||||
Replace = 194,
|
||||
IncrSat = 195,
|
||||
DecrSat = 196,
|
||||
Invert = 197,
|
||||
Incr = 198,
|
||||
Decr = 199,
|
||||
Red = 200,
|
||||
Green = 201,
|
||||
Blue = 202,
|
||||
Alpha = 203,
|
||||
All = 204,
|
||||
Cw = 205,
|
||||
Ccw = 206,
|
||||
Solid = 207,
|
||||
WireFrame= 208,
|
||||
Add = 209,
|
||||
Subtract= 210,
|
||||
RevSubtract= 211,
|
||||
Min = 212,
|
||||
Max = 213,
|
||||
One = 214,
|
||||
SrcColor= 215,
|
||||
InvSrcColor= 216,
|
||||
SrcAlpha= 217,
|
||||
InvSrcAlpha= 218,
|
||||
DestAlpha= 219,
|
||||
InvDestAlpha= 220,
|
||||
DestColor= 221,
|
||||
InvDestColor= 222,
|
||||
SrcAlphaSat= 223,
|
||||
BlendFactor= 224,
|
||||
InvBlendFactor= 225
|
||||
}
|
||||
|
||||
public class Token
|
||||
{
|
||||
private string file;
|
||||
private int line;
|
||||
private int column;
|
||||
private int startpos;
|
||||
private int endpos;
|
||||
private string text;
|
||||
private object value;
|
||||
|
||||
// contains all prior skipped symbols
|
||||
private List<Token> skipped;
|
||||
|
||||
public string File {
|
||||
get { return file; }
|
||||
set { file = value; }
|
||||
}
|
||||
|
||||
public int Line {
|
||||
get { return line; }
|
||||
set { line = value; }
|
||||
}
|
||||
|
||||
public int Column {
|
||||
get { return column; }
|
||||
set { column = value; }
|
||||
}
|
||||
|
||||
public int StartPos {
|
||||
get { return startpos;}
|
||||
set { startpos = value; }
|
||||
}
|
||||
|
||||
public int Length {
|
||||
get { return endpos - startpos;}
|
||||
}
|
||||
|
||||
public int EndPos {
|
||||
get { return endpos;}
|
||||
set { endpos = value; }
|
||||
}
|
||||
|
||||
public string Text {
|
||||
get { return text;}
|
||||
set { text = value; }
|
||||
}
|
||||
|
||||
public List<Token> Skipped {
|
||||
get { return skipped;}
|
||||
set { skipped = value; }
|
||||
}
|
||||
public object Value {
|
||||
get { return value;}
|
||||
set { this.value = value; }
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public TokenType Type;
|
||||
|
||||
public Token()
|
||||
: this(0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
public Token(int start, int end)
|
||||
{
|
||||
Type = TokenType._UNDETERMINED_;
|
||||
startpos = start;
|
||||
endpos = end;
|
||||
Text = ""; // must initialize with empty string, may cause null reference exceptions otherwise
|
||||
Value = null;
|
||||
}
|
||||
|
||||
public void UpdateRange(Token token)
|
||||
{
|
||||
if (token.StartPos < startpos) startpos = token.StartPos;
|
||||
if (token.EndPos > endpos) endpos = token.EndPos;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (Text != null)
|
||||
return Type.ToString() + " '" + Text + "'";
|
||||
else
|
||||
return Type.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// MonoGame - Copyright (C) The MonoGame Team
|
||||
// This file is subject to the terms and conditions defined in
|
||||
// file 'LICENSE.txt', which is part of this source code package.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
public class ShaderInfo
|
||||
{
|
||||
public List<TechniqueInfo> Techniques = new List<TechniqueInfo>();
|
||||
|
||||
public Dictionary<string, SamplerStateInfo> SamplerStates = new Dictionary<string, SamplerStateInfo>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TwoMGFX.TPGParser
|
||||
{
|
||||
public class TechniqueInfo
|
||||
{
|
||||
public int startPos;
|
||||
public int length;
|
||||
|
||||
public string name;
|
||||
public List<PassInfo> Passes = new List<PassInfo>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user