Exemplo n.º 1
0
        public static void RenderPtx(this Renderable renderable, RenderPtxContext ctx)
        {
            if (renderable == null) return;
            if (ctx == null) RenderPtx(renderable);

            using (RenderPtxContext.Push(ctx))
            {
                renderable.RenderPtx();
            }
        }
Exemplo n.º 2
0
        public static String PeekRenderPtx(this Renderable renderable, RenderPtxContext ctx)
        {
            if (renderable == null) return null;
            if (ctx == null) return PeekRenderPtx(renderable);

            using (RenderPtxContext.Push(ctx))
            {
                var buf = new StringBuilder();
                using (ctx.OverrideBuf(buf))
                {
                    renderable.RenderPtx(ctx);
                    var ptx = ctx.Result;
                    return ptx;
                }
            }
        }
Exemplo n.º 3
0
        public static IDisposable Push(RenderPtxContext ctx)
        {
            if (Current == ctx)
            {
                return new DisposableAction(() => {});
            }
            else
            {
                _stack.Push(ctx);

                return new DisposableAction(() =>
                {
                    (Current == ctx).AssertTrue();
                    _stack.Pop();
                });
            }
        }
Exemplo n.º 4
0
        public String RenderPtx()
        {
            var ctx = new RenderPtxContext(this);
            using (RenderPtxContext.Push(ctx))
            {
                Comments.ForEach(c => c.RenderPtx());
                if (Comments.IsNotEmpty()) ctx.Writer.WriteLine();

                ctx.Writer.WriteLine(".version {0}.{1}", (int)Version / 10, (int)Version % 10);
                ctx.Writer.Write(".target sm_{0}", (int)Target);
            //                if (Version >= SoftwareIsa.PTX_15 && UnifiedTexturing == true) ctx.Writer.Write(", texmode_unified");
                if (Version >= SoftwareIsa.PTX_15 && UnifiedTexturing == false) ctx.Writer.Write(", texmode_independent");
                if (DowngradeDoubles) ctx.Writer.Write(", map_f64_to_f32");
                ctx.Writer.WriteLine();

                if (Pragmas.IsNotEmpty()) ctx.Writer.WriteLine();
                Pragmas.ForEach(p => p.RenderPtx());

                ctx.DelayRender(() =>
                {
                    var opaques = ctx.VisitedExprs.OfType<Var>().Where(v => v.is_opaque()).ToReadOnly();
                    if (opaques.IsNotEmpty()) ctx.Writer.WriteLine();
                    opaques.ForEach(v => v.RenderPtx());
                });

                foreach (var entry in Entries)
                {
                    ctx.Writer.WriteLine();
                    entry.RenderPtx();
                }

                ctx.CommitRender();
                return ctx.Result;
            }
        }