示例#1
0
        public void EmitImplDraw()
        {
            var uniformElement = GetElement("Uniform");
            var drawSpanAttr   = GetAttribute(uniformElement, "IA_DrawSpan");

            ExecBlock.BuiltinApp(EmitTarget.VoidType, "{0}.Submit({1})",
                                 new[] {
                EmitContext.EmitAttributeRef(drawSpanAttr, ExecBlock, SubmitEnv),
                SubmitContext,
            });
        }
示例#2
0
        public void EmitImplBindOM()
        {
            ExecBlock.AppendComment("D3D11 Output Merger");

            if (renderTargetAttributes.Length != 0)
            {
                var renderTargetViewVals = (from a in renderTargetAttributes
                                            select EmitContext.EmitAttributeRef(a, ExecBlock, SubmitEnv)).ToArray();
                var renderTargetViewsVal = ExecBlock.Temp(
                    "renderTargetViews",
                    ExecBlock.Array(
                        EmitTarget.GetOpaqueType("ID3D11RenderTargetView*"),
                        renderTargetViewVals));

                ExecBlock.CallCOM(
                    SubmitContext,
                    "ID3D11DeviceContext",
                    "OMSetRenderTargets",
                    ExecBlock.LiteralU32((UInt32)renderTargetCount),
                    renderTargetViewsVal.GetAddress(),
                    EmitContext.EmitAttributeRef(depthStencilViewAttribute, ExecBlock, SubmitEnv));
            }
            else
            {
                ExecBlock.CallCOM(
                    SubmitContext,
                    "ID3D11DeviceContext",
                    "OMSetRenderTargets",
                    ExecBlock.LiteralU32(0),
                    EmitTarget.GetNullPointer(
                        EmitTarget.GetOpaqueType("ID3D11RenderTargetView**")),
                    EmitContext.EmitAttributeRef(depthStencilViewAttribute, ExecBlock, SubmitEnv));
            }

            var floatOne       = ExecBlock.LiteralF32(1.0f);
            var blendFactorVal = ExecBlock.Temp(
                "blendFactor",
                ExecBlock.Array(
                    EmitTarget.GetBuiltinType("float"),
                    new IEmitVal[] { floatOne, floatOne, floatOne, floatOne }));

            ExecBlock.CallCOM(
                SubmitContext,
                "ID3D11DeviceContext",
                "OMSetBlendState",
                ExecBlock.GetArrow(SubmitThis, blendStateField),
                blendFactorVal.GetAddress(),
                ExecBlock.LiteralU32(0xFFFFFFFF));
        }
示例#3
0
        public override void EmitImplBind()
        {
            ExecBlock.AppendComment("D3D11 Input Assembler");


            var uniformElement = GetElement("Uniform");
            var drawSpanAttr   = GetAttribute(uniformElement, "IA_DrawSpan");

            ExecBlock.BuiltinApp(EmitTarget.VoidType, "{0}.Bind({1})",
                                 new[] {
                EmitContext.EmitAttributeRef(drawSpanAttr, ExecBlock, SubmitEnv),
                SubmitContext,
            });

            var inputLayoutPointerType = EmitTarget.GetOpaqueType("ID3D11InputLayout*");
            var inputLayoutToBind      = _inputElementCount == 0
                ? EmitTarget.GetNullPointer(inputLayoutPointerType)
                : ExecBlock.GetArrow(SubmitThis, inputLayoutField);

            ExecBlock.CallCOM(
                SubmitContext,
                "ID3D11DeviceContext",
                "IASetInputLayout",
                inputLayoutToBind);

            if (_vertexBuffers.Count != 0)
            {
                var vertexBuffersVal = ExecBlock.Temp(
                    "inputVertexBuffers",
                    ExecBlock.Array(
                        EmitTarget.GetOpaqueType("ID3D11Buffer*"),
                        (from b in _vertexBuffers
                         select EmitExp(b, ExecBlock, SubmitEnv))));

                var vertexBuffersStridesVal = ExecBlock.Temp(
                    "inputVertexBufferStrides",
                    ExecBlock.Array(
                        EmitTarget.GetBuiltinType("UINT"),
                        (from b in _vertexBufferStrides
                         select EmitExp(b, ExecBlock, SubmitEnv))));

                var vertexBuffersOffsetsVal = ExecBlock.Temp(
                    "inputVertexBufferOffsets",
                    ExecBlock.Array(
                        EmitTarget.GetBuiltinType("UINT"),
                        (from b in _vertexBufferOffsets
                         select EmitExp(b, ExecBlock, SubmitEnv))));

                ExecBlock.CallCOM(
                    SubmitContext,
                    "ID3D11DeviceContext",
                    "IASetVertexBuffers",
                    ExecBlock.LiteralU32(0),
                    ExecBlock.LiteralU32((UInt32)_vertexBuffers.Count),
                    vertexBuffersVal.GetAddress(),
                    vertexBuffersStridesVal.GetAddress(),
                    vertexBuffersOffsetsVal.GetAddress());
            }

            /*
             * ExecBlock.CallCOM(
             *  SubmitContext,
             *  "ID3D11DeviceContext",
             *  "IASetPrimitiveTopology",
             *  EmitContext.EmitAttributeRef( primitiveTopology, ExecBlock, SubmitEnv ) );
             */
        }