コード例 #1
0
            public DecomposeAttrContext SwitchToAlpha()
            {
                DecomposeAttrContext result = this;

                result.flavor = AttrCase.Alpha;
                return(result);
            }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
 private AttrInfo DecomposeAttrImpl(
     MidLit<Int32> exp,
     DecomposeAttrContext context)
 {
     return new LitInfo(exp.Range, (float) exp.Value);
 }
コード例 #6
0
 private AttrInfo DecomposeAttrImpl(
     MidAttributeRef midAttrRef,
     DecomposeAttrContext context)
 {
     return DecomposeAttr(midAttrRef.Decl, context);
 }
コード例 #7
0
 private AttrInfo DecomposeAttrImpl(
     MidExp exp,
     DecomposeAttrContext context)
 {
     throw OperationTooComplexError(exp.Range);
 }
コード例 #8
0
 private AttrInfo DecomposeAttr(
     MidExp exp,
     DecomposeAttrContext context)
 {
     return DecomposeAttrImpl((dynamic)exp, context);
 }
コード例 #9
0
 private AttrInfo DecomposeAttr(
     MidAttributeDecl midAttrDecl,
     DecomposeAttrContext context )
 {
     return DecomposeAttr(midAttrDecl.Exp, context);
 }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
 private AttrInfo DecomposeAttrImpl(
     MidLit <Int32> exp,
     DecomposeAttrContext context)
 {
     return(new LitInfo(exp.Range, (float)exp.Value));
 }
コード例 #12
0
 private AttrInfo DecomposeAttrImpl(
     MidAttributeRef midAttrRef,
     DecomposeAttrContext context)
 {
     return(DecomposeAttr(midAttrRef.Decl, context));
 }
コード例 #13
0
 private AttrInfo DecomposeAttrImpl(
     MidExp exp,
     DecomposeAttrContext context)
 {
     throw OperationTooComplexError(exp.Range);
 }
コード例 #14
0
 private AttrInfo DecomposeAttr(
     MidExp exp,
     DecomposeAttrContext context)
 {
     return(DecomposeAttrImpl((dynamic)exp, context));
 }
コード例 #15
0
 private AttrInfo DecomposeAttr(
     MidAttributeDecl midAttrDecl,
     DecomposeAttrContext context)
 {
     return(DecomposeAttr(midAttrDecl.Exp, context));
 }