//refer bool ToGLSL::Translate()
        private string Decompile()
        {
#if DEBUG
            //Output.AppendLine(RegisterState.Dump());
#endif
            RootSignature.WriteRootSignature(Container, Output);
            if (Container.Shader.Version.ProgramType == ProgramType.HullShader)
            {
                DecompileHullShader();
                return(Output.ToString());
            }
            WriteResoureDefinitions();
            WriteSignatures();
            if (Interfaces != null)
            {
                Output.AppendLine(Interfaces.Dump());
            }
            LogDeclaration(Container.Shader.DeclarationTokens);
            WriteDeclarationAnnotations(Container.Shader.DeclarationTokens);
            WriteMainFuncDec();
            WriteTempRegisters();
            WriteDeclarationVariables(Container.Shader.DeclarationTokens);
            TranslateInstructions();
            indent--;
            Output.AppendLine("}");
            string functionDefs = string.Join("\n", Functions.Values);
            return(string.Format("{0}\n{1}", functionDefs, Output.ToString()));
        }
Beispiel #2
0
        internal static void WriteRootSignature(BytecodeContainer container, StringBuilder output, bool wrap = true)
        {
            var signature = container.Chunks
                            .OfType <RootSignatureChunk>()
                            .FirstOrDefault();

            if (signature == null)
            {
                return;
            }
            var result = new RootSignature().RootSignatureToString(signature);

            result = Regex.Replace(result, @"^(\s*)([^\n\r]*)", @"$1""$2"" \", RegexOptions.Multiline);
            result = result.Substring(0, result.Length - 2);
            output.AppendLine(@"#define RS1 \");
            output.AppendLine(result);
        }