public DecomposeAttrContext SwitchToAlpha() { DecomposeAttrContext result = this; result.flavor = AttrCase.Alpha; return(result); }
private AttrInfo DecomposeAttrImpl( MidAttributeFetch exp, DecomposeAttrContext context) { string obj = exp.Obj.ToString(); if (obj == "__ps2om") { // The operand is then a source to the // blending operation var srcAttr = exp.Attribute; switch (context.flavor) { case AttrCase.Color: SetSource(ref _renderTargetSources[context.index].colorExp, srcAttr); return(new SrcInfo(exp.Range)); case AttrCase.Alpha: SetSource(ref _renderTargetSources[context.index].alphaExp, srcAttr); return(new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_SRC_ALPHA)); case AttrCase.Combined: SetSource(ref _renderTargetSources[context.index].combinedExp, srcAttr); return(new SrcInfo(exp.Range)); default: throw OperationTooComplexError(exp.Range); } } else if (obj == "OM_Dest") { switch (context.flavor) { case AttrCase.Color: return(new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_COLOR)); case AttrCase.Alpha: return(new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_ALPHA)); case AttrCase.Combined: return(new FactorInfo( exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_COLOR, D3D11_BLEND.D3D11_BLEND_DEST_ALPHA)); default: throw OperationTooComplexError(exp.Range); } } else { throw OperationTooComplexError(exp.Range); } }
private AttrInfo DecomposeAttrImpl( MidBuiltinApp app, DecomposeAttrContext context) { string template = app.Decl.GetTemplate("blend"); if (template == null) { throw OperationTooComplexError(app.Range); } var args = app.Args.ToArray(); switch (template) { case "AddFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new OpInfo( app.Range, D3D11_BLEND_OP.D3D11_BLEND_OP_ADD, left, right); } case "MulFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new TermInfo(app.Range, left, right); } case "MulFloat_Float4": { var left = DecomposeAttr(args[0], context.SwitchToAlpha()); var right = DecomposeAttr(args[1], context); return new TermInfo(app.Range, left, right); } case "MulFloat4_Float": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context.SwitchToAlpha()); return new TermInfo(app.Range, left, right); } case "GetAlpha": { var arg = DecomposeAttr(args[0], context.SwitchToAlpha()); return arg; } case "SubFloat": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return new SubInfo(app.Range, left, right); } case "IntToFloat": { var arg = DecomposeAttr(args[0], context); return arg; } default: throw OperationTooComplexError(app.Range); } }
private AttrInfo DecomposeAttrImpl( MidAttributeFetch exp, DecomposeAttrContext context) { string obj = exp.Obj.ToString(); if (obj == "__ps2om") { // The operand is then a source to the // blending operation var srcAttr = exp.Attribute; switch (context.flavor) { case AttrCase.Color: SetSource(ref _renderTargetSources[context.index].colorExp, srcAttr); return new SrcInfo(exp.Range); case AttrCase.Alpha: SetSource(ref _renderTargetSources[context.index].alphaExp, srcAttr); return new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_SRC_ALPHA); case AttrCase.Combined: SetSource(ref _renderTargetSources[context.index].combinedExp, srcAttr); return new SrcInfo(exp.Range); default: throw OperationTooComplexError(exp.Range); } } else if (obj == "OM_Dest") { switch (context.flavor) { case AttrCase.Color: return new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_COLOR); case AttrCase.Alpha: return new FactorInfo(exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_ALPHA); case AttrCase.Combined: return new FactorInfo( exp.Range, D3D11_BLEND.D3D11_BLEND_DEST_COLOR, D3D11_BLEND.D3D11_BLEND_DEST_ALPHA); default: throw OperationTooComplexError(exp.Range); } } else { throw OperationTooComplexError(exp.Range); } }
private AttrInfo DecomposeAttrImpl( MidLit<Int32> exp, DecomposeAttrContext context) { return new LitInfo(exp.Range, (float) exp.Value); }
private AttrInfo DecomposeAttrImpl( MidAttributeRef midAttrRef, DecomposeAttrContext context) { return DecomposeAttr(midAttrRef.Decl, context); }
private AttrInfo DecomposeAttrImpl( MidExp exp, DecomposeAttrContext context) { throw OperationTooComplexError(exp.Range); }
private AttrInfo DecomposeAttr( MidExp exp, DecomposeAttrContext context) { return DecomposeAttrImpl((dynamic)exp, context); }
private AttrInfo DecomposeAttr( MidAttributeDecl midAttrDecl, DecomposeAttrContext context ) { return DecomposeAttr(midAttrDecl.Exp, context); }
private AttrInfo DecomposeAttrImpl( MidBuiltinApp app, DecomposeAttrContext context) { string template = app.Decl.GetTemplate("blend"); if (template == null) { throw OperationTooComplexError(app.Range); } var args = app.Args.ToArray(); switch (template) { case "AddFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return(new OpInfo( app.Range, D3D11_BLEND_OP.D3D11_BLEND_OP_ADD, left, right)); } case "MulFloat4": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return(new TermInfo(app.Range, left, right)); } case "MulFloat_Float4": { var left = DecomposeAttr(args[0], context.SwitchToAlpha()); var right = DecomposeAttr(args[1], context); return(new TermInfo(app.Range, left, right)); } case "MulFloat4_Float": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context.SwitchToAlpha()); return(new TermInfo(app.Range, left, right)); } case "GetAlpha": { var arg = DecomposeAttr(args[0], context.SwitchToAlpha()); return(arg); } case "SubFloat": { var left = DecomposeAttr(args[0], context); var right = DecomposeAttr(args[1], context); return(new SubInfo(app.Range, left, right)); } case "IntToFloat": { var arg = DecomposeAttr(args[0], context); return(arg); } default: throw OperationTooComplexError(app.Range); } }
private AttrInfo DecomposeAttrImpl( MidLit <Int32> exp, DecomposeAttrContext context) { return(new LitInfo(exp.Range, (float)exp.Value)); }
private AttrInfo DecomposeAttrImpl( MidAttributeRef midAttrRef, DecomposeAttrContext context) { return(DecomposeAttr(midAttrRef.Decl, context)); }
private AttrInfo DecomposeAttr( MidExp exp, DecomposeAttrContext context) { return(DecomposeAttrImpl((dynamic)exp, context)); }
private AttrInfo DecomposeAttr( MidAttributeDecl midAttrDecl, DecomposeAttrContext context) { return(DecomposeAttr(midAttrDecl.Exp, context)); }