Пример #1
0
        public PrintVcsFileSummary(ShaderFile shaderFile, HandleOutputWrite OutputWriter = null,
                                   bool showRichTextBoxLinks = false, List <string> relatedFiles = null)
        {
            this.showRichTextBoxLinks = showRichTextBoxLinks;
            this.relatedFiles         = relatedFiles;

            output = new OutputFormatterTabulatedData(OutputWriter);
            if (shaderFile.vcsProgramType == VcsProgramType.Features)
            {
                PrintFeaturesHeader(shaderFile);
                PrintFBlocks(shaderFile);
            }
            else
            {
                PrintPsVsHeader(shaderFile);
                PrintSBlocks(shaderFile);
            }
            PrintStaticConstraints(shaderFile);
            PrintDynamicConfigurations(shaderFile);
            PrintDynamicConstraints(shaderFile);
            PrintParameters(shaderFile);
            PrintMipmapBlocks(shaderFile);
            PrintBufferBlocks(shaderFile);
            PrintVertexSymbolBuffers(shaderFile);
            PrintZFrames(shaderFile);
        }
Пример #2
0
        private void PrintParamWriteSequence(ShaderFile shaderFile, byte[] dataload, int h0, int h1, int h2, string seqName = "")
        {
            string b2Desc          = "dest";
            string b3Desc          = "control";
            string dataBlockHeader = $"{seqName,-35} {b2Desc,-11} {b3Desc}";

            OutputWriteLine(dataBlockHeader);
            if (h0 == 0)
            {
                OutputWriteLine("[empty writesequence]");
                return;
            }
            for (int i = 0; i < h0; i++)
            {
                int    paramId = dataload[i * 4];
                int    b2      = dataload[i * 4 + 2];
                int    b3      = dataload[i * 4 + 3];
                string b2Text  = $"{b2,3} ({b2:X02})";
                if (b2 == 0xff)
                {
                    b2Text = $"  _ ({b2:X02})";
                }
                string b3Text = $"{b3,3} ({b3:X02})";
                if (b3 == 0xff)
                {
                    b3Text = $"  _ ({b2:X02})";
                }
                OutputWrite($"[{paramId,3}] {shaderFile.paramBlocks[paramId].name0,-30} {b2Text,-14} {b3Text}");
                if (i + 1 == h0 && h0 != h2)
                {
                    OutputWrite($"   // {h0}");
                }
                if (i + 1 == h1)
                {
                    OutputWrite($"   // {h1}");
                }
                if (i + 1 == h2)
                {
                    OutputWrite($"   // {h2}");
                }
                OutputWriteLine("");
            }
        }
Пример #3
0
        // If OutputWriter is left as null; output will be written to Console.
        // Otherwise output is directed to the passed HandleOutputWrite object (defined by the calling application, for example GUI element or file)
        public PrintZFrameSummary(ShaderFile shaderFile, ZFrameFile zframeFile,
                                  HandleOutputWrite outputWriter = null, bool showRichTextBoxLinks = false)
        {
            this.shaderFile   = shaderFile;
            this.zframeFile   = zframeFile;
            this.OutputWriter = outputWriter ?? ((x) => { Console.Write(x); });

            if (zframeFile.vcsProgramType == VcsProgramType.Features)
            {
                OutputWriteLine("Zframe byte data (encoding for features files has not been determined)");
                zframeFile.datareader.BaseStream.Position = 0;
                string zframeBytes = zframeFile.datareader.ReadBytesAsString((int)zframeFile.datareader.BaseStream.Length);
                OutputWriteLine(zframeBytes);
                return;
            }

            this.showRichTextBoxLinks = showRichTextBoxLinks;
            if (showRichTextBoxLinks)
            {
                OutputWriteLine($"View byte detail \\\\{Path.GetFileName(shaderFile.filenamepath)}-ZFRAME{zframeFile.zframeId:x08}-databytes");
                OutputWriteLine("");
            }
            PrintConfigurationState();
            PrintFrameLeadingArgs();
            SortedDictionary <int, int> writeSequences = GetWriteSequences();

            PrintWriteSequences(writeSequences);
            PrintDataBlocks(writeSequences);

            if (zframeFile.vcsProgramType == VcsProgramType.VertexShader)
            {
                OutputWriteLine($"// configuration states ({zframeFile.leadingSummary.Length}), leading summary\n");
                OutputWriteLine(SummarizeBytes(zframeFile.leadingSummary) + "\n");
            }
            OutputWriteLine($"// configuration states ({zframeFile.trailingSummary.Length}), trailing summary\n");
            OutputWriteLine(SummarizeBytes(zframeFile.trailingSummary) + "\n");
            OutputWrite("\n");

            PrintSourceSummary();
            PrintEndBlocks();
        }
        private void GenerateOffsetAndStateLookups(ShaderFile shaderFile)
        {
            if (shaderFile.dBlocks.Count == 0)
            {
                offsets   = Array.Empty <int>();
                nr_states = Array.Empty <int>();
                return;
            }

            offsets   = new int[shaderFile.dBlocks.Count];
            nr_states = new int[shaderFile.dBlocks.Count];

            offsets[0]   = 1;
            nr_states[0] = shaderFile.dBlocks[0].arg2 + 1;

            for (int i = 1; i < shaderFile.dBlocks.Count; i++)
            {
                nr_states[i] = shaderFile.dBlocks[i].arg2 + 1;
                offsets[i]   = offsets[i - 1] * nr_states[i - 1];
            }
        }
Пример #5
0
        private void PrintFeaturesHeader(ShaderFile shaderFile)
        {
            output.WriteLine($"Valve Compiled Shader 2 (vcs2), version {shaderFile.featuresHeader.vcsFileVersion}");
            output.BreakLine();
            output.Write($"Showing {shaderFile.vcsProgramType}: {Path.GetFileName(shaderFile.filenamepath)}");
            if (showRichTextBoxLinks)
            {
                output.WriteLine($" (view byte detail \\\\{Path.GetFileName(shaderFile.filenamepath)}\\bytes)");
            }
            else
            {
                output.BreakLine();
            }
            if (showRichTextBoxLinks && relatedFiles != null && relatedFiles.Count > 1)
            {
                output.Write("Related files:");
                foreach (var relatedFile in relatedFiles)
                {
                    output.Write($" \\\\{relatedFile.Replace("/","\\")}");
                }
                output.BreakLine();
            }
            output.BreakLine();

            output.WriteLine($"VFX File Desc: {shaderFile.featuresHeader.file_description}");
            output.BreakLine();
            output.WriteLine($"has_psrs_file = {shaderFile.featuresHeader.has_psrs_file}");
            output.WriteLine($"unknown_val = {shaderFile.featuresHeader.unknown_val} values seen (0,1) (likely editor related)");
            var ftHeader = shaderFile.featuresHeader;

            output.WriteLine($"bool flags = ({ftHeader.arg0},{ftHeader.arg1},{ftHeader.arg2},{ftHeader.arg3}," +
                             $"{ftHeader.arg4},{ftHeader.arg5},{ftHeader.arg6},{ftHeader.arg7}) (related to editor dependencies)");
            output.WriteLine($"possible editor description = {shaderFile.possibleEditorDescription}");
            output.BreakLine();
            output.WriteLine("Editor/Shader compiler stack");
            for (int i = 0; i < ftHeader.editorIDs.Count - 1; i++)
            {
                output.WriteLine($"{ftHeader.editorIDs[i].Item1}    {ftHeader.editorIDs[i].Item2}");
            }
            output.WriteLine($"{ftHeader.editorIDs[^1].Item1}    // Editor ref. ID{ftHeader.editorIDs.Count - 1} " +
 public ConfigMappingDParams(ShaderFile shaderfile)
 {
     this.shaderfile = shaderfile;
     GenerateOffsetAndStateLookups(shaderfile);
 }